]> Gentwo Git Trees - linux/.git/commitdiff
iommupt/x86: Support SW bits and permit PT_FEAT_DMA_INCOHERENT
authorJason Gunthorpe <jgg@nvidia.com>
Thu, 23 Oct 2025 18:22:35 +0000 (15:22 -0300)
committerJoerg Roedel <joerg.roedel@amd.com>
Wed, 5 Nov 2025 08:50:19 +0000 (09:50 +0100)
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>
drivers/iommu/generic_pt/fmt/iommu_x86_64.c
drivers/iommu/generic_pt/fmt/x86_64.h

index 5c5960d871a32ff9bbd34ca876ba78b81da0edba..5472660c2d7156227af701533ef229f7491a0e39 100644 (file)
@@ -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"
index 7d01370e4ab0ba9a121feda4741bf3bb4daabdbb..a86353f1481e5cd0261c60b95ca56fe615950192 100644 (file)
@@ -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 <linux/generic_pt/iommu.h>
 #include <linux/iommu.h>