From: Avi Kivity <avi@qumranet.com>
To: kvm-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, Avi Kivity <avi@qumranet.com>
Subject: [PATCH 5/7] KVM: Remove extraneous guest entry on mmio read
Date: Sun, 29 Apr 2007 18:50:20 +0300 [thread overview]
Message-ID: <11778618221425-git-send-email-avi@qumranet.com> (raw)
In-Reply-To: <1177861822889-git-send-email-avi@qumranet.com>
When emulating an mmio read, we actually emulate twice: once to determine
the physical address of the mmio, and, after we've exited to userspace to
get the mmio value, we emulate again to place the value in the result
register and update any flags.
But we don't really need to enter the guest again for that, only to take
an immediate vmexit. So, if we detect that we're doing an mmio read,
emulate a single instruction before entering the guest again.
Signed-off-by: Avi Kivity <avi@qumranet.com>
---
drivers/kvm/kvm.h | 1 +
drivers/kvm/kvm_main.c | 5 ++++-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index f99e89e..41634fd 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -310,6 +310,7 @@ struct kvm_vcpu {
int mmio_size;
unsigned char mmio_data[8];
gpa_t mmio_phys_addr;
+ gva_t mmio_fault_cr2;
struct kvm_pio_request pio;
void *pio_data;
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index cdf0b17..a9ba42f 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1186,6 +1186,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
int r;
int cs_db, cs_l;
+ vcpu->mmio_fault_cr2 = cr2;
kvm_arch_ops->cache_regs(vcpu);
kvm_arch_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
@@ -1804,9 +1805,11 @@ static int kvm_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
r = complete_pio(vcpu);
if (r)
goto out;
- } else {
+ } else if (!vcpu->mmio_is_write) {
memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8);
vcpu->mmio_read_completed = 1;
+ emulate_instruction(vcpu, kvm_run,
+ vcpu->mmio_fault_cr2, 0);
}
}
--
1.5.0.6
next prev parent reply other threads:[~2007-04-29 15:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-29 15:50 [PATCH 0/7] KVM: More 2.6.22 merge candidates Avi Kivity
2007-04-29 15:50 ` [PATCH 1/7] KVM: VMX: Properly shadow the CR0 register in the vcpu struct Avi Kivity
2007-04-29 15:50 ` [PATCH 2/7] KVM: VMX: Add lazy FPU support for VT Avi Kivity
2007-04-29 15:50 ` [PATCH 3/7] KVM: fix an if() condition Avi Kivity
2007-04-29 15:50 ` Avi Kivity [this message]
2007-04-29 15:50 ` [PATCH 6/7] KVM: Don't require explicit indication of completion of mmio or pio Avi Kivity
2007-04-29 15:50 ` [PATCH 7/7] KVM: Remove unused 'instruction_length' 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=11778618221425-git-send-email-avi@qumranet.com \
--to=avi@qumranet.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.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
Powered by JetHome