Commit a6d116d
LoongArch: BPF: Fix sign extension for 12-bit immediates
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]>1 parent 9a71dd4 commit a6d116d
1 file changed
+2
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
| 126 | + | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| |||
0 commit comments