aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2008-09-23 12:18:34 -0400
committerAvi Kivity <avi@redhat.com>2008-10-15 08:25:20 -0400
commit0ba73cdadb8ac172f396df7e23c4a9cebd59b550 (patch)
tree5e21a3f93397299cb64fcd3e442106c86624709d /arch/x86/kvm
parente8bc217aef67d41d767ede6e7a7eb10f1d47c86c (diff)
KVM: MMU: sync roots on mmu reload
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/mmu.c36
-rw-r--r--arch/x86/kvm/x86.c1
2 files changed, 37 insertions, 0 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 90f01169c8f0..9d8c4bb68a81 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1471,6 +1471,41 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu)
1471 vcpu->arch.mmu.root_hpa = __pa(vcpu->arch.mmu.pae_root); 1471 vcpu->arch.mmu.root_hpa = __pa(vcpu->arch.mmu.pae_root);
1472} 1472}
1473 1473
1474static void mmu_sync_children(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
1475{
1476}
1477
1478static void mmu_sync_roots(struct kvm_vcpu *vcpu)
1479{
1480 int i;
1481 struct kvm_mmu_page *sp;
1482
1483 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
1484 return;
1485 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) {
1486 hpa_t root = vcpu->arch.mmu.root_hpa;
1487 sp = page_header(root);
1488 mmu_sync_children(vcpu, sp);
1489 return;
1490 }
1491 for (i = 0; i < 4; ++i) {
1492 hpa_t root = vcpu->arch.mmu.pae_root[i];
1493
1494 if (root) {
1495 root &= PT64_BASE_ADDR_MASK;
1496 sp = page_header(root);
1497 mmu_sync_children(vcpu, sp);
1498 }
1499 }
1500}
1501
1502void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu)
1503{
1504 spin_lock(&vcpu->kvm->mmu_lock);
1505 mmu_sync_roots(vcpu);
1506 spin_unlock(&vcpu->kvm->mmu_lock);
1507}
1508
1474static gpa_t nonpaging_gva_to_gpa(struct kvm_vcpu *vcpu, gva_t vaddr) 1509static gpa_t nonpaging_gva_to_gpa(struct kvm_vcpu *vcpu, gva_t vaddr)
1475{ 1510{
1476 return vaddr; 1511 return vaddr;
@@ -1715,6 +1750,7 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu)
1715 spin_lock(&vcpu->kvm->mmu_lock); 1750 spin_lock(&vcpu->kvm->mmu_lock);
1716 kvm_mmu_free_some_pages(vcpu); 1751 kvm_mmu_free_some_pages(vcpu);
1717 mmu_alloc_roots(vcpu); 1752 mmu_alloc_roots(vcpu);
1753 mmu_sync_roots(vcpu);
1718 spin_unlock(&vcpu->kvm->mmu_lock); 1754 spin_unlock(&vcpu->kvm->mmu_lock);
1719 kvm_x86_ops->set_cr3(vcpu, vcpu->arch.mmu.root_hpa); 1755 kvm_x86_ops->set_cr3(vcpu, vcpu->arch.mmu.root_hpa);
1720 kvm_mmu_flush_tlb(vcpu); 1756 kvm_mmu_flush_tlb(vcpu);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 08edeabf15e6..88e6d9abbd2b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -594,6 +594,7 @@ EXPORT_SYMBOL_GPL(kvm_set_cr4);
594void kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) 594void kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
595{ 595{
596 if (cr3 == vcpu->arch.cr3 && !pdptrs_changed(vcpu)) { 596 if (cr3 == vcpu->arch.cr3 && !pdptrs_changed(vcpu)) {
597 kvm_mmu_sync_roots(vcpu);
597 kvm_mmu_flush_tlb(vcpu); 598 kvm_mmu_flush_tlb(vcpu);
598 return; 599 return;
599 } 600 }