mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
When returning to userspace, the SCS is empty and so the SCS SP just points to the base address of the SCS page. Rather than saving and restoring this address in the current task, we can simply restore the SCS SP to point at the base of the stack on entry to EL1 from EL0. Cc: Ard Biesheuvel <ardb@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Will Deacon <will@kernel.org> Acked-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Sami Tolvanen <samitolvanen@google.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
69 lines
1.2 KiB
C
69 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _ASM_SCS_H
|
|
#define _ASM_SCS_H
|
|
|
|
#ifdef __ASSEMBLER__
|
|
|
|
#include <asm/asm-offsets.h>
|
|
#include <asm/sysreg.h>
|
|
|
|
#ifdef CONFIG_SHADOW_CALL_STACK
|
|
scs_sp .req x18
|
|
|
|
.macro scs_load_current_base
|
|
get_current_task scs_sp
|
|
ldr scs_sp, [scs_sp, #TSK_TI_SCS_BASE]
|
|
.endm
|
|
|
|
.macro scs_load_current
|
|
get_current_task scs_sp
|
|
ldr scs_sp, [scs_sp, #TSK_TI_SCS_SP]
|
|
.endm
|
|
|
|
.macro scs_save tsk
|
|
str scs_sp, [\tsk, #TSK_TI_SCS_SP]
|
|
.endm
|
|
#else
|
|
.macro scs_load_current_base
|
|
.endm
|
|
|
|
.macro scs_load_current
|
|
.endm
|
|
|
|
.macro scs_save tsk
|
|
.endm
|
|
#endif /* CONFIG_SHADOW_CALL_STACK */
|
|
|
|
|
|
#else
|
|
|
|
#include <linux/scs.h>
|
|
#include <asm/cpufeature.h>
|
|
|
|
#ifdef CONFIG_UNWIND_PATCH_PAC_INTO_SCS
|
|
static inline void dynamic_scs_init(void)
|
|
{
|
|
extern bool __pi_dynamic_scs_is_enabled;
|
|
|
|
if (__pi_dynamic_scs_is_enabled) {
|
|
pr_info("Enabling dynamic shadow call stack\n");
|
|
static_branch_enable(&dynamic_scs_enabled);
|
|
}
|
|
}
|
|
#else
|
|
static inline void dynamic_scs_init(void) {}
|
|
#endif
|
|
|
|
enum {
|
|
EDYNSCS_INVALID_CIE_HEADER = 1,
|
|
EDYNSCS_INVALID_CIE_SDATA_SIZE = 2,
|
|
EDYNSCS_INVALID_FDE_AUGM_DATA_SIZE = 3,
|
|
EDYNSCS_INVALID_CFA_OPCODE = 4,
|
|
};
|
|
|
|
int __pi_scs_patch(const u8 eh_frame[], int size, bool skip_dry_run);
|
|
|
|
#endif /* __ASSEMBLER__ */
|
|
|
|
#endif /* _ASM_SCS_H */
|