Re: [PATCH v4 3/5] KVM: SVM: Fix nested NPF injection of PFERR_GUEST_{PAGE,FINAL}_MASK bits

From: Sean Christopherson

Date: Wed May 27 2026 - 14:23:59 EST


On Tue, May 26, 2026, Yosry Ahmed wrote:
> > > > + vmcb->control.exit_code = SVM_EXIT_NPF;
> > > > + vmcb->control.exit_info_1 = fault_stage |
> > > > + (fault->error_code & ~PFERR_GUEST_FAULT_STAGE_MASK);
> > >
> > > Do we need to do this in the common path?
> >
> > What do you mean by "this"? Pulling flags from fault->error_code?
>
> Yes, sorry if that wasn't clear.
>
> >
> > > If from_hardware=true, can the fault injected by KVM have different flags
> > > from the one produced by hardware?
> >
> > Flags, yes. fault_stage, no.
>
> Right, I meant the flags.
>
> >
> > > I guess the answer is yes, (e.g. if KVM is doing write-protection?). Might be
> > > worth a comment.
> >
> > Or if L1 has modified its TDP PTEs in memory, but hasn't yet flushed TLBs. In
> > that case, KVM's software walker can see the updated PTEs, while hardware may
> > have seen something else.
>
> Makes sense. A comment would be helpful for laymans like myself.

I elected to not add a comment for now, because I'm not 100% confident the nSVM
code is correct, and so didn't want to stealth in a comment that wasn't correct
either. It's certainly much better than it was, but especially with GMET in play,
I need to stare more to convince myself it handles all the edge cases correctly.