From: "Jan Beulich" Subject: Re: [PATCH v4 04/10] x86: Add support for STAC/CLAC instructions Date: Mon, 05 May 2014 12:06:26 +0100 Message-ID: <53678CD2020000780000EF5A@mail.emea.novell.com> References: <1399278112-6522-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: <1399278112-6522-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 05.05.14 at 10:21, wrote: > +#ifdef __ASSEMBLY__ > +#define ASM_AC(op) \ > + btl $X86_FEATURE_SMAP & 31, \ > + CPUINFO_FEATURE_OFFSET(X86_FEATURE_SMAP)+boot_cpu_data(%rip); \ > + jnc 881f; \ > + __ASM_##op; \ > +881: > +#else > +#define ASM_AC(op) \ > + "btl $" __stringify(X86_FEATURE_SMAP) "&31, " \ > + CPUINFO_FEATURE_OFFSET(X86_FEATURE_SMAP) \ > + "+ boot_cpu_data(%%rip)\n\t" \ > + "jnc 881f\n\t" \ > + __stringify(__ASM_##op) "\n\t" \ > +"881:" Please use something like .L##op##%= as the label name for the C version ... > +static inline void clac(void) > +{ > + asm volatile (ASM_CLAC : : : "memory"); > +} > + > +static inline void stac(void) > +{ > + asm volatile (ASM_STAC : : : "memory"); > +} ... provided it wouldn't be better anyway to do all this properly in C, with just the raw instructions emitted via asm(). That would also eliminate the need for the C variant of CPUINFO_FEATURE_OFFSET() in the first patch. Jan