From mboxrd@z Thu Jan 1 00:00:00 1970 From: Laurent Vivier Subject: [PATCH 2/2] pio cleanup, split kvm_setup_pio() in two functions Date: Fri, 03 Aug 2007 11:37:57 +0200 Message-ID: <46B2F775.2060301@bull.net> References: <46B2F559.5060604@bull.net> <46B2F6A7.5010301@bull.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1485571050==" To: kvm-devel Return-path: In-Reply-To: <46B2F6A7.5010301-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) --===============1485571050== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigE00F960B05E32F902E719924" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigE00F960B05E32F902E719924 Content-Type: multipart/mixed; boundary="------------090900050206010704040802" This is a multi-part message in MIME format. --------------090900050206010704040802 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable PATCH 2/2] setup_pio-cleanup, some cleanup, split kvm_setup_pio() in two functions, one to setup in/out pio (kvm_emulate_pio()) and one to setup i= ns/outs pio (kvm_emulate_pio_string()). Signed-off-by: Laurent Vivier --=20 ------------- Laurent.Vivier-6ktuUTfB/bM@public.gmane.org -------------- "Software is hard" - Donald Knuth --------------090900050206010704040802 Content-Type: text/plain; name="setup_pio-cleanup" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="setup_pio-cleanup" Index: kvm/drivers/kvm/kvm.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/kvm.h 2007-08-03 10:03:26.000000000 +0200 +++ kvm/drivers/kvm/kvm.h 2007-08-03 10:04:25.000000000 +0200 @@ -539,9 +539,11 @@ =20 struct x86_emulate_ctxt; =20 -int kvm_setup_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in, - int size, unsigned long count, int string, int down, - gva_t address, int rep, unsigned port); +int kvm_emulate_pio (struct kvm_vcpu *vcpu, struct kvm_run *run, int in,= + int size, unsigned port); +int kvm_emulate_pio_string(struct kvm_vcpu *vcpu, struct kvm_run *run, i= nt in, + int size, unsigned long count, int down, + gva_t address, int rep, unsigned port); void kvm_emulate_cpuid(struct kvm_vcpu *vcpu); int kvm_emulate_halt(struct kvm_vcpu *vcpu); int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address); 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-08-03 09:52:37.000000000 +0200 +++ kvm/drivers/kvm/kvm_main.c 2007-08-03 11:11:17.000000000 +0200 @@ -1734,8 +1734,39 @@ } } =20 -int kvm_setup_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in, - int size, unsigned long count, int string, int down, +int kvm_emulate_pio (struct kvm_vcpu *vcpu, struct kvm_run *run, int in,= + int size, unsigned port) +{ + struct kvm_io_device *pio_dev; + + vcpu->run->exit_reason =3D KVM_EXIT_IO; + vcpu->run->io.direction =3D in ? KVM_EXIT_IO_IN : KVM_EXIT_IO_OUT; + vcpu->run->io.size =3D vcpu->pio.size =3D size; + vcpu->run->io.data_offset =3D KVM_PIO_PAGE_OFFSET * PAGE_SIZE; + vcpu->run->io.count =3D vcpu->pio.count =3D vcpu->pio.cur_count =3D 1; + vcpu->run->io.port =3D vcpu->pio.port =3D port; + vcpu->pio.in =3D in; + vcpu->pio.string =3D 0; + vcpu->pio.down =3D 0; + vcpu->pio.guest_page_offset =3D 0; + vcpu->pio.rep =3D 0; + + kvm_arch_ops->cache_regs(vcpu); + memcpy(vcpu->pio_data, &vcpu->regs[VCPU_REGS_RAX], 4); + kvm_arch_ops->decache_regs(vcpu); + + pio_dev =3D vcpu_find_pio_dev(vcpu, port); + if (pio_dev) { + kernel_pio(pio_dev, vcpu, vcpu->pio_data); + complete_pio(vcpu); + return 1; + } + return 0; +} +EXPORT_SYMBOL_GPL(kvm_emulate_pio); + +int kvm_emulate_pio_string(struct kvm_vcpu *vcpu, struct kvm_run *run, i= nt in, + int size, unsigned long count, int down, gva_t address, int rep, unsigned port) { unsigned now, in_page; @@ -1746,33 +1777,16 @@ =20 vcpu->run->exit_reason =3D KVM_EXIT_IO; vcpu->run->io.direction =3D in ? KVM_EXIT_IO_IN : KVM_EXIT_IO_OUT; - vcpu->run->io.size =3D size; + vcpu->run->io.size =3D vcpu->pio.size =3D size; vcpu->run->io.data_offset =3D KVM_PIO_PAGE_OFFSET * PAGE_SIZE; - vcpu->run->io.count =3D count; - vcpu->run->io.port =3D port; - vcpu->pio.count =3D count; - vcpu->pio.cur_count =3D count; - vcpu->pio.size =3D size; + vcpu->run->io.count =3D vcpu->pio.count =3D vcpu->pio.cur_count =3D cou= nt; + vcpu->run->io.port =3D vcpu->pio.port =3D port; vcpu->pio.in =3D in; - vcpu->pio.port =3D port; - vcpu->pio.string =3D string; + vcpu->pio.string =3D 1; vcpu->pio.down =3D down; vcpu->pio.guest_page_offset =3D offset_in_page(address); vcpu->pio.rep =3D rep; =20 - pio_dev =3D vcpu_find_pio_dev(vcpu, port); - if (!string) { - kvm_arch_ops->cache_regs(vcpu); - memcpy(vcpu->pio_data, &vcpu->regs[VCPU_REGS_RAX], 4); - kvm_arch_ops->decache_regs(vcpu); - if (pio_dev) { - kernel_pio(pio_dev, vcpu, vcpu->pio_data); - complete_pio(vcpu); - return 1; - } - return 0; - } - if (!count) { kvm_arch_ops->skip_emulated_instruction(vcpu); return 1; @@ -1817,6 +1831,7 @@ } } =20 + pio_dev =3D vcpu_find_pio_dev(vcpu, port); if (!vcpu->pio.in) { /* string PIO write */ ret =3D pio_copy_data(vcpu); @@ -1833,7 +1848,7 @@ =20 return ret; } -EXPORT_SYMBOL_GPL(kvm_setup_pio); +EXPORT_SYMBOL_GPL(kvm_emulate_pio_string); =20 static int kvm_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm= _run) { Index: kvm/drivers/kvm/svm.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/svm.c 2007-08-03 10:02:58.000000000 +0200 +++ kvm/drivers/kvm/svm.c 2007-08-03 10:05:40.000000000 +0200 @@ -1005,8 +1005,7 @@ rep =3D (io_info & SVM_IOIO_REP_MASK) !=3D 0; down =3D (svm->vmcb->save.rflags & X86_EFLAGS_DF) !=3D 0; =20 - return kvm_setup_pio(&svm->vcpu, kvm_run, in, size, 1, 0, - down, 0, rep, port); + return kvm_emulate_pio(&svm->vcpu, kvm_run, in, size, port); } =20 static int nop_on_interception(struct vcpu_svm *svm, struct kvm_run *kvm= _run) 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-03 10:00:11.000000000 +0200 +++ kvm/drivers/kvm/vmx.c 2007-08-03 10:02:55.000000000 +0200 @@ -1783,8 +1783,7 @@ rep =3D (exit_qualification & 32) !=3D 0; port =3D exit_qualification >> 16; =20 - return kvm_setup_pio(vcpu, kvm_run, in, size, 1, 0, down, - 0, rep, port); + return kvm_emulate_pio(vcpu, kvm_run, in, size, port); } =20 static void 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-08-03 10:04:34.000000000 +020= 0 +++ kvm/drivers/kvm/x86_emulate.c 2007-08-03 10:05:16.000000000 +0200 @@ -1123,12 +1123,11 @@ switch(b) { case 0x6c: /* insb */ case 0x6d: /* insw/insd */ - if (kvm_setup_pio(ctxt->vcpu, NULL, + if (kvm_emulate_pio_string(ctxt->vcpu, NULL, 1, /* in */ (d & ByteOp) ? 1 : op_bytes, /* size */ rep_prefix ? address_mask(_regs[VCPU_REGS_RCX]) : 1, /* count */ - 1, /* strings */ (_eflags & EFLG_DF), /* down */ register_address(ctxt->es_base, _regs[VCPU_REGS_RDI]), /* address */ @@ -1139,12 +1138,11 @@ return 0; case 0x6e: /* outsb */ case 0x6f: /* outsw/outsd */ - if (kvm_setup_pio(ctxt->vcpu, NULL, + if (kvm_emulate_pio_string(ctxt->vcpu, NULL, 0, /* in */ (d & ByteOp) ? 1 : op_bytes, /* size */ rep_prefix ? address_mask(_regs[VCPU_REGS_RCX]) : 1, /* count */ - 1, /* strings */ (_eflags & EFLG_DF), /* down */ register_address(override_base ? *override_base : ctxt->ds_base, --------------090900050206010704040802-- --------------enigE00F960B05E32F902E719924 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) iD8DBQFGsvd19Kffa9pFVzwRAtkaAJ4wuWfdwjXKoALe671oc5u00um2VgCgxOmp bPDZczjxG9ByMS0tKep1fOs= =pjyv -----END PGP SIGNATURE----- --------------enigE00F960B05E32F902E719924-- --===============1485571050== 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/ --===============1485571050== 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 --===============1485571050==--