From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH v2 25/30] KVM: x86 emulator: fix in/out emulation. Date: Mon, 15 Mar 2010 09:44:58 +0200 Message-ID: <20100315074458.GE4294@redhat.com> References: <1268583675-3101-1-git-send-email-gleb@redhat.com> <1268583675-3101-26-git-send-email-gleb@redhat.com> <4B9D14B3.2020002@redhat.com> <20100314173555.GA5406@redhat.com> <4B9DE4BF.1080203@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: mtosatti@redhat.com, kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:38600 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933904Ab0COHpA (ORCPT ); Mon, 15 Mar 2010 03:45:00 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2F7ixbp003398 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 15 Mar 2010 03:44:59 -0400 Content-Disposition: inline In-Reply-To: <4B9DE4BF.1080203@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Mar 15, 2010 at 09:41:51AM +0200, Avi Kivity wrote: > On 03/14/2010 07:35 PM, Gleb Natapov wrote: > >On Sun, Mar 14, 2010 at 06:54:11PM +0200, Avi Kivity wrote: > >>On 03/14/2010 06:21 PM, Gleb Natapov wrote: > >>>in/out emulation is broken now. The breakage is different depending > >>>on where IO device resides. If it is in userspace emulator reports > >>>emulation failure since it incorrectly interprets kvm_emulate_pio() > >>>return value. If IO device is in the kernel emulation of 'in' will do > >>>nothing since kvm_emulate_pio() stores result directly into vcpu > >>>registers, so emulator will overwrite result of emulation during > >>>commit of shadowed register. > >>> > >>> > >>>diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c > >>>index 8f5e4c8..344e17b 100644 > >>>--- a/arch/x86/kvm/emulate.c > >>>+++ b/arch/x86/kvm/emulate.c > >>>@@ -210,13 +210,13 @@ static u32 opcode_table[256] = { > >>> 0, 0, 0, 0, 0, 0, 0, 0, > >>> /* 0xE0 - 0xE7 */ > >>> 0, 0, 0, 0, > >>>- ByteOp | SrcImmUByte, SrcImmUByte, > >>>- ByteOp | SrcImmUByte, SrcImmUByte, > >>>+ ByteOp | SrcImmUByte | DstAcc, SrcImmUByte | DstAcc, > >>>+ ByteOp | SrcImmUByte | DstAcc, SrcImmUByte | DstAcc, > >>REX prefix shouldn't expand DstAcc to 64 bits here. Might cause > >>problems further down in the pipeline.+ > >Is REX prefix allowed with this opcodes? > > > >If yes: > > > >if (c->dst.bytes == 8) > > c->dst.bytes = 4; > > > >inside IN/OUT emulation will fix this. > > I don't know, but I guess REX is allowed and ignored. > Hmm, curious. I'll test. -- Gleb.