diff --git a/hypervisor/arch/x86/guest/virq.c b/hypervisor/arch/x86/guest/virq.c index 7d3890b42..11d1d3e0d 100644 --- a/hypervisor/arch/x86/guest/virq.c +++ b/hypervisor/arch/x86/guest/virq.c @@ -374,7 +374,10 @@ int32_t acrn_handle_pending_request(struct acrn_vcpu *vcpu) } else { if (bitmap_test_and_clear_lock(ACRN_REQUEST_EPT_FLUSH, pending_req_bits)) { - invept(vcpu); + invept(vcpu->vm->arch_vm.nworld_eptp); + if (vcpu->vm->sworld_control.flag.active != 0UL) { + invept(vcpu->vm->arch_vm.sworld_eptp); + } } if (bitmap_test_and_clear_lock(ACRN_REQUEST_VPID_FLUSH, pending_req_bits)) { diff --git a/hypervisor/arch/x86/mmu.c b/hypervisor/arch/x86/mmu.c index 1668d8deb..9784daa1d 100644 --- a/hypervisor/arch/x86/mmu.c +++ b/hypervisor/arch/x86/mmu.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -123,19 +122,13 @@ void flush_vpid_global(void) local_invvpid(VMX_VPID_TYPE_ALL_CONTEXT, 0U, 0UL); } -void invept(const struct acrn_vcpu *vcpu) +void invept(const void *eptp) { struct invept_desc desc = {0}; if (pcpu_has_vmx_ept_cap(VMX_EPT_INVEPT_SINGLE_CONTEXT)) { - desc.eptp = hva2hpa(vcpu->vm->arch_vm.nworld_eptp) | - (3UL << 3U) | 6UL; + desc.eptp = hva2hpa(eptp) | (3UL << 3U) | 6UL; local_invept(INVEPT_TYPE_SINGLE_CONTEXT, desc); - if (vcpu->vm->sworld_control.flag.active != 0UL) { - desc.eptp = hva2hpa(vcpu->vm->arch_vm.sworld_eptp) - | (3UL << 3U) | 6UL; - local_invept(INVEPT_TYPE_SINGLE_CONTEXT, desc); - } } else if (pcpu_has_vmx_ept_cap(VMX_EPT_INVEPT_GLOBAL_CONTEXT)) { local_invept(INVEPT_TYPE_ALL_CONTEXTS, desc); } else { diff --git a/hypervisor/include/arch/x86/mmu.h b/hypervisor/include/arch/x86/mmu.h index 4bb63c0d4..8dcd6507e 100644 --- a/hypervisor/include/arch/x86/mmu.h +++ b/hypervisor/include/arch/x86/mmu.h @@ -165,11 +165,11 @@ void flush_address_space(void *addr, uint64_t size); /** * @brief Guest-physical mappings and combined mappings invalidation * - * @param[in] vcpu the pointer that points the vcpu data structure + * @param[in] eptp the pointer that points the eptp * * @return None */ -void invept(const struct acrn_vcpu *vcpu); +void invept(const void *eptp); static inline void cache_flush_invalidate_all(void) { diff --git a/hypervisor/include/arch/x86/pgtable.h b/hypervisor/include/arch/x86/pgtable.h index 8c95c0c25..37c9ba17a 100644 --- a/hypervisor/include/arch/x86/pgtable.h +++ b/hypervisor/include/arch/x86/pgtable.h @@ -186,7 +186,7 @@ static inline void *hpa2hva(uint64_t x) * * @return The translated host-physical address */ -static inline uint64_t hva2hpa(void *x) +static inline uint64_t hva2hpa(const void *x) { return (uint64_t)x; }