Skip to content

Commit 32ed3d1

Browse files
binbinwu1lijinxia
authored andcommitted
hv: vtd: move public API to the bottom part of the file
Move move public API to the bottom part of the file. Tracked-On: #1855 Signed-off-by: Binbin Wu <binbin.wu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent efb2492 commit 32ed3d1

File tree

1 file changed

+44
-45
lines changed

1 file changed

+44
-45
lines changed

hypervisor/arch/x86/vtd.c

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -796,51 +796,6 @@ static void dmar_disable(struct dmar_drhd_rt *dmar_unit)
796796
dmar_fault_event_mask(dmar_unit);
797797
}
798798

799-
struct iommu_domain *create_iommu_domain(uint16_t vm_id, uint64_t translation_table, uint32_t addr_width)
800-
{
801-
struct iommu_domain *domain;
802-
803-
/* TODO: check if a domain with the vm_id exists */
804-
805-
if (translation_table == 0UL) {
806-
pr_err("translation table is NULL");
807-
return NULL;
808-
}
809-
810-
/*
811-
* A hypercall is called to create an iommu domain for a valid VM,
812-
* and hv code limit the VM number to CONFIG_MAX_VM_NUM.
813-
* So the array iommu_domains will not be accessed out of range.
814-
*/
815-
domain = &iommu_domains[vmid_to_domainid(vm_id)];
816-
817-
domain->is_host = false;
818-
domain->vm_id = vm_id;
819-
domain->trans_table_ptr = translation_table;
820-
domain->addr_width = addr_width;
821-
domain->is_tt_ept = true;
822-
domain->iommu_snoop = true;
823-
824-
dev_dbg(ACRN_DBG_IOMMU, "create domain [%d]: vm_id = %hu, ept@0x%x",
825-
vmid_to_domainid(domain->vm_id), domain->vm_id, domain->trans_table_ptr);
826-
827-
return domain;
828-
}
829-
830-
/**
831-
* @pre domain != NULL
832-
*/
833-
void destroy_iommu_domain(struct iommu_domain *domain)
834-
{
835-
/* currently only support ept */
836-
if (!domain->is_tt_ept) {
837-
ASSERT(false, "translation_table is not EPT!");
838-
}
839-
840-
/* TODO: check if any device assigned to this domain */
841-
(void)memset(domain, 0U, sizeof(*domain));
842-
}
843-
844799
static int add_iommu_device(struct iommu_domain *domain, uint16_t segment, uint8_t bus, uint8_t devfun)
845800
{
846801
struct dmar_drhd_rt *dmar_unit;
@@ -994,6 +949,50 @@ static int remove_iommu_device(const struct iommu_domain *domain, uint16_t segme
994949
return 0;
995950
}
996951

952+
struct iommu_domain *create_iommu_domain(uint16_t vm_id, uint64_t translation_table, uint32_t addr_width)
953+
{
954+
struct iommu_domain *domain;
955+
956+
/* TODO: check if a domain with the vm_id exists */
957+
958+
if (translation_table == 0UL) {
959+
pr_err("translation table is NULL");
960+
return NULL;
961+
}
962+
963+
/*
964+
* A hypercall is called to create an iommu domain for a valid VM,
965+
* and hv code limit the VM number to CONFIG_MAX_VM_NUM.
966+
* So the array iommu_domains will not be accessed out of range.
967+
*/
968+
domain = &iommu_domains[vmid_to_domainid(vm_id)];
969+
970+
domain->is_host = false;
971+
domain->vm_id = vm_id;
972+
domain->trans_table_ptr = translation_table;
973+
domain->addr_width = addr_width;
974+
domain->is_tt_ept = true;
975+
976+
dev_dbg(ACRN_DBG_IOMMU, "create domain [%d]: vm_id = %hu, ept@0x%x",
977+
vmid_to_domainid(domain->vm_id), domain->vm_id, domain->trans_table_ptr);
978+
979+
return domain;
980+
}
981+
982+
/**
983+
* @pre domain != NULL
984+
*/
985+
void destroy_iommu_domain(struct iommu_domain *domain)
986+
{
987+
/* currently only support ept */
988+
if (!domain->is_tt_ept) {
989+
ASSERT(false, "translation_table is not EPT!");
990+
}
991+
992+
/* TODO: check if any device assigned to this domain */
993+
(void)memset(domain, 0U, sizeof(*domain));
994+
}
995+
997996
int assign_iommu_device(struct iommu_domain *domain, uint8_t bus, uint8_t devfun)
998997
{
999998
/* TODO: check if the device assigned */

0 commit comments

Comments
 (0)