xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
	"Jun Nakajima" <jun.nakajima@intel.com>,
	"Kevin Tian" <kevin.tian@intel.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 0/3] x86: Initial pieces for guest CET support
Date: Wed, 28 Apr 2021 13:25:45 +0100	[thread overview]
Message-ID: <d687a294-f0d8-62d0-12ac-2cb5582b8605@citrix.com> (raw)
In-Reply-To: <3e5369d1-a6eb-92c4-868c-0b9d205aba7a@citrix.com>

On 27/04/2021 11:13, Andrew Cooper wrote:
> There are 3 emulator complexities for shadow stack instructions.  SSP
> itself as a register, WRUSS no longer being CPL-based for
> user/supervisor, and the fact that RSTORSSP in particular uses an atomic
> block which microcode can express, but can't be encoded at an ISA
> level.  I've got no idea what to do about this last problem, because we
> can't map the two guest frames and re-issue the instruction - the
> aliasing check on the tokens forces us to map the two frames in their
> correct linear addresses.

Actually, RSTORSSP isn't too difficult.  I'd mis-read the pseudocode.

The atomic block is a check&edit of the token on the remote stack (not
both stacks, as I'd mistakenly thought).  The purpose is to prevent two
concurrent RSTORSSP's moving two threads onto the same shadow stack.

Without microcode superpowers, the best we can do this with a read,
check, cmpxchg() loop.

The common case will be no conflict, as stack switching will be well
formed (outside of debugging).  Any conflict here from real code is
going to yield #GP/#CP on one of the threads participating, so in the
case of a conflict in the emulator, a likely consequence of the 2nd
iteration is going to be a hard failure.

That said, malicious cases within the guest, or from foreign mappings,
can cause the cmpxchg() loop to take an unbounded time, so after 3
retries or so, we need to escalate to vcpu_pause_all_except_self(), and
or the ARM stop_machine() big hammer.

I'm tempted to just throw #GP back after 3 retries.  Its potentially
non-architectural behaviour, but won't occur in non-malicious
circumstances, and all fallback mechanisms have system-wide implications
that we oughtn't to be bowing to in a malicious circumstance.

~Andrew



  reply	other threads:[~2021-04-28 12:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-26 17:54 [PATCH 0/3] x86: Initial pieces for guest CET support Andrew Cooper
2021-04-26 17:54 ` [PATCH 1/3] x86/hvm: Introduce experimental " Andrew Cooper
2021-04-27 15:47   ` Jan Beulich
2021-04-27 17:39     ` Andrew Cooper
2021-04-28  9:11       ` Jan Beulich
2021-04-28 17:54         ` Andrew Cooper
2021-04-29  9:07           ` Jan Beulich
2021-04-30 15:08             ` Andrew Cooper
2021-04-26 17:54 ` [PATCH 2/3] x86/svm: Enumeration for CET Andrew Cooper
2021-04-27 15:53   ` Jan Beulich
2021-04-27 17:47     ` Andrew Cooper
2021-04-28  9:14       ` Jan Beulich
2021-04-28 14:17         ` Andrew Cooper
2021-04-26 17:54 ` [PATCH 3/3] x86/VT-x: " Andrew Cooper
2021-04-27 15:56   ` Jan Beulich
2021-04-27 16:27     ` Andrew Cooper
2021-04-28  9:18       ` Jan Beulich
2021-04-27  6:46 ` [PATCH 0/3] x86: Initial pieces for guest CET support Jan Beulich
2021-04-27 10:13   ` Andrew Cooper
2021-04-28 12:25     ` Andrew Cooper [this message]
2021-04-28 13:03       ` 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=d687a294-f0d8-62d0-12ac-2cb5582b8605@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).