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

From: Yosry Ahmed

Date: Tue May 26 2026 - 14:56:56 EST


> > > + 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.