-
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: arm64: Support per_cpu_ptr in nVHE hyp code
When compiling with __KVM_NVHE_HYPERVISOR__, redefine per_cpu_offset() to __hyp_per_cpu_offset() which looks up the base of the nVHE per-CPU region of the given cpu and computes its offset from the .hyp.data..percpu section. This enables use of per_cpu_ptr() helpers in nVHE hyp code. Until now only this_cpu_ptr() was supported by setting TPIDR_EL2. Signed-off-by: David Brazdil <dbrazdil@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20201202184122.26046-14-dbrazdil@google.com
- Loading branch information
David Brazdil
authored and
Marc Zyngier
committed
Dec 4, 2020
1 parent
2d7bf21
commit 687413d
Showing
4 changed files
with
35 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,24 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* Copyright (C) 2020 - Google LLC | ||
* Author: David Brazdil <dbrazdil@google.com> | ||
*/ | ||
|
||
#include <asm/kvm_asm.h> | ||
#include <asm/kvm_hyp.h> | ||
#include <asm/kvm_mmu.h> | ||
|
||
unsigned long __hyp_per_cpu_offset(unsigned int cpu) | ||
{ | ||
unsigned long *cpu_base_array; | ||
unsigned long this_cpu_base; | ||
unsigned long elf_base; | ||
|
||
if (cpu >= ARRAY_SIZE(kvm_arm_hyp_percpu_base)) | ||
hyp_panic(); | ||
|
||
cpu_base_array = (unsigned long *)hyp_symbol_addr(kvm_arm_hyp_percpu_base); | ||
this_cpu_base = kern_hyp_va(cpu_base_array[cpu]); | ||
elf_base = (unsigned long)hyp_symbol_addr(__per_cpu_start); | ||
return this_cpu_base - elf_base; | ||
} |