lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4Bza7hTwLOgELWDyFUZEL_RpTkWYZ_abS8O1uoE5gqVYh8w@mail.gmail.com>
Date:   Mon, 27 Feb 2023 09:40:15 -0800
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
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,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next v2 2/3] selftests/bpf: Check __TARGET_ARCH_loongarch
 if target is bpf for LoongArch

On Fri, Feb 24, 2023 at 2:37 AM Tiezhu Yang <yangtiezhu@...ngson.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@...ngson.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
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ