From: "Jan Beulich" Subject: Re: [PATCH v2 1/7] x86: Add support for STAC/CLAC instructions Date: Wed, 23 Apr 2014 11:16:35 +0100 Message-ID: <5357AF23020000780000B515@nat28.tlf.novell.com> References: <1398263648-31994-1-git-send-email-feng.wu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1398263648-31994-1-git-send-email-feng.wu@intel.com> 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@intel.com, ian.campbell@citrix.com, andrew.cooper3@citrix.com, eddie.dong@intel.com, xen-devel@lists.xen.org, jun.nakajima@intel.com List-Id: xen-devel@lists.xenproject.org >>> On 23.04.14 at 16:34, wrote: > @@ -103,4 +105,45 @@ void ret_from_intr(void); > > #endif > > +/* "Raw" instruction opcodes */ > +#define __ASM_CLAC .byte 0x0f,0x01,0xca > +#define __ASM_STAC .byte 0x0f,0x01,0xcb > + > +#ifdef __ASSEMBLY__ > +#define ASM_AC(op) \ > + pushq %rax; \ > + leaq boot_cpu_data(%rip), %rax; \ > + btl $X86_FEATURE_SMAP-7*32, CPUINFO86_leaf7_features(%rax); \ > + jnc 881f; \ > + op; \ > +881: popq %rax So why are you pushing/popping %rax here? There's no need for the lea. And the hard coded 7 here should be replaced too; I don't see a need for CPUINFO86_leaf7_features either - just calculate everything you need from X86_FEATURE_SMAP (these are all constants, so other than the expression getting a little long there's nothing keeping this from being a single btl). > +#define ASM_STAC(prefix) ASM_AC(__ASM_STAC, prefix) > +#define ASM_CLAC(prefix) ASM_AC(__ASM_CLAC, prefix) What is "prefix" good for here, i.e. why can't you put the % right in the macro? Jan