e567e8aa61a11eb431f027065ecbb104b770c050
[linux-2.6-microblaze.git] / arch / x86 / kvm / mmu / tdp_mmu.c
1 // SPDX-License-Identifier: GPL-2.0
2
3 #include "tdp_mmu.h"
4
5 static bool __read_mostly tdp_mmu_enabled = false;
6
7 static bool is_tdp_mmu_enabled(void)
8 {
9 #ifdef CONFIG_X86_64
10         return tdp_enabled && READ_ONCE(tdp_mmu_enabled);
11 #else
12         return false;
13 #endif /* CONFIG_X86_64 */
14 }
15
16 /* Initializes the TDP MMU for the VM, if enabled. */
17 void kvm_mmu_init_tdp_mmu(struct kvm *kvm)
18 {
19         if (!is_tdp_mmu_enabled())
20                 return;
21
22         /* This should not be changed for the lifetime of the VM. */
23         kvm->arch.tdp_mmu_enabled = true;
24 }
25
26 void kvm_mmu_uninit_tdp_mmu(struct kvm *kvm)
27 {
28         if (!kvm->arch.tdp_mmu_enabled)
29                 return;
30 }