mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-01-05 23:57:10 +00:00
hv: mmio_dev: add hypercall to support mmio device pass through
Add two hypercalls to support MMIO device pass through for post-launched VM. And when we support MMIO pass through for pre-launched VM, we could re-use the code in mmio_dev.c Tracked-On: #5053 Signed-off-by: Li Fei1 <fei1.li@intel.com>
This commit is contained in:
43
hypervisor/dm/mmio_dev.c
Normal file
43
hypervisor/dm/mmio_dev.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <util.h>
|
||||
#include <acrn_hv_defs.h>
|
||||
#include <pgtable.h>
|
||||
#include <vm.h>
|
||||
#include <ept.h>
|
||||
|
||||
int32_t assign_mmio_dev(struct acrn_vm *vm, const struct acrn_mmiodev *mmiodev)
|
||||
{
|
||||
int32_t ret = -EINVAL;
|
||||
|
||||
if (mem_aligned_check(mmiodev->base_gpa, PAGE_SIZE) &&
|
||||
mem_aligned_check(mmiodev->base_hpa, PAGE_SIZE) &&
|
||||
mem_aligned_check(mmiodev->size, PAGE_SIZE)) {
|
||||
ept_add_mr(vm, (uint64_t *)vm->arch_vm.nworld_eptp, mmiodev->base_hpa,
|
||||
is_sos_vm(vm) ? mmiodev->base_hpa : mmiodev->base_gpa,
|
||||
mmiodev->size, EPT_RWX | EPT_UNCACHED);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t deassign_mmio_dev(struct acrn_vm *vm, const struct acrn_mmiodev *mmiodev)
|
||||
{
|
||||
int32_t ret = -EINVAL;
|
||||
|
||||
if (mem_aligned_check(mmiodev->base_gpa, PAGE_SIZE) &&
|
||||
mem_aligned_check(mmiodev->base_hpa, PAGE_SIZE) &&
|
||||
mem_aligned_check(mmiodev->size, PAGE_SIZE)) {
|
||||
ept_del_mr(vm, (uint64_t *)vm->arch_vm.nworld_eptp,
|
||||
is_sos_vm(vm) ? mmiodev->base_hpa : mmiodev->base_gpa, mmiodev->size);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user