From: "Jan Beulich" Subject: Re: [PATCH v2 6/7] x86/hvm: Add SMAP support to HVM guest Date: Thu, 24 Apr 2014 09:27:50 +0100 Message-ID: <5358E726020000780000BD72@nat28.tlf.novell.com> References: <1398263874-32227-1-git-send-email-feng.wu@intel.com> <5357B6C9020000780000B5E4@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 24.04.14 at 10:19, wrote: >> From: Jan Beulich [mailto:JBeulich@suse.com] >> >>> On 23.04.14 at 16:37, wrote: >> > + smap = hvm_smap_enabled(v) && >> > + !(!ring_3(regs) && (regs->eflags & X86_EFLAGS_AC)); >> >> ring_3() isn't supposed to be used for HVM guests. Please use proper >> HVM methods here. > > To get the guest CS, I should use the following code path, right? > hvm_get_segment_register() --> vmx_get_segment_register() > > I don't find any HVM methods, so can I just use ((regs->cs & 3) < 3) here? I'm confused - you found the method, but you say you didn't? hvm_get_segment_register() is the correct one (just that you need to do this on SS rather than CS, and on the DPL field rather than the selector's RPL - there are a number of existing cases you could use as reference; just grep for comparisons of attr.fields.dpl with 3). Jan