[PATCH v6 21/33] arm64: kvm: Annotate unwind_hint for hyp entry

From: Chen Zhongjin
Date: Wed Jun 22 2022 - 21:53:56 EST


Symbol __guest_enter and kvm_hyp_vector saved x0, x1 on stack.

Symbol __guest_exit and __guest_exit_panic is reached when resuming
EL2 execution, and the previous stack pointer gets restored.

Add adequate unwind hints.

Signed-off-by: Julien Thierry <jthierry@xxxxxxxxxx>
Signed-off-by: Chen Zhongjin <chenzhongjin@xxxxxxxxxx>
---
arch/arm64/kvm/hyp/entry.S | 5 +++++
arch/arm64/kvm/hyp/hyp-entry.S | 3 +++
2 files changed, 8 insertions(+)

diff --git a/arch/arm64/kvm/hyp/entry.S b/arch/arm64/kvm/hyp/entry.S
index 045d4481c820..81e30d56bf28 100644
--- a/arch/arm64/kvm/hyp/entry.S
+++ b/arch/arm64/kvm/hyp/entry.S
@@ -15,6 +15,7 @@
#include <asm/kvm_mmu.h>
#include <asm/kvm_mte.h>
#include <asm/kvm_ptrauth.h>
+#include <asm/unwind_hints.h>

.text

@@ -22,6 +23,7 @@
* u64 __guest_enter(struct kvm_vcpu *vcpu);
*/
SYM_CODE_START(__guest_enter)
+ UNWIND_HINT_FUNC
// x0: vcpu
// x1-x17: clobbered by macros
// x29: guest context
@@ -88,6 +90,7 @@ SYM_INNER_LABEL(__guest_exit_panic, SYM_L_GLOBAL)
// vcpu x0-x1 on the stack

// If the hyp context is loaded, go straight to hyp_panic
+ UNWIND_HINT_FUNC
get_loaded_vcpu x0, x1
cbnz x0, 1f
b hyp_panic
@@ -110,6 +113,7 @@ SYM_INNER_LABEL(__guest_exit, SYM_L_GLOBAL)
// x1: vcpu
// x2-x29,lr: vcpu regs
// vcpu x0-x1 on the stack
+ UNWIND_HINT_FUNC sp_offset=16

add x1, x1, #VCPU_CONTEXT

@@ -199,6 +203,7 @@ abort_guest_exit_end:
msr daifset, #4 // Mask aborts
ret

+ UNWIND_HINT_FUNC
_kvm_extable abort_guest_exit_start, 9997f
_kvm_extable abort_guest_exit_end, 9997f
9997:
diff --git a/arch/arm64/kvm/hyp/hyp-entry.S b/arch/arm64/kvm/hyp/hyp-entry.S
index 4a65262a4f3a..d72143c59707 100644
--- a/arch/arm64/kvm/hyp/hyp-entry.S
+++ b/arch/arm64/kvm/hyp/hyp-entry.S
@@ -151,6 +151,7 @@ SYM_CODE_END(\label)

.macro valid_vect target
.align 7
+ UNWIND_HINT_FUNC
661:
esb
stp x0, x1, [sp, #-16]!
@@ -162,6 +163,7 @@ check_preamble_length 661b, 662b

.macro invalid_vect target
.align 7
+ UNWIND_HINT_FUNC
661:
nop
stp x0, x1, [sp, #-16]!
@@ -209,6 +211,7 @@ SYM_CODE_END(__kvm_hyp_vector)
.macro hyp_ventry indirect, spectrev2
.align 7
1: esb
+ UNWIND_HINT_FUNC
.if \spectrev2 != 0
spectrev2_smccc_wa1_smc
.else
--
2.17.1