From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Wei Liu <wei.liu2@citrix.com>,
George Dunlap <George.Dunlap@eu.citrix.com>,
Tim Deegan <tim@xen.org>, IanJackson <Ian.Jackson@eu.citrix.com>,
xen-devel <xen-devel@lists.xenproject.org>,
Feng Wu <feng.wu@intel.com>
Subject: Re: Ping: [PATCH v3 2/4] x86: suppress SMEP and SMAP while running 32-bit PV guest code
Date: Wed, 4 May 2016 11:03:55 +0100 [thread overview]
Message-ID: <5729C90B.4050809@citrix.com> (raw)
In-Reply-To: <5728D0E502000078000E813C@prv-mh.provo.novell.com>
On 03/05/16 15:25, Jan Beulich wrote:
>>>> On 03.05.16 at 16:10, <andrew.cooper3@citrix.com> wrote:
>> On 03/05/16 14:58, Jan Beulich wrote:
>>>>>> On 17.03.16 at 09:03, wrote:
>>>> Since such guests' kernel code runs in ring 1, their memory accesses,
>>>> at the paging layer, are supervisor mode ones, and hence subject to
>>>> SMAP/SMEP checks. Such guests cannot be expected to be aware of those
>>>> two features though (and so far we also don't expose the respective
>>>> feature flags), and hence may suffer page faults they cannot deal with.
>>>>
>>>> While the placement of the re-enabling slightly weakens the intended
>>>> protection, it was selected such that 64-bit paths would remain
>>>> unaffected where possible. At the expense of a further performance hit
>>>> the re-enabling could be put right next to the CLACs.
>>>>
>>>> Note that this introduces a number of extra TLB flushes - CR4.SMEP
>>>> transitioning from 0 to 1 always causes a flush, and it transitioning
>>>> from 1 to 0 may also do.
>>>>
>>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>> So I think we need to take some decision here, and I'm afraid
>>> Andrew and I won't be able to settle this between us. He's
>>> validly concerned about the performance impact this got proven
>>> to have (for 32-bit PV guests), yet I continue to think that correct
>>> behavior is more relevant than performance. Hence I think we
>>> should bite the bullet and take the change. For those who value
>>> performance more than security, they can always disable the use
>>> of SMEP and SMAP via command line option.
>>>
>>> Of course I'm also concerned that Intel, who did introduce the
>>> functional regression in the first place, so far didn't participate at
>>> all in finding an acceptable solution to the problem at hand...
>> What I am even more concerned with is that the supposedly-optimised
>> version which tried to omit cr4 writes whenever possible caused a higher
>> performance overhead than the version which rewrite cr4 all the time.
>>
>> As is stands, v3 of the series is even worse for performance than v2.
>> That alone means that v3 is not in a suitable state to be accepted, as
>> there is some hidden bug in it.
> For one, we could take v2 (albeit that would feel odd).
>
> And then, from v3 showing worse performance (which only you
> have seen the numbers for, and [hopefully] know what deviations
> in them really mean)
The highlights for both v2 and v3 are on xen-devel.
> it does not follow that v3 is buggy.
It very much does follow.
> That's one
> possibility, sure (albeit hard to explain, as functionally everything
> is working fine for both you and me, afaik), but not the only one.
> Another may be that hardware processes CR4 writes faster when
> they happen in close succession to CR4 reads. And I'm sure more
> could be come up with.
v3 has logic intended to omit cr4 changes while in the content of 32bit
PV guest userspace. This in turn was intended to increase performance
by reducing the quantity of TLB flushes.
Even if hardware has logic to speed up CR4 writes when following reads,
the complete omission of the writes in the first place should
necessarily be faster still.
v3 performs ~20% worse compared to v2, which indicates that one of the
logical steps is wrong.
>
> And finally, I'm not tied to this patch set. I'd be fine with some
> other fix to restore correct behavior. What I'm not fine with is the
> limbo state this is being left in, with me all the time having to revive
> the discussion.
I agree that context switching cr4 is the only way of allowing 32bit PV
guests to function without impacting other functionality. After all,
the PV guest is doing precisely what SMAP is intended to catch.
I also accept that this will come with a performance overhead, but
frankly, the performance regression on these specific patches is
massive. I am very concerned that the first thing I will have to do in
XenServer is revert them.
I don't like this situation, but blindly ploughing ahead given these
issues is also a problem.
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-05-04 10:04 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-04 11:08 [PATCH 0/4] x86: accommodate 32-bit PV guests with SMAP/SMEP handling Jan Beulich
2016-03-04 11:27 ` [PATCH 1/4] x86/alternatives: correct near branch check Jan Beulich
2016-03-07 15:43 ` Andrew Cooper
2016-03-07 15:56 ` Jan Beulich
2016-03-07 16:11 ` Andrew Cooper
2016-03-07 16:21 ` Jan Beulich
2016-03-08 17:33 ` Andrew Cooper
2016-03-04 11:27 ` [PATCH 2/4] x86: suppress SMAP and SMEP while running 32-bit PV guest code Jan Beulich
2016-03-07 16:59 ` Andrew Cooper
2016-03-08 7:57 ` Jan Beulich
2016-03-09 8:09 ` Wu, Feng
2016-03-09 14:09 ` Jan Beulich
2016-03-09 11:19 ` Andrew Cooper
2016-03-09 14:28 ` Jan Beulich
2016-03-09 8:09 ` Wu, Feng
2016-03-09 10:45 ` Andrew Cooper
2016-03-09 12:27 ` Wu, Feng
2016-03-09 12:33 ` Andrew Cooper
2016-03-09 12:36 ` Jan Beulich
2016-03-09 12:54 ` Wu, Feng
2016-03-09 13:35 ` Wu, Feng
2016-03-09 13:42 ` Andrew Cooper
2016-03-09 14:03 ` Jan Beulich
2016-03-09 14:07 ` Jan Beulich
2016-03-04 11:28 ` [PATCH 3/4] x86: use optimal NOPs to fill the SMAP/SMEP placeholders Jan Beulich
2016-03-07 17:43 ` Andrew Cooper
2016-03-08 8:02 ` Jan Beulich
2016-03-04 11:29 ` [PATCH 4/4] x86: use 32-bit loads for 32-bit PV guest state reload Jan Beulich
2016-03-07 17:45 ` Andrew Cooper
2016-03-10 9:44 ` [PATCH v2 0/3] x86: accommodate 32-bit PV guests with SMEP/SMAP handling Jan Beulich
2016-03-10 9:53 ` [PATCH v2 1/3] x86: suppress SMEP and SMAP while running 32-bit PV guest code Jan Beulich
2016-05-13 15:48 ` Andrew Cooper
2016-03-10 9:54 ` [PATCH v2 2/3] x86: use optimal NOPs to fill the SMEP/SMAP placeholders Jan Beulich
2016-05-13 15:49 ` Andrew Cooper
2016-03-10 9:55 ` [PATCH v2 3/3] x86: use 32-bit loads for 32-bit PV guest state reload Jan Beulich
[not found] ` <56E9A0DB02000078000DD54C@prv-mh.provo.novell.com>
2016-03-17 7:50 ` [PATCH v3 0/4] x86: accommodate 32-bit PV guests with SMEP/SMAP handling Jan Beulich
2016-03-17 8:02 ` [PATCH v3 1/4] x86: move cached CR4 value to struct cpu_info Jan Beulich
2016-03-17 16:20 ` Andrew Cooper
2016-03-17 8:03 ` [PATCH v3 2/4] x86: suppress SMEP and SMAP while running 32-bit PV guest code Jan Beulich
2016-03-25 18:01 ` Konrad Rzeszutek Wilk
2016-03-29 6:55 ` Jan Beulich
2016-05-13 15:58 ` Andrew Cooper
2016-03-17 8:03 ` [PATCH v3 3/4] x86: use optimal NOPs to fill the SMEP/SMAP placeholders Jan Beulich
2016-05-13 15:57 ` Andrew Cooper
2016-05-13 16:06 ` Jan Beulich
2016-05-13 16:09 ` Andrew Cooper
2016-03-17 8:04 ` [PATCH v3 4/4] x86: use 32-bit loads for 32-bit PV guest state reload Jan Beulich
2016-03-25 18:02 ` Konrad Rzeszutek Wilk
2016-03-17 16:14 ` [PATCH v3 5/4] x86: reduce code size of struct cpu_info member accesses Jan Beulich
2016-03-25 18:47 ` Konrad Rzeszutek Wilk
2016-03-29 6:59 ` Jan Beulich
2016-03-30 14:28 ` Konrad Rzeszutek Wilk
2016-03-30 14:42 ` Jan Beulich
2016-05-13 16:11 ` Andrew Cooper
2016-05-03 13:58 ` Ping: [PATCH v3 2/4] x86: suppress SMEP and SMAP while running 32-bit PV guest code Jan Beulich
2016-05-03 14:10 ` Andrew Cooper
2016-05-03 14:25 ` Jan Beulich
2016-05-04 10:03 ` Andrew Cooper [this message]
2016-05-04 13:35 ` Jan Beulich
2016-05-04 3:07 ` Wu, Feng
2016-05-13 15:21 ` Wei Liu
2016-05-13 15:30 ` Jan Beulich
2016-05-13 15:33 ` Wei Liu
2016-05-13 17:02 ` [PATCH v3 0/4] x86: accommodate 32-bit PV guests with SMEP/SMAP handling Wei Liu
2016-05-13 17:21 ` Andrew Cooper
2016-06-21 6:19 ` Wu, Feng
2016-06-21 7:17 ` 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=5729C90B.4050809@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=feng.wu@intel.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@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 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).