All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: George.Dunlap@eu.citrix.com, jbeulich@suse.com, julien@xen.org,
	roger.pau@citrix.com, sstabellini@kernel.org, wl@xen.org,
	xen-devel@lists.xenproject.org
Subject: Re: [Xen-devel] [PATCH] x86/sm{e, a}p: do not enable SMEP/SMAP in PV shim by default on AMD
Date: Thu, 12 Oct 2023 16:33:05 +0800	[thread overview]
Message-ID: <a055111e-c04e-4975-9fdc-81d6e74f1c74@citrix.com> (raw)
In-Reply-To: <26fd7f099ab39ffccc2a5db8b4224fac6806461e.camel@infradead.org>

On 12/10/2023 4:21 pm, David Woodhouse wrote:
> On Thu, 2023-10-12 at 10:13 +0800, andrew.cooper3@citrix.com wrote:
>> On 11/10/2023 7:34 pm, David Woodhouse wrote:
>>> But why does the shim even need to turn it off when switching to the
>>> guest context? Its guest isn't running in supervisor mode so surely it
>>> doesn't *matter* whether SMEP is enabled or not? Why not just leave it
>>> on at all times?
>>
>> 32bit PV kernels run in Ring1.  Which is supervisor and not user.
> 
> Ah, thanks.
> 
>> Some older PV kernels do execute on user pages, and don't like getting
>> SMEP faults when they didn't turn it on to begin with.
> 
> PV guests never actually had the option to turn SMEP on, did they? 
> 
> (Otherwise I may have to rethink the approach of just putting
> 'smep=off' onto the shim command line when running under KVM...)


Xen and PV guests share a set of pagetables.  There is no ability to
independently control SMEP/SMAP.

While we could in principle make SMEP an feature that PV kernels can opt
into, SMAP we really can't.  The emulation costs of STAC/CLAC are
obscene from a perf perspective.

One TODO which has yet to be done is to look at the PV kernel's
ELF32/64-ness.  For a shimmed 64bit guest, SMEP/SMAP should be on and
stay on.

TBH, it's probably best to just hide the SMEP/SMAP features, rather than
to play around with the cmdline.

~Andrew


  reply	other threads:[~2023-10-12  8:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-16 16:00 [Xen-devel] [PATCH] x86/sm{e, a}p: do not enable SMEP/SMAP in PV shim by default on AMD Igor Druzhinin
2020-01-16 16:16 ` Andrew Cooper
2023-10-11 11:34   ` David Woodhouse
2023-10-12  2:13     ` andrew.cooper3
2023-10-12  8:21       ` David Woodhouse
2023-10-12  8:33         ` Andrew Cooper [this message]
2020-01-17 11:10 ` Jan Beulich
2020-01-20 14:07 ` Roger Pau Monné
2020-01-20 14:38   ` Jan Beulich
2020-01-20 15:37     ` Roger Pau Monné

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=a055111e-c04e-4975-9fdc-81d6e74f1c74@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=dwmw2@infradead.org \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --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 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.