Re: [PATCH] KVM: x86: fix access code passed to gva_to_gpa

From: Paolo Bonzini
Date: Mon Aug 17 2020 - 14:56:54 EST


On 17/08/20 20:42, Sean Christopherson wrote:
>
> Don't suppose you'd be in the mood to kill the bare 'unsigned'?
>
> WARNING: Prefer 'unsigned int' to bare use of 'unsigned'

u32 is even better.

> Alternatively, what about capturing the result in a new variable (instead of
> defining the mask) to make the wrap suck less (or just overflow like the
> current code), e.g.:
>
> u32 access = error_code &
> (PFERR_WRITE_MASK | PFERR_FETCH_MASK | PFERR_USER_MASK);
>
> if (!(error_code & PFERR_PRESENT_MASK) ||
> vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, access, &fault) != UNMAPPED_GVA) {

Sure, that's better.

Paolo