Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2602288rwl; Mon, 27 Mar 2023 02:33:08 -0700 (PDT) X-Google-Smtp-Source: AKy350aZuV+99Wjwily7dM1CCsSkHHcpUkVdQZC/E/TaxA5ShEF97QQcyVGd7iiavaU1XF0+Y8vt X-Received: by 2002:a17:903:230b:b0:1a0:4fb2:6623 with SMTP id d11-20020a170903230b00b001a04fb26623mr13671252plh.40.1679909588357; Mon, 27 Mar 2023 02:33:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679909588; cv=none; d=google.com; s=arc-20160816; b=qdGCfNcKn6nRNTYPcl0xcrpt1FRoqjj5KX1v0/gTDRfgAvYrTp4Rp094MHU6a62SPU KzCtYOA3ksVo5HeRHtEK8tVCA1Vaj6JQzSA12mALyBQ1dPiLPF/qEoTpBiNup7hcFC1H K/JxWo3hBC0btKDayYrxuXdh66r7z3/DoFtYosALYWd+Ypw5mmdEOJMUCR/0RsVjx/y5 Vxu+9oXONaGQav03zBF/WgoVLWkeAy0DALBcEQRAISMvmSrGSwcCYYgNzBKC5Cqytl/1 IVwQPJvlLqfwdcMWswOweWGHInUuttJzsTdI+/6y1/RXWX/AqSBvIKGR1i4PRUk/TXXW 4e6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=NQ76cs9m2PfyRb1nvWbSz8Et10awSsHsXz4HNPXF8yg=; b=csWaH3QMEFMFLQJAzrY7R1eCxWaD9iZ+80Rwqhi1Fn4lJVbLZX23XbT/sFza1X97Hy EEBYfyLD9mPJG8dWV1HU5racVX54AaJ4G/+SRuc6i6olxZr/J5x/G7FKzvp1GWDqqlw2 mbouCLdzEZeRwT6Ngr3YPOGGsT0EXps8kMoCYkOcI19WhqeeCDhLda1UTFZAHhYp6AT1 UimdpZYdnyfe2BnfONYg77dm59mHY7yxn2SAknA0iIR/IkabFKqOehBkddxxVfo7R/s8 E0nizkwtmFfQwkfL2L7tni8vkBPU17L07IthVIY5FJ3URd84IBddQ18OzTZIlZm8kARQ slHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@iogearbox.net header.s=default2302 header.b=QZ9Vn6XQ; 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; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=iogearbox.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x13-20020a63db4d000000b0050ab982ea06si24612963pgi.291.2023.03.27.02.32.56; Mon, 27 Mar 2023 02:33:08 -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; dkim=pass header.i=@iogearbox.net header.s=default2302 header.b=QZ9Vn6XQ; 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; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=iogearbox.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232789AbjC0Jad (ORCPT + 99 others); Mon, 27 Mar 2023 05:30:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232453AbjC0Jab (ORCPT ); Mon, 27 Mar 2023 05:30:31 -0400 Received: from www62.your-server.de (www62.your-server.de [213.133.104.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B47EF3A92; Mon, 27 Mar 2023 02:30:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=iogearbox.net; s=default2302; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=NQ76cs9m2PfyRb1nvWbSz8Et10awSsHsXz4HNPXF8yg=; b=QZ9Vn6XQoPo/vkVnwWKgjNwNQF i+T6Yl3JETlALqU5VTD5LuRKWBkxlUZfMnccx1V/R8P1y1jb2Nn5vNn7qwhEJjK8c6CJnqa+IvXYv fSsK289ahjDc6UcYJ6PNuPJdYbA6zEy2NiIQ1OKZDK5Ou9RVm5ztS1GIL6bIVPQLOz4PR1pye5B0O 3vVEIr7XrOnjpURdrjUhayo44zsagA6WzNAlLWxZihURKdHXLk/exMEpuHu1wCA+H5uKVfWFO4jHw sx55zP9IskZDpk3E1MCtVVDVaPNI846+iakQvvoZc3HFZinQFEwTulPbXBfyfpt6jwzMW6C0Vf0N7 kIjdICDw==; Received: from sslproxy06.your-server.de ([78.46.172.3]) by www62.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pgjAz-0007hb-0h; Mon, 27 Mar 2023 11:30:05 +0200 Received: from [219.59.88.22] (helo=localhost.localdomain) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgjAw-000UQh-Hd; Mon, 27 Mar 2023 11:30:03 +0200 Subject: Re: [PATCH] loongarch/bpf: Fix bpf load failed with CONFIG_BPF_JIT_ALWAYS_ON, caused by jit (BPF_ST | BPF_NOSPEC) code To: George Guo , chenhuacai@kernel.org, masahiroy@kernel.org, michal.lkml@markovi.net Cc: kernel@xen0n.name, ndesaulniers@google.com, ast@kernel.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, bpf@vger.kernel.org References: <20230326044019.2139628-1-guodongtai@kylinos.cn> From: Daniel Borkmann Message-ID: Date: Mon, 27 Mar 2023 11:29:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20230326044019.2139628-1-guodongtai@kylinos.cn> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.8/26856/Mon Mar 27 09:24:05 2023) X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS 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 On 3/26/23 6:40 AM, George Guo wrote: > 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; > + } Small nit, but could we align with other JIT implementations and place it into similar location for consistency? Above looks a bit out of place and it should really be part of build_insn. diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c index 288003a9f0ca..d586df48ecc6 100644 --- a/arch/loongarch/net/bpf_jit.c +++ b/arch/loongarch/net/bpf_jit.c @@ -1022,6 +1022,10 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext emit_atomic(insn, ctx); break; + /* Speculation barrier */ + case BPF_ST | BPF_NOSPEC: + break; + default: pr_err("bpf_jit: unknown opcode %02x\n", code); return -EINVAL;