Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1275973rwl; Sat, 25 Mar 2023 22:29:30 -0700 (PDT) X-Google-Smtp-Source: AKy350bRvI32xx3NMpt/88+MZ6SIaLE2FYv4yZ+rf4CoVJYWrHF/E9H9gtu+OSUJAgV0eqQTaaTn X-Received: by 2002:a17:906:364d:b0:930:60ba:d4b with SMTP id r13-20020a170906364d00b0093060ba0d4bmr8467625ejb.37.1679808570387; Sat, 25 Mar 2023 22:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679808570; cv=none; d=google.com; s=arc-20160816; b=gnEgGRlZIhCeJE61oIINDd4HDo1R0aOOI+QT7AQjgO9/GIw6/Oj1P6/kl1bGKnT0ks fN5T4W0KOTeQa2jJDsnHf0a9ucYPBuo9tShsf1kI87mumPZ3xoGj8j8P0Cpufo2jrJks uW45nxu9YP4c3LDxOUJN6HclUzDEVwLT8oflXeICArg0cwnsu/05o2J9eIcI1aw+yuhN nkcdvdBtbiMkR90pkQobMhjnmqkoYf9OiqS6tEuits0Qitf/R+0c0Nmewssm+qduQUxx Khv9eDRb/IOY2IWM7SFNz8RgzM6Kcp2N9hwrAEDZvJgGANLA90rvRGKxYaZcXk8hl/td i08Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=a4rNss9/jCAF2CD2hB8QOEAr800YAbzDULI//LlJdo0=; b=bKzG8+n0bBiuXg2J2T7LhYoyGLQRRYHe4IzGi9/FsDY7ADP2HPJ3+jbGu950TOFajn Bz4uhBPAc4HkESXlp+XMhccr18srCxyl1aJSTGZlW5YSxFHZmJYiyEgjA+1B/8IOnQjX yi+olQdcydgj23a+y1rnZH65Z91z58jPWN/CWsbdcajGKtvyl+ZSUOnejHJ8KTho1Wmi dhzHwS6sPFNc6zy79xm2BIhFKVPgxvlSxcZBA98Ku4kZugqx0Rrk3Sm0NB7JJyWSM2Lg yTfS5dCsOQG5SiCIP2ZdLKCmsp1ruEvjiGjzEP6q6c5ArlQxsQpjwnurs/DXax4szBrH nXIw== 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 sy17-20020a1709076f1100b0093defbd627bsi5831361ejc.1026.2023.03.25.22.28.57; Sat, 25 Mar 2023 22:29:30 -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 S231821AbjCZEkf (ORCPT + 99 others); Sun, 26 Mar 2023 00:40:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231410AbjCZEkd (ORCPT ); Sun, 26 Mar 2023 00:40:33 -0400 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD8B1618D; Sat, 25 Mar 2023 21:40:30 -0700 (PDT) X-UUID: b6cde0c7e2b64c718c7dc18a8eab4dc3-20230326 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.20,REQID:8e8edc52-f736-4f72-9b68-3722b697739c,IP:10, URL:0,TC:0,Content:0,EDM:25,RT:0,SF:1,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:36 X-CID-INFO: VERSION:1.1.20,REQID:8e8edc52-f736-4f72-9b68-3722b697739c,IP:10,UR L:0,TC:0,Content:0,EDM:25,RT:0,SF:1,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:36 X-CID-META: VersionHash:25b5999,CLOUDID:0cdd7f29-564d-42d9-9875-7c868ee415ec,B ulkID:230326123044RXI7AJ6O,BulkQuantity:3,Recheck:0,SF:38|24|17|19|43|102, TC:nil,Content:0,EDM:5,IP:-2,URL:0,File:nil,Bulk:40,QS:nil,BEC:nil,COL:0,O SI:0,OSA:0,AV:0 X-CID-BVR: 0 X-UUID: b6cde0c7e2b64c718c7dc18a8eab4dc3-20230326 X-User: guodongtai@kylinos.cn Received: from localhost.localdomain [(210.12.40.82)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 124657828; Sun, 26 Mar 2023 12:40:21 +0800 From: George Guo To: chenhuacai@kernel.org, masahiroy@kernel.org, michal.lkml@markovi.net Cc: kernel@xen0n.name, ndesaulniers@google.com, daniel@iogearbox.net, ast@kernel.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH] loongarch/bpf: Fix bpf load failed with CONFIG_BPF_JIT_ALWAYS_ON, caused by jit (BPF_ST | BPF_NOSPEC) code Date: Sun, 26 Mar 2023 12:40:19 +0800 Message-Id: <20230326044019.2139628-1-guodongtai@kylinos.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable 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 Here just skip the code(BPF_ST | BPF_NOSPEC) that has no couterpart to the loongarch. To verify, use ltp testcase: Without this patch: $ ./bpf_prog02 ... ... bpf_common.c:123: TBROK: Failed verification: ??? (524) Summary: passed 0 failed 0 broken 1 skipped 0 warnings 0 With this patch: $ ./bpf_prog02 ... ... Summary: passed 0 failed 0 broken 0 skipped 0 warnings 0 Signed-off-by: George Guo --- arch/loongarch/net/bpf_jit.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c index 288003a9f0ca..745d344385ed 100644 --- a/arch/loongarch/net/bpf_jit.c +++ b/arch/loongarch/net/bpf_jit.c @@ -1046,6 +1046,11 @@ static int build_body(struct jit_ctx *ctx, bool extra_pass) if (ctx->image == NULL) ctx->offset[i] = ctx->idx; + /* skip the code that has no couterpart to the host arch */ + if(insn->code == (BPF_ST | BPF_NOSPEC)) { + continue; + } + ret = build_insn(insn, ctx, extra_pass); if (ret > 0) { i++; -- 2.34.1