History

iommu/vt-d: Enable write protect propagation from guest

Write protect bit, when set, inhibits supervisor writes to the read-only pages. In guest supervisor shared virtual addressing (SVA), write-protect should be honored upon guest bind supervisor PASID request. This patch extends the VT-d portion of the IOMMU UAPI to include WP bit. WPE bit of the supervisor PASID entry will be set to match CPU CR0.WP bit.

Jacob Pan committed 5 years ago

Commit bb0f6151 parent f68c7f52 files · +5 −1Browse files

Unified · Split

2 files
  1. drivers/iommu/intel/pasid.c +3 −0
  2. include/uapi/linux/iommu.h +2 −1
drivers/iommu/intel/pasid.c+3−0
@@ -732,6 +732,9 @@ intel_pasid_setup_bind_data(struct intel_iommu *iommu, struct pasid_entry *pte, · 731 unmodified lines
732732 return -EINVAL;
733733 }
734734 pasid_set_sre(pte);
735+ /* Enable write protect WP if guest requested */
736+ if (pasid_data->flags & IOMMU_SVA_VTD_GPASID_WPE)
737+ pasid_set_wpe(pte);
735738 }
736739
737740 if (pasid_data->flags & IOMMU_SVA_VTD_GPASID_EAFE) {
include/uapi/linux/iommu.h+2−1
@@ -288,7 +288,8 @@ struct iommu_gpasid_bind_data_vtd { · 287 unmodified lines
288288 #define IOMMU_SVA_VTD_GPASID_PWT (1 << 3) /* page-level write through */
289289 #define IOMMU_SVA_VTD_GPASID_EMTE (1 << 4) /* extended mem type enable */
290290 #define IOMMU_SVA_VTD_GPASID_CD (1 << 5) /* PASID-level cache disable */
291−#define IOMMU_SVA_VTD_GPASID_LAST (1 << 6)
291+#define IOMMU_SVA_VTD_GPASID_WPE (1 << 6) /* Write protect enable */
292+#define IOMMU_SVA_VTD_GPASID_LAST (1 << 7)
292293 __u64 flags;
293294 __u32 pat;
294295 __u32 emt;