[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAAhV-H65jzk+PpuXBH79Q2XwYVzFdL55vFUhXTD1R4iUQ3zd-g@mail.gmail.com>
Date: Tue, 25 Jul 2023 15:12:31 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Tiezhu Yang <yangtiezhu@...ngson.cn>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>, bpf@...r.kernel.org,
loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org,
loongson-kernel@...ts.loongnix.cn, stable@...r.kernel.org,
#@....codeaurora.org, 6.1@....codeaurora.org
Subject: Re: [PATCH bpf-next] LoongArch: BPF: Fix check condition to call
lu32id in move_imm()
Queued for loongarch-next, thanks.
Huacai
On Tue, Jul 25, 2023 at 3:05 PM Tiezhu Yang <yangtiezhu@...ngson.cn> wrote:
>
> 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, fix it.
>
> Cc: stable@...r.kernel.org # 6.1
> Fixes: 5dc615520c4d ("LoongArch: Add BPF JIT support")
> Reported-by: Colin King (gmail) <colin.i.king@...il.com>
> Closes: https://lore.kernel.org/all/bcf97046-e336-712a-ac68-7fd194f2953e@gmail.com/
> Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
> ---
> arch/loongarch/net/bpf_jit.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/net/bpf_jit.h b/arch/loongarch/net/bpf_jit.h
> index c335dc4..6858633 100644
> --- a/arch/loongarch/net/bpf_jit.h
> +++ b/arch/loongarch/net/bpf_jit.h
> @@ -150,7 +150,7 @@ static inline void move_imm(struct jit_ctx *ctx, enum loongarch_gpr rd, long imm
> * no need to call lu32id to do a new filled operation.
> */
> imm_51_31 = (imm >> 31) & 0x1fffff;
> - if (imm_51_31 != 0 || imm_51_31 != 0x1fffff) {
> + if (imm_51_31 != 0 && imm_51_31 != 0x1fffff) {
> /* lu32id rd, imm_51_32 */
> imm_51_32 = (imm >> 32) & 0xfffff;
> emit_insn(ctx, lu32id, rd, imm_51_32);
> --
> 2.1.0
>
>
Powered by blists - more mailing lists