Re: [BUG] KVM: x86: __set_regs() silently drops a pending nested exception destined to VM-exit to L1

From: Sean Christopherson

Date: Fri Oct 16 2026 - 20:51:22 EST


On Sat, Oct 17, 2026, Amirmohammad Eftekhar wrote:
> Hi,
>
> __set_regs() (arch/x86/kvm/regs.c:102) unconditionally clears both pending
> exception queues:
>
> vcpu->arch.exception.pending = false; /* regs.c:129 */
> vcpu->arch.exception_vmexit.pending = false; /* regs.c:130 */

And? It's an ioctl. KVM can do whatever it wants, so long as it doesn't break
userspace. Clearing the exception queue was deliberately added by commit
b4f14abd95cd ("KVM: Avoid spurious execeptions after setting registers") back in
2008. Whether or not that was the best fix way back when, probably not. But it
simply doesn't matter, this has been KVM's behavior for 18+ years.