Skip to content

Commit ad5348c

Browse files
radimkrcmarPaul Walmsley
authored andcommitted
riscv, bpf: use lw when reading int cpu in BPF_MOV64_PERCPU_REG
emit_ld is wrong, because thread_info.cpu is 32-bit, not xlen-bit wide. The struct currently has a hole after cpu, so little endian accesses seemed fine. Fixes: 19c56d4 ("riscv, bpf: add internal-only MOV instruction to resolve per-CPU addrs") Cc: [email protected] Signed-off-by: Radim Krčmář <[email protected]> Reviewed-by: Pu Lehui <[email protected]> Acked-by: Björn Töpel <[email protected]> Tested-by: Björn Töpel <[email protected]> # QEMU Reviewed-by: Alexandre Ghiti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paul Walmsley <[email protected]>
1 parent 1046791 commit ad5348c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/riscv/net/bpf_jit_comp64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
13561356
emit_mv(rd, rs, ctx);
13571357
#ifdef CONFIG_SMP
13581358
/* Load current CPU number in T1 */
1359-
emit_ld(RV_REG_T1, offsetof(struct thread_info, cpu),
1359+
emit_lw(RV_REG_T1, offsetof(struct thread_info, cpu),
13601360
RV_REG_TP, ctx);
13611361
/* Load address of __per_cpu_offset array in T2 */
13621362
emit_addr(RV_REG_T2, (u64)&__per_cpu_offset, extra_pass, ctx);

0 commit comments

Comments
 (0)