All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: andrew.cooper3@citrix.com
Cc: George.Dunlap@eu.citrix.com, ian.jackson@eu.citrix.com,
	 igor.druzhinin@citrix.com, jbeulich@suse.com, julien@xen.org,
	 konrad.wilk@oracle.com, 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: Wed, 11 Oct 2023 12:34:22 +0100	[thread overview]
Message-ID: <b4e8835566bc6e9becc4f8adea7bb3c6cc558db2.camel@infradead.org> (raw)
In-Reply-To: <40176a33-924e-8e81-7231-1b8df8b5e69f@citrix.com>

[-- Attachment #1: Type: text/plain, Size: 2342 bytes --]

> 
> On 16/01/2020 16:00, Igor Druzhinin wrote:
> > Due to AMD and Hygon being unable to selectively trap CR4 bit modifications
> > running 32-bit PV guest inside PV shim comes with significant performance
> > hit. Moreover, for SMEP in particular every time CR4.SMEP changes on context
> > switch to/from 32-bit PV guest, it gets trapped by L0 Xen which then
> > tries to perform global TLB invalidation for PV shim domain. This usually
> > results in eventual hang of a PV shim with at least several vCPUs.
> >
> > Since the overall security risk is generally lower for shim Xen as it being
> > there more of a defense-in-depth mechanism, choose to disable SMEP/SMAP in
> > it by default on AMD and Hygon unless a user chose otherwise.
> >
> > Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
> > ---
> > I'm a little bit on the fence with this one. We're having the same issue with
> > general nested virt but I'm not inclined to trade security for a user in
> > general case. Disabling it by default for PV shim only seems rather inocuous
> > due to the use case restricion. I'd like to hear more opinions.
> 
> So everyone on the list is up to date with the discussion we had IRL.
> 
> SMEP/SMAP are defence in depth measures.  We support running on hardware
> without these features, and the overall result is the same, security wise.
> 
> In the PV Shim case, there is only a single guest and nothing
> interesting in Xen, data wise.  We specifically do not have the risk of
> sideways data leakage from other guests to be worried about.
> 
> We do however care for performance, and not taking a VMExit on every
> SYSCALL/Interrupt/Exception makes a massive difference overall.

FWIW when running the shim under KVM even on Intel, constantly frobbing
the CR4.SMEP bit still performs awfully.

(Yes, we should make KVM pass that bit through to its guest on Intel
hardware, just as Xen does when it's the HVM host. cf.
https://lore.kernel.org/kvm/7fba6d8fc3de0bcb86bf629a4f5b0217552fe999.camel@infradead.org/T/#m39a117e90f29fc862b78ec1441b761459e7be86a
)

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?

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]

  reply	other threads:[~2023-10-11 11:35 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 [this message]
2023-10-12  2:13     ` andrew.cooper3
2023-10-12  8:21       ` David Woodhouse
2023-10-12  8:33         ` Andrew Cooper
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=b4e8835566bc6e9becc4f8adea7bb3c6cc558db2.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=igor.druzhinin@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=konrad.wilk@oracle.com \
    --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.