hypervisor: use "wbinvd" carefully in RT environment

Due to the side-effect to cache of "wbinvd" instruction, just apply it
in case of noncoherent DMA.

Tracked-On: #1824
Signed-off-by: Zheng, Gen <gen.zheng@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
This commit is contained in:
Zheng, Gen
2018-11-14 22:03:04 +08:00
committed by lijinxia
parent 61e6c1f054
commit b32e689a64
4 changed files with 47 additions and 5 deletions

View File

@@ -131,6 +131,7 @@ struct iommu_domain {
uint16_t vm_id;
uint32_t addr_width; /* address width of the domain */
uint64_t trans_table_ptr;
bool iommu_snoop;
};
struct context_table {
@@ -152,6 +153,15 @@ get_ctx_table(uint32_t dmar_index, uint8_t bus_no)
return ctx_tables[dmar_index].buses[bus_no].contents;
}
bool iommu_snoop_supported(struct acrn_vm *vm)
{
if (vm->iommu == NULL || vm->iommu->iommu_snoop) {
return true;
}
return false;
}
static struct dmar_drhd_rt dmar_drhd_units[CONFIG_MAX_IOMMU_NUM];
static struct iommu_domain *vm0_domain;
@@ -892,6 +902,7 @@ struct iommu_domain *create_iommu_domain(uint16_t vm_id, uint64_t translation_ta
domain->trans_table_ptr = translation_table;
domain->addr_width = addr_width;
domain->is_tt_ept = true;
domain->iommu_snoop = true;
dev_dbg(ACRN_DBG_IOMMU, "create domain [%d]: vm_id = %hu, ept@0x%x",
vmid_to_domainid(domain->vm_id),
@@ -915,7 +926,7 @@ void destroy_iommu_domain(struct iommu_domain *domain)
(void)memset(domain, 0U, sizeof(*domain));
}
static int add_iommu_device(const struct iommu_domain *domain, uint16_t segment,
static int add_iommu_device(struct iommu_domain *domain, uint16_t segment,
uint8_t bus, uint8_t devfun)
{
struct dmar_drhd_rt *dmar_uint;
@@ -946,6 +957,12 @@ static int add_iommu_device(const struct iommu_domain *domain, uint16_t segment,
return 1;
}
if (iommu_ecap_sc(dmar_uint->ecap) == 0U) {
domain->iommu_snoop = false;
dev_dbg(ACRN_DBG_IOMMU, "vm=%d add %x:%x no snoop control!",
domain->vm_id, bus, devfun);
}
ASSERT(dmar_uint->root_table_addr != 0UL, "root table is not setup");
root_table =
@@ -1104,7 +1121,7 @@ remove_iommu_device(const struct iommu_domain *domain, uint16_t segment,
return 0;
}
int assign_iommu_device(const struct iommu_domain *domain, uint8_t bus,
int assign_iommu_device(struct iommu_domain *domain, uint8_t bus,
uint8_t devfun)
{
/* TODO: check if the device assigned */