aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorSheng Yang <sheng.yang@intel.com>2008-04-24 22:20:22 -0400
committerAvi Kivity <avi@qumranet.com>2008-05-04 07:44:34 -0400
commit67253af52e9133fb4cfbf7a2448a2d3524d1fa6c (patch)
tree5098624f90989a3844bb1b494658ea400d629b1f /arch/x86/kvm
parent8c6d6adc6b87daa364ee9deb2e966021d37a7622 (diff)
KVM: Add kvm_x86_ops get_tdp_level()
The function get_tdp_level() provided the number of tdp level for EPT and NPT rather than the NPT specific macro. Signed-off-by: Sheng Yang <sheng.yang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/mmu.c4
-rw-r--r--arch/x86/kvm/mmu.h6
-rw-r--r--arch/x86/kvm/svm.c10
-rw-r--r--arch/x86/kvm/vmx.c6
-rw-r--r--arch/x86/kvm/vmx.h1
5 files changed, 19 insertions, 8 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index bcfaf7e4a2dc..20fb3c852db7 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1343,7 +1343,7 @@ static int tdp_page_fault(struct kvm_vcpu *vcpu, gva_t gpa,
1343 spin_lock(&vcpu->kvm->mmu_lock); 1343 spin_lock(&vcpu->kvm->mmu_lock);
1344 kvm_mmu_free_some_pages(vcpu); 1344 kvm_mmu_free_some_pages(vcpu);
1345 r = __direct_map(vcpu, gpa, error_code & PFERR_WRITE_MASK, 1345 r = __direct_map(vcpu, gpa, error_code & PFERR_WRITE_MASK,
1346 largepage, gfn, pfn, TDP_ROOT_LEVEL); 1346 largepage, gfn, pfn, kvm_x86_ops->get_tdp_level());
1347 spin_unlock(&vcpu->kvm->mmu_lock); 1347 spin_unlock(&vcpu->kvm->mmu_lock);
1348 1348
1349 return r; 1349 return r;
@@ -1450,7 +1450,7 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
1450 context->page_fault = tdp_page_fault; 1450 context->page_fault = tdp_page_fault;
1451 context->free = nonpaging_free; 1451 context->free = nonpaging_free;
1452 context->prefetch_page = nonpaging_prefetch_page; 1452 context->prefetch_page = nonpaging_prefetch_page;
1453 context->shadow_root_level = TDP_ROOT_LEVEL; 1453 context->shadow_root_level = kvm_x86_ops->get_tdp_level();
1454 context->root_hpa = INVALID_PAGE; 1454 context->root_hpa = INVALID_PAGE;
1455 1455
1456 if (!is_paging(vcpu)) { 1456 if (!is_paging(vcpu)) {
diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
index a4fcb78ebf42..1730757bbc7a 100644
--- a/arch/x86/kvm/mmu.h
+++ b/arch/x86/kvm/mmu.h
@@ -3,12 +3,6 @@
3 3
4#include <linux/kvm_host.h> 4#include <linux/kvm_host.h>
5 5
6#ifdef CONFIG_X86_64
7#define TDP_ROOT_LEVEL PT64_ROOT_LEVEL
8#else
9#define TDP_ROOT_LEVEL PT32E_ROOT_LEVEL
10#endif
11
12#define PT64_PT_BITS 9 6#define PT64_PT_BITS 9
13#define PT64_ENT_PER_PAGE (1 << PT64_PT_BITS) 7#define PT64_ENT_PER_PAGE (1 << PT64_PT_BITS)
14#define PT32_PT_BITS 10 8#define PT32_PT_BITS 10
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 89e0be2c10d0..ab22615eee89 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1863,6 +1863,15 @@ static bool svm_cpu_has_accelerated_tpr(void)
1863 return false; 1863 return false;
1864} 1864}
1865 1865
1866static int get_npt_level(void)
1867{
1868#ifdef CONFIG_X86_64
1869 return PT64_ROOT_LEVEL;
1870#else
1871 return PT32E_ROOT_LEVEL;
1872#endif
1873}
1874
1866static struct kvm_x86_ops svm_x86_ops = { 1875static struct kvm_x86_ops svm_x86_ops = {
1867 .cpu_has_kvm_support = has_svm, 1876 .cpu_has_kvm_support = has_svm,
1868 .disabled_by_bios = is_disabled, 1877 .disabled_by_bios = is_disabled,
@@ -1920,6 +1929,7 @@ static struct kvm_x86_ops svm_x86_ops = {
1920 .inject_pending_vectors = do_interrupt_requests, 1929 .inject_pending_vectors = do_interrupt_requests,
1921 1930
1922 .set_tss_addr = svm_set_tss_addr, 1931 .set_tss_addr = svm_set_tss_addr,
1932 .get_tdp_level = get_npt_level,
1923}; 1933};
1924 1934
1925static int __init svm_init(void) 1935static int __init svm_init(void)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index d93250d11caa..98e4f2b036de 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2788,6 +2788,11 @@ static void __init vmx_check_processor_compat(void *rtn)
2788 } 2788 }
2789} 2789}
2790 2790
2791static int get_ept_level(void)
2792{
2793 return VMX_EPT_DEFAULT_GAW + 1;
2794}
2795
2791static struct kvm_x86_ops vmx_x86_ops = { 2796static struct kvm_x86_ops vmx_x86_ops = {
2792 .cpu_has_kvm_support = cpu_has_kvm_support, 2797 .cpu_has_kvm_support = cpu_has_kvm_support,
2793 .disabled_by_bios = vmx_disabled_by_bios, 2798 .disabled_by_bios = vmx_disabled_by_bios,
@@ -2844,6 +2849,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
2844 .inject_pending_vectors = do_interrupt_requests, 2849 .inject_pending_vectors = do_interrupt_requests,
2845 2850
2846 .set_tss_addr = vmx_set_tss_addr, 2851 .set_tss_addr = vmx_set_tss_addr,
2852 .get_tdp_level = get_ept_level,
2847}; 2853};
2848 2854
2849static int __init vmx_init(void) 2855static int __init vmx_init(void)
diff --git a/arch/x86/kvm/vmx.h b/arch/x86/kvm/vmx.h
index 5f7fdc965d39..093b085daf6a 100644
--- a/arch/x86/kvm/vmx.h
+++ b/arch/x86/kvm/vmx.h
@@ -351,5 +351,6 @@ enum vmcs_field {
351#define VMX_EPT_EXTENT_INDIVIDUAL_BIT (1ull << 24) 351#define VMX_EPT_EXTENT_INDIVIDUAL_BIT (1ull << 24)
352#define VMX_EPT_EXTENT_CONTEXT_BIT (1ull << 25) 352#define VMX_EPT_EXTENT_CONTEXT_BIT (1ull << 25)
353#define VMX_EPT_EXTENT_GLOBAL_BIT (1ull << 26) 353#define VMX_EPT_EXTENT_GLOBAL_BIT (1ull << 26)
354#define VMX_EPT_DEFAULT_GAW 3
354 355
355#endif 356#endif