Commit 12214540 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'loongarch-fixes-6.5-1' of...

Merge tag 'loongarch-fixes-6.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson

Pull LoongArch fixes from Huacai Chen:
 "Some bug fixes for build system, builtin cmdline handling, bpf and
  {copy, clear}_user, together with a trivial cleanup"

* tag 'loongarch-fixes-6.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson:
  LoongArch: Cleanup __builtin_constant_p() checking for cpu_has_*
  LoongArch: BPF: Fix check condition to call lu32id in move_imm()
  LoongArch: BPF: Enable bpf_probe_read{, str}() on LoongArch
  LoongArch: Fix return value underflow in exception path
  LoongArch: Fix CMDLINE_EXTEND and CMDLINE_BOOTLOADER handling
  LoongArch: Fix module relocation error with binutils 2.41
  LoongArch: Only fiddle with CHECKFLAGS if `need-compiler'
parents ffabf7c7 1e74ae32
...@@ -14,6 +14,7 @@ config LOONGARCH ...@@ -14,6 +14,7 @@ config LOONGARCH
select ARCH_HAS_CPU_FINALIZE_INIT select ARCH_HAS_CPU_FINALIZE_INIT
select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_FORTIFY_SOURCE
select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_PTE_SPECIAL
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_INLINE_READ_LOCK if !PREEMPTION select ARCH_INLINE_READ_LOCK if !PREEMPTION
......
...@@ -68,6 +68,8 @@ LDFLAGS_vmlinux += -static -n -nostdlib ...@@ -68,6 +68,8 @@ LDFLAGS_vmlinux += -static -n -nostdlib
ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS
cflags-y += $(call cc-option,-mexplicit-relocs) cflags-y += $(call cc-option,-mexplicit-relocs)
KBUILD_CFLAGS_KERNEL += $(call cc-option,-mdirect-extern-access) KBUILD_CFLAGS_KERNEL += $(call cc-option,-mdirect-extern-access)
KBUILD_AFLAGS_MODULE += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
else else
cflags-y += $(call cc-option,-mno-explicit-relocs) cflags-y += $(call cc-option,-mno-explicit-relocs)
KBUILD_AFLAGS_KERNEL += -Wa,-mla-global-with-pcrel KBUILD_AFLAGS_KERNEL += -Wa,-mla-global-with-pcrel
...@@ -111,7 +113,7 @@ KBUILD_CFLAGS += -isystem $(shell $(CC) -print-file-name=include) ...@@ -111,7 +113,7 @@ KBUILD_CFLAGS += -isystem $(shell $(CC) -print-file-name=include)
KBUILD_LDFLAGS += -m $(ld-emul) KBUILD_LDFLAGS += -m $(ld-emul)
ifdef CONFIG_LOONGARCH ifdef need-compiler
CHECKFLAGS += $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ CHECKFLAGS += $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \
grep -E -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \ grep -E -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \
sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g') sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g')
......
...@@ -218,15 +218,8 @@ static inline void restore_lsx(struct task_struct *t) ...@@ -218,15 +218,8 @@ static inline void restore_lsx(struct task_struct *t)
static inline void init_lsx_upper(void) static inline void init_lsx_upper(void)
{ {
/* if (cpu_has_lsx)
* Check cpu_has_lsx only if it's a constant. This will allow the _init_lsx_upper();
* compiler to optimise out code for CPUs without LSX without adding
* an extra redundant check for CPUs with LSX.
*/
if (__builtin_constant_p(cpu_has_lsx) && !cpu_has_lsx)
return;
_init_lsx_upper();
} }
static inline void restore_lsx_upper(struct task_struct *t) static inline void restore_lsx_upper(struct task_struct *t)
...@@ -294,7 +287,7 @@ static inline void restore_lasx_upper(struct task_struct *t) {} ...@@ -294,7 +287,7 @@ static inline void restore_lasx_upper(struct task_struct *t) {}
static inline int thread_lsx_context_live(void) static inline int thread_lsx_context_live(void)
{ {
if (__builtin_constant_p(cpu_has_lsx) && !cpu_has_lsx) if (!cpu_has_lsx)
return 0; return 0;
return test_thread_flag(TIF_LSX_CTX_LIVE); return test_thread_flag(TIF_LSX_CTX_LIVE);
...@@ -302,7 +295,7 @@ static inline int thread_lsx_context_live(void) ...@@ -302,7 +295,7 @@ static inline int thread_lsx_context_live(void)
static inline int thread_lasx_context_live(void) static inline int thread_lasx_context_live(void)
{ {
if (__builtin_constant_p(cpu_has_lasx) && !cpu_has_lasx) if (!cpu_has_lasx)
return 0; return 0;
return test_thread_flag(TIF_LASX_CTX_LIVE); return test_thread_flag(TIF_LASX_CTX_LIVE);
......
...@@ -332,9 +332,25 @@ static void __init bootcmdline_init(char **cmdline_p) ...@@ -332,9 +332,25 @@ static void __init bootcmdline_init(char **cmdline_p)
strlcat(boot_command_line, " ", COMMAND_LINE_SIZE); strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
strlcat(boot_command_line, init_command_line, COMMAND_LINE_SIZE); strlcat(boot_command_line, init_command_line, COMMAND_LINE_SIZE);
goto out;
} }
#endif #endif
/*
* Append built-in command line to the bootloader command line if
* CONFIG_CMDLINE_EXTEND is enabled.
*/
if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) && CONFIG_CMDLINE[0]) {
strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
strlcat(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
}
/*
* Use built-in command line if the bootloader command line is empty.
*/
if (IS_ENABLED(CONFIG_CMDLINE_BOOTLOADER) && !boot_command_line[0])
strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
out: out:
*cmdline_p = boot_command_line; *cmdline_p = boot_command_line;
} }
......
...@@ -108,6 +108,7 @@ SYM_FUNC_START(__clear_user_fast) ...@@ -108,6 +108,7 @@ SYM_FUNC_START(__clear_user_fast)
addi.d a3, a2, -8 addi.d a3, a2, -8
bgeu a0, a3, .Llt8 bgeu a0, a3, .Llt8
15: st.d zero, a0, 0 15: st.d zero, a0, 0
addi.d a0, a0, 8
.Llt8: .Llt8:
16: st.d zero, a2, -8 16: st.d zero, a2, -8
...@@ -188,7 +189,7 @@ SYM_FUNC_START(__clear_user_fast) ...@@ -188,7 +189,7 @@ SYM_FUNC_START(__clear_user_fast)
_asm_extable 13b, .L_fixup_handle_0 _asm_extable 13b, .L_fixup_handle_0
_asm_extable 14b, .L_fixup_handle_1 _asm_extable 14b, .L_fixup_handle_1
_asm_extable 15b, .L_fixup_handle_0 _asm_extable 15b, .L_fixup_handle_0
_asm_extable 16b, .L_fixup_handle_1 _asm_extable 16b, .L_fixup_handle_0
_asm_extable 17b, .L_fixup_handle_s0 _asm_extable 17b, .L_fixup_handle_s0
_asm_extable 18b, .L_fixup_handle_s0 _asm_extable 18b, .L_fixup_handle_s0
_asm_extable 19b, .L_fixup_handle_s0 _asm_extable 19b, .L_fixup_handle_s0
......
...@@ -136,6 +136,7 @@ SYM_FUNC_START(__copy_user_fast) ...@@ -136,6 +136,7 @@ SYM_FUNC_START(__copy_user_fast)
bgeu a1, a4, .Llt8 bgeu a1, a4, .Llt8
30: ld.d t0, a1, 0 30: ld.d t0, a1, 0
31: st.d t0, a0, 0 31: st.d t0, a0, 0
addi.d a0, a0, 8
.Llt8: .Llt8:
32: ld.d t0, a3, -8 32: ld.d t0, a3, -8
...@@ -246,7 +247,7 @@ SYM_FUNC_START(__copy_user_fast) ...@@ -246,7 +247,7 @@ SYM_FUNC_START(__copy_user_fast)
_asm_extable 30b, .L_fixup_handle_0 _asm_extable 30b, .L_fixup_handle_0
_asm_extable 31b, .L_fixup_handle_0 _asm_extable 31b, .L_fixup_handle_0
_asm_extable 32b, .L_fixup_handle_0 _asm_extable 32b, .L_fixup_handle_0
_asm_extable 33b, .L_fixup_handle_1 _asm_extable 33b, .L_fixup_handle_0
_asm_extable 34b, .L_fixup_handle_s0 _asm_extable 34b, .L_fixup_handle_s0
_asm_extable 35b, .L_fixup_handle_s0 _asm_extable 35b, .L_fixup_handle_s0
_asm_extable 36b, .L_fixup_handle_s0 _asm_extable 36b, .L_fixup_handle_s0
......
...@@ -150,7 +150,7 @@ static inline void move_imm(struct jit_ctx *ctx, enum loongarch_gpr rd, long imm ...@@ -150,7 +150,7 @@ static inline void move_imm(struct jit_ctx *ctx, enum loongarch_gpr rd, long imm
* no need to call lu32id to do a new filled operation. * no need to call lu32id to do a new filled operation.
*/ */
imm_51_31 = (imm >> 31) & 0x1fffff; imm_51_31 = (imm >> 31) & 0x1fffff;
if (imm_51_31 != 0 || imm_51_31 != 0x1fffff) { if (imm_51_31 != 0 && imm_51_31 != 0x1fffff) {
/* lu32id rd, imm_51_32 */ /* lu32id rd, imm_51_32 */
imm_51_32 = (imm >> 32) & 0xfffff; imm_51_32 = (imm >> 32) & 0xfffff;
emit_insn(ctx, lu32id, rd, imm_51_32); emit_insn(ctx, lu32id, rd, imm_51_32);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment