From: Andrew Cooper <andrew.cooper3@citrix.com>
To: "Wu, Feng" <feng.wu@intel.com>, Jan Beulich <JBeulich@suse.com>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
"Dong, Eddie" <eddie.dong@intel.com>,
"ian.campbell@citrix.com" <ian.campbell@citrix.com>,
"Nakajima, Jun" <jun.nakajima@intel.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH v6 05/10] Clear AC bit in RFLAGS to protect Xen itself by SMAP
Date: Thu, 8 May 2014 10:48:37 +0100 [thread overview]
Message-ID: <536B52F5.4050801@citrix.com> (raw)
In-Reply-To: <E959C4978C3B6342920538CF579893F001F703AB@SHSMSX104.ccr.corp.intel.com>
On 08/05/2014 03:02, Wu, Feng wrote:
>> -----Original Message-----
>> From: Andrew Cooper [mailto:amc96@hermes.cam.ac.uk] On Behalf Of
>> Andrew Cooper
>> Sent: Thursday, May 08, 2014 9:58 AM
>> To: Wu, Feng; Jan Beulich
>> Cc: ian.campbell@citrix.com; Dong, Eddie; Nakajima, Jun; Tian, Kevin;
>> xen-devel@lists.xen.org
>> Subject: Re: [PATCH v6 05/10] Clear AC bit in RFLAGS to protect Xen itself by
>> SMAP
>>
>> On 08/05/2014 02:41, Wu, Feng wrote:
>>>> -----Original Message-----
>>>> From: Andrew Cooper [mailto:andrew.cooper3@citrix.com]
>>>> Sent: Wednesday, May 07, 2014 7:54 PM
>>>> To: Jan Beulich
>>>> Cc: Wu, Feng; ian.campbell@citrix.com; Dong, Eddie; Nakajima, Jun; Tian,
>>>> Kevin; xen-devel@lists.xen.org
>>>> Subject: Re: [PATCH v6 05/10] Clear AC bit in RFLAGS to protect Xen itself by
>>>> SMAP
>>>>
>>>> On 07/05/14 12:40, Jan Beulich wrote:
>>>>>>>> On 07.05.14 at 11:44, <andrew.cooper3@citrix.com> wrote:
>>>>>> On 07/05/14 09:19, Feng Wu wrote:
>>>>>>> @@ -673,6 +675,7 @@ ENTRY(nmi_crash)
>>>>>>> ud2
>>>>>>>
>>>>>>> ENTRY(machine_check)
>>>>>>> + ASM_CLAC
>>>>>> This is not needed. the start of handle_ist_exception has a SAVE_ALL,
>>>>>> which also covers the nmi entry point.
>>>>>>
>>>>>> On the subject of IST exceptions, perhaps the double fault explicitly
>>>>>> wants a STAC to reduce the likelihood of taking a further fault while
>>>>>> trying to dump state. ?
>>>>> I agree. And perhaps along with do_double_fault(), fatal_trap()
>>>>> should then also get a stac() added?
>>>>>
>>>>> Jan
>>>>>
>>>> With doubt_fault: being sole caller of do_double_fault(), editing the
>>>> entry point in entry.S to "ASM_STAC; SAVE_ALL 0" is sufficient to avoid
>>>> stac() in do_doube_fault() itself.
>>> I think it's better to add "ASM_STAC" just before " call do_double_fault".
>>> Do you think this is okay, Andrew? Thanks!
>> I am not fussed where exactly the STAC goes in the entry point, but
>> don't leave a CLAC in the SAVE_ALL.
> Sure, thanks for the suggestion! I will pass 0 to SAVE_ALL.
> My point is that ASM_STAC should be deferred as much as possible.
In the double_fault entry, currently only way to get an SMAP violation
would if the Interrupt Stack Table mechanism landed us on a stack with
user mapings, at which point all bets are already off with respect to
dumping state and rebooting.
In the case that our stack is actually good, a pagefault from trying to
peek at boot_cpu_data would land us in a loop of nested pagefaults until
we wandered off the stack, as each entry point attempted to CLAC.
>From a safety point of view clearing CR4.SMAP would be the best action,
as we can manage that safely on the stack before looking outside.
On the otherhand, if we fault when looking at boot_cpu_data, the chances
of successfully calling do_page_fault() is tantamount to 0.
In the past while hacking^W debugging, I have noticed that the double
fault handling in Xen does have a tendency to end itself up in infinite
loops. I don't think this series is the appropriate place to sure this
up (I might find some particularly distant copious free time), although
not leaving it in a worse state than it currently is would be nice.
~Andrew
next prev parent reply other threads:[~2014-05-08 9:48 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-07 8:19 [PATCH v6 00/10] x86: Enable Supervisor Mode Access Prevention (SMAP) Feng Wu
2014-05-07 8:19 ` [PATCH v6 01/10] x86: define macros CPUINFO_features and CPUINFO_FEATURE_OFFSET Feng Wu
2014-05-07 8:19 ` [PATCH v6 02/10] x86: move common_interrupt to entry.S Feng Wu
2014-05-07 8:19 ` [PATCH v6 03/10] x86: merge stuff from asm-x86/x86_64/asm_defns.h to asm-x86/asm_defns.h Feng Wu
2014-05-07 8:19 ` [PATCH v6 04/10] x86: Add support for STAC/CLAC instructions Feng Wu
2014-05-07 9:36 ` Andrew Cooper
2014-05-07 8:19 ` [PATCH v6 05/10] Clear AC bit in RFLAGS to protect Xen itself by SMAP Feng Wu
2014-05-07 9:44 ` Andrew Cooper
2014-05-07 11:40 ` Jan Beulich
2014-05-07 11:53 ` Andrew Cooper
2014-05-08 1:41 ` Wu, Feng
2014-05-08 1:57 ` Andrew Cooper
2014-05-08 2:02 ` Wu, Feng
2014-05-08 6:40 ` Jan Beulich
2014-05-08 6:49 ` Wu, Feng
2014-05-08 6:54 ` Jan Beulich
2014-05-08 6:58 ` Wu, Feng
2014-05-08 7:08 ` Jan Beulich
2014-05-08 7:13 ` Wu, Feng
2014-05-08 9:48 ` Andrew Cooper [this message]
2014-05-07 8:19 ` [PATCH v6 06/10] x86: Temporary disable SMAP to legally access user pages in kernel mode Feng Wu
2014-05-07 9:49 ` Andrew Cooper
2014-05-08 1:14 ` Tian, Kevin
2014-05-07 8:19 ` [PATCH v6 07/10] VMX: Disable SMAP feature when guest is in non-paging mode Feng Wu
2014-05-08 1:16 ` Tian, Kevin
2014-05-07 8:19 ` [PATCH v6 08/10] x86: Enable Supervisor Mode Access Prevention (SMAP) for Xen Feng Wu
2014-05-07 10:26 ` Andrew Cooper
2014-05-07 11:44 ` Jan Beulich
2014-05-07 11:47 ` Andrew Cooper
2014-05-08 2:32 ` Wu, Feng
2014-05-08 1:20 ` Tian, Kevin
2014-05-08 6:25 ` Wu, Feng
2014-05-08 7:06 ` Jan Beulich
2014-05-07 8:19 ` [PATCH v6 09/10] x86/hvm: Add SMAP support to HVM guest Feng Wu
2014-05-07 10:46 ` Andrew Cooper
2014-05-07 11:47 ` Jan Beulich
2014-05-08 1:22 ` Tian, Kevin
2014-05-07 8:19 ` [PATCH v6 10/10] x86/tools: Expose SMAP to HVM guests Feng Wu
2014-05-07 8:35 ` [PATCH v6 00/10] x86: Enable Supervisor Mode Access Prevention (SMAP) Jan Beulich
2014-05-07 9:00 ` Wu, Feng
2014-05-07 9:33 ` Jan Beulich
2014-05-07 8:57 ` Ian Campbell
2014-05-07 8:59 ` Wu, Feng
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=536B52F5.4050801@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=eddie.dong@intel.com \
--cc=feng.wu@intel.com \
--cc=ian.campbell@citrix.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=xen-devel@lists.xen.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.