Re: [PATCH V2 2/4] KVM: SVM: Fix nested NPF injection to set PFERR_GUEST_{PAGE,FINAL}_MASK

From: Sean Christopherson

Date: Tue Feb 24 2026 - 12:05:13 EST


On Tue, Feb 24, 2026, Sean Christopherson wrote:
> > diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h
> > index 37eba7dafd14f..f148c92b606ba 100644
> > --- a/arch/x86/kvm/mmu/paging_tmpl.h
> > +++ b/arch/x86/kvm/mmu/paging_tmpl.h
> > @@ -385,18 +385,12 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
> > real_gpa = kvm_translate_gpa(vcpu, mmu, gfn_to_gpa(table_gfn),
> > nested_access, &walker->fault);
> >
> > - /*
> > - * FIXME: This can happen if emulation (for of an INS/OUTS
> > - * instruction) triggers a nested page fault. The exit
> > - * qualification / exit info field will incorrectly have
> > - * "guest page access" as the nested page fault's cause,
> > - * instead of "guest page structure access". To fix this,
> > - * the x86_exception struct should be augmented with enough
> > - * information to fix the exit_qualification or exit_info_1
> > - * fields.
> > - */
> > - if (unlikely(real_gpa == INVALID_GPA))
> > + if (unlikely(real_gpa == INVALID_GPA)) {
> > +#if PTTYPE != PTTYPE_EPT
>
> I would rather swap the order of patches two and three, so that we end up with
> a "positive" if-statement. I.e. add EPT first so that we get (spoiler alert):
>
> #if PTTYPE == PTTYPE_EPT
> walker->fault.exit_qualification |= EPT_VIOLATION_GVA_IS_VALID;
> #else
> walker->fault.error_code |= PFERR_GUEST_PAGE_MASK;
> #endif

Scratch this comment, I got my walkers confused.