Skip to content

Commit b37008d

Browse files
mgcaolijinxia
authored andcommitted
HV: check secure/normal world for EPTP in gpa2hpa
for secure and normal world has different EPTP, in secure world, it could trap to hypervisor and call gpa2hpa function. So it need check if it is in normal or secure world for EPTP selection. Detailed explanation from Yadong Qi <yadong.qi@intel.com>: Currently, trusty OS does not handle interrupt, so when an interrupt is delivering in trusty, trusty will set it to LAPIC IRR register by inject self_ipi() and then call world_switch to switch to Android, So android will receive/handle the interrupt properly.Since the vLAPIC is enabled in ACRN, so when trusty try to inject self_ipi(), APIC-ACCESS vmexit will happen. Then ACRN will do instruction decode/emulation, so the GPA2HPA will fail since page walk is using nworld_eptp. It is probability an issue. Signed-off-by: Minggui Cao <minggui.cao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 10a4c6c commit b37008d

File tree

2 files changed

+10
-3
lines changed
  • hypervisor

2 files changed

+10
-3
lines changed

hypervisor/arch/x86/ept.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,16 @@ uint64_t local_gpa2hpa(const struct vm *vm, uint64_t gpa, uint32_t *size)
104104
{
105105
uint64_t hpa = 0UL;
106106
uint64_t *pgentry, pg_size = 0UL;
107+
void *eptp;
108+
struct vcpu *vcpu = vcpu_from_pid(vm, get_cpu_id());
107109

108-
pgentry = lookup_address((uint64_t *)vm->arch_vm.nworld_eptp,
109-
gpa, &pg_size, PTT_EPT);
110+
if (vcpu && (vcpu->arch_vcpu.cur_context == SECURE_WORLD)) {
111+
eptp = vm->arch_vm.sworld_eptp;
112+
} else {
113+
eptp = vm->arch_vm.nworld_eptp;
114+
}
115+
116+
pgentry = lookup_address((uint64_t *)eptp, gpa, &pg_size, PTT_EPT);
110117
if (pgentry != NULL) {
111118
hpa = ((*pgentry & (~(pg_size - 1UL)))
112119
| (gpa & (pg_size - 1UL)));

hypervisor/include/arch/x86/guest/vm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ static inline struct vcpu *vcpu_from_vid(struct vm *vm, uint16_t vcpu_id)
216216
return NULL;
217217
}
218218

219-
static inline struct vcpu *vcpu_from_pid(struct vm *vm, uint16_t pcpu_id)
219+
static inline struct vcpu *vcpu_from_pid(const struct vm *vm, uint16_t pcpu_id)
220220
{
221221
uint16_t i;
222222
struct vcpu *vcpu;

0 commit comments

Comments
 (0)