diff mbox

x86, kvm: Remove incorrect redundant assembly constraint

Message ID 1353537681-18759-1-git-send-email-hpa@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

H. Peter Anvin Nov. 21, 2012, 10:41 p.m. UTC
From: "H. Peter Anvin" <hpa@linux.intel.com>

In __emulate_1op_rax_rdx, we use "+a" and "+d" which are input/output
constraints, and *then* use "a" and "d" as input constraints.  This is
incorrect, but happens to work on some versions of gcc.

However, it breaks gcc with -O0 and icc, and may break on future
versions of gcc.

Reported-and-tested-by: Melanie Blower <melanie.blower@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Link: http://lkml.kernel.org/r/B3584E72CFEBED439A3ECA9BCE67A4EF1B17AF90@FMSMSX107.amr.corp.intel.com
---
 arch/x86/kvm/emulate.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Paolo Bonzini Nov. 26, 2012, 7:22 a.m. UTC | #1
Il 21/11/2012 23:41, H. Peter Anvin ha scritto:
> From: "H. Peter Anvin" <hpa@linux.intel.com>
> 
> In __emulate_1op_rax_rdx, we use "+a" and "+d" which are input/output
> constraints, and *then* use "a" and "d" as input constraints.  This is
> incorrect, but happens to work on some versions of gcc.
> 
> However, it breaks gcc with -O0 and icc, and may break on future
> versions of gcc.
> 
> Reported-and-tested-by: Melanie Blower <melanie.blower@intel.com>
> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
> Link: http://lkml.kernel.org/r/B3584E72CFEBED439A3ECA9BCE67A4EF1B17AF90@FMSMSX107.amr.corp.intel.com
> ---
>  arch/x86/kvm/emulate.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 39171cb..bba39bf 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -426,8 +426,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
>  			_ASM_EXTABLE(1b, 3b)				\
>  			: "=m" ((ctxt)->eflags), "=&r" (_tmp),		\
>  			  "+a" (*rax), "+d" (*rdx), "+qm"(_ex)		\
> -			: "i" (EFLAGS_MASK), "m" ((ctxt)->src.val),	\
> -			  "a" (*rax), "d" (*rdx));			\
> +			: "i" (EFLAGS_MASK), "m" ((ctxt)->src.val));	\
>  	} while (0)
>  
>  /* instruction has only one source operand, destination is implicit (e.g. mul, div, imul, idiv) */
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
H. Peter Anvin Nov. 26, 2012, 10:48 p.m. UTC | #2
On 11/25/2012 11:22 PM, Paolo Bonzini wrote:
> Il 21/11/2012 23:41, H. Peter Anvin ha scritto:
>> From: "H. Peter Anvin" <hpa@linux.intel.com>
>>
>> In __emulate_1op_rax_rdx, we use "+a" and "+d" which are input/output
>> constraints, and *then* use "a" and "d" as input constraints.  This is
>> incorrect, but happens to work on some versions of gcc.
>>
>> However, it breaks gcc with -O0 and icc, and may break on future
>> versions of gcc.
>>
>> Reported-and-tested-by: Melanie Blower <melanie.blower@intel.com>
>> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
>> Link: http://lkml.kernel.org/r/B3584E72CFEBED439A3ECA9BCE67A4EF1B17AF90@FMSMSX107.amr.corp.intel.com
>> ---
>>  arch/x86/kvm/emulate.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
>> index 39171cb..bba39bf 100644
>> --- a/arch/x86/kvm/emulate.c
>> +++ b/arch/x86/kvm/emulate.c
>> @@ -426,8 +426,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
>>  			_ASM_EXTABLE(1b, 3b)				\
>>  			: "=m" ((ctxt)->eflags), "=&r" (_tmp),		\
>>  			  "+a" (*rax), "+d" (*rdx), "+qm"(_ex)		\
>> -			: "i" (EFLAGS_MASK), "m" ((ctxt)->src.val),	\
>> -			  "a" (*rax), "d" (*rdx));			\
>> +			: "i" (EFLAGS_MASK), "m" ((ctxt)->src.val));	\
>>  	} while (0)
>>  
>>  /* instruction has only one source operand, destination is implicit (e.g. mul, div, imul, idiv) */
>>
> 
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> 

Gleb, Marcelo: are you going to apply this or would you prefer I took it
in x86/urgent?

	-hpa

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcelo Tosatti Nov. 26, 2012, 11:48 p.m. UTC | #3
On Mon, Nov 26, 2012 at 02:48:50PM -0800, H. Peter Anvin wrote:
> On 11/25/2012 11:22 PM, Paolo Bonzini wrote:
> > Il 21/11/2012 23:41, H. Peter Anvin ha scritto:
> >> From: "H. Peter Anvin" <hpa@linux.intel.com>
> >>
> >> In __emulate_1op_rax_rdx, we use "+a" and "+d" which are input/output
> >> constraints, and *then* use "a" and "d" as input constraints.  This is
> >> incorrect, but happens to work on some versions of gcc.
> >>
> >> However, it breaks gcc with -O0 and icc, and may break on future
> >> versions of gcc.
> >>
> >> Reported-and-tested-by: Melanie Blower <melanie.blower@intel.com>
> >> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
> >> Link: http://lkml.kernel.org/r/B3584E72CFEBED439A3ECA9BCE67A4EF1B17AF90@FMSMSX107.amr.corp.intel.com
> >> ---
> >>  arch/x86/kvm/emulate.c | 3 +--
> >>  1 file changed, 1 insertion(+), 2 deletions(-)
> >>
> >> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> >> index 39171cb..bba39bf 100644
> >> --- a/arch/x86/kvm/emulate.c
> >> +++ b/arch/x86/kvm/emulate.c
> >> @@ -426,8 +426,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
> >>  			_ASM_EXTABLE(1b, 3b)				\
> >>  			: "=m" ((ctxt)->eflags), "=&r" (_tmp),		\
> >>  			  "+a" (*rax), "+d" (*rdx), "+qm"(_ex)		\
> >> -			: "i" (EFLAGS_MASK), "m" ((ctxt)->src.val),	\
> >> -			  "a" (*rax), "d" (*rdx));			\
> >> +			: "i" (EFLAGS_MASK), "m" ((ctxt)->src.val));	\
> >>  	} while (0)
> >>  
> >>  /* instruction has only one source operand, destination is implicit (e.g. mul, div, imul, idiv) */
> >>
> > 
> > Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> > 
> 
> Gleb, Marcelo: are you going to apply this or would you prefer I took it
> in x86/urgent?
> 
> 	-hpa

Feel free to merge it through x86/urgent.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
H. Peter Anvin Nov. 26, 2012, 11:49 p.m. UTC | #4
On 11/26/2012 03:48 PM, Marcelo Tosatti wrote:
>>
>> Gleb, Marcelo: are you going to apply this or would you prefer I took it
>> in x86/urgent?
>>
>> 	-hpa
> 
> Feel free to merge it through x86/urgent.
> 

I presume that's an Acked-by?

	-hpa

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcelo Tosatti Nov. 27, 2012, 12:53 a.m. UTC | #5
On Mon, Nov 26, 2012 at 03:49:36PM -0800, H. Peter Anvin wrote:
> On 11/26/2012 03:48 PM, Marcelo Tosatti wrote:
> >>
> >> Gleb, Marcelo: are you going to apply this or would you prefer I took it
> >> in x86/urgent?
> >>
> >> 	-hpa
> > 
> > Feel free to merge it through x86/urgent.
> > 
> 
> I presume that's an Acked-by?
> 
> 	-hpa

Yes.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 39171cb..bba39bf 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -426,8 +426,7 @@  static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
 			_ASM_EXTABLE(1b, 3b)				\
 			: "=m" ((ctxt)->eflags), "=&r" (_tmp),		\
 			  "+a" (*rax), "+d" (*rdx), "+qm"(_ex)		\
-			: "i" (EFLAGS_MASK), "m" ((ctxt)->src.val),	\
-			  "a" (*rax), "d" (*rdx));			\
+			: "i" (EFLAGS_MASK), "m" ((ctxt)->src.val));	\
 	} while (0)
 
 /* instruction has only one source operand, destination is implicit (e.g. mul, div, imul, idiv) */