Skip to content

Conversation

@kernel-patches-daemon-bpf-rc
Copy link

Pull request for series with
subject: LoongArch: BPF: Fix sign extension for 12-bit immediates
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1018805

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: ab01bfa
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1018805
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: e6e10c5
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1018805
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 5dae745
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1018805
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 11369e6
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1018805
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: efa4756
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1018805
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: b3387b3
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1018805
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 4cb4897
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1018805
version: 1

When loading immediate values that fit within 12-bit signed range,
the move_imm function incorrectly used zero extension instead of
sign extension.

The bug was exposed when scx_simple scheduler failed with -EINVAL
in ops.init() after passing node = -1 to scx_bpf_create_dsq().
Due to incorrect sign extension, `node >= (int)nr_node_ids`
evaluated to true instead of false, causing BPF program failure.

Verified by testing with the scx_simple scheduler (located in
tools/sched_ext/). After building with `make` and running
./tools/sched_ext/build/bin/scx_simple, the scheduler now
initializes successfully with this fix.

Fix this by using sign extension (sext) instead of zero extension
for signed immediate values in move_imm.

Fixes: 5dc6155 ("LoongArch: Add BPF JIT support")
Reported-by: Bing Huang <[email protected]>
Signed-off-by: George Guo <[email protected]>
@kernel-patches-daemon-bpf-rc
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1018805 expired. Closing PR.

@kernel-patches-daemon-bpf-rc kernel-patches-daemon-bpf-rc bot deleted the series/1018805=>bpf-next branch November 8, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants