public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien-rXXEIb44qovR7s880joybQ@public.gmane.org>
To: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: KVM: Fix the invlpg instruction emulation on AMD64
Date: Wed, 17 Oct 2007 17:43:35 +0200	[thread overview]
Message-ID: <47162DA7.7060501@aurel32.net> (raw)
In-Reply-To: <47162C30.9040106-atKUWr5tajBWk0Htik3J/w@public.gmane.org>

Avi Kivity a écrit :
> Aurelien Jarno wrote:
>>>> diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
>>>> index e974ace..06e183b 100644
>>>> --- a/drivers/kvm/x86_emulate.c
>>>> +++ b/drivers/kvm/x86_emulate.c
>>>> @@ -825,12 +825,12 @@ modrm_done:
>>>>  		c->src.bytes = 4;
>>>>  		goto srcmem_common;
>>>>  	case SrcMem:
>>>> -		c->src.bytes = (c->d & ByteOp) ? 1 :
>>>> -							   c->op_bytes;
>>>>  		/* Don't fetch the address for invlpg: it could be unmapped. */
>>>> -		if (c->twobyte && c->b == 0x01
>>>> -				    && c->modrm_reg == 7)
>>>> +		if ((c->d & ModRM) && c->modrm_mod == 3) {
>>>> +			c->src.type = OP_REG;
>>>>  			break;
>>>> +		}
>>>> +		c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
>>>>  srcmem_common:
>>>>  		c->src.type = OP_MEM;
>>>>  		break;
>>>>   
>>>>       
>>> Why did you remove the check for invlpg?  It need not be executed with
>>> modrm_mod == 3 (in fact invlpg with modrm_mod == 3 is useless), so it
>>> won't be caught by this.
>>>     
>> Because I really thing this check is buggy. On my tests, modrm_reg is
>> always different than 7 for the invlpg instruction, so the test is
>> always false.
>>
>>   
> 
> 
> But invlpg is defined as having reg == 7! The manual says:
> 
> 0F 01/7 INVLPG m
> 
> where "/7" is the notation for "reg in the mod reg r/m byte:
> 
> " /digit — A digit between 0 and 7 indicates that the ModR/M byte of the
> instruction uses
> only the r/m (register or memory) operand. The reg field contains the
> digit that provides an
> extension to the instruction's opcode."
> 
> 
> So what you're seeing is not the invlpg instruction but something else
> in the same group.
> 

I see.

Anyway the previous behaviour on AMD was to disable SrcMem on all 0F 01
instructions. It's actually what I tried to do in the first version of
the patch, ie have the same behaviour as the SrcNone case for the 0F 01
instructions.

The 0F 01 instruction is then correctly emulated, but another of this
group is probably not, as the patch clearly fix the problem on AMD.

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org         | aurelien-rXXEIb44qovR7s880joybQ@public.gmane.org
   `-    people.debian.org/~aurel32 | www.aurel32.net

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

  parent reply	other threads:[~2007-10-17 15:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-15 19:08 KVM: Fix the invlpg instruction emulation on AMD64 Aurelien Jarno
     [not found] ` <20071015190823.GA11333-OqXK5JiLQY5aJl8KAwiEcA@public.gmane.org>
2007-10-16  9:27   ` Avi Kivity
     [not found]     ` <47148403.6010603-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-16  9:46       ` Aurelien Jarno
     [not found]         ` <47148867.9070600-rXXEIb44qovR7s880joybQ@public.gmane.org>
2007-10-16 10:12           ` Avi Kivity
     [not found]             ` <47148E82.9090103-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-17 13:50               ` Aurelien Jarno
     [not found]                 ` <20071017135021.GA32185-OqXK5JiLQY5aJl8KAwiEcA@public.gmane.org>
2007-10-17 14:37                   ` Avi Kivity
     [not found]                     ` <47161E2B.1000006-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-17 15:31                       ` Aurelien Jarno
     [not found]                         ` <47162AD3.6070602-rXXEIb44qovR7s880joybQ@public.gmane.org>
2007-10-17 15:33                           ` Aurelien Jarno
     [not found]                             ` <47162B4F.3050002-rXXEIb44qovR7s880joybQ@public.gmane.org>
2007-10-17 15:40                               ` Avi Kivity
2007-10-17 15:37                           ` Avi Kivity
     [not found]                             ` <47162C30.9040106-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-17 15:43                               ` Aurelien Jarno [this message]
     [not found]                                 ` <47162DA7.7060501-rXXEIb44qovR7s880joybQ@public.gmane.org>
2007-10-17 15:45                                   ` Aurelien Jarno
2007-10-17 15:46                                   ` Aurelien Jarno
2007-10-17 15:46                                   ` Aurelien Jarno
2007-10-17 15:48                                   ` Aurelien Jarno
     [not found]                                     ` <47162ED9.8040902-rXXEIb44qovR7s880joybQ@public.gmane.org>
2007-10-17 16:23                                       ` Aurelien Jarno

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=47162DA7.7060501@aurel32.net \
    --to=aurelien-rxxeib44qovr7s880joybq@public.gmane.org \
    --cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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