Skip to content

Commit b10a3cc

Browse files
committed
Merge tag 'loongarch-fixes-6.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
Pull LoongArch fixes from Huacai Chen: "Preserve syscall nr across execve(), slightly clean up drdtime(), fix the Clang built zboot kernel, fix a stack unwinder bug and several bpf jit bugs" * tag 'loongarch-fixes-6.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson: LoongArch: BPF: Fix unconditional bswap instructions LoongArch: BPF: Fix sign-extension mov instructions LoongArch: BPF: Don't sign extend function return value LoongArch: BPF: Don't sign extend memory load operand LoongArch: Preserve syscall nr across execve() LoongArch: Set unwind stack type to unknown rather than set error flag LoongArch: Slightly clean up drdtime() LoongArch: Apply dynamic relocations for LLD
2 parents b8503b2 + e2f7b3d commit b10a3cc

File tree

7 files changed

+12
-20
lines changed

7 files changed

+12
-20
lines changed

arch/loongarch/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ endif
8383

8484
ifeq ($(CONFIG_RELOCATABLE),y)
8585
KBUILD_CFLAGS_KERNEL += -fPIE
86-
LDFLAGS_vmlinux += -static -pie --no-dynamic-linker -z notext
86+
LDFLAGS_vmlinux += -static -pie --no-dynamic-linker -z notext $(call ld-option, --apply-dynamic-relocs)
8787
endif
8888

8989
cflags-y += $(call cc-option, -mno-check-zero-division)

arch/loongarch/include/asm/elf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ extern const char *__elf_platform;
293293
#define ELF_PLAT_INIT(_r, load_addr) do { \
294294
_r->regs[1] = _r->regs[2] = _r->regs[3] = _r->regs[4] = 0; \
295295
_r->regs[5] = _r->regs[6] = _r->regs[7] = _r->regs[8] = 0; \
296-
_r->regs[9] = _r->regs[10] = _r->regs[11] = _r->regs[12] = 0; \
296+
_r->regs[9] = _r->regs[10] /* syscall n */ = _r->regs[12] = 0; \
297297
_r->regs[13] = _r->regs[14] = _r->regs[15] = _r->regs[16] = 0; \
298298
_r->regs[17] = _r->regs[18] = _r->regs[19] = _r->regs[20] = 0; \
299299
_r->regs[21] = _r->regs[22] = _r->regs[23] = _r->regs[24] = 0; \

arch/loongarch/include/asm/loongarch.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,12 +1098,11 @@
10981098

10991099
static __always_inline u64 drdtime(void)
11001100
{
1101-
int rID = 0;
11021101
u64 val = 0;
11031102

11041103
__asm__ __volatile__(
1105-
"rdtime.d %0, %1 \n\t"
1106-
: "=r"(val), "=r"(rID)
1104+
"rdtime.d %0, $zero\n\t"
1105+
: "=r"(val)
11071106
:
11081107
);
11091108
return val;

arch/loongarch/kernel/stacktrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
3232
}
3333

3434
for (unwind_start(&state, task, regs);
35-
!unwind_done(&state) && !unwind_error(&state); unwind_next_frame(&state)) {
35+
!unwind_done(&state); unwind_next_frame(&state)) {
3636
addr = unwind_get_return_address(&state);
3737
if (!addr || !consume_entry(cookie, addr))
3838
break;

arch/loongarch/kernel/unwind.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,5 @@ bool default_next_frame(struct unwind_state *state)
2828

2929
} while (!get_stack_info(state->sp, state->task, info));
3030

31-
state->error = true;
3231
return false;
3332
}

arch/loongarch/kernel/unwind_prologue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static bool next_frame(struct unwind_state *state)
227227
} while (!get_stack_info(state->sp, state->task, info));
228228

229229
out:
230-
state->error = true;
230+
state->stack_info.type = STACK_TYPE_UNKNOWN;
231231
return false;
232232
}
233233

arch/loongarch/net/bpf_jit.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,12 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
480480
case 8:
481481
move_reg(ctx, t1, src);
482482
emit_insn(ctx, extwb, dst, t1);
483+
emit_zext_32(ctx, dst, is32);
483484
break;
484485
case 16:
485486
move_reg(ctx, t1, src);
486487
emit_insn(ctx, extwh, dst, t1);
488+
emit_zext_32(ctx, dst, is32);
487489
break;
488490
case 32:
489491
emit_insn(ctx, addw, dst, src, LOONGARCH_GPR_ZERO);
@@ -772,8 +774,8 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
772774
break;
773775
case 32:
774776
emit_insn(ctx, revb2w, dst, dst);
775-
/* zero-extend 32 bits into 64 bits */
776-
emit_zext_32(ctx, dst, is32);
777+
/* clear the upper 32 bits */
778+
emit_zext_32(ctx, dst, true);
777779
break;
778780
case 64:
779781
emit_insn(ctx, revbd, dst, dst);
@@ -911,8 +913,6 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
911913

912914
/* function return */
913915
case BPF_JMP | BPF_EXIT:
914-
emit_sext_32(ctx, regmap[BPF_REG_0], true);
915-
916916
if (i == ctx->prog->len - 1)
917917
break;
918918

@@ -988,14 +988,8 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
988988
}
989989
break;
990990
case BPF_DW:
991-
if (is_signed_imm12(off)) {
992-
emit_insn(ctx, ldd, dst, src, off);
993-
} else if (is_signed_imm14(off)) {
994-
emit_insn(ctx, ldptrd, dst, src, off);
995-
} else {
996-
move_imm(ctx, t1, off, is32);
997-
emit_insn(ctx, ldxd, dst, src, t1);
998-
}
991+
move_imm(ctx, t1, off, is32);
992+
emit_insn(ctx, ldxd, dst, src, t1);
999993
break;
1000994
}
1001995

0 commit comments

Comments
 (0)