[PW_SID:1155369] [bpf] bpf, riscv: Make arena support depend on ZACAS - #2565
[PW_SID:1155369] [bpf] bpf, riscv: Make arena support depend on ZACAS#2565linux-riscv-bot wants to merge 4 commits into
Conversation
Overflow status and restart masks are u64, but bits were built with BIT(). On RV32 that is an unsigned long shift, so indices >= 32 truncate or wrap and corrupt the mask. Use BIT_ULL() for those u64 bitops. Fixes: a862521 ("drivers/perf: riscv: Implement SBI PMU snapshot function") Assisted-by: DeepSeek:deepseek-v3 Signed-off-by: Xixin Liu <liuxixin@kylinos.cn> Link: https://patch.msgid.link/prpmask01bitul.v2.1786434000.git.liuxixin@kylinos.cn [pjw@kernel.org: updated to apply] Signed-off-by: Paul Walmsley <pjw@kernel.org>
The available-counter mask was a single unsigned long, but iteration uses RISCV_MAX_COUNTERS, which is 64. On RV32 that reads past the object. Filling with an unsigned-long bit at index 32 and above is also wrong. Use DECLARE_BITMAP and set_bit/bitmap helpers. Walk each bitmap word into CFG_MATCH when checking events, when allocating an index, and when stopping all counters. Set the counter base to i times BITS_PER_LONG. Share the CFG_MATCH ecall through a small helper so the 32-bit argument split is not duplicated. On qemu-system-riscv32 the probe bitmap has bits above XLEN set, so the first word alone is not enough. Fixes: e999143 ("RISC-V: Add perf platform driver based on SBI PMU extension") Assisted-by: DeepSeek:deepseek-v3 Signed-off-by: Xixin Liu <liuxixin@kylinos.cn> Link: https://patch.msgid.link/prpmask02cmap.v2.1786434000.git.liuxixin@kylinos.cn [pjw@kernel.org: updated to apply] Signed-off-by: Paul Walmsley <pjw@kernel.org>
The arena range tree allocates its nodes with kmalloc_nolock() since commit f8c67d8 ("bpf: Use kmalloc_nolock() in range tree"). kmalloc_nolock() requires slab caches with cmpxchg128 support (__CMPXCHG_DOUBLE); on riscv cmpxchg128 is provided by the ZACAS extension. On systems without ZACAS every arena map creation fails with a misleading -ENOMEM. Report the missing support instead: make bpf_jit_supports_arena() return system_has_cmpxchg128(), so arena map creation fails with -EOPNOTSUPP on systems without ZACAS. This matches how arena BPF_CMPXCHG instructions are already gated on ZACAS in bpf_jit_supports_insn(). Fixes: f8c67d8 ("bpf: Use kmalloc_nolock() in range tree") Cc: stable@vger.kernel.org Signed-off-by: Chen Pei <cp0613@linux.alibaba.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
c27f74f to
9ed823f
Compare
|
Patch 1: "[bpf] bpf, riscv: Make arena support depend on ZACAS" |
|
Patch 1: "[bpf] bpf, riscv: Make arena support depend on ZACAS" |
|
Patch 1: "[bpf] bpf, riscv: Make arena support depend on ZACAS" |
|
Patch 1: "[bpf] bpf, riscv: Make arena support depend on ZACAS" |
|
Patch 1: "[bpf] bpf, riscv: Make arena support depend on ZACAS" |
|
Patch 1: "[bpf] bpf, riscv: Make arena support depend on ZACAS" |
|
Patch 1: "[bpf] bpf, riscv: Make arena support depend on ZACAS" |
|
Patch 1: "[bpf] bpf, riscv: Make arena support depend on ZACAS" |
|
Patch 1: "[bpf] bpf, riscv: Make arena support depend on ZACAS" |
|
Patch 1: "[bpf] bpf, riscv: Make arena support depend on ZACAS" |
|
Patch 1: "[bpf] bpf, riscv: Make arena support depend on ZACAS" |
|
Patch 1: "[bpf] bpf, riscv: Make arena support depend on ZACAS" |
PR for series 1155369 applied to workflow__riscv__fixes
Name: [bpf] bpf, riscv: Make arena support depend on ZACAS
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1155369
Version: 1