Re: Usage of "p" constraint in BPF inline asm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks.  I will give it a try.

> On Fri, 2023-08-11 at 16:10 +0200, Jose E. Marchesi wrote:
>> > Do you need any help with the environment itself?
>> > (I can describe my setup if you need that).
>> 
>> That would be useful yes, thank you.
>
> There are several things needed:
> - bpf-next source code:
>   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git
> - Specific kernel configuration
> - QEMU to run selftests in
> - Root file system for QEMU to boot
> - Means to kickstart tests execution inside the VM.
>
> There is a script vmtest.sh located in the kernel repository:
>
>     tools/testing/selftests/bpf/vmtest.sh
>     
> Which takes care of kernel configuration, compilation, selftests
> compilation, qemu rootfs image download and test execution.
>
> This is not exactly what I use but I tested in right now and it works
> with a few caveats. Explaining my setup would take longer so I'll
> start with this one. I will submit patches with fixes for caveats.
>
> ## Caveat #1: libc version
>
> The script downloads rootfs image from predefined location on github
> (aws?) and that image is based on debian bullseye. libc version on my
> system is newer, so there is an error when test binaries built on my
> system are executed inside VM. So, I have to prepare my own rootfs
> image and point vmtest.sh to it. It might not be a problem in your
> case, if so -- skip the rest of the section.
>
> Unfortunately, there is no option to override rootfs via command line
> of that script, so the following patch is needed:
>
> ```diff
> diff --git a/tools/testing/selftests/bpf/vmtest.sh b/tools/testing/selftests/bpf/vmtest.sh
> index 685034528018..3d0c7e7c0135 100755
> --- a/tools/testing/selftests/bpf/vmtest.sh
> +++ b/tools/testing/selftests/bpf/vmtest.sh
> @@ -124,6 +124,15 @@ download_rootfs()
>                 exit 1
>         fi
>  
> +        echo "download_rootfs: $ROOTFS_OVERRIDE"
> +        if [[ "$ROOTFS_OVERRIDE" != "" ]]; then
> +            if [[ ! -e $ROOTFS_OVERRIDE ]]; then
> +               echo "Can't find rootfs image referred to by ROOTFS_OVERRIDE: $ROOTFS_OVERRIDE"
> +               exit 1
> +            fi
> +            cat $ROOTFS_OVERRIDE | zstd -d | sudo tar -C "$dir" -x
> +            exit
> +        fi
>         download "${ARCH}/libbpf-vmtest-rootfs-$rootfsversion.tar.zst" |
>                 zstd -d | sudo tar -C "$dir" -x
>  }
> ```
>
>
> Here is how to prepare the disk image for bookworm:
>
>     $ git clone https://github.com/libbpf/ci libbpf-ci
>     $ cd libbpf-ci
>     $ sudo ./rootfs/mkrootfs_debian.sh -d bookworm
>       # !! eddy -- is my user name locally, update accordingly
>     $ sudo chown eddy libbpf-vmtest-rootfs-2023.08.11-bookworm-amd64.tar.zst
>     $ export ROOTFS_OVERRIDE=$(realpath libbpf-vmtest-rootfs-2023.08.11-bookworm-amd64.tar.zst)
>
> Script stores Qemu disk image in ~/.bpf_selftests/root.img .
> We need to prepare/update that image using the following command:
>
>       # !! make sure ROOTFS_OVERRIDE is set
>     $ cd <kernel-sources>
>     $ cd tools/testing/selftests/bpf
>     $ ./vmtest.sh -i
>
> (Note: script uses sudo internally, so it might ask for password).
>
> ## Caveat #2: make headers
>
> Kernel compilation command requires the following patch:
>
> ```diff
> diff --git a/tools/testing/selftests/bpf/vmtest.sh b/tools/testing/selftests/bpf/vmtest.sh
> index 685034528018..3d0c7e7c0135 100755
> --- a/tools/testing/selftests/bpf/vmtest.sh
> +++ b/tools/testing/selftests/bpf/vmtest.sh
> @@ -137,6 +146,7 @@ recompile_kernel()
>  
>         ${make_command} olddefconfig
>         ${make_command}
> +        ${make_command} headers
>  }
>  
>  mount_image()
> ```
>
> ## Running tests
>
> Running tests is simple:
>
>     $ cd <kernel-sources>
>     $ cd tools/testing/selftests/bpf
>     $ ./vmtest.sh -- ./test_verifier
>
> The script will rebuild both kernel and selftests if necessary.
> The log should look as follows:
>
>     $ ./vmtest.sh -- ./test_verifier
>     Output directory: /home/eddy/.bpf_selftests
>     ... build log ....
>     [    0.000000] Linux version 6.5.0-rc4-g2adbb7637fd1-dirty ...
>     ... boot log ...
>     + /etc/rcS.d/S50-startup
>     ./test_verifier
>     #0/u BPF_ATOMIC_AND without fetch OK
>     #0/p BPF_ATOMIC_AND without fetch OK
>     #1/u BPF_ATOMIC_AND with fetch OK
>     ... test_verifier log ...
>     #524/p wide load from bpf_sock_addr.msg_src_ip6[3] OK
>     Summary: 790 PASSED, 0 SKIPPED, 0 FAILED
>     [    3.724015] ACPI: PM: Preparing to enter system sleep state S5
>     [    3.725169] reboot: Power down
>     Logs saved in /home/eddy/.bpf_selftests/bpf_selftests.2023-08-11_18-53-05.log
>
> ## Selecting individual tests
>
> For test_verifier individual tests could be selected using command:
>
>     $ ./vmtest.sh -- ./test_verifier -vv 42
>
> (-vv forces detailed logging).
>
> For test_progs/test_progs-no_alu32/test_progs-cpuv4 using the
> following command:
>
>     $ ./vmtest.sh -- ./test_progs-cpuv4 -vvv -a verifier_ldsx
>
> (-a stands for allow and filters tests by names).
>
> `test_maps` do not take any options AFAIK.
>
> ---
>
> Hope this helps.
> Feel free to ask about any issues, or we can have a call in zoom.




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux