From 0d90515bf6ee678a7de21e86f60323932826f82a Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Thu, 28 Feb 2019 16:23:15 +0800 Subject: [PATCH] HV: refine is_lapic_pt - Do not refer vm_configs[] directly in vm module; Tracked-On: #2291 Signed-off-by: Victor Sun Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/vm.c | 10 ++++++++++ hypervisor/include/arch/x86/guest/vm.h | 5 +---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index f720528b2..f1d99a183 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -60,6 +60,16 @@ bool is_sos_vm(const struct acrn_vm *vm) return (vm != NULL) && (vm == sos_vm_ptr); } +/** + * @pre vm != NULL && vm_config != NULL && vm->vmid < CONFIG_MAX_VM_NUM + */ +bool is_lapic_pt(const struct acrn_vm *vm) +{ + struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id); + + return ((vm_config->guest_flags & LAPIC_PASSTHROUGH) != 0U); +} + /** * @brief Initialize the I/O bitmap for \p vm * diff --git a/hypervisor/include/arch/x86/guest/vm.h b/hypervisor/include/arch/x86/guest/vm.h index 0f2007160..56e04f82f 100644 --- a/hypervisor/include/arch/x86/guest/vm.h +++ b/hypervisor/include/arch/x86/guest/vm.h @@ -244,10 +244,7 @@ uint16_t get_vm_pcpu_nums(const struct acrn_vm_config *vm_config); void vrtc_init(struct acrn_vm *vm); #endif -static inline bool is_lapic_pt(const struct acrn_vm *vm) -{ - return ((vm_configs[vm->vm_id].guest_flags & LAPIC_PASSTHROUGH) != 0U); -} +bool is_lapic_pt(const struct acrn_vm *vm); #endif /* !ASSEMBLER */