HV: Modularize vtd.c to remove acrn_vm usage

This patch is a modified one. It removes the usage
of acrn_vm struct from inside vtd.c.
It also puts struct iommu_domain inside vtd.h,
from vtd.c.
It modifies the signature of init_iommu_domain
in order to remove dependency on acrn_vm from
inside vtd.c.
Incorporated comments from Jason and Eddie.
Changed the name of sos_vm_domain to
fallback_iommu_domain
Removed any reference of sos_vm from vtd.[c|h]
files, including comments.

Tracked-On: #2496
Signed-off-by: Arindam Roy <arindam.roy@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Arindam Roy
2019-01-25 14:18:55 -08:00
committed by wenlingz
parent 24cf377d5d
commit de8d85753e
13 changed files with 49 additions and 39 deletions

View File

@@ -38,7 +38,6 @@
#include <vmx.h>
#include <vmcs.h>
#include <assign.h>
#include <vtd.h>
#include <guest_memory.h>
#include <vmexit.h>

View File

@@ -47,6 +47,15 @@ enum acpi_dmar_scope_type {
ACPI_DMAR_SCOPE_TYPE_RESERVED = 6 /* 6 and greater are reserved */
};
struct iommu_domain {
bool is_host;
bool is_tt_ept; /* if reuse EPT of the domain */
uint16_t vm_id;
uint32_t addr_width; /* address width of the domain */
uint64_t trans_table_ptr;
bool iommu_snoop;
};
static inline uint8_t dmar_ver_major(uint64_t version)
{
return (((uint8_t)version & 0xf0U) >> 4U);
@@ -532,7 +541,7 @@ struct iommu_domain;
/**
* @brief Assign a device specified by bus & devfun to a iommu domain.
*
* Remove the device from the SOS_VM domain (if present), and add it to the specific domain.
* Remove the device from the fallback iommu domain (if present), and add it to the specific domain.
*
* @param[in] domain iommu domain the device is assigned to
* @param[in] bus the 8-bit bus number of the device
@@ -549,7 +558,7 @@ int32_t assign_iommu_device(struct iommu_domain *domain, uint8_t bus, uint8_t de
/**
* @brief Unassign a device specified by bus & devfun from a iommu domain .
*
* Remove the device from the specific domain, and then add it to the SOS_VM domain (if present).
* Remove the device from the specific domain, and then add it to the fallback iommu domain (if present).
*
* @param[in] domain iommu domain the device is assigned to
* @param[in] bus the 8-bit bus number of the device
@@ -641,30 +650,32 @@ void resume_iommu(void);
int32_t init_iommu(void);
/**
* @brief Init SOS_VM domain of iommu.
* @brief Init fallback iommu domain of iommu.
*
* Create SOS_VM domain using the Normal World's EPT table of SOS_VM as address translation table.
* All PCI devices are added to the SOS_VM domain when creating it.
* Create fallback iommu domain using the Normal World's EPT table of fallback iommu as address translation table.
* All PCI devices are added to the fallback iommu domain when creating it.
*
* @param[in] sos_vm pointer to SOS_VM
* @param[in] iommu_dmn pointer to fallback iommu domain
* @param[in] vm_id ID of the VM for which iommu_domain needs to be created
* @param[in] eptp EPT hieararchy table
*
* @pre sos_vm shall point to SOS_VM
* @pre iommu shall point to fallback iommu domain
*
* @remark to reduce boot time & memory cost, a config IOMMU_INIT_BUS_LIMIT, which limit the bus number.
*
*/
void init_iommu_sos_vm_domain(struct acrn_vm *sos_vm);
void init_fallback_iommu_domain(struct iommu_domain *iommu_dmn, uint16_t vm_id, void *eptp);
/**
* @brief check the iommu if support cache snoop.
*
* @param[in] vm pointer to VM to check
* @param[in] iommu pointer to iommu domain to check
*
* @retval true support
* @retval false not support
*
*/
bool iommu_snoop_supported(const struct acrn_vm *vm);
bool iommu_snoop_supported(const struct iommu_domain *iommu);
/**
* @brief Assign RTE for Interrupt Remapping Table.