From: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
To: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Cc: Avi Kivity <avi@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
LKML <linux-kernel@vger.kernel.org>, KVM <kvm@vger.kernel.org>
Subject: [PATCH 3/9] KVM: x86: introduce set_mmio_exit_info
Date: Tue, 17 Jul 2012 21:52:13 +0800 [thread overview]
Message-ID: <50056E0D.1070905@linux.vnet.ibm.com> (raw)
In-Reply-To: <50056DB8.7080702@linux.vnet.ibm.com>
Introduce set_mmio_exit_info to cleanup the common code
Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
arch/x86/kvm/x86.c | 33 +++++++++++++++++----------------
1 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 875b8d8..8171836 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3759,9 +3759,6 @@ static int read_exit_mmio(struct kvm_vcpu *vcpu, gpa_t gpa,
static int write_exit_mmio(struct kvm_vcpu *vcpu, gpa_t gpa,
void *val, int bytes)
{
- struct kvm_mmio_fragment *frag = &vcpu->mmio_fragments[0];
-
- memcpy(vcpu->run->mmio.data, frag->data, frag->len);
return X86EMUL_CONTINUE;
}
@@ -3829,6 +3826,20 @@ mmio:
return X86EMUL_CONTINUE;
}
+static void set_mmio_exit_info(struct kvm_vcpu *vcpu,
+ struct kvm_mmio_fragment *frag, bool write)
+{
+ struct kvm_run *run = vcpu->run;
+
+ run->exit_reason = KVM_EXIT_MMIO;
+ run->mmio.phys_addr = frag->gpa;
+ run->mmio.len = frag->len;
+ run->mmio.is_write = vcpu->mmio_is_write = write;
+
+ if (write)
+ memcpy(run->mmio.data, frag->data, frag->len);
+}
+
int emulator_read_write(struct x86_emulate_ctxt *ctxt, unsigned long addr,
void *val, unsigned int bytes,
struct x86_exception *exception,
@@ -3868,14 +3879,10 @@ int emulator_read_write(struct x86_emulate_ctxt *ctxt, unsigned long addr,
return rc;
gpa = vcpu->mmio_fragments[0].gpa;
-
vcpu->mmio_needed = 1;
vcpu->mmio_cur_fragment = 0;
- vcpu->run->mmio.len = vcpu->mmio_fragments[0].len;
- vcpu->run->mmio.is_write = vcpu->mmio_is_write = ops->write;
- vcpu->run->exit_reason = KVM_EXIT_MMIO;
- vcpu->run->mmio.phys_addr = gpa;
+ set_mmio_exit_info(vcpu, &vcpu->mmio_fragments[0], ops->write);
return ops->read_write_exit_mmio(vcpu, gpa, val, bytes);
}
@@ -5485,7 +5492,6 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
*/
static int complete_mmio(struct kvm_vcpu *vcpu)
{
- struct kvm_run *run = vcpu->run;
struct kvm_mmio_fragment *frag;
int r;
@@ -5496,7 +5502,7 @@ static int complete_mmio(struct kvm_vcpu *vcpu)
/* Complete previous fragment */
frag = &vcpu->mmio_fragments[vcpu->mmio_cur_fragment++];
if (!vcpu->mmio_is_write)
- memcpy(frag->data, run->mmio.data, frag->len);
+ memcpy(frag->data, vcpu->run->mmio.data, frag->len);
if (vcpu->mmio_cur_fragment == vcpu->mmio_nr_fragments) {
vcpu->mmio_needed = 0;
if (vcpu->mmio_is_write)
@@ -5506,12 +5512,7 @@ static int complete_mmio(struct kvm_vcpu *vcpu)
}
/* Initiate next fragment */
++frag;
- run->exit_reason = KVM_EXIT_MMIO;
- run->mmio.phys_addr = frag->gpa;
- if (vcpu->mmio_is_write)
- memcpy(run->mmio.data, frag->data, frag->len);
- run->mmio.len = frag->len;
- run->mmio.is_write = vcpu->mmio_is_write;
+ set_mmio_exit_info(vcpu, frag, vcpu->mmio_is_write);
return 0;
}
--
1.7.7.6
next prev parent reply other threads:[~2012-07-17 13:52 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-17 13:50 [PATCH 1/9] KVM: x86: remvoe unnecessary mark_page_dirty Xiao Guangrong
2012-07-17 13:51 ` [PATCH 2/9] KVM: x86: simplify read_emulated Xiao Guangrong
2012-07-19 23:58 ` Marcelo Tosatti
2012-07-20 2:17 ` Xiao Guangrong
2012-07-20 10:58 ` Marcelo Tosatti
2012-07-20 13:15 ` Xiao Guangrong
2012-07-20 19:52 ` Marcelo Tosatti
2012-07-23 4:23 ` Xiao Guangrong
2012-07-17 13:52 ` Xiao Guangrong [this message]
2012-07-20 0:03 ` [PATCH 3/9] KVM: x86: introduce set_mmio_exit_info Marcelo Tosatti
2012-07-20 2:24 ` Xiao Guangrong
2012-07-17 13:52 ` [PATCH 4/9] KVM: MMU: track the refcount when unmap the page Xiao Guangrong
2012-07-20 0:09 ` Marcelo Tosatti
2012-07-17 13:53 ` [PATCH 5/9] KVM: MMU: fask check write-protect for direct mmu Xiao Guangrong
2012-07-20 0:39 ` Marcelo Tosatti
2012-07-20 2:34 ` Xiao Guangrong
2012-07-20 11:09 ` Marcelo Tosatti
2012-07-20 13:33 ` Xiao Guangrong
2012-07-20 3:45 ` Xiao Guangrong
2012-07-20 11:45 ` Marcelo Tosatti
2012-07-17 13:54 ` [PATCH 6/9] KVM: using get_fault_pfn to get the fault pfn Xiao Guangrong
2012-07-17 13:54 ` [PATCH 7/9] KVM: mark do not extern bad_pfn Xiao Guangrong
2012-07-17 13:55 ` [PATCH 8/9] KVM: remove is_error_hpa Xiao Guangrong
2012-07-17 13:56 ` [PATCH 9/9] KVM: remove the unused parameter of gfn_to_pfn_memslot Xiao Guangrong
2012-07-20 0:40 ` [PATCH 1/9] KVM: x86: remvoe unnecessary mark_page_dirty Marcelo Tosatti
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=50056E0D.1070905@linux.vnet.ibm.com \
--to=xiaoguangrong@linux.vnet.ibm.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.