Skip to content

Commit 8a16586

Browse files
radimkrcmarPaul Walmsley
authored andcommitted
riscv, bpf: use lw when reading int cpu in bpf_get_smp_processor_id
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: 2ddec2c ("riscv, bpf: inline bpf_get_smp_processor_id()") Cc: [email protected] Signed-off-by: Radim Krčmář <[email protected]> Reviewed-by: Pu Lehui <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paul Walmsley <[email protected]>
1 parent ad5348c commit 8a16586

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
@@ -1763,7 +1763,7 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
17631763
*/
17641764
if (insn->src_reg == 0 && insn->imm == BPF_FUNC_get_smp_processor_id) {
17651765
/* Load current CPU number in R0 */
1766-
emit_ld(bpf_to_rv_reg(BPF_REG_0, ctx), offsetof(struct thread_info, cpu),
1766+
emit_lw(bpf_to_rv_reg(BPF_REG_0, ctx), offsetof(struct thread_info, cpu),
17671767
RV_REG_TP, ctx);
17681768
break;
17691769
}

0 commit comments

Comments
 (0)