Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3866168rwo; Mon, 24 Jul 2023 18:52:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlFtQQPdmUAW1tQDZHH+vEczVxgmCOz9snGcPgNeCBLOhXns/X7EjXfWWgocch9aeXzjnEaf X-Received: by 2002:a17:902:850c:b0:1b8:6cae:4400 with SMTP id bj12-20020a170902850c00b001b86cae4400mr6925569plb.37.1690249976673; Mon, 24 Jul 2023 18:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690249976; cv=none; d=google.com; s=arc-20160816; b=Fa694QCEBnIVflBkDWt1ujtIxWnOA0nliAksNeDIJUNAMSrFZFiPGJsUAJLRE3PSc6 1toWtg5rG3MUw2pwvivhOrkOLfMo+jPE6+Gt5yNSduoBQjopmbPNfzmaLwdKPxhbJmPG eXaiyrzt0ddn6wK1k7CWRvww3fmTIa92+lGqjCAPkNuwcajbnhUBSYPyTbXqz7RSncnA S1sh01fkdoC7/VGwHd71pLCrQDh3xrI9qqNzu9JP7tF0hlA4SHL4wahE9qw+pN1SVq1z +DeXkMzBEMAj/oAoArk3OobPo6LJ0P8JgreS+nfII30n3v8uEZmrqA9RF3mUIPnxWLGS fjcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=79VxercEbc16vXZik2hzqbD7Ajx6WOIY5syFBfPakwg=; fh=jqf9OijkcXpqOsVYEJyh49tMVvcYTZYM6MNYm8RFo34=; b=MFJLo/a6KyBAmZsC+QsI36xuSHDSR9QOBWV2szsZMeYUCsFgifzgM4BChePZSc9z3L kQI0LA5d2G3P3ZqF5xArwFyLYtJV4EsIkWzcm6+5Y8Cx4KouSs5P9M6dLmQ1950IqsoR vM9oqM0Q68nl/dHLOxaAyzlLkfN8mrzeZ1o+Kv9oX/iZfeaesgZ5jJrYfY0IkLdQXc1e GC5XW0AFovOIEVHqgemRKpQWClM/lduH6pPhR6fsVx7jSn9HWJxnUbvnhjoLgQPG1qv7 +anRMo0waIMtPg6UB8tKyDrIM/XFfs4DIMVLAUMxiJ6dCT8BqibWXXW40wUPU1BN0ge7 9Vxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020a170903018200b001b7d2b55d8asi11229444plg.626.2023.07.24.18.52.44; Mon, 24 Jul 2023 18:52:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230265AbjGYAwR (ORCPT + 99 others); Mon, 24 Jul 2023 20:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbjGYAwQ (ORCPT ); Mon, 24 Jul 2023 20:52:16 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E5EA171E; Mon, 24 Jul 2023 17:52:05 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8AxTeuzHL9kr3wJAA--.18382S3; Tue, 25 Jul 2023 08:52:03 +0800 (CST) Received: from [10.130.0.149] (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxXSOyHL9kwvM5AA--.6637S3; Tue, 25 Jul 2023 08:52:03 +0800 (CST) Subject: Re: LoongArch: Add BPF JIT support To: "Colin King (gmail)" References: Cc: Huacai Chen , loongarch@lists.linux.dev, "bpf@vger.kernel.org >> bpf" , "linux-kernel@vger.kernel.org" From: Tiezhu Yang Message-ID: <9ce766dd-4bd9-d4a0-6da5-a29af7d9aa28@loongson.cn> Date: Tue, 25 Jul 2023 08:52:02 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: AQAAf8BxXSOyHL9kwvM5AA--.6637S3 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7XF4kJryxWrW7AFyxZw4UZFc_yoW8JF1rpF Z3ua17AryIgF17u3ZrJr45WF4UtrWfGw48Wa1UJ348uFn8Wrn2vw1Ig3yUAF97Xa15ta4S qr42k3sFgFW8GabCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUv0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lc7I2V7IY0VAS07AlzV AYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r 4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU8j-e5UU UUU== X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > 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