* re: LoongArch: Add BPF JIT support
@ 2023-07-24 12:27 Colin King (gmail)
2023-07-25 0:52 ` Tiezhu Yang
0 siblings, 1 reply; 2+ messages in thread
From: Colin King (gmail) @ 2023-07-24 12:27 UTC (permalink / raw)
To: Tiezhu Yang
Cc: Youling Tang, Huacai Chen, loongarch,
bpf@vger.kernel.org >> bpf, linux-kernel
Hi,
Static analysis with clang scan build on arch/loongarch/net/bpf_jit.h
has detected a potential issue with the following commit:
commit 5dc615520c4dfb358245680f1904bad61116648e
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
Date: Wed Oct 12 16:36:20 2022 +0800
LoongArch: Add BPF JIT support
This issue is as follows:
arch/loongarch/net/bpf_jit.h:153:23: warning: Logical disjunction always
evaluates to true: imm_51_31 != 0 || imm_51_31 != 0x1fffff.
[incorrectLogicOperator]
if (imm_51_31 != 0 || imm_51_31 != 0x1fffff) {
The statement seems to be always true. I suspect it should it be instead:
if (imm_51_31 != 0 && imm_51_31 != 0x1fffff) {
regards,
Colin
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: LoongArch: Add BPF JIT support
2023-07-24 12:27 LoongArch: Add BPF JIT support Colin King (gmail)
@ 2023-07-25 0:52 ` Tiezhu Yang
0 siblings, 0 replies; 2+ messages in thread
From: Tiezhu Yang @ 2023-07-25 0:52 UTC (permalink / raw)
To: Colin King (gmail)
Cc: Huacai Chen, loongarch, bpf@vger.kernel.org >> bpf, linux-kernel
Hi Colin,
On 07/24/2023 08:27 PM, Colin King (gmail) wrote:
> Hi,
>
> Static analysis with clang scan build on arch/loongarch/net/bpf_jit.h
> has detected a potential issue with the following commit:
>
> commit 5dc615520c4dfb358245680f1904bad61116648e
> Author: Tiezhu Yang <yangtiezhu@loongson.cn>
> Date: Wed Oct 12 16:36:20 2022 +0800
>
> LoongArch: Add BPF JIT support
>
> This issue is as follows:
>
> arch/loongarch/net/bpf_jit.h:153:23: warning: Logical disjunction always
> evaluates to true: imm_51_31 != 0 || imm_51_31 != 0x1fffff.
> [incorrectLogicOperator]
> if (imm_51_31 != 0 || imm_51_31 != 0x1fffff) {
Thanks for your report.
>
>
> The statement seems to be always true. I suspect it should it be instead:
>
> if (imm_51_31 != 0 && imm_51_31 != 0x1fffff) {
Yes, you are right. It is same with
if (!(imm_51_31 == 0 || imm_51_31 == 0x1fffff)) {
As the code comment says, the initial aim is to reduce one instruction
in some corner cases, if bit[51:31] is all 0 or all 1, no need to call
lu32id, that is to say, it should call lu32id only if bit[51:31] is not
all 0 and not all 1. The current code always call lu32id, the result is
right but the logic is unexpected and wrong.
I will send a patch to fix it as soon as possible.
Thanks,
Tiezhu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-25 0:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-24 12:27 LoongArch: Add BPF JIT support Colin King (gmail)
2023-07-25 0:52 ` Tiezhu Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).