[bpf-next,v2,2/3] selftests/bpf: Check __TARGET_ARCH_loongarch if target is bpf for LoongArch
Message ID | 1677235015-21717-3-git-send-email-yangtiezhu@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp831174wrd; Fri, 24 Feb 2023 02:47:46 -0800 (PST) X-Google-Smtp-Source: AK7set8LxlJCh3HlrJ+gffYob2Ow/Z5aFc8h04kk9RzhG4yIEB7bsCmQNqYnFGihfHhWQZV45iqg X-Received: by 2002:a17:907:980e:b0:8ae:ea17:bae4 with SMTP id ji14-20020a170907980e00b008aeea17bae4mr23219111ejc.30.1677235666052; Fri, 24 Feb 2023 02:47:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677235666; cv=none; d=google.com; s=arc-20160816; b=Nd4eOABZgpzwj1Uu5RFPwTWAjQ+rwSmFnVfMsL6HogHLLkdPjqrpIfBu1pljWwdDdw kR8GaocZR0k2mR1fTO3Xmlt2Q4/xfnIeWZboNVdQ+cYzcowJTQzPQ1DF0T03Qj1BTp0J 5oycNHG2NT80lKdOdPatbruINMNGN5yHL2VYbXRvYwh+9Xed4DqDNX5IyUfa/dZmJF/k j3dXistlGBTb1dRvCsMadhbVcxsadyCazlEijuFsp8XAOhpoQgndYGzN7xBR8qslCZRO 8OrNH0tdr0c8iGKwnJ+doZfhDGImK+pfj625nVJNW8IsnY0hAB5WTtn/XDvUcIvJZLsW uqTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=klopg2KIQp/KU52YrAS6NQSkXSwSdHtIvBny5HOaaeI=; b=BwupO6sayQmUUMR6jagdv3N7o60RNONHHMxFE7kgwLTwGtt784+h70+2db2AKQJSn2 iayXEMNWgtFG29HK7kh3n4u5Tr3xGbv6Sz4NMsAxi2CYF5a8tS+VExVg433/U735lH2u jOrlJcUj3zgX3ZRng2Dfj7URosH+4ozcrfE2ATgTiZL5tYF52s8RR+CqcVBFH7WN02RO OoTkYuVsV5+lrOXhq5jhwKsybSaF9kFQ89w5AHzWWLiUXaH3Zxy5TZWEhjmz7FnBRl61 ySuMYP2mvw8WLdVBIi+3svDBLjiKW2uC5cTaDOkFKcSwXC7GHLn/6t9TBcmFMd4FD2IP T1jg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m11-20020a170906598b00b008cfad03e95asi18472714ejs.752.2023.02.24.02.47.22; Fri, 24 Feb 2023 02:47:46 -0800 (PST) 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 S229977AbjBXKiq (ORCPT <rfc822;jeff.pang.chn@gmail.com> + 99 others); Fri, 24 Feb 2023 05:38:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229765AbjBXKiA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 24 Feb 2023 05:38:00 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0EBEC17146; Fri, 24 Feb 2023 02:36:58 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8AxYcxKk_hjBacEAA--.3713S3; Fri, 24 Feb 2023 18:36:58 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxQuVHk_hjToM6AA--.5828S4; Fri, 24 Feb 2023 18:36:57 +0800 (CST) From: Tiezhu Yang <yangtiezhu@loongson.cn> To: Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org> Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v2 2/3] selftests/bpf: Check __TARGET_ARCH_loongarch if target is bpf for LoongArch Date: Fri, 24 Feb 2023 18:36:54 +0800 Message-Id: <1677235015-21717-3-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1677235015-21717-1-git-send-email-yangtiezhu@loongson.cn> References: <1677235015-21717-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8CxQuVHk_hjToM6AA--.5828S4 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoW7Aw1UGr45uw45Cw1DCFWfXwb_yoW8Cw4fpF WkCr9FyFWUurWFk3s5JFy09Fy7J3s7tr4UtFWFg34kWFWrJ3W8Gws2krZrCasaga97tFna 9ry7K3y5Wa18Aw7anT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b7AYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JrI_Jryl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWUCVW8JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJVW0owAS 0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xva j40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JV W8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8QJ57UUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758709065682382296?= X-GMAIL-MSGID: =?utf-8?q?1758709065682382296?= |
Series |
Fix some build errors for bpf selftest on LoongArch
|
|
Commit Message
Tiezhu Yang
Feb. 24, 2023, 10:36 a.m. UTC
If target is bpf, there is no __loongarch__ definition, __BITS_PER_LONG
defaults to 32, __NR_nanosleep is not defined:
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
#define __NR_nanosleep 101
__SC_3264(__NR_nanosleep, sys_nanosleep_time32, sys_nanosleep)
#endif
Check __TARGET_ARCH_loongarch to include arch specified bitsperlong.h,
then __BITS_PER_LONG is 64, __NR_nanosleep can also be defined to fix
the following build errors:
clang -g -Werror -D__TARGET_ARCH_loongarch ... -target bpf -c progs/test_vmlinux.c ...
progs/test_vmlinux.c:24:18: error: use of undeclared identifier '__NR_nanosleep'
if (args->id != __NR_nanosleep)
^
progs/test_vmlinux.c:42:12: error: use of undeclared identifier '__NR_nanosleep'
if (id != __NR_nanosleep)
^
progs/test_vmlinux.c:60:12: error: use of undeclared identifier '__NR_nanosleep'
if (id != __NR_nanosleep)
^
3 errors generated.
make: *** [Makefile:572: tools/testing/selftests/bpf/test_vmlinux.bpf.o] Error 1
make: Leaving directory 'tools/testing/selftests/bpf'
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
tools/include/uapi/asm/bitsperlong.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, Feb 24, 2023 at 2:37 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote: > > If target is bpf, there is no __loongarch__ definition, __BITS_PER_LONG > defaults to 32, __NR_nanosleep is not defined: > > #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 > #define __NR_nanosleep 101 > __SC_3264(__NR_nanosleep, sys_nanosleep_time32, sys_nanosleep) > #endif > > Check __TARGET_ARCH_loongarch to include arch specified bitsperlong.h, > then __BITS_PER_LONG is 64, __NR_nanosleep can also be defined to fix > the following build errors: > > clang -g -Werror -D__TARGET_ARCH_loongarch ... -target bpf -c progs/test_vmlinux.c ... > progs/test_vmlinux.c:24:18: error: use of undeclared identifier '__NR_nanosleep' > if (args->id != __NR_nanosleep) > ^ > progs/test_vmlinux.c:42:12: error: use of undeclared identifier '__NR_nanosleep' > if (id != __NR_nanosleep) > ^ > progs/test_vmlinux.c:60:12: error: use of undeclared identifier '__NR_nanosleep' > if (id != __NR_nanosleep) > ^ > 3 errors generated. > make: *** [Makefile:572: tools/testing/selftests/bpf/test_vmlinux.bpf.o] Error 1 > make: Leaving directory 'tools/testing/selftests/bpf' > > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> > --- > tools/include/uapi/asm/bitsperlong.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/include/uapi/asm/bitsperlong.h b/tools/include/uapi/asm/bitsperlong.h > index da52065..10b4023 100644 > --- a/tools/include/uapi/asm/bitsperlong.h > +++ b/tools/include/uapi/asm/bitsperlong.h > @@ -17,7 +17,7 @@ > #include "../../../arch/riscv/include/uapi/asm/bitsperlong.h" > #elif defined(__alpha__) > #include "../../../arch/alpha/include/uapi/asm/bitsperlong.h" > -#elif defined(__loongarch__) > +#elif defined(__loongarch__) || defined(__TARGET_ARCH_loongarch) __TARGET_ARCH_ is libbpf-specific convention, we can't add that to UAPI headers let's think about some other solution > #include "../../../arch/loongarch/include/uapi/asm/bitsperlong.h" > #else > #include <asm-generic/bitsperlong.h> > -- > 2.1.0 >
diff --git a/tools/include/uapi/asm/bitsperlong.h b/tools/include/uapi/asm/bitsperlong.h index da52065..10b4023 100644 --- a/tools/include/uapi/asm/bitsperlong.h +++ b/tools/include/uapi/asm/bitsperlong.h @@ -17,7 +17,7 @@ #include "../../../arch/riscv/include/uapi/asm/bitsperlong.h" #elif defined(__alpha__) #include "../../../arch/alpha/include/uapi/asm/bitsperlong.h" -#elif defined(__loongarch__) +#elif defined(__loongarch__) || defined(__TARGET_ARCH_loongarch) #include "../../../arch/loongarch/include/uapi/asm/bitsperlong.h" #else #include <asm-generic/bitsperlong.h>