Linux-kselftest Archive on lore.kernel.org
 help / color / Atom feed
* Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf
@ 2019-10-20 13:47 Prabhakar Kushwaha
  2019-10-21  3:50 ` Prabhakar Kushwaha
  0 siblings, 1 reply; 12+ messages in thread
From: Prabhakar Kushwaha @ 2019-10-20 13:47 UTC (permalink / raw)
  To: linux-kselftest


Hi All,

I am trying to build kselftest on Linux-5.4 on ubuntu 18.04. I installed
LLVM-9.0.0 and Clang-9.0.0 from below links after following steps from
[1] because of discussion [2]

 https://releases.llvm.org/9.0.0/llvm-9.0.0.src.tar.xz
 https://releases.llvm.org/9.0.0/clang-tools-extra-9.0.0.src.tar.xz
 https://releases.llvm.org/9.0.0/cfe-9.0.0.src.tar.xz


Now, i am trying with llc -march=bpf, with this segmentation fault is
coming as below:


gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
-I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
-I../../../include -Dbpf_prog_load=bpf_prog_test_load
-Dbpf_load_program=bpf_test_load_program    test_flow_dissector.c
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
/usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
-lrt -lpthread -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_flow_dissector
gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
-I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
-I../../../include -Dbpf_prog_load=bpf_prog_test_load
-Dbpf_load_program=bpf_test_load_program
test_tcp_check_syncookie_user.c
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
/usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
-lrt -lpthread -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_tcp_check_syncookie_user
gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
-I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
-I../../../include -Dbpf_prog_load=bpf_prog_test_load
-Dbpf_load_program=bpf_test_load_program    test_lirc_mode2_user.c
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
/usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
-lrt -lpthread -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_lirc_mode2_user
(clang -I. -I./include/uapi -I../../../include/uapi
-I/usr/src/tovards/linux/tools/testing/selftests/bpf/../usr/include
-D__TARGET_ARCH_arm64 -g -idirafter /usr/local/include -idirafter
/usr/local/lib/clang/9.0.0/include -idirafter
/usr/include/aarch64-linux-gnu -idirafter /usr/include
-Wno-compare-distinct-pointer-types -O2 -target bpf -emit-llvm \
	-c progs/test_core_reloc_arrays.c -o - || echo "clang failed") | \
llc -march=bpf -mcpu=probe  -filetype=obj -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
Stack dump:
0.	Program arguments: llc -march=bpf -mcpu=probe -filetype=obj -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
1.	Running pass 'Function Pass Manager' on module '<stdin>'.
2.	Running pass 'BPF Assembly Printer' on function '@test_core_arrays'
#0 0x0000aaaac618db08 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/bin/llc+0x152eb08)
Segmentation fault
Makefile:260: recipe for target
'/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o'
failed
make[1]: ***
[/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o]
Error 139



Please suggest!!


--prabhakar(pk)

[1]
https://stackoverflow.com/questions/47255526/how-to-build-the-latest-clang-tidy

[2] https://www.mail-archive.com/netdev@vger.kernel.org/msg315096.html


Linux top-commit
----------------
commit bc88f85c6c09306bd21917e1ae28205e9cd775a7 (HEAD -> master,
origin/master, origin/HEAD)
Author: Ben Dooks <ben.dooks@codethink.co.uk>
Date:   Wed Oct 16 12:24:58 2019 +0100

    kthread: make __kthread_queue_delayed_work static

    The __kthread_queue_delayed_work is not exported so
    make it static, to avoid the following sparse warning:

      kernel/kthread.c:869:6: warning: symbol
'__kthread_queue_delayed_work' was not declared. Should it be static?

    Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf
  2019-10-20 13:47 Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf Prabhakar Kushwaha
@ 2019-10-21  3:50 ` Prabhakar Kushwaha
  0 siblings, 0 replies; 12+ messages in thread
From: Prabhakar Kushwaha @ 2019-10-21  3:50 UTC (permalink / raw)
  To: linux-kselftest

On Sun, Oct 20, 2019 at 7:18 PM Prabhakar Kushwaha
<prabhakar.pkin@gmail.com> wrote:
>
>
> Hi All,
>
> I am trying to build kselftest on Linux-5.4 on ubuntu 18.04. I installed
> LLVM-9.0.0 and Clang-9.0.0 from below links after following steps from
> [1] because of discussion [2]
>
>  https://releases.llvm.org/9.0.0/llvm-9.0.0.src.tar.xz
>  https://releases.llvm.org/9.0.0/clang-tools-extra-9.0.0.src.tar.xz
>  https://releases.llvm.org/9.0.0/cfe-9.0.0.src.tar.xz
>
>
> Now, i am trying with llc -march=bpf, with this segmentation fault is
> coming as below:
>
>
> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
> -Dbpf_load_program=bpf_test_load_program    test_flow_dissector.c
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
> -lrt -lpthread -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_flow_dissector
> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
> -Dbpf_load_program=bpf_test_load_program
> test_tcp_check_syncookie_user.c
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
> -lrt -lpthread -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_tcp_check_syncookie_user
> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
> -Dbpf_load_program=bpf_test_load_program    test_lirc_mode2_user.c
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
> -lrt -lpthread -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_lirc_mode2_user
> (clang -I. -I./include/uapi -I../../../include/uapi
> -I/usr/src/tovards/linux/tools/testing/selftests/bpf/../usr/include
> -D__TARGET_ARCH_arm64 -g -idirafter /usr/local/include -idirafter
> /usr/local/lib/clang/9.0.0/include -idirafter
> /usr/include/aarch64-linux-gnu -idirafter /usr/include
> -Wno-compare-distinct-pointer-types -O2 -target bpf -emit-llvm \
>         -c progs/test_core_reloc_arrays.c -o - || echo "clang failed") | \
> llc -march=bpf -mcpu=probe  -filetype=obj -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
> Stack dump:
> 0.      Program arguments: llc -march=bpf -mcpu=probe -filetype=obj -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
> 1.      Running pass 'Function Pass Manager' on module '<stdin>'.
> 2.      Running pass 'BPF Assembly Printer' on function '@test_core_arrays'
> #0 0x0000aaaac618db08 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
> (/usr/local/bin/llc+0x152eb08)
> Segmentation fault
> Makefile:260: recipe for target
> '/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o'
> failed
> make[1]: ***
> [/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o]
> Error 139
>

To add more details,
Commenting following lines in bpf/progs/test_core_reloc_arrays.c
removes the segmentation fault.

--- a/tools/testing/selftests/bpf/progs/test_core_reloc_arrays.c
+++ b/tools/testing/selftests/bpf/progs/test_core_reloc_arrays.c
@@ -41,15 +41,14 @@ int test_core_arrays(void *ctx)
        if (BPF_CORE_READ(&out->a2, &in->a[2]))
                return 1;
        /* in->b[1][2][3] */
-       if (BPF_CORE_READ(&out->b123, &in->b[1][2][3]))
-               return 1;
+//     if (BPF_CORE_READ(&out->b123, &in->b[1][2][3]))
+//             return 1;
        /* in->c[1].c */
        if (BPF_CORE_READ(&out->c1c, &in->c[1].c))
                return 1;
        /* in->d[0][0].d */
-       if (BPF_CORE_READ(&out->d00d, &in->d[0][0].d))
-               return 1;
-
+//     if (BPF_CORE_READ(&out->d00d, &in->d[0][0].d))
+//             return 1;
        return 0;
 }

It looks to be something related llc and more than 1 dimension array.
has anyone faced such error.

--prabhakar (pk)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf
  2019-10-24 18:31     ` Ilya Leoshkevich
@ 2019-10-25 21:50       ` Yonghong Song
  0 siblings, 0 replies; 12+ messages in thread
From: Yonghong Song @ 2019-10-25 21:50 UTC (permalink / raw)
  To: Ilya Leoshkevich; +Cc: Prabhakar Kushwaha, ast, daniel, netdev, linux-kselftest



On 10/24/19 11:31 AM, Ilya Leoshkevich wrote:
>> Am 24.10.2019 um 19:49 schrieb Yonghong Song <yhs@fb.com>:
>>
>>
>>
>> On 10/24/19 9:04 AM, Ilya Leoshkevich wrote:
>>>> Am 23.10.2019 um 03:35 schrieb Prabhakar Kushwaha <prabhakar.pkin@gmail.com>:
>>>>
>>>>
>>>> Adding other mailing list, folks...
>>>>
>>>> Hi All,
>>>>
>>>> I am trying to build kselftest on Linux-5.4 on ubuntu 18.04. I installed
>>>> LLVM-9.0.0 and Clang-9.0.0 from below links after following steps from
>>>> [1] because of discussion [2]
>>>>
>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__releases.llvm.org_9.0.0_llvm-2D9.0.0.src.tar.xz&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=se8pV6OlDAeF2g5iEAvSB2qhLBJGPaHADv3NQVNFx6U&s=IzBxNhAvcILfAD_XcSB7t0s6-B-wFY3TBoVGH6WhRK8&e=
>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__releases.llvm.org_9.0.0_clang-2Dtools-2Dextra-2D9.0.0.src.tar.xz&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=se8pV6OlDAeF2g5iEAvSB2qhLBJGPaHADv3NQVNFx6U&s=KkjCjWm_q2iMfFh50rTKtFqQEMbRBVhT9Oh8KMfgwW4&e=
>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__releases.llvm.org_9.0.0_cfe-2D9.0.0.src.tar.xz&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=se8pV6OlDAeF2g5iEAvSB2qhLBJGPaHADv3NQVNFx6U&s=TvkN9sb5rSB5BNxJP27UmCsfNHsRQdaVeAnBa1TkyjM&e=
>>>>
>>>> Now, i am trying with llc -march=bpf, with this segmentation fault is
>>>> coming as below:
>>>>
>>>> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
>>>> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
>>>> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
>>>> -Dbpf_load_program=bpf_test_load_program    test_flow_dissector.c
>>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
>>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
>>>> -lrt -lpthread -o
>>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_flow_dissector
>>>> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
>>>> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
>>>> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
>>>> -Dbpf_load_program=bpf_test_load_program
>>>> test_tcp_check_syncookie_user.c
>>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
>>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
>>>> -lrt -lpthread -o
>>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_tcp_check_syncookie_user
>>>> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
>>>> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
>>>> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
>>>> -Dbpf_load_program=bpf_test_load_program    test_lirc_mode2_user.c
>>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
>>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
>>>> -lrt -lpthread -o
>>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_lirc_mode2_user
>>>> (clang -I. -I./include/uapi -I../../../include/uapi
>>>> -I/usr/src/tovards/linux/tools/testing/selftests/bpf/../usr/include
>>>> -D__TARGET_ARCH_arm64 -g -idirafter /usr/local/include -idirafter
>>>> /usr/local/lib/clang/9.0.0/include -idirafter
>>>> /usr/include/aarch64-linux-gnu -idirafter /usr/include
>>>> -Wno-compare-distinct-pointer-types -O2 -target bpf -emit-llvm \
>>>> -c progs/test_core_reloc_arrays.c -o - || echo "clang failed") | \
>>>> llc -march=bpf -mcpu=probe  -filetype=obj -o
>>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
>>>> Stack dump:
>>>> 0. Program arguments: llc -march=bpf -mcpu=probe -filetype=obj -o
>>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
>>>> 1. Running pass 'Function Pass Manager' on module '<stdin>'.
>>>> 2. Running pass 'BPF Assembly Printer' on function '@test_core_arrays'
>>>> #0 0x0000aaaac618db08 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
>>>> (/usr/local/bin/llc+0x152eb08)
>>>> Segmentation fault
>>>
>>> Hi,
>>>
>>> FWIW I can confirm that this is happening on s390 too with llvm-project
>>> commit 950b800c451f.
>>>
>>> Here is the reduced sample that triggers this (with -march=bpf
>>> -mattr=+alu32):
>>>
>>> struct b {
>>>    int e;
>>> } c;
>>> int f() {
>>>    return __builtin_preserve_field_info(c.e, 0);
>>> }
>>>
>>> This is compiled into:
>>>
>>> 0B      bb.0 (%ir-block.0):
>>> 16B       %0:gpr = LD_imm64 @"b:0:0$0:0"
>>> 32B       $w0 = COPY %0:gpr, debug-location !17; 1-E.c:5:3
>>> 48B       RET implicit killed $w0, debug-location !17; 1-E.c:5:3
>>>
>>> and then BPFInstrInfo::copyPhysReg chokes on COPY, since $w0 and %0 are
>>> in different register classes.
>>
>> Ilya,
>>
>> Thanks for reporting. I can reproduce the issue with latest trunk.
>> I will investigate and fix the problem soon.
>>
>> Yonghong
> 
> Thanks for taking care of this! Just FYI, bisect pointed to 05e46979d2f4
> ("[BPF] do compile-once run-everywhere relocation for bitfields").
> 
> Could you please add me to Phabricator review? I'm curious what the

I did add you in the diff https://reviews.llvm.org/D69438.

> proper solution is going to be, as I'm still not sure whether handling
> asymmetric copies is the right approach, or whether they should rather
> be prevented from occuring in the first place.

The change has been pushed into the trunk.
We indeed used asymmetric copy. Please do let me know if you think
there is a better way to do that. Thanks!

> 
> Best regards,
> Ilya
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf
  2019-10-24 17:49   ` Yonghong Song
@ 2019-10-24 18:31     ` Ilya Leoshkevich
  2019-10-25 21:50       ` Yonghong Song
  0 siblings, 1 reply; 12+ messages in thread
From: Ilya Leoshkevich @ 2019-10-24 18:31 UTC (permalink / raw)
  To: Yonghong Song; +Cc: Prabhakar Kushwaha, ast, daniel, netdev, linux-kselftest

> Am 24.10.2019 um 19:49 schrieb Yonghong Song <yhs@fb.com>:
> 
> 
> 
> On 10/24/19 9:04 AM, Ilya Leoshkevich wrote:
>>> Am 23.10.2019 um 03:35 schrieb Prabhakar Kushwaha <prabhakar.pkin@gmail.com>:
>>> 
>>> 
>>> Adding other mailing list, folks...
>>> 
>>> Hi All,
>>> 
>>> I am trying to build kselftest on Linux-5.4 on ubuntu 18.04. I installed
>>> LLVM-9.0.0 and Clang-9.0.0 from below links after following steps from
>>> [1] because of discussion [2]
>>> 
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__releases.llvm.org_9.0.0_llvm-2D9.0.0.src.tar.xz&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=se8pV6OlDAeF2g5iEAvSB2qhLBJGPaHADv3NQVNFx6U&s=IzBxNhAvcILfAD_XcSB7t0s6-B-wFY3TBoVGH6WhRK8&e=
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__releases.llvm.org_9.0.0_clang-2Dtools-2Dextra-2D9.0.0.src.tar.xz&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=se8pV6OlDAeF2g5iEAvSB2qhLBJGPaHADv3NQVNFx6U&s=KkjCjWm_q2iMfFh50rTKtFqQEMbRBVhT9Oh8KMfgwW4&e=
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__releases.llvm.org_9.0.0_cfe-2D9.0.0.src.tar.xz&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=se8pV6OlDAeF2g5iEAvSB2qhLBJGPaHADv3NQVNFx6U&s=TvkN9sb5rSB5BNxJP27UmCsfNHsRQdaVeAnBa1TkyjM&e=
>>> 
>>> Now, i am trying with llc -march=bpf, with this segmentation fault is
>>> coming as below:
>>> 
>>> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
>>> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
>>> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
>>> -Dbpf_load_program=bpf_test_load_program    test_flow_dissector.c
>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
>>> -lrt -lpthread -o
>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_flow_dissector
>>> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
>>> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
>>> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
>>> -Dbpf_load_program=bpf_test_load_program
>>> test_tcp_check_syncookie_user.c
>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
>>> -lrt -lpthread -o
>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_tcp_check_syncookie_user
>>> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
>>> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
>>> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
>>> -Dbpf_load_program=bpf_test_load_program    test_lirc_mode2_user.c
>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
>>> -lrt -lpthread -o
>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_lirc_mode2_user
>>> (clang -I. -I./include/uapi -I../../../include/uapi
>>> -I/usr/src/tovards/linux/tools/testing/selftests/bpf/../usr/include
>>> -D__TARGET_ARCH_arm64 -g -idirafter /usr/local/include -idirafter
>>> /usr/local/lib/clang/9.0.0/include -idirafter
>>> /usr/include/aarch64-linux-gnu -idirafter /usr/include
>>> -Wno-compare-distinct-pointer-types -O2 -target bpf -emit-llvm \
>>> -c progs/test_core_reloc_arrays.c -o - || echo "clang failed") | \
>>> llc -march=bpf -mcpu=probe  -filetype=obj -o
>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
>>> Stack dump:
>>> 0. Program arguments: llc -march=bpf -mcpu=probe -filetype=obj -o
>>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
>>> 1. Running pass 'Function Pass Manager' on module '<stdin>'.
>>> 2. Running pass 'BPF Assembly Printer' on function '@test_core_arrays'
>>> #0 0x0000aaaac618db08 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
>>> (/usr/local/bin/llc+0x152eb08)
>>> Segmentation fault
>> 
>> Hi,
>> 
>> FWIW I can confirm that this is happening on s390 too with llvm-project
>> commit 950b800c451f.
>> 
>> Here is the reduced sample that triggers this (with -march=bpf
>> -mattr=+alu32):
>> 
>> struct b {
>>   int e;
>> } c;
>> int f() {
>>   return __builtin_preserve_field_info(c.e, 0);
>> }
>> 
>> This is compiled into:
>> 
>> 0B      bb.0 (%ir-block.0):
>> 16B       %0:gpr = LD_imm64 @"b:0:0$0:0"
>> 32B       $w0 = COPY %0:gpr, debug-location !17; 1-E.c:5:3
>> 48B       RET implicit killed $w0, debug-location !17; 1-E.c:5:3
>> 
>> and then BPFInstrInfo::copyPhysReg chokes on COPY, since $w0 and %0 are
>> in different register classes.
> 
> Ilya,
> 
> Thanks for reporting. I can reproduce the issue with latest trunk.
> I will investigate and fix the problem soon.
> 
> Yonghong

Thanks for taking care of this! Just FYI, bisect pointed to 05e46979d2f4
("[BPF] do compile-once run-everywhere relocation for bitfields").

Could you please add me to Phabricator review? I'm curious what the
proper solution is going to be, as I'm still not sure whether handling
asymmetric copies is the right approach, or whether they should rather
be prevented from occuring in the first place.

Best regards,
Ilya

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf
  2019-10-24 16:04 ` Ilya Leoshkevich
@ 2019-10-24 17:49   ` Yonghong Song
  2019-10-24 18:31     ` Ilya Leoshkevich
  0 siblings, 1 reply; 12+ messages in thread
From: Yonghong Song @ 2019-10-24 17:49 UTC (permalink / raw)
  To: Ilya Leoshkevich, Prabhakar Kushwaha; +Cc: ast, daniel, netdev, linux-kselftest



On 10/24/19 9:04 AM, Ilya Leoshkevich wrote:
>> Am 23.10.2019 um 03:35 schrieb Prabhakar Kushwaha <prabhakar.pkin@gmail.com>:
>>
>>
>> Adding other mailing list, folks...
>>
>> Hi All,
>>
>> I am trying to build kselftest on Linux-5.4 on ubuntu 18.04. I installed
>> LLVM-9.0.0 and Clang-9.0.0 from below links after following steps from
>> [1] because of discussion [2]
>>
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__releases.llvm.org_9.0.0_llvm-2D9.0.0.src.tar.xz&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=se8pV6OlDAeF2g5iEAvSB2qhLBJGPaHADv3NQVNFx6U&s=IzBxNhAvcILfAD_XcSB7t0s6-B-wFY3TBoVGH6WhRK8&e=
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__releases.llvm.org_9.0.0_clang-2Dtools-2Dextra-2D9.0.0.src.tar.xz&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=se8pV6OlDAeF2g5iEAvSB2qhLBJGPaHADv3NQVNFx6U&s=KkjCjWm_q2iMfFh50rTKtFqQEMbRBVhT9Oh8KMfgwW4&e=
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__releases.llvm.org_9.0.0_cfe-2D9.0.0.src.tar.xz&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=se8pV6OlDAeF2g5iEAvSB2qhLBJGPaHADv3NQVNFx6U&s=TvkN9sb5rSB5BNxJP27UmCsfNHsRQdaVeAnBa1TkyjM&e=
>>
>> Now, i am trying with llc -march=bpf, with this segmentation fault is
>> coming as below:
>>
>> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
>> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
>> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
>> -Dbpf_load_program=bpf_test_load_program    test_flow_dissector.c
>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
>> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
>> -lrt -lpthread -o
>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_flow_dissector
>> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
>> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
>> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
>> -Dbpf_load_program=bpf_test_load_program
>> test_tcp_check_syncookie_user.c
>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
>> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
>> -lrt -lpthread -o
>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_tcp_check_syncookie_user
>> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
>> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
>> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
>> -Dbpf_load_program=bpf_test_load_program    test_lirc_mode2_user.c
>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
>> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
>> -lrt -lpthread -o
>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_lirc_mode2_user
>> (clang -I. -I./include/uapi -I../../../include/uapi
>> -I/usr/src/tovards/linux/tools/testing/selftests/bpf/../usr/include
>> -D__TARGET_ARCH_arm64 -g -idirafter /usr/local/include -idirafter
>> /usr/local/lib/clang/9.0.0/include -idirafter
>> /usr/include/aarch64-linux-gnu -idirafter /usr/include
>> -Wno-compare-distinct-pointer-types -O2 -target bpf -emit-llvm \
>> -c progs/test_core_reloc_arrays.c -o - || echo "clang failed") | \
>> llc -march=bpf -mcpu=probe  -filetype=obj -o
>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
>> Stack dump:
>> 0. Program arguments: llc -march=bpf -mcpu=probe -filetype=obj -o
>> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
>> 1. Running pass 'Function Pass Manager' on module '<stdin>'.
>> 2. Running pass 'BPF Assembly Printer' on function '@test_core_arrays'
>> #0 0x0000aaaac618db08 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
>> (/usr/local/bin/llc+0x152eb08)
>> Segmentation fault
> 
> Hi,
> 
> FWIW I can confirm that this is happening on s390 too with llvm-project
> commit 950b800c451f.
> 
> Here is the reduced sample that triggers this (with -march=bpf
> -mattr=+alu32):
> 
> struct b {
>    int e;
> } c;
> int f() {
>    return __builtin_preserve_field_info(c.e, 0);
> }
> 
> This is compiled into:
> 
> 0B      bb.0 (%ir-block.0):
> 16B       %0:gpr = LD_imm64 @"b:0:0$0:0"
> 32B       $w0 = COPY %0:gpr, debug-location !17; 1-E.c:5:3
> 48B       RET implicit killed $w0, debug-location !17; 1-E.c:5:3
> 
> and then BPFInstrInfo::copyPhysReg chokes on COPY, since $w0 and %0 are
> in different register classes.

Ilya,

Thanks for reporting. I can reproduce the issue with latest trunk.
I will investigate and fix the problem soon.

Yonghong

> 
> I'm currently bisecting, and also checking whether supporting asymmetric
> copies (like X86 does in CopyToFromAsymmetricReg) would resolve that.
> 
> Best regards,
> Ilya
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf
  2019-10-23  1:35 Prabhakar Kushwaha
  2019-10-23  2:34 ` Yonghong Song
@ 2019-10-24 16:04 ` Ilya Leoshkevich
  2019-10-24 17:49   ` Yonghong Song
  1 sibling, 1 reply; 12+ messages in thread
From: Ilya Leoshkevich @ 2019-10-24 16:04 UTC (permalink / raw)
  To: Prabhakar Kushwaha; +Cc: Yonghong Song, ast, daniel, netdev, linux-kselftest

> Am 23.10.2019 um 03:35 schrieb Prabhakar Kushwaha <prabhakar.pkin@gmail.com>:
> 
> 
> Adding other mailing list, folks...
> 
> Hi All,
> 
> I am trying to build kselftest on Linux-5.4 on ubuntu 18.04. I installed
> LLVM-9.0.0 and Clang-9.0.0 from below links after following steps from
> [1] because of discussion [2]
> 
> https://releases.llvm.org/9.0.0/llvm-9.0.0.src.tar.xz
> https://releases.llvm.org/9.0.0/clang-tools-extra-9.0.0.src.tar.xz
> https://releases.llvm.org/9.0.0/cfe-9.0.0.src.tar.xz
> 
> Now, i am trying with llc -march=bpf, with this segmentation fault is
> coming as below:
> 
> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
> -Dbpf_load_program=bpf_test_load_program    test_flow_dissector.c
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
> -lrt -lpthread -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_flow_dissector
> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
> -Dbpf_load_program=bpf_test_load_program
> test_tcp_check_syncookie_user.c
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
> -lrt -lpthread -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_tcp_check_syncookie_user
> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
> -Dbpf_load_program=bpf_test_load_program    test_lirc_mode2_user.c
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
> -lrt -lpthread -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_lirc_mode2_user
> (clang -I. -I./include/uapi -I../../../include/uapi
> -I/usr/src/tovards/linux/tools/testing/selftests/bpf/../usr/include
> -D__TARGET_ARCH_arm64 -g -idirafter /usr/local/include -idirafter
> /usr/local/lib/clang/9.0.0/include -idirafter
> /usr/include/aarch64-linux-gnu -idirafter /usr/include
> -Wno-compare-distinct-pointer-types -O2 -target bpf -emit-llvm \
> -c progs/test_core_reloc_arrays.c -o - || echo "clang failed") | \
> llc -march=bpf -mcpu=probe  -filetype=obj -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
> Stack dump:
> 0. Program arguments: llc -march=bpf -mcpu=probe -filetype=obj -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
> 1. Running pass 'Function Pass Manager' on module '<stdin>'.
> 2. Running pass 'BPF Assembly Printer' on function '@test_core_arrays'
> #0 0x0000aaaac618db08 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
> (/usr/local/bin/llc+0x152eb08)
> Segmentation fault

Hi,

FWIW I can confirm that this is happening on s390 too with llvm-project
commit 950b800c451f.

Here is the reduced sample that triggers this (with -march=bpf
-mattr=+alu32):

struct b {
  int e;
} c;
int f() {
  return __builtin_preserve_field_info(c.e, 0);
}

This is compiled into:

0B      bb.0 (%ir-block.0):
16B       %0:gpr = LD_imm64 @"b:0:0$0:0"
32B       $w0 = COPY %0:gpr, debug-location !17; 1-E.c:5:3
48B       RET implicit killed $w0, debug-location !17; 1-E.c:5:3

and then BPFInstrInfo::copyPhysReg chokes on COPY, since $w0 and %0 are
in different register classes.

I'm currently bisecting, and also checking whether supporting asymmetric
copies (like X86 does in CopyToFromAsymmetricReg) would resolve that.

Best regards,
Ilya

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf
  2019-10-23  4:42     ` Yonghong Song
@ 2019-10-23  8:49       ` Prabhakar Kushwaha
  0 siblings, 0 replies; 12+ messages in thread
From: Prabhakar Kushwaha @ 2019-10-23  8:49 UTC (permalink / raw)
  To: Yonghong Song; +Cc: ast, daniel, netdev, linux-kselftest

On Wed, Oct 23, 2019 at 10:12 AM Yonghong Song <yhs@fb.com> wrote:
>
>
>
> On 10/22/19 8:29 PM, Prabhakar Kushwaha wrote:
> > Thanks Yonghong for replying.
> >
> >
> >
> > On Wed, Oct 23, 2019 at 8:04 AM Yonghong Song <yhs@fb.com> wrote:
> >>
> >>
> >>
> >> On 10/22/19 6:35 PM, Prabhakar Kushwaha wrote:
> >>>
> >>>    Adding other mailing list, folks...
> >>>
> >>> Hi All,
> >>>
> >>> I am trying to build kselftest on Linux-5.4 on ubuntu 18.04. I installed
> >>> LLVM-9.0.0 and Clang-9.0.0 from below links after following steps from
> >>> [1] because of discussion [2]
> >>
> >> Could you try latest llvm trunk (pre-release 10.0.0)?
> >> LLVM 9.0.0 has some codes for CORE, but it is not fully supported and
> >> has some bugs which are only fixed in LLVM 10.0.0. We intend to make
> >> llvm 10 as the one we claim we have support. Indeed CORE related
> >> changes are mostly added during 10.0.0 development period.
> >>
> >
> > can you please help me the link to download as
> > "https://urldefense.proofpoint.com/v2/url?u=https-3A__prereleases.llvm.org_&d=DwIBaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=-6k0f7iKZO54kHLKBjYdU_7pDlCh61HdtyWQ-d43zwU&s=7fbobFiC619_9Pr5b1FbrKvoHl6sg79NZc3rQgNWa1Q&e= " does not have LLVM-10.0.0 packages.
>
> llvm 10 has not been released.
> Could you follow LLVM source build insn at
> https://github.com/iovisor/bcc/blob/master/INSTALL.md?
>
> Specifically:
> git clone http://llvm.org/git/llvm.git
> cd llvm/tools; git clone http://llvm.org/git/clang.git
> cd ..; mkdir -p build/install; cd build
> cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
>    -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install ..
> make
> make install
> export PATH=$PWD/install/bin:$PATH
>

Thanks Yonghong..

after following above steps no more segmentation fault are there.

--pk

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf
  2019-10-23  3:29   ` Prabhakar Kushwaha
@ 2019-10-23  4:42     ` Yonghong Song
  2019-10-23  8:49       ` Prabhakar Kushwaha
  0 siblings, 1 reply; 12+ messages in thread
From: Yonghong Song @ 2019-10-23  4:42 UTC (permalink / raw)
  To: Prabhakar Kushwaha; +Cc: ast, daniel, netdev, linux-kselftest



On 10/22/19 8:29 PM, Prabhakar Kushwaha wrote:
> Thanks Yonghong for replying.
> 
> 
> 
> On Wed, Oct 23, 2019 at 8:04 AM Yonghong Song <yhs@fb.com> wrote:
>>
>>
>>
>> On 10/22/19 6:35 PM, Prabhakar Kushwaha wrote:
>>>
>>>    Adding other mailing list, folks...
>>>
>>> Hi All,
>>>
>>> I am trying to build kselftest on Linux-5.4 on ubuntu 18.04. I installed
>>> LLVM-9.0.0 and Clang-9.0.0 from below links after following steps from
>>> [1] because of discussion [2]
>>
>> Could you try latest llvm trunk (pre-release 10.0.0)?
>> LLVM 9.0.0 has some codes for CORE, but it is not fully supported and
>> has some bugs which are only fixed in LLVM 10.0.0. We intend to make
>> llvm 10 as the one we claim we have support. Indeed CORE related
>> changes are mostly added during 10.0.0 development period.
>>
> 
> can you please help me the link to download as
> "https://urldefense.proofpoint.com/v2/url?u=https-3A__prereleases.llvm.org_&d=DwIBaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=-6k0f7iKZO54kHLKBjYdU_7pDlCh61HdtyWQ-d43zwU&s=7fbobFiC619_9Pr5b1FbrKvoHl6sg79NZc3rQgNWa1Q&e= " does not have LLVM-10.0.0 packages.

llvm 10 has not been released.
Could you follow LLVM source build insn at 
https://github.com/iovisor/bcc/blob/master/INSTALL.md?

Specifically:
git clone http://llvm.org/git/llvm.git
cd llvm/tools; git clone http://llvm.org/git/clang.git
cd ..; mkdir -p build/install; cd build
cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
   -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install ..
make
make install
export PATH=$PWD/install/bin:$PATH

> 
> --pk
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf
  2019-10-23  2:34 ` Yonghong Song
@ 2019-10-23  3:29   ` Prabhakar Kushwaha
  2019-10-23  4:42     ` Yonghong Song
  0 siblings, 1 reply; 12+ messages in thread
From: Prabhakar Kushwaha @ 2019-10-23  3:29 UTC (permalink / raw)
  To: Yonghong Song; +Cc: ast, daniel, netdev, linux-kselftest

Thanks Yonghong for replying.



On Wed, Oct 23, 2019 at 8:04 AM Yonghong Song <yhs@fb.com> wrote:
>
>
>
> On 10/22/19 6:35 PM, Prabhakar Kushwaha wrote:
> >
> >   Adding other mailing list, folks...
> >
> > Hi All,
> >
> > I am trying to build kselftest on Linux-5.4 on ubuntu 18.04. I installed
> > LLVM-9.0.0 and Clang-9.0.0 from below links after following steps from
> > [1] because of discussion [2]
>
> Could you try latest llvm trunk (pre-release 10.0.0)?
> LLVM 9.0.0 has some codes for CORE, but it is not fully supported and
> has some bugs which are only fixed in LLVM 10.0.0. We intend to make
> llvm 10 as the one we claim we have support. Indeed CORE related
> changes are mostly added during 10.0.0 development period.
>

can you please help me the link to download as
"https://prereleases.llvm.org/" does not have LLVM-10.0.0 packages.

--pk

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf
  2019-10-23  1:35 Prabhakar Kushwaha
@ 2019-10-23  2:34 ` Yonghong Song
  2019-10-23  3:29   ` Prabhakar Kushwaha
  2019-10-24 16:04 ` Ilya Leoshkevich
  1 sibling, 1 reply; 12+ messages in thread
From: Yonghong Song @ 2019-10-23  2:34 UTC (permalink / raw)
  To: Prabhakar Kushwaha, ast, daniel, netdev, linux-kselftest



On 10/22/19 6:35 PM, Prabhakar Kushwaha wrote:
> 
>   Adding other mailing list, folks...
> 
> Hi All,
> 
> I am trying to build kselftest on Linux-5.4 on ubuntu 18.04. I installed
> LLVM-9.0.0 and Clang-9.0.0 from below links after following steps from
> [1] because of discussion [2]

Could you try latest llvm trunk (pre-release 10.0.0)?
LLVM 9.0.0 has some codes for CORE, but it is not fully supported and
has some bugs which are only fixed in LLVM 10.0.0. We intend to make
llvm 10 as the one we claim we have support. Indeed CORE related
changes are mostly added during 10.0.0 development period.

> 
>   https://urldefense.proofpoint.com/v2/url?u=https-3A__releases.llvm.org_9.0.0_llvm-2D9.0.0.src.tar.xz&d=DwICaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=skkgb9pZFIuJRG9JQNUcOnsiNBoYeDxEgrmStbFX4qs&s=fCk1MYIywY_WcJU6MlTqGT5KLLY95b5DhNMJwSxUv_8&e=
>   https://urldefense.proofpoint.com/v2/url?u=https-3A__releases.llvm.org_9.0.0_clang-2Dtools-2Dextra-2D9.0.0.src.tar.xz&d=DwICaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=skkgb9pZFIuJRG9JQNUcOnsiNBoYeDxEgrmStbFX4qs&s=2-ZFVNs_M0v6CT-oUpUvNRx_UHjMswWPhK9XNiuqLck&e=
>   https://urldefense.proofpoint.com/v2/url?u=https-3A__releases.llvm.org_9.0.0_cfe-2D9.0.0.src.tar.xz&d=DwICaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=skkgb9pZFIuJRG9JQNUcOnsiNBoYeDxEgrmStbFX4qs&s=C4i_D5AKTLTT0cYgHySiy-SOIuYCWvusxlANj0NrGLY&e=
> 
> Now, i am trying with llc -march=bpf, with this segmentation fault is
> coming as below:
> 
> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
> -Dbpf_load_program=bpf_test_load_program    test_flow_dissector.c
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
> -lrt -lpthread -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_flow_dissector
> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
> -Dbpf_load_program=bpf_test_load_program
> test_tcp_check_syncookie_user.c
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
> -lrt -lpthread -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_tcp_check_syncookie_user
> gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
> -I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
> -I../../../include -Dbpf_prog_load=bpf_prog_test_load
> -Dbpf_load_program=bpf_test_load_program    test_lirc_mode2_user.c
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
> -lrt -lpthread -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_lirc_mode2_user
> (clang -I. -I./include/uapi -I../../../include/uapi
> -I/usr/src/tovards/linux/tools/testing/selftests/bpf/../usr/include
> -D__TARGET_ARCH_arm64 -g -idirafter /usr/local/include -idirafter
> /usr/local/lib/clang/9.0.0/include -idirafter
> /usr/include/aarch64-linux-gnu -idirafter /usr/include
> -Wno-compare-distinct-pointer-types -O2 -target bpf -emit-llvm \
> -c progs/test_core_reloc_arrays.c -o - || echo "clang failed") | \
> llc -march=bpf -mcpu=probe  -filetype=obj -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
> Stack dump:
> 0. Program arguments: llc -march=bpf -mcpu=probe -filetype=obj -o
> /usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
> 1. Running pass 'Function Pass Manager' on module '<stdin>'.
> 2. Running pass 'BPF Assembly Printer' on function '@test_core_arrays'
> #0 0x0000aaaac618db08 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
> (/usr/local/bin/llc+0x152eb08)
> Segmentation fault
> Makefile:260: recipe for target
> '/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o'
> failed
> make[1]: ***
> [/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o]
> Error 139
> 
> To add more details,
> Commenting following lines in bpf/progs/test_core_reloc_arrays.c
> removes the segmentation fault.
> 
> --- a/tools/testing/selftests/bpf/progs/test_core_reloc_arrays.c
> +++ b/tools/testing/selftests/bpf/progs/test_core_reloc_arrays.c
> @@ -41,15 +41,14 @@ int test_core_arrays(void *ctx)
>          if (BPF_CORE_READ(&out->a2, &in->a[2]))
>                  return 1;
>          /* in->b[1][2][3] */
> -       if (BPF_CORE_READ(&out->b123, &in->b[1][2][3]))
> -               return 1;
> +//     if (BPF_CORE_READ(&out->b123, &in->b[1][2][3]))
> +//             return 1;
>          /* in->c[1].c */
>          if (BPF_CORE_READ(&out->c1c, &in->c[1].c))
>                  return 1;
>          /* in->d[0][0].d */
> -       if (BPF_CORE_READ(&out->d00d, &in->d[0][0].d))
> -               return 1;
> -
> +//     if (BPF_CORE_READ(&out->d00d, &in->d[0][0].d))
> +//             return 1;
>          return 0;
>   }
> 
> It looks to be something related llc and more than 1 dimension array.
> has anyone faced such error.
> 
> Please suggest!!
> 
> --prabhakar(pk)
> 
> [1]
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com_questions_47255526_how-2Dto-2Dbuild-2Dthe-2Dlatest-2Dclang-2Dtidy&d=DwICaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=skkgb9pZFIuJRG9JQNUcOnsiNBoYeDxEgrmStbFX4qs&s=TdMHOl9-id7Li_XWFnrTefdK8yPUO1NUYr7u9AJdg1E&e=
> 
> [2] https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mail-2Darchive.com_netdev-40vger.kernel.org_msg315096.html&d=DwICaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=skkgb9pZFIuJRG9JQNUcOnsiNBoYeDxEgrmStbFX4qs&s=gYS_CfBlAQG4gD3PxCEg82a5vBF2hpZjvvmXFaKOphY&e=
> 
> 
> Linux top-commit
> ----------------
> commit bc88f85c6c09306bd21917e1ae28205e9cd775a7 (HEAD -> master,
> origin/master, origin/HEAD)
> Author: Ben Dooks <ben.dooks@codethink.co.uk>
> Date:   Wed Oct 16 12:24:58 2019 +0100
> 
>      kthread: make __kthread_queue_delayed_work static
> 
>      The __kthread_queue_delayed_work is not exported so
>      make it static, to avoid the following sparse warning:
> 
>        kernel/kthread.c:869:6: warning: symbol
> '__kthread_queue_delayed_work' was not declared. Should it be static?
> 
>      Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
>      Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf
@ 2019-10-23  1:35 Prabhakar Kushwaha
  2019-10-23  2:34 ` Yonghong Song
  2019-10-24 16:04 ` Ilya Leoshkevich
  0 siblings, 2 replies; 12+ messages in thread
From: Prabhakar Kushwaha @ 2019-10-23  1:35 UTC (permalink / raw)
  To: yhs, ast, daniel, netdev, linux-kselftest


 Adding other mailing list, folks...

Hi All,

I am trying to build kselftest on Linux-5.4 on ubuntu 18.04. I installed
LLVM-9.0.0 and Clang-9.0.0 from below links after following steps from
[1] because of discussion [2]

 https://releases.llvm.org/9.0.0/llvm-9.0.0.src.tar.xz
 https://releases.llvm.org/9.0.0/clang-tools-extra-9.0.0.src.tar.xz
 https://releases.llvm.org/9.0.0/cfe-9.0.0.src.tar.xz

Now, i am trying with llc -march=bpf, with this segmentation fault is
coming as below:

gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
-I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
-I../../../include -Dbpf_prog_load=bpf_prog_test_load
-Dbpf_load_program=bpf_test_load_program    test_flow_dissector.c
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
/usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
-lrt -lpthread -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_flow_dissector
gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
-I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
-I../../../include -Dbpf_prog_load=bpf_prog_test_load
-Dbpf_load_program=bpf_test_load_program
test_tcp_check_syncookie_user.c
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
/usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
-lrt -lpthread -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_tcp_check_syncookie_user
gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
-I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
-I../../../include -Dbpf_prog_load=bpf_prog_test_load
-Dbpf_load_program=bpf_test_load_program    test_lirc_mode2_user.c
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
/usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
-lrt -lpthread -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_lirc_mode2_user
(clang -I. -I./include/uapi -I../../../include/uapi
-I/usr/src/tovards/linux/tools/testing/selftests/bpf/../usr/include
-D__TARGET_ARCH_arm64 -g -idirafter /usr/local/include -idirafter
/usr/local/lib/clang/9.0.0/include -idirafter
/usr/include/aarch64-linux-gnu -idirafter /usr/include
-Wno-compare-distinct-pointer-types -O2 -target bpf -emit-llvm \
-c progs/test_core_reloc_arrays.c -o - || echo "clang failed") | \
llc -march=bpf -mcpu=probe  -filetype=obj -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
Stack dump:
0. Program arguments: llc -march=bpf -mcpu=probe -filetype=obj -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
1. Running pass 'Function Pass Manager' on module '<stdin>'.
2. Running pass 'BPF Assembly Printer' on function '@test_core_arrays'
#0 0x0000aaaac618db08 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/bin/llc+0x152eb08)
Segmentation fault
Makefile:260: recipe for target
'/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o'
failed
make[1]: ***
[/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o]
Error 139

To add more details,
Commenting following lines in bpf/progs/test_core_reloc_arrays.c
removes the segmentation fault.

--- a/tools/testing/selftests/bpf/progs/test_core_reloc_arrays.c
+++ b/tools/testing/selftests/bpf/progs/test_core_reloc_arrays.c
@@ -41,15 +41,14 @@ int test_core_arrays(void *ctx)
        if (BPF_CORE_READ(&out->a2, &in->a[2]))
                return 1;
        /* in->b[1][2][3] */
-       if (BPF_CORE_READ(&out->b123, &in->b[1][2][3]))
-               return 1;
+//     if (BPF_CORE_READ(&out->b123, &in->b[1][2][3]))
+//             return 1;
        /* in->c[1].c */
        if (BPF_CORE_READ(&out->c1c, &in->c[1].c))
                return 1;
        /* in->d[0][0].d */
-       if (BPF_CORE_READ(&out->d00d, &in->d[0][0].d))
-               return 1;
-
+//     if (BPF_CORE_READ(&out->d00d, &in->d[0][0].d))
+//             return 1;
        return 0;
 }

It looks to be something related llc and more than 1 dimension array.
has anyone faced such error.

Please suggest!!

--prabhakar(pk)

[1]
https://stackoverflow.com/questions/47255526/how-to-build-the-latest-clang-tidy

[2] https://www.mail-archive.com/netdev@vger.kernel.org/msg315096.html


Linux top-commit
----------------
commit bc88f85c6c09306bd21917e1ae28205e9cd775a7 (HEAD -> master,
origin/master, origin/HEAD)
Author: Ben Dooks <ben.dooks@codethink.co.uk>
Date:   Wed Oct 16 12:24:58 2019 +0100

    kthread: make __kthread_queue_delayed_work static

    The __kthread_queue_delayed_work is not exported so
    make it static, to avoid the following sparse warning:

      kernel/kthread.c:869:6: warning: symbol
'__kthread_queue_delayed_work' was not declared. Should it be static?

    Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf
@ 2019-10-22 14:12 Prabhakar Kushwaha
  0 siblings, 0 replies; 12+ messages in thread
From: Prabhakar Kushwaha @ 2019-10-22 14:12 UTC (permalink / raw)
  To: linux-kselftest, llvm-bugs

 Adding llvm-bugs@lists.llvm.org mailing list...

Hi All,

I am trying to build kselftest on Linux-5.4 on ubuntu 18.04. I installed
LLVM-9.0.0 and Clang-9.0.0 from below links after following steps from
[1] because of discussion [2]

 https://releases.llvm.org/9.0.0/llvm-9.0.0.src.tar.xz
 https://releases.llvm.org/9.0.0/clang-tools-extra-9.0.0.src.tar.xz
 https://releases.llvm.org/9.0.0/cfe-9.0.0.src.tar.xz

Now, i am trying with llc -march=bpf, with this segmentation fault is
coming as below:

gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
-I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
-I../../../include -Dbpf_prog_load=bpf_prog_test_load
-Dbpf_load_program=bpf_test_load_program    test_flow_dissector.c
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
/usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
-lrt -lpthread -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_flow_dissector
gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
-I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
-I../../../include -Dbpf_prog_load=bpf_prog_test_load
-Dbpf_load_program=bpf_test_load_program
test_tcp_check_syncookie_user.c
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
/usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
-lrt -lpthread -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_tcp_check_syncookie_user
gcc -g -Wall -O2 -I../../../include/uapi -I../../../lib
-I../../../lib/bpf -I../../../../include/generated -DHAVE_GENHDR
-I../../../include -Dbpf_prog_load=bpf_prog_test_load
-Dbpf_load_program=bpf_test_load_program    test_lirc_mode2_user.c
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_stub.o
/usr/src/tovards/linux/tools/testing/selftests/bpf/libbpf.a -lcap -lelf
-lrt -lpthread -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_lirc_mode2_user
(clang -I. -I./include/uapi -I../../../include/uapi
-I/usr/src/tovards/linux/tools/testing/selftests/bpf/../usr/include
-D__TARGET_ARCH_arm64 -g -idirafter /usr/local/include -idirafter
/usr/local/lib/clang/9.0.0/include -idirafter
/usr/include/aarch64-linux-gnu -idirafter /usr/include
-Wno-compare-distinct-pointer-types -O2 -target bpf -emit-llvm \
-c progs/test_core_reloc_arrays.c -o - || echo "clang failed") | \
llc -march=bpf -mcpu=probe  -filetype=obj -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
Stack dump:
0. Program arguments: llc -march=bpf -mcpu=probe -filetype=obj -o
/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o
1. Running pass 'Function Pass Manager' on module '<stdin>'.
2. Running pass 'BPF Assembly Printer' on function '@test_core_arrays'
#0 0x0000aaaac618db08 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/bin/llc+0x152eb08)
Segmentation fault
Makefile:260: recipe for target
'/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o'
failed
make[1]: ***
[/usr/src/tovards/linux/tools/testing/selftests/bpf/test_core_reloc_arrays.o]
Error 139

To add more details,
Commenting following lines in bpf/progs/test_core_reloc_arrays.c
removes the segmentation fault.

--- a/tools/testing/selftests/bpf/progs/test_core_reloc_arrays.c
+++ b/tools/testing/selftests/bpf/progs/test_core_reloc_arrays.c
@@ -41,15 +41,14 @@ int test_core_arrays(void *ctx)
        if (BPF_CORE_READ(&out->a2, &in->a[2]))
                return 1;
        /* in->b[1][2][3] */
-       if (BPF_CORE_READ(&out->b123, &in->b[1][2][3]))
-               return 1;
+//     if (BPF_CORE_READ(&out->b123, &in->b[1][2][3]))
+//             return 1;
        /* in->c[1].c */
        if (BPF_CORE_READ(&out->c1c, &in->c[1].c))
                return 1;
        /* in->d[0][0].d */
-       if (BPF_CORE_READ(&out->d00d, &in->d[0][0].d))
-               return 1;
-
+//     if (BPF_CORE_READ(&out->d00d, &in->d[0][0].d))
+//             return 1;
        return 0;
 }

It looks to be something related llc and more than 1 dimension array.
has anyone faced such error.

Please suggest!!

--prabhakar(pk)

[1]
https://stackoverflow.com/questions/47255526/how-to-build-the-latest-clang-tidy

[2] https://www.mail-archive.com/netdev@vger.kernel.org/msg315096.html


Linux top-commit
----------------
commit bc88f85c6c09306bd21917e1ae28205e9cd775a7 (HEAD -> master,
origin/master, origin/HEAD)
Author: Ben Dooks <ben.dooks@codethink.co.uk>
Date:   Wed Oct 16 12:24:58 2019 +0100

    kthread: make __kthread_queue_delayed_work static

    The __kthread_queue_delayed_work is not exported so
    make it static, to avoid the following sparse warning:

      kernel/kthread.c:869:6: warning: symbol
'__kthread_queue_delayed_work' was not declared. Should it be static?

    Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, back to index

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-20 13:47 Linux-5.4: bpf: test_core_reloc_arrays.o: Segmentation fault with llc -march=bpf Prabhakar Kushwaha
2019-10-21  3:50 ` Prabhakar Kushwaha
2019-10-22 14:12 Prabhakar Kushwaha
2019-10-23  1:35 Prabhakar Kushwaha
2019-10-23  2:34 ` Yonghong Song
2019-10-23  3:29   ` Prabhakar Kushwaha
2019-10-23  4:42     ` Yonghong Song
2019-10-23  8:49       ` Prabhakar Kushwaha
2019-10-24 16:04 ` Ilya Leoshkevich
2019-10-24 17:49   ` Yonghong Song
2019-10-24 18:31     ` Ilya Leoshkevich
2019-10-25 21:50       ` Yonghong Song

Linux-kselftest Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-kselftest/0 linux-kselftest/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-kselftest linux-kselftest/ https://lore.kernel.org/linux-kselftest \
		linux-kselftest@vger.kernel.org
	public-inbox-index linux-kselftest

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kselftest


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git