162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * KVM nVHE hypervisor stack tracing support. 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * The unwinder implementation depends on the nVHE mode: 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * 1) Non-protected nVHE mode - the host can directly access the 862306a36Sopenharmony_ci * HYP stack pages and unwind the HYP stack in EL1. This saves having 962306a36Sopenharmony_ci * to allocate shared buffers for the host to read the unwinded 1062306a36Sopenharmony_ci * stacktrace. 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * 2) pKVM (protected nVHE) mode - the host cannot directly access 1362306a36Sopenharmony_ci * the HYP memory. The stack is unwinded in EL2 and dumped to a shared 1462306a36Sopenharmony_ci * buffer where the host can read and print the stacktrace. 1562306a36Sopenharmony_ci * 1662306a36Sopenharmony_ci * Copyright (C) 2022 Google LLC 1762306a36Sopenharmony_ci */ 1862306a36Sopenharmony_ci#ifndef __ASM_STACKTRACE_NVHE_H 1962306a36Sopenharmony_ci#define __ASM_STACKTRACE_NVHE_H 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#include <asm/stacktrace/common.h> 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci/** 2462306a36Sopenharmony_ci * kvm_nvhe_unwind_init() - Start an unwind from the given nVHE HYP fp and pc 2562306a36Sopenharmony_ci * 2662306a36Sopenharmony_ci * @state : unwind_state to initialize 2762306a36Sopenharmony_ci * @fp : frame pointer at which to start the unwinding. 2862306a36Sopenharmony_ci * @pc : program counter at which to start the unwinding. 2962306a36Sopenharmony_ci */ 3062306a36Sopenharmony_cistatic inline void kvm_nvhe_unwind_init(struct unwind_state *state, 3162306a36Sopenharmony_ci unsigned long fp, 3262306a36Sopenharmony_ci unsigned long pc) 3362306a36Sopenharmony_ci{ 3462306a36Sopenharmony_ci unwind_init_common(state, NULL); 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci state->fp = fp; 3762306a36Sopenharmony_ci state->pc = pc; 3862306a36Sopenharmony_ci} 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci#ifndef __KVM_NVHE_HYPERVISOR__ 4162306a36Sopenharmony_ci/* 4262306a36Sopenharmony_ci * Conventional (non-protected) nVHE HYP stack unwinder 4362306a36Sopenharmony_ci * 4462306a36Sopenharmony_ci * In non-protected mode, the unwinding is done from kernel proper context 4562306a36Sopenharmony_ci * (by the host in EL1). 4662306a36Sopenharmony_ci */ 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ciDECLARE_KVM_NVHE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack); 4962306a36Sopenharmony_ciDECLARE_KVM_NVHE_PER_CPU(struct kvm_nvhe_stacktrace_info, kvm_stacktrace_info); 5062306a36Sopenharmony_ciDECLARE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page); 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_civoid kvm_nvhe_dump_backtrace(unsigned long hyp_offset); 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci#endif /* __KVM_NVHE_HYPERVISOR__ */ 5562306a36Sopenharmony_ci#endif /* __ASM_STACKTRACE_NVHE_H */ 56