iommu: Add capability IOMMU_CAP_VIOMMU_HINT
commit 80cb89a09af3f244983e5d7157026830c7bf0e41 Intel-BKC. Some IOMMU specification defines some kind of hint mechanism, through which BIOS can imply that OS runs in a virtualized environment. For example, the caching mode defined in VT-d spec and NpCache capability defined in the AMD IOMMU specification. This hint could also be used outside of the IOMMU subsystem, where it could be used with other known means (CPUID, smbios) to sense whether Linux is running in a virtualized environment. Add a capability bit so that it could be used there. Cc: Joerg Roedel <joro@8bytes.org> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Megha Dey <megha.dey@intel.com> Signed-off-by: Chen Zhuo <sagazchen@tencent.com> Signed-off-by: Xinghui Li <korantli@tencent.com>
This commit is contained in:
parent
ccef7b053f
commit
1742bfbecb
|
@ -2562,6 +2562,8 @@ static bool amd_iommu_capable(enum iommu_cap cap)
|
|||
return (irq_remapping_enabled == 1);
|
||||
case IOMMU_CAP_NOEXEC:
|
||||
return false;
|
||||
case IOMMU_CAP_VIOMMU_HINT:
|
||||
return amd_iommu_np_cache;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -315,6 +315,7 @@ static inline void context_clear_entry(struct context_entry *context)
|
|||
*/
|
||||
static struct dmar_domain *si_domain;
|
||||
static int hw_pass_through = 1;
|
||||
static int intel_caching_mode;
|
||||
|
||||
#define for_each_domain_iommu(idx, domain) \
|
||||
for (idx = 0; idx < g_num_of_iommus; idx++) \
|
||||
|
@ -3476,6 +3477,8 @@ static int __init init_dmars(void)
|
|||
|
||||
if (!ecap_pass_through(iommu->ecap))
|
||||
hw_pass_through = 0;
|
||||
if (cap_caching_mode(iommu->cap))
|
||||
intel_caching_mode = 1;
|
||||
|
||||
if (!intel_iommu_strict && cap_caching_mode(iommu->cap)) {
|
||||
pr_info("Disable batched IOTLB flush due to virtualization");
|
||||
|
@ -5382,6 +5385,8 @@ static bool intel_iommu_capable(enum iommu_cap cap)
|
|||
return domain_update_iommu_snooping(NULL);
|
||||
if (cap == IOMMU_CAP_INTR_REMAP)
|
||||
return irq_remapping_enabled == 1;
|
||||
if (cap == IOMMU_CAP_VIOMMU_HINT)
|
||||
return intel_caching_mode;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -944,7 +944,16 @@ static int viommu_of_xlate(struct device *dev, struct of_phandle_args *args)
|
|||
return iommu_fwspec_add_ids(dev, args->args, 1);
|
||||
}
|
||||
|
||||
static bool viommu_capable(enum iommu_cap cap)
|
||||
{
|
||||
if (cap == IOMMU_CAP_VIOMMU_HINT)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static struct iommu_ops viommu_ops = {
|
||||
.capable = viommu_capable,
|
||||
.domain_alloc = viommu_domain_alloc,
|
||||
.domain_free = viommu_domain_free,
|
||||
.attach_dev = viommu_attach_dev,
|
||||
|
|
|
@ -114,6 +114,8 @@ enum iommu_cap {
|
|||
transactions */
|
||||
IOMMU_CAP_INTR_REMAP, /* IOMMU supports interrupt isolation */
|
||||
IOMMU_CAP_NOEXEC, /* IOMMU_NOEXEC flag */
|
||||
IOMMU_CAP_VIOMMU_HINT, /* IOMMU can detect a hit for running in
|
||||
VM */
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue