Skip to content

Commit cd40980

Browse files
mingqiangchiacrnsi
authored andcommitted
hv:change function parameter for invept
change the input parameter from vcpu to eptp in order to let this api more generic, no need to care normal world or secure world. Tracked-On: #1842 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
1 parent 1547a4c commit cd40980

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

hypervisor/arch/x86/guest/virq.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,10 @@ int32_t acrn_handle_pending_request(struct acrn_vcpu *vcpu)
374374
} else {
375375

376376
if (bitmap_test_and_clear_lock(ACRN_REQUEST_EPT_FLUSH, pending_req_bits)) {
377-
invept(vcpu);
377+
invept(vcpu->vm->arch_vm.nworld_eptp);
378+
if (vcpu->vm->sworld_control.flag.active != 0UL) {
379+
invept(vcpu->vm->arch_vm.sworld_eptp);
380+
}
378381
}
379382

380383
if (bitmap_test_and_clear_lock(ACRN_REQUEST_VPID_FLUSH, pending_req_bits)) {

hypervisor/arch/x86/mmu.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include <mmu.h>
3636
#include <vmx.h>
3737
#include <reloc.h>
38-
#include <vcpu.h>
3938
#include <vm.h>
4039
#include <ld_sym.h>
4140
#include <logmsg.h>
@@ -123,19 +122,13 @@ void flush_vpid_global(void)
123122
local_invvpid(VMX_VPID_TYPE_ALL_CONTEXT, 0U, 0UL);
124123
}
125124

126-
void invept(const struct acrn_vcpu *vcpu)
125+
void invept(const void *eptp)
127126
{
128127
struct invept_desc desc = {0};
129128

130129
if (pcpu_has_vmx_ept_cap(VMX_EPT_INVEPT_SINGLE_CONTEXT)) {
131-
desc.eptp = hva2hpa(vcpu->vm->arch_vm.nworld_eptp) |
132-
(3UL << 3U) | 6UL;
130+
desc.eptp = hva2hpa(eptp) | (3UL << 3U) | 6UL;
133131
local_invept(INVEPT_TYPE_SINGLE_CONTEXT, desc);
134-
if (vcpu->vm->sworld_control.flag.active != 0UL) {
135-
desc.eptp = hva2hpa(vcpu->vm->arch_vm.sworld_eptp)
136-
| (3UL << 3U) | 6UL;
137-
local_invept(INVEPT_TYPE_SINGLE_CONTEXT, desc);
138-
}
139132
} else if (pcpu_has_vmx_ept_cap(VMX_EPT_INVEPT_GLOBAL_CONTEXT)) {
140133
local_invept(INVEPT_TYPE_ALL_CONTEXTS, desc);
141134
} else {

hypervisor/include/arch/x86/mmu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ void flush_address_space(void *addr, uint64_t size);
165165
/**
166166
* @brief Guest-physical mappings and combined mappings invalidation
167167
*
168-
* @param[in] vcpu the pointer that points the vcpu data structure
168+
* @param[in] eptp the pointer that points the eptp
169169
*
170170
* @return None
171171
*/
172-
void invept(const struct acrn_vcpu *vcpu);
172+
void invept(const void *eptp);
173173

174174
static inline void cache_flush_invalidate_all(void)
175175
{

hypervisor/include/arch/x86/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static inline void *hpa2hva(uint64_t x)
186186
*
187187
* @return The translated host-physical address
188188
*/
189-
static inline uint64_t hva2hpa(void *x)
189+
static inline uint64_t hva2hpa(const void *x)
190190
{
191191
return (uint64_t)x;
192192
}

0 commit comments

Comments
 (0)