From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] x86: properly macroize the two XRSTOR flavors Date: Fri, 27 Nov 2015 13:49:52 +0000 Message-ID: <56585F80.6050709@citrix.com> References: <5658527602000078000B9AAE@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a2JPR-0003yz-72 for xen-devel@lists.xenproject.org; Fri, 27 Nov 2015 13:49:57 +0000 In-Reply-To: <5658527602000078000B9AAE@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , xen-devel Cc: Keir Fraser , Shuai Ruan List-Id: xen-devel@lists.xenproject.org On 27/11/15 11:54, Jan Beulich wrote: > All they differ by is the REX64 prefix. Create a single macro covering > both, at once allowing to get rid of the disconnect between the current > partial macro and its two use sites. > > No change in generated code. > > Signed-off-by: Jan Beulich > > --- a/xen/arch/x86/xstate.c > +++ b/xen/arch/x86/xstate.c > @@ -334,16 +334,6 @@ void xsave(struct vcpu *v, uint64_t mask > ptr->fpu_sse.x[FPU_WORD_SIZE_OFFSET] = word_size; > } > > -#define XRSTOR_FIXUP ".section .fixup,\"ax\" \n" \ > - "2: mov %[size],%%ecx \n" \ > - " xor %[lmask_out],%[lmask_out] \n" \ > - " rep stosb \n" \ > - " lea %[mem],%[ptr] \n" \ > - " mov %[lmask_in],%[lmask_out] \n" \ > - " jmp 1b \n" \ > - ".previous \n" \ > - _ASM_EXTABLE(1b, 2b) > - > void xrstor(struct vcpu *v, uint64_t mask) > { > uint32_t hmask = mask >> 32; > @@ -372,29 +362,33 @@ void xrstor(struct vcpu *v, uint64_t mas > */ > switch ( __builtin_expect(ptr->fpu_sse.x[FPU_WORD_SIZE_OFFSET], 8) ) > { > +#define XRSTOR(pfx) \ > + alternative_io("1: .byte " pfx "0x0f,0xae,0x2f\n" \ > + " .section .fixup,\"ax\"\n" \ > + "2: mov %[size],%%ecx\n" \ > + " xor %[lmask_out],%[lmask_out]\n" \ > + " rep stosb\n" \ > + " lea %[mem],%[ptr]\n" \ > + " mov %[lmask_in],%[lmask_out]\n" \ > + " jmp 1b\n" \ > + " .previous\n" \ > + _ASM_EXTABLE(1b, 2b), \ > + ".byte " pfx "0x0f,0xc7,0x1f\n", \ > + X86_FEATURE_XSAVES, \ > + ASM_OUTPUT2([ptr] "+&D" (ptr), [lmask_out] "+&a" (lmask)), \ > + [mem] "m" (*ptr), [lmask_in] "g" (lmask), \ > + [hmask] "d" (hmask), [size] "m" (xsave_cntxt_size) \ > + : "ecx") Please align the \'s on the RHS. It makes the resulting blob rather easier to read, especially given the \n's in the text. Reviewed-by: Andrew Cooper