Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Mohammed Gamal <m.gamal005@gmail.com>
Cc: mtosatti@redhat.com, kvm@vger.kernel.org
Subject: Re: [PATCH 1/2] x86 emulator: Add unary mul, imul, div, and idiv instructions
Date: Sun, 08 Aug 2010 16:27:44 -0400	[thread overview]
Message-ID: <4C5F1340.7030906@redhat.com> (raw)
In-Reply-To: <AANLkTin86w9fUrYO8QQ4ke2vTEDkpXzL8R8P1GQLZfP=@mail.gmail.com>

  On 08/08/2010 07:53 AM, Mohammed Gamal wrote:
> On Sun, Aug 8, 2010 at 2:34 PM, Avi Kivity<avi@redhat.com>  wrote:
>>   On 08/08/2010 05:27 AM, Mohammed Gamal wrote:
>>> This adds unary mul, imul, div, and idiv instructions (group 3 r/m 4-7).
>>>
>>> Signed-off-by: Mohammed Gamal<m.gamal005@gmail.com>
>>> ---
>>>   arch/x86/kvm/emulate.c |   41 ++++++++++++++++++++++++++++++++++++++++-
>>>   1 files changed, 40 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
>>> index 7d78832..6d1ec53 100644
>>> --- a/arch/x86/kvm/emulate.c
>>> +++ b/arch/x86/kvm/emulate.c
>>> @@ -315,6 +315,31 @@ struct group_dual {
>>>                 }                                                       \
>>>         } while (0)
>>>
>>> +#define __emulate_1op_src(_op, _src, _ax, _dx, _eflags, _suffix)
>>>        \
>> Not just 1op - add rax_rdx to the name to indicate these are implicit
>> operands.
>>
>>> +       do {                                                            \
>>> +               unsigned long _tmp;                                     \
>>> +                                                                       \
>>> +               __asm__ __volatile__ (                                  \
>>> +                       _PRE_EFLAGS("0", "4", "1")                      \
>>> +                       _op _suffix " %5; "                             \
>>> +                       _POST_EFLAGS("0", "4", "1")                     \
>>> +                       : "=m" (_eflags), "=&r" (_tmp),                 \
>>> +                         "=a" (_ax), "=d" (_dx)                        \
>>> +                       : "i" (EFLAGS_MASK), "m" ((_src).val),          \
>>> +                         "a" (_ax), "d" (_dx));                        \
>>> +       } while (0)
>> The byte form of the instruction doesn't update dx, and the word form
>> doesn't update edx[16:31].  So the "=a" and "=d" operands need to be "+a"
>> and "+d" so the compiler loads them before the operation is started.
>>

I see you have "a" and "d" also in the inputs section.  So the code is 
correct.

>> Please add a test to the effect, for example start with eax=0x12345678, and
>> multiply (byte size) 0x80 by 0x40,
> We already have a value store in eax, so I can only either multiply it
> by 0x80 or 0x40. Or do you mean we should have eax=0x12345680 and then
> perhaps multply by 0x40 and make sure the upper 16 bits are preserved?

Yes.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


  reply	other threads:[~2010-08-08 20:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-08  2:27 [PATCH 1/2] x86 emulator: Add unary mul, imul, div, and idiv instructions Mohammed Gamal
2010-08-08  2:27 ` [PATCH 2/2] x86 emulator: Fix emulate_grp3 return values Mohammed Gamal
2010-08-08 11:34 ` [PATCH 1/2] x86 emulator: Add unary mul, imul, div, and idiv instructions Avi Kivity
2010-08-08 11:53   ` Mohammed Gamal
2010-08-08 20:27     ` Avi Kivity [this message]
2010-08-08 21:19       ` Mohammed Gamal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C5F1340.7030906@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=m.gamal005@gmail.com \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox