Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: smccc: Save lr before calling __arm_smccc_sve_check()

Commit cfa7ff959a78 ("arm64: smccc: Support SMCCC v1.3 SVE register
saving hint") added a call to __arm_smccc_sve_check() which clobbers the
lr (register x30), causing __arm_smccc_hvc() to return to itself and
crash. Save lr on the stack before calling __arm_smccc_sve_check(). Save
the frame pointer (x29) to complete the frame record, and adjust the
offsets used to access stack parameters.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Mark Brown <broonie@kernel.org>
Fixes: cfa7ff959a78 ("arm64: smccc: Support SMCCC v1.3 SVE register saving hint")
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Link: https://lore.kernel.org/r/20210721071834.69130-1-jean-philippe@linaro.org
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Jean-Philippe Brucker and committed by
Will Deacon
a7c3acca e6f85cbe

+6 -3
+6 -3
arch/arm64/kernel/smccc-call.S
··· 32 32 EXPORT_SYMBOL(__arm_smccc_sve_check) 33 33 34 34 .macro SMCCC instr 35 + stp x29, x30, [sp, #-16]! 36 + mov x29, sp 35 37 alternative_if ARM64_SVE 36 38 bl __arm_smccc_sve_check 37 39 alternative_else_nop_endif 38 40 \instr #0 39 - ldr x4, [sp] 41 + ldr x4, [sp, #16] 40 42 stp x0, x1, [x4, #ARM_SMCCC_RES_X0_OFFS] 41 43 stp x2, x3, [x4, #ARM_SMCCC_RES_X2_OFFS] 42 - ldr x4, [sp, #8] 44 + ldr x4, [sp, #24] 43 45 cbz x4, 1f /* no quirk structure */ 44 46 ldr x9, [x4, #ARM_SMCCC_QUIRK_ID_OFFS] 45 47 cmp x9, #ARM_SMCCC_QUIRK_QCOM_A6 46 48 b.ne 1f 47 49 str x6, [x4, ARM_SMCCC_QUIRK_STATE_OFFS] 48 - 1: ret 50 + 1: ldp x29, x30, [sp], #16 51 + ret 49 52 .endm 50 53 51 54 /*