Skip to content

Commit 1221454

Browse files
committed
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'
2 parents ffabf7c + 1e74ae3 commit 1221454

File tree

7 files changed

+29
-15
lines changed

7 files changed

+29
-15
lines changed

arch/loongarch/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ config LOONGARCH
1414
select ARCH_HAS_CPU_FINALIZE_INIT
1515
select ARCH_HAS_FORTIFY_SOURCE
1616
select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
17+
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
1718
select ARCH_HAS_PTE_SPECIAL
1819
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
1920
select ARCH_INLINE_READ_LOCK if !PREEMPTION

arch/loongarch/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ LDFLAGS_vmlinux += -static -n -nostdlib
6868
ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS
6969
cflags-y += $(call cc-option,-mexplicit-relocs)
7070
KBUILD_CFLAGS_KERNEL += $(call cc-option,-mdirect-extern-access)
71+
KBUILD_AFLAGS_MODULE += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
72+
KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
7173
else
7274
cflags-y += $(call cc-option,-mno-explicit-relocs)
7375
KBUILD_AFLAGS_KERNEL += -Wa,-mla-global-with-pcrel
@@ -111,7 +113,7 @@ KBUILD_CFLAGS += -isystem $(shell $(CC) -print-file-name=include)
111113

112114
KBUILD_LDFLAGS += -m $(ld-emul)
113115

114-
ifdef CONFIG_LOONGARCH
116+
ifdef need-compiler
115117
CHECKFLAGS += $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \
116118
grep -E -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \
117119
sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g')

arch/loongarch/include/asm/fpu.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,8 @@ static inline void restore_lsx(struct task_struct *t)
218218

219219
static inline void init_lsx_upper(void)
220220
{
221-
/*
222-
* Check cpu_has_lsx only if it's a constant. This will allow the
223-
* compiler to optimise out code for CPUs without LSX without adding
224-
* an extra redundant check for CPUs with LSX.
225-
*/
226-
if (__builtin_constant_p(cpu_has_lsx) && !cpu_has_lsx)
227-
return;
228-
229-
_init_lsx_upper();
221+
if (cpu_has_lsx)
222+
_init_lsx_upper();
230223
}
231224

232225
static inline void restore_lsx_upper(struct task_struct *t)
@@ -294,15 +287,15 @@ static inline void restore_lasx_upper(struct task_struct *t) {}
294287

295288
static inline int thread_lsx_context_live(void)
296289
{
297-
if (__builtin_constant_p(cpu_has_lsx) && !cpu_has_lsx)
290+
if (!cpu_has_lsx)
298291
return 0;
299292

300293
return test_thread_flag(TIF_LSX_CTX_LIVE);
301294
}
302295

303296
static inline int thread_lasx_context_live(void)
304297
{
305-
if (__builtin_constant_p(cpu_has_lasx) && !cpu_has_lasx)
298+
if (!cpu_has_lasx)
306299
return 0;
307300

308301
return test_thread_flag(TIF_LASX_CTX_LIVE);

arch/loongarch/kernel/setup.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,25 @@ static void __init bootcmdline_init(char **cmdline_p)
332332
strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
333333

334334
strlcat(boot_command_line, init_command_line, COMMAND_LINE_SIZE);
335+
goto out;
335336
}
336337
#endif
337338

339+
/*
340+
* Append built-in command line to the bootloader command line if
341+
* CONFIG_CMDLINE_EXTEND is enabled.
342+
*/
343+
if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) && CONFIG_CMDLINE[0]) {
344+
strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
345+
strlcat(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
346+
}
347+
348+
/*
349+
* Use built-in command line if the bootloader command line is empty.
350+
*/
351+
if (IS_ENABLED(CONFIG_CMDLINE_BOOTLOADER) && !boot_command_line[0])
352+
strscpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
353+
338354
out:
339355
*cmdline_p = boot_command_line;
340356
}

arch/loongarch/lib/clear_user.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ SYM_FUNC_START(__clear_user_fast)
108108
addi.d a3, a2, -8
109109
bgeu a0, a3, .Llt8
110110
15: st.d zero, a0, 0
111+
addi.d a0, a0, 8
111112

112113
.Llt8:
113114
16: st.d zero, a2, -8
@@ -188,7 +189,7 @@ SYM_FUNC_START(__clear_user_fast)
188189
_asm_extable 13b, .L_fixup_handle_0
189190
_asm_extable 14b, .L_fixup_handle_1
190191
_asm_extable 15b, .L_fixup_handle_0
191-
_asm_extable 16b, .L_fixup_handle_1
192+
_asm_extable 16b, .L_fixup_handle_0
192193
_asm_extable 17b, .L_fixup_handle_s0
193194
_asm_extable 18b, .L_fixup_handle_s0
194195
_asm_extable 19b, .L_fixup_handle_s0

arch/loongarch/lib/copy_user.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ SYM_FUNC_START(__copy_user_fast)
136136
bgeu a1, a4, .Llt8
137137
30: ld.d t0, a1, 0
138138
31: st.d t0, a0, 0
139+
addi.d a0, a0, 8
139140

140141
.Llt8:
141142
32: ld.d t0, a3, -8
@@ -246,7 +247,7 @@ SYM_FUNC_START(__copy_user_fast)
246247
_asm_extable 30b, .L_fixup_handle_0
247248
_asm_extable 31b, .L_fixup_handle_0
248249
_asm_extable 32b, .L_fixup_handle_0
249-
_asm_extable 33b, .L_fixup_handle_1
250+
_asm_extable 33b, .L_fixup_handle_0
250251
_asm_extable 34b, .L_fixup_handle_s0
251252
_asm_extable 35b, .L_fixup_handle_s0
252253
_asm_extable 36b, .L_fixup_handle_s0

arch/loongarch/net/bpf_jit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static inline void move_imm(struct jit_ctx *ctx, enum loongarch_gpr rd, long imm
150150
* no need to call lu32id to do a new filled operation.
151151
*/
152152
imm_51_31 = (imm >> 31) & 0x1fffff;
153-
if (imm_51_31 != 0 || imm_51_31 != 0x1fffff) {
153+
if (imm_51_31 != 0 && imm_51_31 != 0x1fffff) {
154154
/* lu32id rd, imm_51_32 */
155155
imm_51_32 = (imm >> 32) & 0xfffff;
156156
emit_insn(ctx, lu32id, rd, imm_51_32);

0 commit comments

Comments
 (0)