aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2008-02-07 07:47:41 -0500
committerAvi Kivity <avi@qumranet.com>2008-04-27 04:53:19 -0400
commit1855267210e1a8c9d41fe3a3c7a0d42eca5fb7cd (patch)
tree2af29e610ce7c7196798cc5f580f7282f902df2a
parent6c7dac72d5c7dc0e09512dce865398167be9a8f7 (diff)
KVM: export information about NPT to generic x86 code
The generic x86 code has to know if the specific implementation uses Nested Paging. In the generic code Nested Paging is called Two Dimensional Paging (TDP) to avoid confusion with (future) TDP implementations of other vendors. This patch exports the availability of TDP to the generic x86 code. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
-rw-r--r--arch/x86/kvm/mmu.c15
-rw-r--r--arch/x86/kvm/svm.c4
-rw-r--r--include/asm-x86/kvm_host.h2
3 files changed, 20 insertions, 1 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 6651dfadae50..21cfa289d0fe 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -32,6 +32,15 @@
32#include <asm/cmpxchg.h> 32#include <asm/cmpxchg.h>
33#include <asm/io.h> 33#include <asm/io.h>
34 34
35/*
36 * When setting this variable to true it enables Two-Dimensional-Paging
37 * where the hardware walks 2 page tables:
38 * 1. the guest-virtual to guest-physical
39 * 2. while doing 1. it walks guest-physical to host-physical
40 * If the hardware supports that we don't need to do shadow paging.
41 */
42static bool tdp_enabled = false;
43
35#undef MMU_DEBUG 44#undef MMU_DEBUG
36 45
37#undef AUDIT 46#undef AUDIT
@@ -1582,6 +1591,12 @@ out:
1582} 1591}
1583EXPORT_SYMBOL_GPL(kvm_mmu_page_fault); 1592EXPORT_SYMBOL_GPL(kvm_mmu_page_fault);
1584 1593
1594void kvm_enable_tdp(void)
1595{
1596 tdp_enabled = true;
1597}
1598EXPORT_SYMBOL_GPL(kvm_enable_tdp);
1599
1585static void free_mmu_pages(struct kvm_vcpu *vcpu) 1600static void free_mmu_pages(struct kvm_vcpu *vcpu)
1586{ 1601{
1587 struct kvm_mmu_page *sp; 1602 struct kvm_mmu_page *sp;
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index fb5d6c2e6a08..9e29a13136c4 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -426,8 +426,10 @@ static __init int svm_hardware_setup(void)
426 npt_enabled = false; 426 npt_enabled = false;
427 } 427 }
428 428
429 if (npt_enabled) 429 if (npt_enabled) {
430 printk(KERN_INFO "kvm: Nested Paging enabled\n"); 430 printk(KERN_INFO "kvm: Nested Paging enabled\n");
431 kvm_enable_tdp();
432 }
431 433
432 return 0; 434 return 0;
433 435
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
index 274f153c8704..5c6ba2212b1b 100644
--- a/include/asm-x86/kvm_host.h
+++ b/include/asm-x86/kvm_host.h
@@ -493,6 +493,8 @@ int kvm_fix_hypercall(struct kvm_vcpu *vcpu);
493 493
494int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code); 494int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code);
495 495
496void kvm_enable_tdp(void);
497
496int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3); 498int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3);
497int complete_pio(struct kvm_vcpu *vcpu); 499int complete_pio(struct kvm_vcpu *vcpu);
498 500