Re: [PATCH v2 5/8] KVM: arm64: nv: Replace a pending SError when injecting a new one
From: Dan Carpenter
Date: Wed Nov 25 2026 - 04:51:47 EST
On Wed, Nov 25, 2026 at 12:00:15AM -0800, Oliver Upton wrote:
> Hi Dan,
>
> On Wed, Nov 25, 2026 at 09:56:20AM +0300, Dan Carpenter wrote:
> > The kvm_inject_serror_esr() function injects SErrors as the name
> > implies. The bug is that it doesn't handle already pending errors
> > correctly in nested virtualization.
> >
> > In vanilla KVM the kvm_inject_serror_esr() function always sets
> > the SError to pending. However with nested KVM, it might set it
> > to pending or it might deliver the SError directly. We can only
> > have one pending error at a time. Imagine we enter the function
> > with an SError pending already. In the current code if we decide
> > to pend the new error that's fine, everything works. However if
> > we decide to deliver it directly then the pend flags should be
> > cleared but they are not. So we deliver the SError directly and
> > then the SError that was pending on the next exit or entry.
>
> I could use a bit more color on how we got here. From what I can tell
> this state is only possible if userspace changed the routing / masking
> of the SError outside the context of a KVM_RUN. Otherwise, if the SError
> is deliverable on guest exit we perform the injection prior to exiting
> to userspace.
>
Yes, but the main reason is that I'm changing the way
kvm_nested_sync_hwstate() works in patch 7. Now every stored SError
stays in NESTED_SERROR_PENDING across handle_exit() so this situation
will become more common.
I will include that in the commit message when I resend.
regards,
dan carpenter