Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommupt/x86: Support SW bits and permit PT_FEAT_DMA_INCOHERENT

VT-d requires PT_FEAT_DMA_INCOHERENT for the x86 page table as well,
implement the required SW bits and enable the feature.

Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

authored by

Jason Gunthorpe and committed by
Joerg Roedel
ef7bfe5b 1978fac2

+28 -1
+1 -1
drivers/iommu/generic_pt/fmt/iommu_x86_64.c
··· 6 6 #define PT_SUPPORTED_FEATURES \ 7 7 (BIT(PT_FEAT_SIGN_EXTEND) | BIT(PT_FEAT_FLUSH_RANGE) | \ 8 8 BIT(PT_FEAT_FLUSH_RANGE_NO_GAPS) | \ 9 - BIT(PT_FEAT_X86_64_AMD_ENCRYPT_TABLES)) 9 + BIT(PT_FEAT_X86_64_AMD_ENCRYPT_TABLES) | BIT(PT_FEAT_DMA_INCOHERENT)) 10 10 11 11 #include "iommu_template.h"
+27
drivers/iommu/generic_pt/fmt/x86_64.h
··· 167 167 } 168 168 #define pt_attr_from_entry x86_64_pt_attr_from_entry 169 169 170 + static inline unsigned int x86_64_pt_max_sw_bit(struct pt_common *common) 171 + { 172 + return 12; 173 + } 174 + #define pt_max_sw_bit x86_64_pt_max_sw_bit 175 + 176 + static inline u64 x86_64_pt_sw_bit(unsigned int bitnr) 177 + { 178 + /* Bits marked Ignored/AVL in the specification */ 179 + switch (bitnr) { 180 + case 0: 181 + return BIT(9); 182 + case 1: 183 + return BIT(11); 184 + case 2 ... 12: 185 + return BIT_ULL((bitnr - 2) + 52); 186 + /* Some bits in 8,6,4,3 are available in some entries */ 187 + default: 188 + if (__builtin_constant_p(bitnr)) 189 + BUILD_BUG(); 190 + else 191 + PT_WARN_ON(true); 192 + return 0; 193 + } 194 + } 195 + #define pt_sw_bit x86_64_pt_sw_bit 196 + 170 197 /* --- iommu */ 171 198 #include <linux/generic_pt/iommu.h> 172 199 #include <linux/iommu.h>