Skip to content

Commit 0e773da

Browse files
author
Marc Zyngier
committed
KVM: arm64: Move nVHE-only helpers into kvm/stacktrace.c
kvm_nvhe_stack_kern_va() only makes sense as part of the nVHE unwinder, so simply move it there. Signed-off-by: Marc Zyngier <[email protected]> Reviewed-by: Kalesh Singh <[email protected]> Tested-by: Kalesh Singh <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4e00532 commit 0e773da

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed

arch/arm64/include/asm/stacktrace/nvhe.h

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -49,47 +49,6 @@ DECLARE_KVM_NVHE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overf
4949
DECLARE_KVM_NVHE_PER_CPU(struct kvm_nvhe_stacktrace_info, kvm_stacktrace_info);
5050
DECLARE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page);
5151

52-
/*
53-
* kvm_nvhe_stack_kern_va - Convert KVM nVHE HYP stack addresses to a kernel VAs
54-
*
55-
* The nVHE hypervisor stack is mapped in the flexible 'private' VA range, to
56-
* allow for guard pages below the stack. Consequently, the fixed offset address
57-
* translation macros won't work here.
58-
*
59-
* The kernel VA is calculated as an offset from the kernel VA of the hypervisor
60-
* stack base.
61-
*
62-
* Returns true on success and updates @addr to its corresponding kernel VA;
63-
* otherwise returns false.
64-
*/
65-
static inline bool kvm_nvhe_stack_kern_va(unsigned long *addr,
66-
enum stack_type type)
67-
{
68-
struct kvm_nvhe_stacktrace_info *stacktrace_info;
69-
unsigned long hyp_base, kern_base, hyp_offset;
70-
71-
stacktrace_info = this_cpu_ptr_nvhe_sym(kvm_stacktrace_info);
72-
73-
switch (type) {
74-
case STACK_TYPE_HYP:
75-
kern_base = (unsigned long)*this_cpu_ptr(&kvm_arm_hyp_stack_page);
76-
hyp_base = (unsigned long)stacktrace_info->stack_base;
77-
break;
78-
case STACK_TYPE_OVERFLOW:
79-
kern_base = (unsigned long)this_cpu_ptr_nvhe_sym(overflow_stack);
80-
hyp_base = (unsigned long)stacktrace_info->overflow_stack_base;
81-
break;
82-
default:
83-
return false;
84-
}
85-
86-
hyp_offset = *addr - hyp_base;
87-
88-
*addr = kern_base + hyp_offset;
89-
90-
return true;
91-
}
92-
9352
void kvm_nvhe_dump_backtrace(unsigned long hyp_offset);
9453

9554
#endif /* __KVM_NVHE_HYPERVISOR__ */

arch/arm64/kvm/stacktrace.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,47 @@
2121

2222
#include <asm/stacktrace/nvhe.h>
2323

24+
/*
25+
* kvm_nvhe_stack_kern_va - Convert KVM nVHE HYP stack addresses to a kernel VAs
26+
*
27+
* The nVHE hypervisor stack is mapped in the flexible 'private' VA range, to
28+
* allow for guard pages below the stack. Consequently, the fixed offset address
29+
* translation macros won't work here.
30+
*
31+
* The kernel VA is calculated as an offset from the kernel VA of the hypervisor
32+
* stack base.
33+
*
34+
* Returns true on success and updates @addr to its corresponding kernel VA;
35+
* otherwise returns false.
36+
*/
37+
static bool kvm_nvhe_stack_kern_va(unsigned long *addr,
38+
enum stack_type type)
39+
{
40+
struct kvm_nvhe_stacktrace_info *stacktrace_info;
41+
unsigned long hyp_base, kern_base, hyp_offset;
42+
43+
stacktrace_info = this_cpu_ptr_nvhe_sym(kvm_stacktrace_info);
44+
45+
switch (type) {
46+
case STACK_TYPE_HYP:
47+
kern_base = (unsigned long)*this_cpu_ptr(&kvm_arm_hyp_stack_page);
48+
hyp_base = (unsigned long)stacktrace_info->stack_base;
49+
break;
50+
case STACK_TYPE_OVERFLOW:
51+
kern_base = (unsigned long)this_cpu_ptr_nvhe_sym(overflow_stack);
52+
hyp_base = (unsigned long)stacktrace_info->overflow_stack_base;
53+
break;
54+
default:
55+
return false;
56+
}
57+
58+
hyp_offset = *addr - hyp_base;
59+
60+
*addr = kern_base + hyp_offset;
61+
62+
return true;
63+
}
64+
2465
static bool on_overflow_stack(unsigned long sp, unsigned long size,
2566
struct stack_info *info)
2667
{

0 commit comments

Comments
 (0)