repository: /home/avi/kvm/linux-2.6
branch: master
commit 27642d1e1c61646751ebbf5a740f81e1358e40b1
Author: Avi Kivity <[EMAIL PROTECTED]>
Date:   Wed Nov 28 18:14:43 2007 +0200

    KVM: Don't bypass the mmu if in pae and pdptrs changed
    
    Relading cr3 with unchanged values usually means just a tlb flush, but if in
    pae mode and the pdptrs have changed, we have to reload them.
    
    This fixes a Solaris x86 regression.
    
    Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index c70ac33..f0d2aab 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -144,6 +144,9 @@ int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3)
        int ret;
        u64 pdpte[ARRAY_SIZE(vcpu->pdptrs)];
 
+       if (is_long_mode(vcpu) || !is_pae(vcpu))
+               return false;
+
        mutex_lock(&vcpu->kvm->lock);
        ret = kvm_read_guest_page(vcpu->kvm, pdpt_gfn, pdpte,
                                  offset * sizeof(u64), sizeof(pdpte));
@@ -166,6 +169,23 @@ out:
        return ret;
 }
 
+static bool pdptrs_changed(struct kvm_vcpu *vcpu)
+{
+       u64 pdpte[ARRAY_SIZE(vcpu->pdptrs)];
+       bool changed = true;
+       int r;
+
+       mutex_lock(&vcpu->kvm->lock);
+       r = kvm_read_guest(vcpu->kvm, vcpu->cr3 & ~31u, pdpte, sizeof(pdpte));
+       if (r < 0)
+               goto out;
+       changed = memcmp(pdpte, vcpu->pdptrs, sizeof(pdpte)) != 0;
+out:
+       mutex_unlock(&vcpu->kvm->lock);
+
+       return changed;
+}
+
 void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
 {
        if (cr0 & CR0_RESERVED_BITS) {
@@ -271,7 +291,7 @@ EXPORT_SYMBOL_GPL(set_cr4);
 
 void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
 {
-       if (cr3 == vcpu->cr3) {
+       if (cr3 == vcpu->cr3 && !pdptrs_changed(vcpu)) {
                kvm_mmu_flush_tlb(vcpu);
                return;
        }

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
kvm-commits mailing list
kvm-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-commits

Reply via email to