mirror of
https://gitee.com/open-loongarch/linux-6.12.git
synced 2026-10-25 20:47:11 +08:00
When CONFIG_RANDSTRUCT enabled, members of task_struct are randomized. There is a chance that TASK_STACK_CANARY be out of 12bit immediate's range and causes build errors. TASK_STACK_CANARY is naturally aligned, so fix it by replacing ld.d/st.d with ldptr.d/stptr.d which have 14bit immediates. Cc: stable@vger.kernel.org Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202511240656.0NaPcJs1-lkp@intel.com/ Suggested-by: Rui Wang <wangrui@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn>
43 lines
1018 B
ArmAsm
43 lines
1018 B
ArmAsm
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited
|
|
*/
|
|
#include <asm/asm.h>
|
|
#include <asm/asmmacro.h>
|
|
#include <asm/asm-offsets.h>
|
|
#include <asm/loongarch.h>
|
|
#include <asm/regdef.h>
|
|
#include <asm/stackframe.h>
|
|
#include <asm/thread_info.h>
|
|
|
|
/*
|
|
* task_struct *__switch_to(task_struct *prev, task_struct *next,
|
|
* struct thread_info *next_ti, void *sched_ra, void *sched_cfa)
|
|
*/
|
|
.align 5
|
|
SYM_FUNC_START(__switch_to)
|
|
csrrd t1, LOONGARCH_CSR_PRMD
|
|
stptr.d t1, a0, THREAD_CSRPRMD
|
|
|
|
cpu_save_nonscratch a0
|
|
stptr.d ra, a0, THREAD_REG01
|
|
stptr.d a3, a0, THREAD_SCHED_RA
|
|
stptr.d a4, a0, THREAD_SCHED_CFA
|
|
#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
|
|
la t7, __stack_chk_guard
|
|
ldptr.d t8, a1, TASK_STACK_CANARY
|
|
stptr.d t8, t7, 0
|
|
#endif
|
|
move tp, a2
|
|
cpu_restore_nonscratch a1
|
|
|
|
li.w t0, _THREAD_SIZE
|
|
PTR_ADD t0, t0, tp
|
|
set_saved_sp t0, t1, t2
|
|
|
|
ldptr.d t1, a1, THREAD_CSRPRMD
|
|
csrwr t1, LOONGARCH_CSR_PRMD
|
|
|
|
jr ra
|
|
SYM_FUNC_END(__switch_to)
|