From mboxrd@z Thu Jan 1 00:00:00 1970 From: Laurent Vivier Subject: [PATCH 4/5] vmx.c uses x86_decode_prefix() instead of get_io_count(). Date: Wed, 01 Aug 2007 11:19:24 +0200 Message-ID: <46B0501C.6060409@bull.net> References: <46B04CCA.2010503@bull.net> <46B04DD6.7010702@bull.net> <46B04EB9.5010103@bull.net> <46B04F56.60607@bull.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0910013340==" To: kvm-devel Return-path: In-Reply-To: <46B04F56.60607-6ktuUTfB/bM@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --===============0910013340== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigB44870B7C6EC66404722314F" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB44870B7C6EC66404722314F Content-Type: multipart/mixed; boundary="------------000209070106090107070001" This is a multi-part message in MIME format. --------------000209070106090107070001 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable vmx.c uses x86_decode_prefix() instead of get_io_count(). Signed-off-by: Laurent Vivier --=20 ------------- Laurent.Vivier-6ktuUTfB/bM@public.gmane.org -------------- "Software is hard" - Donald Knuth --------------000209070106090107070001 Content-Type: text/plain; name="vmx-decode_prefix" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="vmx-decode_prefix" Index: kvm/drivers/kvm/vmx.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- kvm.orig/drivers/kvm/vmx.c 2007-08-01 10:37:40.000000000 +0200 +++ kvm/drivers/kvm/vmx.c 2007-08-01 10:40:04.000000000 +0200 @@ -1761,57 +1761,6 @@ return 0; } =20 -static int get_io_count(struct kvm_vcpu *vcpu, unsigned long *count) -{ - u64 inst; - gva_t rip; - int countr_size; - int i; - - if ((vmcs_readl(GUEST_RFLAGS) & X86_EFLAGS_VM)) { - countr_size =3D 2; - } else { - u32 cs_ar =3D vmcs_read32(GUEST_CS_AR_BYTES); - - countr_size =3D (cs_ar & AR_L_MASK) ? 8: - (cs_ar & AR_DB_MASK) ? 4: 2; - } - - rip =3D vmcs_readl(GUEST_RIP); - if (countr_size !=3D 8) - rip +=3D vmcs_readl(GUEST_CS_BASE); - - if (emulator_read_std(rip, &inst, sizeof(inst), vcpu) !=3D - X86EMUL_CONTINUE) - return 0; - - for (i =3D 0; i < sizeof(inst); i++) { - switch (((u8*)&inst)[i]) { - case 0xf0: - case 0xf2: - case 0xf3: - case 0x2e: - case 0x36: - case 0x3e: - case 0x26: - case 0x64: - case 0x65: - case 0x66: - break; - case 0x67: - countr_size =3D (countr_size =3D=3D 2) ? 4: (countr_size >> 1); - default: - goto done; - } - } - return 0; -done: - countr_size *=3D 8; - *count =3D vcpu->regs[VCPU_REGS_RCX] & (~0ULL >> (64 - countr_size)); - //printk("cx: %lx\n", vcpu->regs[VCPU_REGS_RCX]); - return 1; -} - static int handle_io(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) { u64 exit_qualification; @@ -1831,8 +1780,32 @@ port =3D exit_qualification >> 16; address =3D 0; if (string) { - if (rep && !get_io_count(vcpu, &count)) + int mode; + u64 inst; + gva_t rip; + struct x86_prefix prefix; + u32 cs_ar =3D vmcs_read32(GUEST_CS_AR_BYTES); + unsigned long addr_mask; + + mode =3D (vmcs_readl(GUEST_RFLAGS) & X86_EFLAGS_VM) ? + X86EMUL_MODE_REAL : (cs_ar & AR_L_MASK) + ? X86EMUL_MODE_PROT64 : (cs_ar & AR_DB_MASK) + ? X86EMUL_MODE_PROT32 : X86EMUL_MODE_PROT16; + + rip =3D vmcs_readl(GUEST_RIP); + if (mode !=3D X86EMUL_MODE_PROT64) + rip +=3D vmcs_readl(GUEST_CS_BASE); + if (emulator_read_std(rip, &inst, sizeof(inst), vcpu) + !=3D X86EMUL_CONTINUE) + return 1; + + if (x86_decode_prefix(mode, (u8*)&inst, &prefix) =3D=3D -1) return 1; + + addr_mask =3D (~0ULL >> (64 - (prefix.ad_bytes <<3))); + if (rep) + count =3D vcpu->regs[VCPU_REGS_RCX] & addr_mask; + address =3D vmcs_readl(GUEST_LINEAR_ADDRESS); } return kvm_setup_pio(vcpu, kvm_run, in, size, count, string, down, --------------000209070106090107070001-- --------------enigB44870B7C6EC66404722314F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.7 (GNU/Linux) iD8DBQFGsFAc9Kffa9pFVzwRAovVAJsHDPn9kJgOMWfbdYnWaWSPbAd62QCguCjE e8mKnxJIE5sfVAU7/I0TJgE= =FEcF -----END PGP SIGNATURE----- --------------enigB44870B7C6EC66404722314F-- --===============0910013340== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- 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/ --===============0910013340== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kvm-devel mailing list kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/kvm-devel --===============0910013340==--