Re: [PATCH] x86/entry: Read CR2 in asm entry stub to redcue NMI clobbering window
From: Andrew Cooper
Date: Thu May 14 2026 - 15:49:51 EST
> I don't think there's a concrete enough problem being solved here to
> justify adding complexity to the entry code. Especially since it's not
> even a robust solution for the problem.
Well, corrupting CR2 is a real problem.
The very best case is that fixing the pagefault at the wrong CR2 is
benign, then rerun the faulting instruction having not fixed it up, and
get a repeat fault which this time wins the race with the NMI and
doesn't corrupt CR2, and gets fixed up properly.
It's not just CR2 which is a problem; DR6 and XFD_ERR. (the other
registers which have automatic side effects from exception delivery).
Really, the NMI handler needs to preserve the registers it potentially
clobbers, and that still requires the NMI handler doing it in assembly
before entering C.
~Andrew