]> xenbits.xensource.com Git - xen.git/commit
x86/traps: Re-enable interrupts after reading cr2 in the #PF handler
authorAlejandro Vallejo <alejandro.vallejo@cloud.com>
Tue, 29 Oct 2024 15:37:32 +0000 (16:37 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 29 Oct 2024 15:37:32 +0000 (16:37 +0100)
commita5823065558b98f2c8ae78dfa882f2293e1a8a2f
treeffdd70d6a29c43fa7c2c817ace702ce534b2d2c1
parent0902958b51a6135ce43bee2c9eadd43f481e311d
x86/traps: Re-enable interrupts after reading cr2 in the #PF handler

Hitting a page fault clobbers %cr2, so if a page fault is handled while
handling a previous page fault then %cr2 will hold the address of the
latter fault rather than the former. In particular, if a debug key
handler happens to trigger during #PF and before %cr2 is read, and that
handler itself encounters a #PF, then %cr2 will be corrupt for the outer #PF
handler.

This patch makes the page fault path delay re-enabling IRQs until %cr2
has been read in order to ensure it stays consistent.

A similar argument holds in additional cases, but they happen to be safe:
    * %dr6 inside #DB: Safe because IST exceptions don't re-enable IRQs.
    * MSR_XFD_ERR inside #NM: Safe because AMX isn't used in #NM handler.

While in the area, remove redundant q suffix to a movq in entry.S and
the space after the comma.

Fixes: a4cd20a19073 ("[XEN] 'd' key dumps both host and guest state.")
Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
master commit: b06e76db7c35974f1b127762683e7852ca0c8e76
master date: 2024-10-01 09:45:49 +0200
xen/arch/x86/traps.c
xen/arch/x86/x86_64/entry.S