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>
This commit is contained in:
Yin Fengwei 2020-04-22 13:23:42 +08:00 committed by wenlingz
parent 440385d53f
commit e8d00c2cec

View File

@ -443,5 +443,6 @@ int32_t copy_from_gva(struct acrn_vcpu *vcpu, void *h_ptr, uint64_t gva,
/* gpa --> hpa -->hva */
void *gpa2hva(struct acrn_vm *vm, uint64_t x)
{
return hpa2hva(gpa2hpa(vm, x));
uint64_t hpa = gpa2hpa(vm, x);
return (hpa == INVALID_HPA) ? NULL : hpa2hva(hpa);
}