diff options
author | Quentin Perret <qperret@google.com> | 2021-12-08 18:22:59 +0300 |
---|---|---|
committer | Marc Zyngier <maz@kernel.org> | 2021-12-15 17:18:31 +0300 |
commit | 64a1fbda59f4b14adde7f21cda687e2b9703b7bb (patch) | |
tree | b5c803ef11943394ad725803c4d6b80ba51d4e7f /arch/arm64/kvm/mmu.c | |
parent | bff01cb6b1bf68052739eb6155132f7d6d974208 (diff) | |
download | linux-64a1fbda59f4b14adde7f21cda687e2b9703b7bb.tar.xz |
KVM: arm64: pkvm: Make kvm_host_owns_hyp_mappings() robust to VHE
The kvm_host_owns_hyp_mappings() function should return true if and only
if the host kernel is responsible for creating the hypervisor stage-1
mappings. That is only possible in standard non-VHE mode, or during boot
in protected nVHE mode. But either way, none of this makes sense in VHE,
so make sure to catch this case as well, hence making the function
return sensible values in any context (VHE or not).
Suggested-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Quentin Perret <qperret@google.com>
Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211208152300.2478542-7-qperret@google.com
Diffstat (limited to 'arch/arm64/kvm/mmu.c')
-rw-r--r-- | arch/arm64/kvm/mmu.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 605c104eb030..ea840fa223b5 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -239,6 +239,9 @@ void free_hyp_pgds(void) static bool kvm_host_owns_hyp_mappings(void) { + if (is_kernel_in_hyp_mode()) + return false; + if (static_branch_likely(&kvm_protected_mode_initialized)) return false; |