diff options
-rw-r--r-- | arch/x86/kvm/mmu.c | 4 | ||||
-rw-r--r-- | arch/x86/kvm/mmu.h | 6 | ||||
-rw-r--r-- | arch/x86/kvm/svm.c | 10 | ||||
-rw-r--r-- | arch/x86/kvm/vmx.c | 6 | ||||
-rw-r--r-- | arch/x86/kvm/vmx.h | 1 | ||||
-rw-r--r-- | include/asm-x86/kvm_host.h | 1 |
6 files changed, 20 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 | ||
1866 | static 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 | |||
1866 | static struct kvm_x86_ops svm_x86_ops = { | 1875 | static 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 | ||
1925 | static int __init svm_init(void) | 1935 | static 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 | ||
2791 | static int get_ept_level(void) | ||
2792 | { | ||
2793 | return VMX_EPT_DEFAULT_GAW + 1; | ||
2794 | } | ||
2795 | |||
2791 | static struct kvm_x86_ops vmx_x86_ops = { | 2796 | static 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 | ||
2849 | static int __init vmx_init(void) | 2855 | static 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 |
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h index 9d963cd6533c..897a1be24cf7 100644 --- a/include/asm-x86/kvm_host.h +++ b/include/asm-x86/kvm_host.h | |||
@@ -422,6 +422,7 @@ struct kvm_x86_ops { | |||
422 | struct kvm_run *run); | 422 | struct kvm_run *run); |
423 | 423 | ||
424 | int (*set_tss_addr)(struct kvm *kvm, unsigned int addr); | 424 | int (*set_tss_addr)(struct kvm *kvm, unsigned int addr); |
425 | int (*get_tdp_level)(void); | ||
425 | }; | 426 | }; |
426 | 427 | ||
427 | extern struct kvm_x86_ops *kvm_x86_ops; | 428 | extern struct kvm_x86_ops *kvm_x86_ops; |