lkml.org 
[lkml]   [2014]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/6] KVM: x86: Wrong emulation on 'xadd X, X'
Il 16/06/2014 19:38, Bandan Das ha scritto:
> Nadav Amit <namit@cs.technion.ac.il> writes:
>
>> The emulator does not emulate the xadd instruction correctly if the two
>> operands are the same. In this (unlikely) situation the result should be the
>> sum of X and X (2X) when it is currently X. The solution is to first perform
>> writeback to the source, before writing to the destination. The only
>> instruction which should be affected is xadd, as the other instructions that
>> perform writeback to the source use the extended accumlator (e.g., RAX:RDX).
>>
>> Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
>> ---
>> arch/x86/kvm/emulate.c | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
>> index f0b0a10..3c8d867 100644
>> --- a/arch/x86/kvm/emulate.c
>> +++ b/arch/x86/kvm/emulate.c
>> @@ -4711,17 +4711,17 @@ special_insn:
>> goto done;
>>
>> writeback:
>> - if (!(ctxt->d & NoWrite)) {
>> - rc = writeback(ctxt, &ctxt->dst);
>> - if (rc != X86EMUL_CONTINUE)
>> - goto done;
>> - }
>> if (ctxt->d & SrcWrite) {
>> BUG_ON(ctxt->src.type == OP_MEM || ctxt->src.type == OP_MEM_STR);
> While we are here, I think we should replace this BUG_ON with a warning
> and return X86EMUL_UNHANDLEABLE if the condition is true.

Sure, please post a patch and I'll apply it right away.

Paolo



\
 
 \ /
  Last update: 2014-06-17 08:21    [W:0.083 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site