From: "Alejandro Vallejo" <alejandro.vallejo@cloud.com>
To: "Alejandro Vallejo" <alejandro.vallejo@cloud.com>,
"Xen-devel" <xen-devel@lists.xenproject.org>
Cc: "Jan Beulich" <jbeulich@suse.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [PATCH v3] x86/traps: Re-enable interrupts after reading cr2 in the #PF handler
Date: Fri, 27 Sep 2024 15:39:29 +0100 [thread overview]
Message-ID: <D4H575Q7NIO1.155E12B37CBAQ@cloud.com> (raw)
In-Reply-To: <20240927142305.299841-1-alejandro.vallejo@cloud.com>
On Fri Sep 27, 2024 at 3:23 PM BST, Alejandro Vallejo wrote:
> 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. 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
> add 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>
> ---
> v3:
> * s/dispatch_handlers/dispatch_exceptions/
> * Updated commit message, spelling out the state of #DB and #NM, and
> state an existing race with debug keys.
Bah, I didn't refresh the patch with the latest commit message. It was meant to
be:
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
add 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>
Would whoever planned to commit this mind replacing the commit msg on commit?
Otherwise I'll just resend.
Cheers,
Alejandro
next prev parent reply other threads:[~2024-09-27 14:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-27 14:23 [PATCH v3] x86/traps: Re-enable interrupts after reading cr2 in the #PF handler Alejandro Vallejo
2024-09-27 14:39 ` Alejandro Vallejo [this message]
2024-09-27 14:50 ` Alejandro Vallejo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D4H575Q7NIO1.155E12B37CBAQ@cloud.com \
--to=alejandro.vallejo@cloud.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.