public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <Laurent.Vivier-6ktuUTfB/bM@public.gmane.org>
To: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: [PATCH 2/2] pio cleanup, split kvm_setup_pio() in two functions
Date: Fri, 03 Aug 2007 11:37:57 +0200	[thread overview]
Message-ID: <46B2F775.2060301@bull.net> (raw)
In-Reply-To: <46B2F6A7.5010301-6ktuUTfB/bM@public.gmane.org>


[-- Attachment #1.1.1: Type: text/plain, Size: 393 bytes --]

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 ins/outs
pio (kvm_emulate_pio_string()).

Signed-off-by: Laurent Vivier <Laurent.Vivier-6ktuUTfB/bM@public.gmane.org>
-- 
------------- Laurent.Vivier-6ktuUTfB/bM@public.gmane.org  --------------
          "Software is hard" - Donald Knuth

[-- Attachment #1.1.2: setup_pio-cleanup --]
[-- Type: text/plain, Size: 6350 bytes --]

Index: kvm/drivers/kvm/kvm.h
===================================================================
--- 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 @@
 
 struct x86_emulate_ctxt;
 
-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, int 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
===================================================================
--- 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 @@
 	}
 }
 
-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 = KVM_EXIT_IO;
+	vcpu->run->io.direction = in ? KVM_EXIT_IO_IN : KVM_EXIT_IO_OUT;
+	vcpu->run->io.size = vcpu->pio.size = size;
+	vcpu->run->io.data_offset = KVM_PIO_PAGE_OFFSET * PAGE_SIZE;
+	vcpu->run->io.count = vcpu->pio.count = vcpu->pio.cur_count = 1;
+	vcpu->run->io.port = vcpu->pio.port = port;
+	vcpu->pio.in = in;
+	vcpu->pio.string = 0;
+	vcpu->pio.down = 0;
+	vcpu->pio.guest_page_offset = 0;
+	vcpu->pio.rep = 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 = 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, int in,
+		  int size, unsigned long count, int down,
 		  gva_t address, int rep, unsigned port)
 {
 	unsigned now, in_page;
@@ -1746,33 +1777,16 @@
 
 	vcpu->run->exit_reason = KVM_EXIT_IO;
 	vcpu->run->io.direction = in ? KVM_EXIT_IO_IN : KVM_EXIT_IO_OUT;
-	vcpu->run->io.size = size;
+	vcpu->run->io.size = vcpu->pio.size = size;
 	vcpu->run->io.data_offset = KVM_PIO_PAGE_OFFSET * PAGE_SIZE;
-	vcpu->run->io.count = count;
-	vcpu->run->io.port = port;
-	vcpu->pio.count = count;
-	vcpu->pio.cur_count = count;
-	vcpu->pio.size = size;
+	vcpu->run->io.count = vcpu->pio.count = vcpu->pio.cur_count = count;
+	vcpu->run->io.port = vcpu->pio.port = port;
 	vcpu->pio.in = in;
-	vcpu->pio.port = port;
-	vcpu->pio.string = string;
+	vcpu->pio.string = 1;
 	vcpu->pio.down = down;
 	vcpu->pio.guest_page_offset = offset_in_page(address);
 	vcpu->pio.rep = rep;
 
-	pio_dev = 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 @@
 		}
 	}
 
+	pio_dev = vcpu_find_pio_dev(vcpu, port);
 	if (!vcpu->pio.in) {
 		/* string PIO write */
 		ret = pio_copy_data(vcpu);
@@ -1833,7 +1848,7 @@
 
 	return ret;
 }
-EXPORT_SYMBOL_GPL(kvm_setup_pio);
+EXPORT_SYMBOL_GPL(kvm_emulate_pio_string);
 
 static int kvm_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 {
Index: kvm/drivers/kvm/svm.c
===================================================================
--- 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 = (io_info & SVM_IOIO_REP_MASK) != 0;
 	down = (svm->vmcb->save.rflags & X86_EFLAGS_DF) != 0;
 
-	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);
 }
 
 static int nop_on_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
Index: kvm/drivers/kvm/vmx.c
===================================================================
--- 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 = (exit_qualification & 32) != 0;
 	port = exit_qualification >> 16;
 
-	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);
 }
 
 static void
Index: kvm/drivers/kvm/x86_emulate.c
===================================================================
--- kvm.orig/drivers/kvm/x86_emulate.c	2007-08-03 10:04:34.000000000 +0200
+++ 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,

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 315 bytes --]

-------------------------------------------------------------------------
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/

[-- Attachment #3: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

  parent reply	other threads:[~2007-08-03  9:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-03  9:28 [PATCH 0/2] Consolidate the insb/outsb emulation into x86_emulate.c (second try) Laurent Vivier
     [not found] ` <46B2F559.5060604-6ktuUTfB/bM@public.gmane.org>
2007-08-03  9:34   ` [PATCH 1/2] call emulate_instruction() to emulate ins/outs Laurent Vivier
     [not found]     ` <46B2F6A7.5010301-6ktuUTfB/bM@public.gmane.org>
2007-08-03  9:37       ` Laurent Vivier [this message]
     [not found]         ` <46B2F775.2060301-6ktuUTfB/bM@public.gmane.org>
2007-08-03 10:53           ` [PATCH 2/2] pio cleanup, split kvm_setup_pio() in two functions Dong, Eddie
     [not found]             ` <10EA09EFD8728347A513008B6B0DA77A01E00832-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-03 11:06               ` Laurent Vivier
     [not found]                 ` <46B30C47.3000007-6ktuUTfB/bM@public.gmane.org>
2007-08-03 11:45                   ` Dong, Eddie
     [not found]                     ` <10EA09EFD8728347A513008B6B0DA77A01E00842-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-03 11:52                       ` Dong, Eddie
     [not found]                         ` <10EA09EFD8728347A513008B6B0DA77A01E00843-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-03 11:56                           ` Laurent Vivier
     [not found]                             ` <46B31801.8030709-6ktuUTfB/bM@public.gmane.org>
2007-08-03 12:06                               ` Dong, Eddie
     [not found]                                 ` <10EA09EFD8728347A513008B6B0DA77A01E00844-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-03 12:24                                   ` Dong, Eddie
     [not found]                                     ` <10EA09EFD8728347A513008B6B0DA77A01E0084D-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-03 14:45                                       ` Laurent Vivier
     [not found]                                         ` <46B33F71.5000605-6ktuUTfB/bM@public.gmane.org>
2007-08-03 14:58                                           ` Laurent Vivier
2007-08-03 15:13                                   ` Laurent Vivier
     [not found]                                     ` <46B34611.7030800-6ktuUTfB/bM@public.gmane.org>
2007-08-04  1:41                                       ` Dong, Eddie
2007-08-05  7:43           ` Avi Kivity
2007-08-05  7:38       ` [PATCH 1/2] call emulate_instruction() to emulate ins/outs Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46B2F775.2060301@bull.net \
    --to=laurent.vivier-6ktuutfb/bm@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox