iommu/vt-d: Enable write protect for supervisor SVM
Write protect bit, when set, inhibits supervisor writes to the read-only pages. In supervisor shared virtual addressing (SVA), where page tables are shared between CPU and DMA, IOMMU PASID entry WPE bit should match CR0.WP bit in the CPU. This patch sets WPE bit for supervisor PASIDs if CR0.WP is set. Signed-off-by: Sanjay Kumar <sanjay.k.kumar@intel.com> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com> Acked-by: Lu Baolu <baolu.lu@linux.intel.com> Link: https://lore.kernel.org/r/1614680040-1989-2-git-send-email-jacob.jun.pan@linux.intel.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
Родитель
6ca69e5841
Коммит
f68c7f539b
|
@ -393,6 +393,15 @@ static inline void pasid_set_sre(struct pasid_entry *pe)
|
||||||
pasid_set_bits(&pe->val[2], 1 << 0, 1);
|
pasid_set_bits(&pe->val[2], 1 << 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Setup the WPE(Write Protect Enable) field (Bit 132) of a
|
||||||
|
* scalable mode PASID entry.
|
||||||
|
*/
|
||||||
|
static inline void pasid_set_wpe(struct pasid_entry *pe)
|
||||||
|
{
|
||||||
|
pasid_set_bits(&pe->val[2], 1 << 4, 1 << 4);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup the P(Present) field (Bit 0) of a scalable mode PASID
|
* Setup the P(Present) field (Bit 0) of a scalable mode PASID
|
||||||
* entry.
|
* entry.
|
||||||
|
@ -522,6 +531,20 @@ static void pasid_flush_caches(struct intel_iommu *iommu,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int pasid_enable_wpe(struct pasid_entry *pte)
|
||||||
|
{
|
||||||
|
unsigned long cr0 = read_cr0();
|
||||||
|
|
||||||
|
/* CR0.WP is normally set but just to be sure */
|
||||||
|
if (unlikely(!(cr0 & X86_CR0_WP))) {
|
||||||
|
pr_err_ratelimited("No CPU write protect!\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
pasid_set_wpe(pte);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up the scalable mode pasid table entry for first only
|
* Set up the scalable mode pasid table entry for first only
|
||||||
* translation type.
|
* translation type.
|
||||||
|
@ -553,6 +576,9 @@ int intel_pasid_setup_first_level(struct intel_iommu *iommu,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
pasid_set_sre(pte);
|
pasid_set_sre(pte);
|
||||||
|
if (pasid_enable_wpe(pte))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & PASID_FLAG_FL5LP) {
|
if (flags & PASID_FLAG_FL5LP) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче