From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: [PATCH] KVM: nSVM: Set correct port for IOIO interception evaluation Date: Mon, 30 Jun 2014 12:52:55 +0200 Message-ID: <53B14187.2010104@web.de> References: <53B128B9.1030205@web.de> <53B12D94.2060900@web.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="du7i5UXTqiRFaqIhaFMLv2b3sBVgIFI54" Cc: Joerg Roedel , Valentine Sinitsyn To: Paolo Bonzini , kvm Return-path: Received: from mout.web.de ([212.227.17.11]:62249 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932077AbaF3KxE (ORCPT ); Mon, 30 Jun 2014 06:53:04 -0400 In-Reply-To: <53B12D94.2060900@web.de> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --du7i5UXTqiRFaqIhaFMLv2b3sBVgIFI54 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable From: Jan Kiszka Obtaining the port number from DX is bogus as a) there are immediate port accesses and b) user space may have changed the register content while processing the PIO access. Forward the correct value from the instruction emulator instead. Signed-off-by: Jan Kiszka --- Valentine, I've a stable Jailhouse root cell under QEMU now :) arch/x86/include/asm/kvm_emulate.h | 1 + arch/x86/kvm/emulate.c | 1 + arch/x86/kvm/svm.c | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kv= m_emulate.h index ffa2671..0e0151c 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h @@ -37,6 +37,7 @@ struct x86_instruction_info { u8 modrm_reg; /* index of register used */ u8 modrm_rm; /* rm part of modrm */ u64 src_val; /* value of source operand */ + u64 dst_val; /* value of destination operand */ u8 src_bytes; /* size of source operand */ u8 dst_bytes; /* size of destination operand */ u8 ad_bytes; /* size of src/dst address */ diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 84dc4ba..15453e5 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -426,6 +426,7 @@ static int emulator_check_intercept(struct x86_emulat= e_ctxt *ctxt, .modrm_reg =3D ctxt->modrm_reg, .modrm_rm =3D ctxt->modrm_rm, .src_val =3D ctxt->src.val64, + .dst_val =3D ctxt->dst.val64, .src_bytes =3D ctxt->src.bytes, .dst_bytes =3D ctxt->dst.bytes, .ad_bytes =3D ctxt->ad_bytes, diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 1824949..85d4458 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -4256,13 +4256,13 @@ static int svm_check_intercept(struct kvm_vcpu *v= cpu, u64 exit_info; u32 bytes; =20 - exit_info =3D (vcpu->arch.regs[VCPU_REGS_RDX] & 0xffff) << 16; - if (info->intercept =3D=3D x86_intercept_in || info->intercept =3D=3D x86_intercept_ins) { - exit_info |=3D SVM_IOIO_TYPE_MASK; + exit_info =3D ((info->src_val & 0xffff) << 16) | + SVM_IOIO_TYPE_MASK; bytes =3D info->dst_bytes; } else { + exit_info =3D (info->dst_val & 0xffff) << 16; bytes =3D info->src_bytes; } =20 --=20 1.8.4.5 --du7i5UXTqiRFaqIhaFMLv2b3sBVgIFI54 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlOxQYcACgkQitSsb3rl5xQ8mwCfbNQabb8pYg505R1L/QaEyyh8 +VIAoO+w9UgYPw+GZU4lr6G4h2OkGgws =F6h4 -----END PGP SIGNATURE----- --du7i5UXTqiRFaqIhaFMLv2b3sBVgIFI54--