From: "Jan Beulich" Subject: Re: [PATCH v3 5/9] x86: Temporary disable SMAP to legally access user pages in kernel mode Date: Mon, 05 May 2014 07:57:08 +0100 Message-ID: <53675264020000780000ED60@mail.emea.novell.com> References: <1398654969-6067-1-git-send-email-feng.wu@intel.com> <535E3CCE020000780000CC33@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Feng Wu Cc: Kevin Tian , "ian.campbell@citrix.com" , "andrew.cooper3@citrix.com" , Eddie Dong , "xen-devel@lists.xen.org" , Jun Nakajima List-Id: xen-devel@lists.xenproject.org >>> On 05.05.14 at 07:12, wrote: >> From: Jan Beulich [mailto:JBeulich@suse.com] >> >>> On 28.04.14 at 05:16, wrote: >> > --- a/xen/arch/x86/x86_64/compat/entry.S >> > +++ b/xen/arch/x86/x86_64/compat/entry.S >> > @@ -266,6 +266,7 @@ ENTRY(compat_int80_direct_trap) >> > /* On return only %rbx and %rdx are guaranteed non-clobbered. >> */ >> > compat_create_bounce_frame: >> > ASSERT_INTERRUPTS_ENABLED >> > + ASM_STAC >> > mov %fs,%edi >> > testb $2,UREGS_cs+8(%rsp) >> > jz 1f >> >> I think this should be deferred as much as possible; I even think it is >> warranted to put this at two places here (in the two conditional >> execution branches) just to avoid doing this too early. > > I think about this again. Seems ASM_STAC/ASM_CLAC is not needed for > compat_create_bounce_frame, since in this chunk of code, it only accesses > the pv guest's kernel stack, which should be in ring 1 for 32-bit pv. Is my > understanding correct? Thanks a lot! This is indeed correct, but at the same time means that we need to be aware that SMAP doesn't shield us at all from 32-bit PV guests, i.e. is only of limited use. Jan