Re: [PATCH 10/28] KVM: x86/mmu: pass PFERR_GUEST_PAGE/FINAL_MASK to kvm_translate_gpa

Sean Christopherson
2026-04-30T18:50:57Z

+Kevin and Yosry

On Thu, Apr 30, 2026, Paolo Bonzini wrote:
> static bool mmio_info_in_cache(struct kvm_vcpu *vcpu, u64 addr, bool direct)
> diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h
> index fb1b5d8b23e5..567f8b77ffe0 100644
> --- a/arch/x86/kvm/mmu/paging_tmpl.h
> +++ b/arch/x86/kvm/mmu/paging_tmpl.h
> @@ -376,7 +376,8 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
> walker->pte_gpa[walker->level - 1] = pte_gpa;
>
> real_gpa = kvm_translate_gpa(vcpu, mmu, gfn_to_gpa(table_gfn),
> - nested_access, &walker->fault);
> + nested_access | PFERR_GUEST_PAGE_MASK,
> + &walker->fault);
>
> /*
> * FIXME: This can happen if emulation (for of an INS/OUTS
> @@ -444,7 +445,9 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
> gfn += pse36_gfn_delta(pte);
> #endif
>
> - real_gpa = kvm_translate_gpa(vcpu, mmu, gfn_to_gpa(gfn), access, &walker->fault);
> + real_gpa = kvm_translate_gpa(vcpu, mmu, gfn_to_gpa(gfn),
> + access | PFERR_GUEST_FINAL_MASK,
> + &walker->fault);

Mostly a note to myself, we should make sure to land Kevin's fixes for synthesizing
the #NPF error code and EPT exit qualification in the same kernel (which I fully
plan on doing). I'm just happy we all came up with the same annotations :-)