-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kvm: x86/mmu: Init / Uninit the TDP MMU
The TDP MMU offers an alternative mode of operation to the x86 shadow paging based MMU, optimized for running an L1 guest with TDP. The TDP MMU will require new fields that need to be initialized and torn down. Add hooks into the existing KVM MMU initialization process to do that initialization / cleanup. Currently the initialization and cleanup fucntions do not do very much, however more operations will be added in future patches. Tested by running kvm-unit-tests and KVM selftests on an Intel Haswell machine. This series introduced no new failures. This series can be viewed in Gerrit at: https://linux-review.googlesource.com/c/virt/kvm/kvm/+/2538 Signed-off-by: Ben Gardon <bgardon@google.com> Message-Id: <20201014182700.2888246-4-bgardon@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
- Loading branch information
Ben Gardon
authored and
Paolo Bonzini
committed
Oct 21, 2020
1 parent
c9180b7
commit fe5db27
Showing
5 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#include "tdp_mmu.h" | ||
|
||
static bool __read_mostly tdp_mmu_enabled = false; | ||
|
||
static bool is_tdp_mmu_enabled(void) | ||
{ | ||
#ifdef CONFIG_X86_64 | ||
return tdp_enabled && READ_ONCE(tdp_mmu_enabled); | ||
#else | ||
return false; | ||
#endif /* CONFIG_X86_64 */ | ||
} | ||
|
||
/* Initializes the TDP MMU for the VM, if enabled. */ | ||
void kvm_mmu_init_tdp_mmu(struct kvm *kvm) | ||
{ | ||
if (!is_tdp_mmu_enabled()) | ||
return; | ||
|
||
/* This should not be changed for the lifetime of the VM. */ | ||
kvm->arch.tdp_mmu_enabled = true; | ||
} | ||
|
||
void kvm_mmu_uninit_tdp_mmu(struct kvm *kvm) | ||
{ | ||
if (!kvm->arch.tdp_mmu_enabled) | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#ifndef __KVM_X86_MMU_TDP_MMU_H | ||
#define __KVM_X86_MMU_TDP_MMU_H | ||
|
||
#include <linux/kvm_host.h> | ||
|
||
void kvm_mmu_init_tdp_mmu(struct kvm *kvm); | ||
void kvm_mmu_uninit_tdp_mmu(struct kvm *kvm); | ||
#endif /* __KVM_X86_MMU_TDP_MMU_H */ |