From mboxrd@z Thu Jan 1 00:00:00 1970 From: Laurent Vivier Subject: [PATCH 1/6] Consolidate the various functions that read and write guest memory Date: Mon, 30 Jul 2007 11:37:38 +0200 Message-ID: <46ADB162.6010100@bull.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1606420900==" To: kvm-devel Return-path: 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) --===============1606420900== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigC78A4D244AC58311BB2E2AA0" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigC78A4D244AC58311BB2E2AA0 Content-Type: multipart/mixed; boundary="------------030401090608020205020506" This is a multi-part message in MIME format. --------------030401090608020205020506 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable emulator_read_std() uses struct kvm_vcpu instead of x86_emulate_ctxt to b= e called in place of kvm_read_guest(). Signed-off-by: Laurent Vivier --=20 ------------- Laurent.Vivier-6ktuUTfB/bM@public.gmane.org -------------- "Software is hard" - Donald Knuth --------------030401090608020205020506 Content-Type: text/plain; name="read_std-vcpu" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="read_std-vcpu" Index: kvm/drivers/kvm/kvm_main.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/kvm_main.c 2007-07-30 10:11:01.000000000 +0200 +++ kvm/drivers/kvm/kvm_main.c 2007-07-30 10:11:06.000000000 +0200 @@ -975,9 +975,8 @@ static int emulator_read_std(unsigned long addr, void *val, unsigned int bytes, - struct x86_emulate_ctxt *ctxt) + struct kvm_vcpu *vcpu) { - struct kvm_vcpu *vcpu =3D ctxt->vcpu; void *data =3D val; =20 while (bytes) { @@ -1048,7 +1047,7 @@ memcpy(val, vcpu->mmio_data, bytes); vcpu->mmio_read_completed =3D 0; return X86EMUL_CONTINUE; - } else if (emulator_read_std(addr, val, bytes, ctxt) + } else if (emulator_read_std(addr, val, bytes, vcpu) =3D=3D X86EMUL_CONTINUE) return X86EMUL_CONTINUE; =20 @@ -1221,7 +1220,7 @@ if (reported) return; =20 - emulator_read_std(rip_linear, (void *)opcodes, 4, ctxt); + emulator_read_std(rip_linear, (void *)opcodes, 4, ctxt->vcpu); =20 printk(KERN_ERR "emulation failed but !mmio_needed?" " rip %lx %02x %02x %02x %02x\n", Index: kvm/drivers/kvm/x86_emulate.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/x86_emulate.c 2007-07-30 10:11:01.000000000 +020= 0 +++ kvm/drivers/kvm/x86_emulate.c 2007-07-30 10:11:06.000000000 +0200 @@ -420,7 +420,7 @@ #define insn_fetch(_type, _size, _eip) = \ ({ unsigned long _x; \ rc =3D ops->read_std((unsigned long)(_eip) + ctxt->cs_base, &_x, \ - (_size), ctxt); = \ + (_size), ctxt->vcpu); = \ if ( rc !=3D 0 ) \ goto done; \ (_eip) +=3D (_size); \ @@ -469,10 +469,12 @@ if (op_bytes =3D=3D 2) op_bytes =3D 3; *address =3D 0; - rc =3D ops->read_std((unsigned long)ptr, (unsigned long *)size, 2, ctxt= ); + rc =3D ops->read_std((unsigned long)ptr, (unsigned long *)size, 2, + ctxt->vcpu); if (rc) return rc; - rc =3D ops->read_std((unsigned long)ptr + 2, address, op_bytes, ctxt); + rc =3D ops->read_std((unsigned long)ptr + 2, address, op_bytes, + ctxt->vcpu); return rc; } =20 @@ -963,7 +965,7 @@ dst.bytes =3D 8; if ((rc =3D ops->read_std(register_address(ctxt->ss_base, _regs[VCPU_REGS_RSP]), - &dst.val, dst.bytes, ctxt)) !=3D 0) + &dst.val, dst.bytes, ctxt->vcpu)) !=3D 0) goto done; register_address_increment(_regs[VCPU_REGS_RSP], dst.bytes); break; @@ -1048,7 +1050,7 @@ dst.bytes =3D 8; if ((rc =3D ops->read_std((unsigned long)dst.ptr, &dst.val, 8, - ctxt)) !=3D 0) + ctxt->vcpu)) !=3D 0) goto done; } register_address_increment(_regs[VCPU_REGS_RSP], @@ -1171,7 +1173,8 @@ =20 pop_instruction: if ((rc =3D ops->read_std(register_address(ctxt->ss_base, - _regs[VCPU_REGS_RSP]), dst.ptr, op_bytes, ctxt)) !=3D 0) + _regs[VCPU_REGS_RSP]), dst.ptr, op_bytes, ctxt->vcpu)) + !=3D 0) goto done; =20 register_address_increment(_regs[VCPU_REGS_RSP], op_bytes); Index: kvm/drivers/kvm/x86_emulate.h =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/x86_emulate.h 2007-07-30 10:11:01.000000000 +020= 0 +++ kvm/drivers/kvm/x86_emulate.h 2007-07-30 10:11:06.000000000 +0200 @@ -60,7 +60,7 @@ * @bytes: [IN ] Number of bytes to read from memory. */ int (*read_std)(unsigned long addr, void *val, - unsigned int bytes, struct x86_emulate_ctxt * ctxt); + unsigned int bytes, struct kvm_vcpu *vcpu); =20 /* * write_std: Write bytes of standard (non-emulated/special) memory. --------------030401090608020205020506-- --------------enigC78A4D244AC58311BB2E2AA0 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) iD8DBQFGrbFi9Kffa9pFVzwRAjzHAJ45WSeVDO8U2vksX0H0hMlkRMaDiQCfTMCQ 7i3EB4ZPrp0kzwZ5oJ/yI/I= =HC4p -----END PGP SIGNATURE----- --------------enigC78A4D244AC58311BB2E2AA0-- --===============1606420900== 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/ --===============1606420900== 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 --===============1606420900==--