Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * KVM nVHE hypervisor stack tracing support.
0004  *
0005  * The unwinder implementation depends on the nVHE mode:
0006  *
0007  *   1) Non-protected nVHE mode - the host can directly access the
0008  *      HYP stack pages and unwind the HYP stack in EL1. This saves having
0009  *      to allocate shared buffers for the host to read the unwinded
0010  *      stacktrace.
0011  *
0012  *   2) pKVM (protected nVHE) mode - the host cannot directly access
0013  *      the HYP memory. The stack is unwinded in EL2 and dumped to a shared
0014  *      buffer where the host can read and print the stacktrace.
0015  *
0016  * Copyright (C) 2022 Google LLC
0017  */
0018 #ifndef __ASM_STACKTRACE_NVHE_H
0019 #define __ASM_STACKTRACE_NVHE_H
0020 
0021 #include <asm/stacktrace/common.h>
0022 
0023 /*
0024  * kvm_nvhe_unwind_init - Start an unwind from the given nVHE HYP fp and pc
0025  *
0026  * @state : unwind_state to initialize
0027  * @fp    : frame pointer at which to start the unwinding.
0028  * @pc    : program counter at which to start the unwinding.
0029  */
0030 static inline void kvm_nvhe_unwind_init(struct unwind_state *state,
0031                     unsigned long fp,
0032                     unsigned long pc)
0033 {
0034     unwind_init_common(state, NULL);
0035 
0036     state->fp = fp;
0037     state->pc = pc;
0038 }
0039 
0040 #ifndef __KVM_NVHE_HYPERVISOR__
0041 /*
0042  * Conventional (non-protected) nVHE HYP stack unwinder
0043  *
0044  * In non-protected mode, the unwinding is done from kernel proper context
0045  * (by the host in EL1).
0046  */
0047 
0048 DECLARE_KVM_NVHE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack);
0049 DECLARE_KVM_NVHE_PER_CPU(struct kvm_nvhe_stacktrace_info, kvm_stacktrace_info);
0050 DECLARE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page);
0051 
0052 void kvm_nvhe_dump_backtrace(unsigned long hyp_offset);
0053 
0054 #endif  /* __KVM_NVHE_HYPERVISOR__ */
0055 #endif  /* __ASM_STACKTRACE_NVHE_H */