public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] KVM: emulate AAM, XLAT, SALC
@ 2013-05-09  9:16 Paolo Bonzini
       [not found] ` <1368090967-3204-4-git-send-email-pbonzini@redhat.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2013-05-09  9:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: gnatapov, j-nomura

These three instructions are not emulated, but can be found in
real mode code.

These are also good for stable, but they conflict before 3.9 and are
not really useful since emulate_invalid_guest_state defaulted to false.
So I'm not marking them for earlier releases.

Paolo Bonzini (3):
  KVM: emulator: emulate AAM
  KVM: emulator: emulate XLAT
  KVM: emulator: emulate SALC

 arch/x86/kvm/emulate.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 3/3] KVM: emulator: emulate SALC
       [not found] ` <1368090967-3204-4-git-send-email-pbonzini@redhat.com>
@ 2013-05-09  9:25   ` Gleb Natapov
  2013-05-09  9:30     ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Gleb Natapov @ 2013-05-09  9:25 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: linux-kernel, j-nomura

On Thu, May 09, 2013 at 11:16:07AM +0200, Paolo Bonzini wrote:
> This is an almost-undocumented instruction available in 32-bit mode.
> I say "almost" undocumented because AMD documents it in their opcode
> maps just to say that it is unavailable in 64-bit mode (sections
> "A.2.1 One-Byte Opcodes" and "B.3 Invalid and Reassigned Instructions
> in 64-Bit Mode").
> 
> It is roughly equivalent to "sbb %al, %al" except it does not
> set the flags.  Use fastop to emulate it, but do not use the opcode
> directly because it would fail if the host is 64-bit!
> 
> Reported-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
> Cc: stable@kernel.org # 3.9
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/kvm/emulate.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 210bb4e..f62d4c8 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -534,6 +534,9 @@ FOP_SETCC(setle)
>  FOP_SETCC(setnle)
>  FOP_END;
>  
> +FOP_START(salc) "pushf; sbb %al, %al; popf; ret \n\t"

FOP_RET

> +FOP_END;
> +
>  #define __emulate_1op_rax_rdx(ctxt, _op, _suffix, _ex)			\
>  	do {								\
>  		unsigned long _tmp;					\
> @@ -3951,7 +3954,8 @@ static const struct opcode opcode_table[256] = {
>  	G(Src2One | ByteOp, group2), G(Src2One, group2),
>  	G(Src2CL | ByteOp, group2), G(Src2CL, group2),
>  	I(DstAcc | SrcImmUByte | No64, em_aam),
> -	I(DstAcc | SrcImmUByte | No64, em_aad), N,
> +	I(DstAcc | SrcImmUByte | No64, em_aad),
> +	F(DstAcc | ByteOp | No64, em_salc),
>  	I(DstAcc | SrcXLat | ByteOp, em_mov),
>  	/* 0xD8 - 0xDF */
>  	N, E(0, &escape_d9), N, E(0, &escape_db), N, E(0, &escape_dd), N, N,
> -- 
> 1.8.1.4

--
			Gleb.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 3/3] KVM: emulator: emulate SALC
  2013-05-09  9:25   ` [PATCH 3/3] KVM: emulator: emulate SALC Gleb Natapov
@ 2013-05-09  9:30     ` Paolo Bonzini
  2013-05-09  9:31       ` Gleb Natapov
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2013-05-09  9:30 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: linux-kernel, j-nomura

Il 09/05/2013 11:25, Gleb Natapov ha scritto:
> On Thu, May 09, 2013 at 11:16:07AM +0200, Paolo Bonzini wrote:
>> This is an almost-undocumented instruction available in 32-bit mode.
>> I say "almost" undocumented because AMD documents it in their opcode
>> maps just to say that it is unavailable in 64-bit mode (sections
>> "A.2.1 One-Byte Opcodes" and "B.3 Invalid and Reassigned Instructions
>> in 64-Bit Mode").
>>
>> It is roughly equivalent to "sbb %al, %al" except it does not
>> set the flags.  Use fastop to emulate it, but do not use the opcode
>> directly because it would fail if the host is 64-bit!
>>
>> Reported-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
>> Cc: stable@kernel.org # 3.9
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  arch/x86/kvm/emulate.c | 6 +++++-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
>> index 210bb4e..f62d4c8 100644
>> --- a/arch/x86/kvm/emulate.c
>> +++ b/arch/x86/kvm/emulate.c
>> @@ -534,6 +534,9 @@ FOP_SETCC(setle)
>>  FOP_SETCC(setnle)
>>  FOP_END;
>>  
>> +FOP_START(salc) "pushf; sbb %al, %al; popf; ret \n\t"
> 
> FOP_RET

Ah, I missed that macro.  I was mimicking FOP_SETCC which doesn't use
it.  Will resend.

Paolo

>> +FOP_END;
>> +
>>  #define __emulate_1op_rax_rdx(ctxt, _op, _suffix, _ex)			\
>>  	do {								\
>>  		unsigned long _tmp;					\
>> @@ -3951,7 +3954,8 @@ static const struct opcode opcode_table[256] = {
>>  	G(Src2One | ByteOp, group2), G(Src2One, group2),
>>  	G(Src2CL | ByteOp, group2), G(Src2CL, group2),
>>  	I(DstAcc | SrcImmUByte | No64, em_aam),
>> -	I(DstAcc | SrcImmUByte | No64, em_aad), N,
>> +	I(DstAcc | SrcImmUByte | No64, em_aad),
>> +	F(DstAcc | ByteOp | No64, em_salc),
>>  	I(DstAcc | SrcXLat | ByteOp, em_mov),
>>  	/* 0xD8 - 0xDF */
>>  	N, E(0, &escape_d9), N, E(0, &escape_db), N, E(0, &escape_dd), N, N,
>> -- 
>> 1.8.1.4
> 
> --
> 			Gleb.
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 3/3] KVM: emulator: emulate SALC
  2013-05-09  9:30     ` Paolo Bonzini
@ 2013-05-09  9:31       ` Gleb Natapov
  0 siblings, 0 replies; 4+ messages in thread
From: Gleb Natapov @ 2013-05-09  9:31 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: linux-kernel, j-nomura

On Thu, May 09, 2013 at 11:30:27AM +0200, Paolo Bonzini wrote:
> Il 09/05/2013 11:25, Gleb Natapov ha scritto:
> > On Thu, May 09, 2013 at 11:16:07AM +0200, Paolo Bonzini wrote:
> >> This is an almost-undocumented instruction available in 32-bit mode.
> >> I say "almost" undocumented because AMD documents it in their opcode
> >> maps just to say that it is unavailable in 64-bit mode (sections
> >> "A.2.1 One-Byte Opcodes" and "B.3 Invalid and Reassigned Instructions
> >> in 64-Bit Mode").
> >>
> >> It is roughly equivalent to "sbb %al, %al" except it does not
> >> set the flags.  Use fastop to emulate it, but do not use the opcode
> >> directly because it would fail if the host is 64-bit!
> >>
> >> Reported-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
> >> Cc: stable@kernel.org # 3.9
> >> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> >> ---
> >>  arch/x86/kvm/emulate.c | 6 +++++-
> >>  1 file changed, 5 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> >> index 210bb4e..f62d4c8 100644
> >> --- a/arch/x86/kvm/emulate.c
> >> +++ b/arch/x86/kvm/emulate.c
> >> @@ -534,6 +534,9 @@ FOP_SETCC(setle)
> >>  FOP_SETCC(setnle)
> >>  FOP_END;
> >>  
> >> +FOP_START(salc) "pushf; sbb %al, %al; popf; ret \n\t"
> > 
> > FOP_RET
> 
> Ah, I missed that macro.  I was mimicking FOP_SETCC which doesn't use
> it.  Will resend.
> 
I think it does not use it by mistake.

> Paolo
> 
> >> +FOP_END;
> >> +
> >>  #define __emulate_1op_rax_rdx(ctxt, _op, _suffix, _ex)			\
> >>  	do {								\
> >>  		unsigned long _tmp;					\
> >> @@ -3951,7 +3954,8 @@ static const struct opcode opcode_table[256] = {
> >>  	G(Src2One | ByteOp, group2), G(Src2One, group2),
> >>  	G(Src2CL | ByteOp, group2), G(Src2CL, group2),
> >>  	I(DstAcc | SrcImmUByte | No64, em_aam),
> >> -	I(DstAcc | SrcImmUByte | No64, em_aad), N,
> >> +	I(DstAcc | SrcImmUByte | No64, em_aad),
> >> +	F(DstAcc | ByteOp | No64, em_salc),
> >>  	I(DstAcc | SrcXLat | ByteOp, em_mov),
> >>  	/* 0xD8 - 0xDF */
> >>  	N, E(0, &escape_d9), N, E(0, &escape_db), N, E(0, &escape_dd), N, N,
> >> -- 
> >> 1.8.1.4
> > 
> > --
> > 			Gleb.
> > 

--
			Gleb.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-05-09  9:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-09  9:16 [PATCH 0/3] KVM: emulate AAM, XLAT, SALC Paolo Bonzini
     [not found] ` <1368090967-3204-4-git-send-email-pbonzini@redhat.com>
2013-05-09  9:25   ` [PATCH 3/3] KVM: emulator: emulate SALC Gleb Natapov
2013-05-09  9:30     ` Paolo Bonzini
2013-05-09  9:31       ` Gleb Natapov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox