From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Teddy Astie" <teddy.astie@vates.tech>
Subject: Re: [PATCH v2 2/3] x86/traps: use entry_ssp in fixup_exception_return()
Date: Wed, 8 Apr 2026 18:34:48 +0100 [thread overview]
Message-ID: <9b9586d2-c18d-47b5-bce0-4c9a4570bcfd@citrix.com> (raw)
In-Reply-To: <79c90706-0530-4b72-9b43-f003dfe87291@suse.com>
On 08/04/2026 1:23 pm, Jan Beulich wrote:
> With the value recorded on entry there's no need anymore to go hunt for
> the respective exception frame on the shadow stack. By deriving "ptr"
> from that field (without any offset), it then ends up pointin one slot
pointing
> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -1187,26 +1174,28 @@ void asmlinkage noreturn do_unhandled_tr
> static void fixup_exception_return(struct cpu_user_regs *regs,
> unsigned long fixup, unsigned long stub_ra)
> {
> - if ( IS_ENABLED(CONFIG_XEN_SHSTK) )
> +#ifdef CONFIG_XEN_SHSTK
> {
> - unsigned long ssp, *ptr, *base;
> + unsigned long ssp = rdssp();
>
> - if ( (ssp = rdssp()) == SSP_NO_SHSTK )
> - goto shstk_done;
> + if ( ssp != SSP_NO_SHSTK )
> + {
> + unsigned long *ptr = _p(regs->entry_ssp);
> + unsigned long primary_shstk =
> + (ssp & ~(STACK_SIZE - 1)) +
> + (PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8;
>
> - ptr = _p(ssp);
> - base = _p(get_shstk_bottom(ssp));
> + BUG_ON((regs->entry_ssp ^ primary_shstk) >> PAGE_SHIFT);
This BUG() isn't correct.
We can be in a fixup while in an IST handler, at which point SSP does
not point to the primary shstk. e.g. wrmsr_safe() in #MC.
If you're looking to at least roughly bound it, check that it's any
where in the stack range. The WRSS below will #PF if SSP isn't
referring to a shadow stack.
Alternatively, add an is_shstk_page() predicate which checks for
get_stack_page() == 5,0 which are the two shstk frames in the block of 8.
~Andrew
next prev parent reply other threads:[~2026-04-08 17:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 12:20 [PATCH v2 0/3] x86: CET-SS related adjustments Jan Beulich
2026-04-08 12:22 ` [PATCH v2 1/3] x86: record SSP at non-guest entry points Jan Beulich
2026-04-08 16:58 ` Andrew Cooper
2026-04-09 8:13 ` Jan Beulich
2026-04-09 11:22 ` Andrew Cooper
2026-04-09 12:44 ` Jan Beulich
2026-04-08 12:23 ` [PATCH v2 2/3] x86/traps: use entry_ssp in fixup_exception_return() Jan Beulich
2026-04-08 17:34 ` Andrew Cooper [this message]
2026-04-08 12:23 ` [PATCH v2 3/3] x86: prefer shadow stack for producing call traces Jan Beulich
2026-04-08 17:53 ` Andrew Cooper
2026-04-09 8:42 ` Jan Beulich
2026-04-09 10:41 ` Jan Beulich
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=9b9586d2-c18d-47b5-bce0-4c9a4570bcfd@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=teddy.astie@vates.tech \
--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.