iommu/vt-d: Omit devTLB invalidation requests when TES=0
[ Upstream commit 0f5432a9b839847dcfe9fa369d72e3d646102ddf ]
The latest VT-d spec indicates that when remapping hardware is disabled
(TES=0 in Global Status Register), upstream ATS Invalidation Completion
requests are treated as UR (Unsupported Request).
Consequently, the spec recommends in section 4.3 Handling of Device-TLB
Invalidations that software refrain from submitting any Device-TLB
invalidation requests when address remapping hardware is disabled.
Verify address remapping hardware is enabled prior to submitting Device-
TLB invalidation requests.
Fixes: 792fb43ce2 ("iommu/vt-d: Enable Intel IOMMU scalable mode by default")
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/20231114011036.70142-2-baolu.lu@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
8aaed5b81d
commit
681aeeda41
1 changed files with 18 additions and 0 deletions
|
|
@ -1495,6 +1495,15 @@ void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid,
|
||||||
{
|
{
|
||||||
struct qi_desc desc;
|
struct qi_desc desc;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* VT-d spec, section 4.3:
|
||||||
|
*
|
||||||
|
* Software is recommended to not submit any Device-TLB invalidation
|
||||||
|
* requests while address remapping hardware is disabled.
|
||||||
|
*/
|
||||||
|
if (!(iommu->gcmd & DMA_GCMD_TE))
|
||||||
|
return;
|
||||||
|
|
||||||
if (mask) {
|
if (mask) {
|
||||||
addr |= (1ULL << (VTD_PAGE_SHIFT + mask - 1)) - 1;
|
addr |= (1ULL << (VTD_PAGE_SHIFT + mask - 1)) - 1;
|
||||||
desc.qw1 = QI_DEV_IOTLB_ADDR(addr) | QI_DEV_IOTLB_SIZE;
|
desc.qw1 = QI_DEV_IOTLB_ADDR(addr) | QI_DEV_IOTLB_SIZE;
|
||||||
|
|
@ -1560,6 +1569,15 @@ void qi_flush_dev_iotlb_pasid(struct intel_iommu *iommu, u16 sid, u16 pfsid,
|
||||||
unsigned long mask = 1UL << (VTD_PAGE_SHIFT + size_order - 1);
|
unsigned long mask = 1UL << (VTD_PAGE_SHIFT + size_order - 1);
|
||||||
struct qi_desc desc = {.qw1 = 0, .qw2 = 0, .qw3 = 0};
|
struct qi_desc desc = {.qw1 = 0, .qw2 = 0, .qw3 = 0};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* VT-d spec, section 4.3:
|
||||||
|
*
|
||||||
|
* Software is recommended to not submit any Device-TLB invalidation
|
||||||
|
* requests while address remapping hardware is disabled.
|
||||||
|
*/
|
||||||
|
if (!(iommu->gcmd & DMA_GCMD_TE))
|
||||||
|
return;
|
||||||
|
|
||||||
desc.qw0 = QI_DEV_EIOTLB_PASID(pasid) | QI_DEV_EIOTLB_SID(sid) |
|
desc.qw0 = QI_DEV_EIOTLB_PASID(pasid) | QI_DEV_EIOTLB_SID(sid) |
|
||||||
QI_DEV_EIOTLB_QDEP(qdep) | QI_DEIOTLB_TYPE |
|
QI_DEV_EIOTLB_QDEP(qdep) | QI_DEIOTLB_TYPE |
|
||||||
QI_DEV_IOTLB_PFSID(pfsid);
|
QI_DEV_IOTLB_PFSID(pfsid);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue