Skip to content

Commit e8d00c2

Browse files
fyin1wenlingz
authored andcommitted
local_gpa2hpa: INVALID_GPA also means failure of address conversion
Either INVALID_GPA or NULL returned from local_gpa2hpa means the page walk failure. But current code only take care of NULL and leave INVALID_GPA not detected. It could trigger ACRN crash in root mode when guest have a invalid gva. We add INVALID_GPA check as well. Tracked-On: #4721 Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
1 parent 440385d commit e8d00c2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

hypervisor/arch/x86/guest/guest_memory.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,5 +443,6 @@ int32_t copy_from_gva(struct acrn_vcpu *vcpu, void *h_ptr, uint64_t gva,
443443
/* gpa --> hpa -->hva */
444444
void *gpa2hva(struct acrn_vm *vm, uint64_t x)
445445
{
446-
return hpa2hva(gpa2hpa(vm, x));
446+
uint64_t hpa = gpa2hpa(vm, x);
447+
return (hpa == INVALID_HPA) ? NULL : hpa2hva(hpa);
447448
}

0 commit comments

Comments
 (0)