From: Jason Gunthorpe Date: Thu, 23 Oct 2025 18:22:35 +0000 (-0300) Subject: iommupt/x86: Support SW bits and permit PT_FEAT_DMA_INCOHERENT X-Git-Tag: v6.19-rc1~133^2^8~34 X-Git-Url: https://gentwo.org/gitweb/?a=commitdiff_plain;h=ef7bfe5bbffdcfa033beeeb068c6317f71730679;p=linux%2F.git 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 Reviewed-by: Kevin Tian Signed-off-by: Jason Gunthorpe Signed-off-by: Joerg Roedel --- diff --git a/drivers/iommu/generic_pt/fmt/iommu_x86_64.c b/drivers/iommu/generic_pt/fmt/iommu_x86_64.c index 5c5960d871a3..5472660c2d71 100644 --- a/drivers/iommu/generic_pt/fmt/iommu_x86_64.c +++ b/drivers/iommu/generic_pt/fmt/iommu_x86_64.c @@ -6,6 +6,6 @@ #define PT_SUPPORTED_FEATURES \ (BIT(PT_FEAT_SIGN_EXTEND) | BIT(PT_FEAT_FLUSH_RANGE) | \ BIT(PT_FEAT_FLUSH_RANGE_NO_GAPS) | \ - BIT(PT_FEAT_X86_64_AMD_ENCRYPT_TABLES)) + BIT(PT_FEAT_X86_64_AMD_ENCRYPT_TABLES) | BIT(PT_FEAT_DMA_INCOHERENT)) #include "iommu_template.h" diff --git a/drivers/iommu/generic_pt/fmt/x86_64.h b/drivers/iommu/generic_pt/fmt/x86_64.h index 7d01370e4ab0..a86353f1481e 100644 --- a/drivers/iommu/generic_pt/fmt/x86_64.h +++ b/drivers/iommu/generic_pt/fmt/x86_64.h @@ -167,6 +167,33 @@ static inline void x86_64_pt_attr_from_entry(const struct pt_state *pts, } #define pt_attr_from_entry x86_64_pt_attr_from_entry +static inline unsigned int x86_64_pt_max_sw_bit(struct pt_common *common) +{ + return 12; +} +#define pt_max_sw_bit x86_64_pt_max_sw_bit + +static inline u64 x86_64_pt_sw_bit(unsigned int bitnr) +{ + /* Bits marked Ignored/AVL in the specification */ + switch (bitnr) { + case 0: + return BIT(9); + case 1: + return BIT(11); + case 2 ... 12: + return BIT_ULL((bitnr - 2) + 52); + /* Some bits in 8,6,4,3 are available in some entries */ + default: + if (__builtin_constant_p(bitnr)) + BUILD_BUG(); + else + PT_WARN_ON(true); + return 0; + } +} +#define pt_sw_bit x86_64_pt_sw_bit + /* --- iommu */ #include #include