Skip to content

LoongArch: bpf: zero-extend signed ALU32 div/mod results#12755

Open
kernel-patches-daemon-bpf[bot] wants to merge 1 commit into
bpf_basefrom
series/1124752=>bpf
Open

LoongArch: bpf: zero-extend signed ALU32 div/mod results#12755
kernel-patches-daemon-bpf[bot] wants to merge 1 commit into
bpf_basefrom
series/1124752=>bpf

Conversation

@kernel-patches-daemon-bpf

Copy link
Copy Markdown

Pull request for series with
subject: LoongArch: bpf: zero-extend signed ALU32 div/mod results
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1124752

@kernel-patches-daemon-bpf

Copy link
Copy Markdown
Author

Upstream branch: 0e35b9b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1124752
version: 1

@kernel-patches-daemon-bpf

Copy link
Copy Markdown
Author

Upstream branch: 7cbd0c4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1124752
version: 1

@kernel-patches-daemon-bpf

Copy link
Copy Markdown
Author

Upstream branch: 7cbd0c4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1124752
version: 1

ALU32 operations write a 32-bit result and leave the upper 32 bits of
the BPF register zero. The LoongArch JIT sign-extends the result of
signed ALU32 BPF_DIV and BPF_MOD (off=1), so a negative 32-bit quotient
or remainder leaves bits 63:32 set in JITted code while the verifier
and interpreter model those bits as zero.

Keep sign-extension on the operands, which signed divide needs, and
zero-extend the ALU32 result after the divide or modulo instruction,
matching the unsigned ALU32 div/mod paths and every other ALU32
operation in this JIT.

Fixes: 2425c9e ("LoongArch: BPF: Support signed div instructions")
Fixes: 7b6b13d ("LoongArch: BPF: Support signed mod instructions")
Signed-off-by: Nicholas Dudar <main.kalliope@gmail.com>
Assisted-by: Claude:claude-opus-4-8
Acked-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Tested-by: Tiezhu Yang <yangtiezhu@loongson.cn>
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.

1 participant