From: Marcelo Tosatti <mtosatti@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v2 2/2] KVM: Fetch guest cr3 from hardware on demand
Date: Wed, 22 Dec 2010 11:44:16 -0200 [thread overview]
Message-ID: <20101222134416.GA10696@amt.cnet> (raw)
In-Reply-To: <1292852772-24247-3-git-send-email-avi@redhat.com>
On Mon, Dec 20, 2010 at 03:46:12PM +0200, Avi Kivity wrote:
> Instead of syncing the guest cr3 every exit, which is expensince on vmx
> with ept enabled, sync it only on demand.
>
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
> arch/x86/include/asm/kvm_host.h | 2 ++
> arch/x86/kvm/kvm_cache_regs.h | 2 ++
> arch/x86/kvm/svm.c | 5 +++++
> arch/x86/kvm/vmx.c | 23 +++++++++++++++++------
> 4 files changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 4461429..07a20f4 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -117,6 +117,7 @@ enum kvm_reg {
>
> enum kvm_reg_ex {
> VCPU_EXREG_PDPTR = NR_VCPU_REGS,
> + VCPU_EXREG_CR3,
> };
>
> enum {
> @@ -533,6 +534,7 @@ struct kvm_x86_ops {
> struct kvm_segment *var, int seg);
> void (*get_cs_db_l_bits)(struct kvm_vcpu *vcpu, int *db, int *l);
> void (*decache_cr0_guest_bits)(struct kvm_vcpu *vcpu);
> + void (*decache_cr3)(struct kvm_vcpu *vcpu);
> void (*decache_cr4_guest_bits)(struct kvm_vcpu *vcpu);
> void (*set_cr0)(struct kvm_vcpu *vcpu, unsigned long cr0);
> void (*set_cr3)(struct kvm_vcpu *vcpu, unsigned long cr3);
> diff --git a/arch/x86/kvm/kvm_cache_regs.h b/arch/x86/kvm/kvm_cache_regs.h
> index a6bf8db..3377d53 100644
> --- a/arch/x86/kvm/kvm_cache_regs.h
> +++ b/arch/x86/kvm/kvm_cache_regs.h
> @@ -75,6 +75,8 @@ static inline ulong kvm_read_cr4_bits(struct kvm_vcpu *vcpu, ulong mask)
>
> static inline ulong kvm_read_cr3(struct kvm_vcpu *vcpu)
> {
> + if (!test_bit(VCPU_EXREG_CR3, (ulong *)&vcpu->arch.regs_avail))
> + kvm_x86_ops->decache_cr3(vcpu);
> return vcpu->arch.cr3;
> }
Should mark register available on vcpu->arch.cr3 assignment
(kvm_set_cr3, kvm_set_sregs, etc), so that subsequent cr3 read does not
use decache value.
next prev parent reply other threads:[~2010-12-22 13:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-20 13:46 [PATCH v2 0/2] Keep cr3 cached in VMCS Avi Kivity
2010-12-20 13:46 ` [PATCH v2 1/2] KVM: Replace reads of vcpu->arch.cr3 by an accessor Avi Kivity
2010-12-20 13:46 ` [PATCH v2 2/2] KVM: Fetch guest cr3 from hardware on demand Avi Kivity
2010-12-22 13:44 ` Marcelo Tosatti [this message]
2010-12-22 14:03 ` 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=20101222134416.GA10696@amt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@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