Support local vmtest for riscv64
Subsystems (8)
cover Support local vmtest for riscv64
Patch 1 is to enable cross platform testing for local vmtest. The remaining patch adds local vmtest support for riscv64. It relies on commit [0] [1] for better regression.
We can now perform cross platform testing for riscv64 bpf using the following command:
PLATFORM=riscv64 CROSS_COMPILE=riscv64-linux-gnu- \
tools/testing/selftests/bpf/vmtest.sh -- \
./test_progs -d \
\"$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \
| cut -d'#' -f1 \
| sed -e 's/^[[:space:]]*//' \
-e 's/[[:space:]]*$//' \
| tr -s '\n' ','\
)\"The test platform is x86_64 architecture, and the versions of relevant components are as follows:
QEMU: 8.2.0
CLANG: 17.0.6 (align to BPF CI)
OpenSBI: 1.3.1 (default by QEMU)
ROOTFS: ubuntu jammy (generated by [2])
Pu Lehui (5):
selftests/bpf: Enable cross platform testing for local vmtest riscv, bpf: Relax restrictions on Zbb instructions selftests/bpf: Add config.riscv64
selftests/bpf: Add DENYLIST.riscv64
selftests/bpf: Add riscv64 configurations to local vmtest
arch/riscv/net/bpf_jit.h | 2 +- tools/testing/selftests/bpf/DENYLIST.riscv64 | 5 ++ tools/testing/selftests/bpf/config.riscv64 | 85 ++++++++++++++++++++ tools/testing/selftests/bpf/vmtest.sh | 48 ++++++++--- 4 files changed, 127 insertions(+), 13 deletions(-) create mode 100644 tools/testing/selftests/bpf/DENYLIST.riscv64 create mode 100644 tools/testing/selftests/bpf/config.riscv64
Signature · 1 line
2.34.1
PATCH 1/5 selftests/bpf: Enable cross platform testing for local vmtest
From: Pu Lehui <[email protected]>
The variable $ARCH in the current script is platform semantics, not kernel semantics. Rename it to $PLATFORM so that we can easily use $ARCH in cross-compilation. For now, Using PLATFORM= and CROSS_COMPILE= options will enable cross platform testing:
PLATFORM=<platform> CROSS_COMPILE=<toolchain> vmtest.sh -- ./test_progs
Meanwhile, some descriptions have been corrected.
--- tools/testing/selftests/bpf/vmtest.sh | 40 +++++++++++++++++++-------- 1 file changed, 28 insertions(+), 12 deletions(-)
tools/testing/selftests/bpf/vmtest.sh +28 -12
@@ -4,28 +4,34 @@ set -u set -e -# This script currently only works for x86_64 and s390x, as -# it is based on the VM image used by the BPF CI, which is +# This script currently only works for the following platforms, +# as it is based on the VM image used by the BPF CI, which is # available only for these architectures. -ARCH="$(uname -m)" -case "${ARCH}" in +PLATFORM="${PLATFORM:-$(uname -m)}" +case "${PLATFORM}" in s390x) QEMU_BINARY=qemu-system-s390x QEMU_CONSOLE="ttyS1" - QEMU_FLAGS=(-smp 2) + HOST_FLAGS=(-smp 2 -enable-kvm) + CROSS_FLAGS=(-smp 2) BZIMAGE="arch/s390/boot/vmlinux" + ARCH="s390" ;; x86_64) QEMU_BINARY=qemu-system-x86_64 QEMU_CONSOLE="ttyS0,115200" - QEMU_FLAGS=(-cpu host -smp 8) + HOST_FLAGS=(-cpu host -enable-kvm -smp 8) + CROSS_FLAGS=(-smp 8) BZIMAGE="arch/x86/boot/bzImage" + ARCH="x86" ;; aarch64) QEMU_BINARY=qemu-system-aarch64 QEMU_CONSOLE="ttyAMA0,115200" - QEMU_FLAGS=(-M virt,gic-version=3 -cpu host -smp 8) + HOST_FLAGS=(-M virt,gic-version=3 -cpu host -enable-kvm -smp 8) + CROSS_FLAGS=(-M virt,gic-version=3 -cpu cortex-a76 -smp 8) BZIMAGE="arch/arm64/boot/Image" + ARCH="arm64" ;; *) echo "Unsupported architecture"
@@ -38,7 +44,7 @@ ROOTFS_IMAGE="root.img" OUTPUT_DIR="$HOME/.bpf_selftests" KCONFIG_REL_PATHS=("tools/testing/selftests/bpf/config" "tools/testing/selftests/bpf/config.vm" - "tools/testing/selftests/bpf/config.${ARCH}") + "tools/testing/selftests/bpf/config.${PLATFORM}") INDEX_URL="https://raw.githubusercontent.com/libbpf/ci/master/INDEX" NUM_COMPILE_JOBS="$(nproc)" LOG_FILE_BASE="$(date +"bpf_selftests.%Y-%m-%d_%H-%M-%S")"
@@ -58,6 +64,10 @@ tools/testing/selftests/bpf. e.g: If no command is specified and a debug shell (-s) is not requested, "${DEFAULT_COMMAND}" will be run by default. +Using PLATFORM= and CROSS_COMPILE= options will enable cross platform testing: + + PLATFORM=<platform> CROSS_COMPILE=<toolchain> $0 -- ./test_progs -t test_lsm + If you build your kernel using KBUILD_OUTPUT= or O= options, these can be passed as environment variables to the script:
@@ -109,7 +119,7 @@ newest_rootfs_version() { { for file in "${!URLS[@]}"; do - if [[ $file =~ ^"${ARCH}"/libbpf-vmtest-rootfs-(.*)\.tar\.zst$ ]]; then + if [[ $file =~ ^"${PLATFORM}"/libbpf-vmtest-rootfs-(.*)\.tar\.zst$ ]]; then echo "${BASH_REMATCH[1]}" fi done
@@ -126,7 +136,7 @@ download_rootfs() exit 1 fi - download "${ARCH}/libbpf-vmtest-rootfs-$rootfsversion.tar.zst" | + download "${PLATFORM}/libbpf-vmtest-rootfs-$rootfsversion.tar.zst" | zstd -d | sudo tar -C "$dir" -x }
@@ -244,12 +254,17 @@ EOF exit 1 fi + if [[ "${CROSS_COMPILE}" != "" ]]; then + QEMU_FLAGS=("${CROSS_FLAGS[@]}") + else + QEMU_FLAGS=("${HOST_FLAGS[@]}") + fi + ${QEMU_BINARY} \ -nodefaults \ -display none \ -serial mon:stdio \ "${QEMU_FLAGS[@]}" \ - -enable-kvm \ -m 4G \ -drive file="${rootfs_img}",format=raw,index=1,media=disk,if=virtio,cache=none \ -kernel "${kernel_bzimage}" \
@@ -384,7 +399,8 @@ main() fi local kconfig_file="${OUTPUT_DIR}/latest.config" - local make_command="make -j ${NUM_COMPILE_JOBS} KCONFIG_CONFIG=${kconfig_file}" + local make_command="make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} \ + -j ${NUM_COMPILE_JOBS} KCONFIG_CONFIG=${kconfig_file}" # Figure out where the kernel is being built. # O takes precedence over KBUILD_OUTPUT.
Signature · 1 line
2.34.1
PATCH 2/5 riscv, bpf: Relax restrictions on Zbb instructions
In reply to Pu LehuiFrom: Pu Lehui <[email protected]>
This patch relaxes the restrictions on the Zbb instructions. The hardware is capable of recognizing the Zbb instructions independently, eliminating the need for reliance on kernel compile configurations.
--- arch/riscv/net/bpf_jit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/net/bpf_jit.h +1 -1
@@ -20,7 +20,7 @@ static inline bool rvc_enabled(void)static inline bool rvzbb_enabled (void ) { -return IS_ENABLED (CONFIG_RISCV_ISA_ZBB ) &&riscv_has_extension_likely (RISCV_ISA_EXT_ZBB ); +return riscv_has_extension_likely (RISCV_ISA_EXT_ZBB ); }enum {
Signature · 1 line
2.34.1
Re: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
Quoted 5 lines · Pu Lehui
From: Pu Lehui <[email protected]>
This patch relaxes the restrictions on the Zbb instructions. The hardware is capable of recognizing the Zbb instructions independently, eliminating the need for reliance on kernel compile configurations.
This doesn't make sense to me.
RISCV_ISA_ZBB is defined as:
Adds support to dynamically detect the presence of the ZBB extension (basic bit manipulation) and enable its usage.
In other words, RISCV_ISA_ZBB=n should disable everything that attempts to detect Zbb at runtime. It is mostly relevant for code size reduction, which is relevant for BPF since if RISCV_ISA_ZBB=n all rvzbb_enabled() checks can be constant-folded.
If BPF needs to become an exception (why?), this should be mentioned in Kconfig.
-s
Quoted 27 lines
Signed-off-by Pu Lehui <[email protected]>--- arch/riscv/net/bpf_jit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/net/bpf_jit.h +1
-1@@ -20,7 +20,7 @@ static inline bool rvc_enabled(void)static inline bool rvzbb_enabled (void ) { -return IS_ENABLED (CONFIG_RISCV_ISA_ZBB ) &&riscv_has_extension_likely (RISCV_ISA_EXT_ZBB ); +return riscv_has_extension_likely (RISCV_ISA_EXT_ZBB ); }enum {
Signature · 7 lines
2.34.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
Quoted 8 lines · Stefan O'Rear
Quoted 5 lines · Pu Lehui
From: Pu Lehui <[email protected]>
This patch relaxes the restrictions on the Zbb instructions. The hardware is capable of recognizing the Zbb instructions independently, eliminating the need for reliance on kernel compile configurations.
This doesn't make sense to me.
It doesn't make sense to me either. Of course the hardware's capability to understand an instruction is independent of whether or not a toolchain is capable of actually emitting the instruction.
Quoted 5 lines
RISCV_ISA_ZBBis defined as:Adds support to dynamically detect the presence of the ZBB extension (basic bit manipulation) and enable its usage.
Quoted 7 lines
In other words, RISCV_ISA_ZBB=n should disable everything that attempts to detect Zbb at runtime. It is mostly relevant for code size reduction, which is relevant for BPF since if RISCV_ISA_ZBB=n all
rvzbb_enabled()checks can be constant-folded.If BPF needs to become an exception (why?), this should be mentioned in
Kconfig.
And in the commit message. On one hand I think this could be a reasonable thing to do in bpf as it is acting as a jit here, and doesn't actually need the alternatives that we are using elsewhere to enable the optimisations nor the compiler support. On the other the intention of that kconfig option is to control optimisations like rvzbb_enabled() gates, so this is gonna need a proper justification as to
As I said on IRC to you earlier, I think the Kconfig options here are in need of a bit of a spring cleaning - they should be modified to explain their individual purposes, be that enabling optimisations in the kernel or being required for userspace. I'll try to send a patch for that if I remember tomorrow.
Thanks,
Conor.
Quoted 32 lines
Quoted 18 lines
Signed-off-by Pu Lehui <[email protected]>--- arch/riscv/net/bpf_jit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/net/bpf_jit.h +1
-1@@ -20,7 +20,7 @@ static inline bool rvc_enabled(void)static inline bool rvzbb_enabled (void ) { -return IS_ENABLED (CONFIG_RISCV_ISA_ZBB ) &&riscv_has_extension_likely (RISCV_ISA_EXT_ZBB ); +return riscv_has_extension_likely (RISCV_ISA_EXT_ZBB ); }Quoted 9 lines
enum {
Signature · 7 lines
2.34.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
Quoted 8 lines · Conor Dooley
Quoted 7 lines · Stefan O'Rear
Quoted 5 lines · Pu Lehui
From: Pu Lehui <[email protected]>
This patch relaxes the restrictions on the Zbb instructions. The hardware is capable of recognizing the Zbb instructions independently, eliminating the need for reliance on kernel compile configurations.
Quoted 15 lines
Quoted 1 line
This doesn't make sense to me.
It doesn't make sense to me either. Of course the hardware's capability to understand an instruction is independent of whether or not a toolchain is capable of actually emitting the instruction.
Quoted 9 lines
RISCV_ISA_ZBBis defined as:Adds support to dynamically detect the presence of the ZBB extension (basic bit manipulation) and enable its usage.
In other words, RISCV_ISA_ZBB=n should disable everything that attempts to detect Zbb at runtime. It is mostly relevant for code size reduction, which is relevant for BPF since if RISCV_ISA_ZBB=n all
rvzbb_enabled()checks can be constant-folded.
Thanks for review. My initial thought was the same as yours, but after discussions [0] and test verifications, the hardware can indeed recognize the zbb instruction even if the kernel has not enabled CONFIG_RISCV_ISA_ZBB. As Conor mentioned, we are just acting as a JIT to emit zbb instruction here. Maybe is_hw_zbb_capable() will be better?
Quoted 52 lines
Quoted 3 lines
If BPF needs to become an exception (why?), this should be mentioned in
Kconfig.And in the commit message. On one hand I think this could be a reasonable thing to do in bpf as it is acting as a jit here, and doesn't actually need the alternatives that we are using elsewhere to enable the optimisations nor the compiler support. On the other the intention of that kconfig option is to control optimisations like
rvzbb_enabled()gates, so this is gonna need a proper justification as toAs I said on IRC to you earlier, I think the
Kconfigoptions here are in need of a bit of a spring cleaning - they should be modified to explain their individual purposes, be that enabling optimisations in the kernel or being required for userspace. I'll try to send a patch for that if I remember tomorrow.Thanks,
Conor.Quoted 32 lines
Quoted 18 lines
Signed-off-by Pu Lehui <[email protected]>--- arch/riscv/net/bpf_jit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/net/bpf_jit.h +1
-1@@ -20,7 +20,7 @@ static inline bool rvc_enabled(void)static inline bool rvzbb_enabled (void ) { -return IS_ENABLED (CONFIG_RISCV_ISA_ZBB ) &&riscv_has_extension_likely (RISCV_ISA_EXT_ZBB ); +return riscv_has_extension_likely (RISCV_ISA_EXT_ZBB ); }Quoted 9 lines
enum {
Signature · 7 lines
2.34.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Björn Töpel
maintainerRe: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
Quoted 25 lines · Pu Lehui
Quoted 8 lines · Conor Dooley
Quoted 7 lines · Stefan O'Rear
Quoted 5 lines · Pu Lehui
From: Pu Lehui <[email protected]>
This patch relaxes the restrictions on the Zbb instructions. The hardware is capable of recognizing the Zbb instructions independently, eliminating the need for reliance on kernel compile configurations.
Quoted 15 lines
Quoted 1 line
This doesn't make sense to me.
It doesn't make sense to me either. Of course the hardware's capability to understand an instruction is independent of whether or not a toolchain is capable of actually emitting the instruction.
Quoted 9 lines
RISCV_ISA_ZBBis defined as:Adds support to dynamically detect the presence of the ZBB extension (basic bit manipulation) and enable its usage.
In other words, RISCV_ISA_ZBB=n should disable everything that attempts to detect Zbb at runtime. It is mostly relevant for code size reduction, which is relevant for BPF since if RISCV_ISA_ZBB=n all
rvzbb_enabled()checks can be constant-folded.
Quoted 5 lines
Thanks for review. My initial thought was the same as yours, but after discussions [0] and test verifications, the hardware can indeed recognize the zbb instruction even if the kernel has not enabled
CONFIG_RISCV_ISA_ZBB. As Conor mentioned, we are just acting as a JIT to emit zbb instruction here. Maybeis_hw_zbb_capable()will be better?
I still think Lehui's patch is correct; Building a kernel that can boot on multiple platforms (w/ or w/o Zbb support) and not having Zbb insn in the kernel proper, and iff Zbb is available at run-time the BPF JIT will emit Zbb.
For these kind of optimizations, (IMO) it's better to let the BPF JIT decide at run-time.
Björn
Re: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
Quoted 33 lines · Björn Töpel
Quoted 25 lines · Pu Lehui
Quoted 8 lines · Conor Dooley
Quoted 7 lines · Stefan O'Rear
Quoted 5 lines · Pu Lehui
From: Pu Lehui <[email protected]>
This patch relaxes the restrictions on the Zbb instructions. The hardware is capable of recognizing the Zbb instructions independently, eliminating the need for reliance on kernel compile configurations.
Quoted 15 lines
Quoted 1 line
This doesn't make sense to me.
It doesn't make sense to me either. Of course the hardware's capability to understand an instruction is independent of whether or not a toolchain is capable of actually emitting the instruction.
Quoted 9 lines
RISCV_ISA_ZBBis defined as:Adds support to dynamically detect the presence of the ZBB extension (basic bit manipulation) and enable its usage.
In other words, RISCV_ISA_ZBB=n should disable everything that attempts to detect Zbb at runtime. It is mostly relevant for code size reduction, which is relevant for BPF since if RISCV_ISA_ZBB=n all
rvzbb_enabled()checks can be constant-folded.Quoted 5 lines
Thanks for review. My initial thought was the same as yours, but after discussions [0] and test verifications, the hardware can indeed recognize the zbb instruction even if the kernel has not enabled
CONFIG_RISCV_ISA_ZBB. As Conor mentioned, we are just acting as a JIT to emit zbb instruction here. Maybeis_hw_zbb_capable()will be better?
Quoted 4 lines
I still think Lehui's patch is correct; Building a kernel that can boot on multiple platforms (w/ or w/o Zbb support) and not having Zbb insn in the kernel proper, and iff Zbb is available at run-time the BPF JIT will emit Zbb.
This sentence is -ENOPARSE to me, did you accidentally omit some words? Additionally he config option has nothing to do with building kernels that boot on multiple platforms, it only controls whether optimisations for Zbb are built so that if Zbb is detected they can be used.
Quoted 2 lines
For these kind of optimizations, (IMO) it's better to let the BPF JIT decide at run-time.
Why is bpf a different case to any other user in this regard? I think that the commit message is misleading and needs to be changed, because the point "the hardware is capable of recognising the Zbb instructions independently..." is completely unrelated to the purpose of the config option. Of course the hardware understanding the option has nothing to do with kernel configuration. The commit message needs to explain why bpf is a special case and is exempt from an
I totally understand any point about bpf being different in terms of needing toolchain support, but IIRC it was I who pointed out up-thread. The part of the conversation that you're replying to here is about the semantics of the Kconfig option and the original patch never mentioned trying to avoid a dependency on toolchains at all, just kernel configurations. The toolchain requirements I don't think are even super hard to fulfill either - the last 3 versions of ld and lld all meet the criteria.
Björn Töpel
maintainerRe: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
Hey Conor!
Quoted 39 lines · Conor Dooley
Quoted 33 lines · Björn Töpel
Quoted 25 lines · Pu Lehui
Quoted 8 lines · Conor Dooley
Quoted 7 lines · Stefan O'Rear
Quoted 5 lines · Pu Lehui
From: Pu Lehui <[email protected]>
This patch relaxes the restrictions on the Zbb instructions. The hardware is capable of recognizing the Zbb instructions independently, eliminating the need for reliance on kernel compile configurations.
Quoted 15 lines
Quoted 1 line
This doesn't make sense to me.
It doesn't make sense to me either. Of course the hardware's capability to understand an instruction is independent of whether or not a toolchain is capable of actually emitting the instruction.
Quoted 9 lines
RISCV_ISA_ZBBis defined as:Adds support to dynamically detect the presence of the ZBB extension (basic bit manipulation) and enable its usage.
In other words, RISCV_ISA_ZBB=n should disable everything that attempts to detect Zbb at runtime. It is mostly relevant for code size reduction, which is relevant for BPF since if RISCV_ISA_ZBB=n all
rvzbb_enabled()checks can be constant-folded.Quoted 5 lines
Thanks for review. My initial thought was the same as yours, but after discussions [0] and test verifications, the hardware can indeed recognize the zbb instruction even if the kernel has not enabled
CONFIG_RISCV_ISA_ZBB. As Conor mentioned, we are just acting as a JIT to emit zbb instruction here. Maybeis_hw_zbb_capable()will be better?Quoted 4 lines
I still think Lehui's patch is correct; Building a kernel that can boot on multiple platforms (w/ or w/o Zbb support) and not having Zbb insn in the kernel proper, and iff Zbb is available at run-time the BPF JIT will emit Zbb.
Quoted 4 lines
This sentence is
-ENOPARSEto me, did you accidentally omit some words? Additionally he config option has nothing to do with building kernels that boot on multiple platforms, it only controls whether optimisations for Zbb are built so that if Zbb is detected they can be used.
Ugh, sorry about that! I'm probably confused myself.
Quoted 11 lines
Quoted 2 lines
For these kind of optimizations, (IMO) it's better to let the BPF JIT decide at run-time.
Why is bpf a different case to any other user in this regard? I think that the commit message is misleading and needs to be changed, because the point "the hardware is capable of recognising the Zbb instructions independently..." is completely unrelated to the purpose of the config option. Of course the hardware understanding the option has nothing to do with kernel configuration. The commit message needs to explain why bpf is a special case and is exempt from an
Quoted 8 lines
I totally understand any point about bpf being different in terms of needing toolchain support, but IIRC it was I who pointed out up-thread. The part of the conversation that you're replying to here is about the semantics of the
Kconfigoption and the original patch never mentioned trying to avoid a dependency on toolchains at all, just kernel configurations. The toolchain requirements I don't think are even super hard to fulfill either - the last 3 versions of ld and lld all meet the criteria.
Thanks for making it more clear, and I agree that the toolchain requirements are not hard to fulfull.
My view has been that "BPF is like userland", but I realize now that's odd. Let's make BPF similar to the rest of the RV kernel. If ZBB=n, then the BPF JIT doesn't know about emitting Zbb.
Björn
Re: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
Quoted 11 lines · Björn Töpel
Quoted 9 lines
Quoted 4 lines
I still think Lehui's patch is correct; Building a kernel that can boot on multiple platforms (w/ or w/o Zbb support) and not having Zbb insn in the kernel proper, and iff Zbb is available at run-time the BPF JIT will emit Zbb.
This sentence is
-ENOPARSEto me, did you accidentally omit some words? Additionally he config option has nothing to do with building kernels that boot on multiple platforms, it only controls whether optimisations for Zbb are built so that if Zbb is detected they can be used.Ugh, sorry about that! I'm probably confused myself.
Reading this back, I a bunch of words too, so no worries...
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
For these kind of optimizations, (IMO) it's better to let the BPF JIT decide at run-time.
Why is bpf a different case to any other user in this regard? I think that the commit message is misleading and needs to be changed, because the point "the hardware is capable of recognising the Zbb instructions independently..." is completely unrelated to the purpose of the config option. Of course the hardware understanding the option
This should have been "understanding the instructions"...
Quoted 2 lines
Quoted 2 lines
has nothing to do with kernel configuration. The commit message needs to explain why bpf is a special case and is exempt from an
And this s/from an//...
Quoted 2 lines
Quoted 2 lines
I totally understand any point about bpf being different in terms of needing toolchain support, but IIRC it was I who pointed out up-thread.
And "pointed that out".
I always make a mess of these emails that I re-write several times :)
Quoted 7 lines
Quoted 6 lines
The part of the conversation that you're replying to here is about the semantics of the
Kconfigoption and the original patch never mentioned trying to avoid a dependency on toolchains at all, just kernel configurations. The toolchain requirements I don't think are even super hard to fulfill either - the last 3 versions of ld and lld all meet the criteria.
Quoted 5 lines
Thanks for making it more clear, and I agree that the toolchain requirements are not hard to fulfull.
My view has been that "BPF is like userland", but I realize now that's odd.
Yeah, I can understand that perspective, but it does seem rather odd to someone that isn't a bpf-ist.
Quoted 2 lines
Let's make BPF similar to the rest of the RV kernel. If ZBB=n, then the BPF JIT doesn't know about emitting Zbb.
Re: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
Quoted 46 lines · Conor Dooley
Quoted 11 lines · Björn Töpel
Quoted 9 lines
Quoted 4 lines
I still think Lehui's patch is correct; Building a kernel that can boot on multiple platforms (w/ or w/o Zbb support) and not having Zbb insn in the kernel proper, and iff Zbb is available at run-time the BPF JIT will emit Zbb.
This sentence is
-ENOPARSEto me, did you accidentally omit some words? Additionally he config option has nothing to do with building kernels that boot on multiple platforms, it only controls whether optimisations for Zbb are built so that if Zbb is detected they can be used.Ugh, sorry about that! I'm probably confused myself.
Reading this back, I a bunch of words too, so no worries...
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
For these kind of optimizations, (IMO) it's better to let the BPF JIT decide at run-time.
Why is bpf a different case to any other user in this regard? I think that the commit message is misleading and needs to be changed, because the point "the hardware is capable of recognising the Zbb instructions independently..." is completely unrelated to the purpose of the config option. Of course the hardware understanding the option
This should have been "understanding the instructions"...
Quoted 2 lines
Quoted 2 lines
has nothing to do with kernel configuration. The commit message needs to explain why bpf is a special case and is exempt from an
And this s/from an//...
Quoted 2 lines
Quoted 2 lines
I totally understand any point about bpf being different in terms of needing toolchain support, but IIRC it was I who pointed out up-thread.
And "pointed that out".
I always make a mess of these emails that I re-write several times :)
Quoted 7 lines
Quoted 6 lines
The part of the conversation that you're replying to here is about the semantics of the
Kconfigoption and the original patch never mentioned trying to avoid a dependency on toolchains at all, just kernel configurations. The toolchain requirements I don't think are even super hard to fulfill either - the last 3 versions of ld and lld all meet the criteria.
Quoted 12 lines
Quoted 5 lines
Thanks for making it more clear, and I agree that the toolchain requirements are not hard to fulfull.
My view has been that "BPF is like userland", but I realize now that's odd.
Yeah, I can understand that perspective, but it does seem rather odd to someone that isn't a bpf-ist.
Quoted 2 lines
Let's make BPF similar to the rest of the RV kernel. If ZBB=n, then the BPF JIT doesn't know about emitting Zbb.
Hi Conor and Björn,
Thanks for your explanation. I totally agree with what you said, "CONFIG_RISCV_ISA_ZBB only controls whether optimizations for Zbb are built so that if Zbb is detected they can be used.".
Since the instructions emited by bpf jit are in kernel space, they should indeed be aligned in this regard.
PS: It's a bit difficult to understand this,😅 if I'm wrong please don't hesitate to tell me.
Re: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
Quoted 11 lines · Pu Lehui
Hi Conor and Björn,
Thanks for your explanation. I totally agree with what you said, "
CONFIG_RISCV_ISA_ZBBonly controls whether optimizations for Zbb are built so that if Zbb is detected they can be used.".Since the instructions emited by bpf jit are in kernel space, they should indeed be aligned in this regard.
PS: It's a bit difficult to understand this,😅 if I'm wrong please don't hesitate to tell me.
I think your understanding is correct. Sorry if I confused you at all!
Re: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
In reply to Conor DooleyQuoted 5 lines · Conor Dooley
As I said on IRC to you earlier, I think the
Kconfigoptions here are in need of a bit of a spring cleaning - they should be modified to explain their individual purposes, be that enabling optimisations in the kernel or being required for userspace. I'll try to send a patch for that if I remember tomorrow.
Something like this:
-- >8 --
commit 5125504beaedd669b082bf74b02003a77360670f
Author: Conor Dooley <[email protected]> Date: Fri Mar 29 11:13:22 2024 +0000
RISC-V: clarify what some RISCV_ISA* config options do
During some discussion on IRC yesterday and on Pu's bpf patch [1] I noticed that these RISCV_ISA* Kconfig options are not really clear about their implications. Many of these options have no impact on what userspace is allowed to do, for example an application can use Zbb regardless of whether or not the kernel does. Change the help text to try and clarify whether or not an option affects just the kernel, or also userspace. None of these options actually control whether or not an extension is detected dynamically as that's done regardless of Kconfig options, so drop any text that implies the option is required for dynamic detection, rewording them as "do x when y is detected".
---
I did this based on top of Samuel's changes dropping the MMU requurements just in case, but I don't think there's a conflict:
https://lore.kernel.org/linux-riscv/[email protected]/
arch/riscv/Kconfig +15 -13
@@ -501,8 +501,8 @@ config RISCV_ISA_SVNAPOT depends on RISCV_ALTERNATIVE default y help - Allow kernel to detect the Svnapot ISA-extension dynamically at boot - time and enable its usage. + Add support for the Svnapot ISA-extension when it is detected by + the kernel at boot. The Svnapot extension is used to mark contiguous PTEs as a range of contiguous virtual-to-physical translations for a naturally
@@ -520,9 +520,9 @@ config RISCV_ISA_SVPBMT depends on RISCV_ALTERNATIVE default y help - Adds support to dynamically detect the presence of the Svpbmt - ISA-extension (Supervisor-mode: page-based memory types) and - enable its usage. + Add support for the Svpbmt ISA-extension (Supervisor-mode: + page-based memory types) when it is detected by the kernel at + boot. The memory type for a page contains a combination of attributes that indicate the cacheability, idempotency, and ordering
@@ -541,14 +541,15 @@ config TOOLCHAIN_HAS_V depends on AS_HAS_OPTION_ARCH config RISCV_ISA_V - bool "VECTOR extension support" + bool "Vector extension support" depends on TOOLCHAIN_HAS_V depends on FPU select DYNAMIC_SIGFRAME default y help Say N here if you want to disable all vector related procedure - in the kernel. + in the kernel. Without this option enabled, neither the kernel nor + userspace may use vector. If you don't know what to do here, say Y.
@@ -606,8 +607,8 @@ config RISCV_ISA_ZBB depends on RISCV_ALTERNATIVE default y help - Adds support to dynamically detect the presence of the ZBB - extension (basic bit manipulation) and enable its usage. + Add support for enabling optimisations in the kernel when the + Zbb extension is detected at boot. The Zbb extension provides instructions to accelerate a number of bit-specific operations (count bit population, sign extending,
@@ -623,9 +624,9 @@ config RISCV_ISA_ZICBOM select RISCV_DMA_NONCOHERENT select DMA_DIRECT_REMAP help - Adds support to dynamically detect the presence of the ZICBOM - extension (Cache Block Management Operations) and enable its - usage. + Add support for the Zicbom extension (Cache Block Management + Operations) and enable its use in the kernel when it is detected + at boot. The Zicbom extension can be used to handle for example non-coherent DMA support on devices that need it.
@@ -684,7 +685,8 @@ config FPU default y help Say N here if you want to disable all floating-point related procedure - in the kernel. + in the kernel. Without this option enabled, neither the kernel nor + userspace may use vector. If you don't know what to do here, say Y.
Re: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
Thanks for the clarification, looks good.
Quoted 116 lines · Conor Dooley
Quoted 5 lines · Conor Dooley
As I said on IRC to you earlier, I think the
Kconfigoptions here are in need of a bit of a spring cleaning - they should be modified to explain their individual purposes, be that enabling optimisations in the kernel or being required for userspace. I'll try to send a patch for that if I remember tomorrow.Something like this:
-- >8 --
commit5125504beaedd669b082bf74b02003a77360670fAuthor: Conor Dooley <[email protected]> Date: Fri Mar 29 11:13:22 2024 +0000RISC-V: clarify what some RISCV_ISA* config options do
During some discussion on IRC yesterday and on Pu's bpf patch [1] I noticed that these RISCV_ISA*
Kconfigoptions are not really clear about their implications. Many of these options have no impact on what userspace is allowed to do, for example an application can use Zbb regardless of whether or not the kernel does. Change the help text to try and clarify whether or not an option affects just the kernel, or also userspace. None of these options actually control whether or not an extension is detected dynamically as that's done regardless ofKconfigoptions, so drop any text that implies the option is required for dynamic detection, rewording them as "do x when y is detected".Signed-off-by Conor Dooley <[email protected]>---
I did this based on top of Samuel's changes dropping the MMU requurements just in case, but I don't think there's a conflict:
https://lore.kernel.org/linux-riscv/[email protected]/arch/riscv/Kconfig +15
-13@@ -501,8 +501,8 @@ config RISCV_ISA_SVNAPOT depends on RISCV_ALTERNATIVE default y help - Allow kernel to detect the Svnapot ISA-extension dynamically at boot - time and enable its usage. + Add support for the Svnapot ISA-extension when it is detected by + the kernel at boot. The Svnapot extension is used to mark contiguous PTEs as a range of contiguous virtual-to-physical translations for a naturally@@ -520,9 +520,9 @@ config RISCV_ISA_SVPBMT depends on RISCV_ALTERNATIVE default y help - Adds support to dynamically detect the presence of the Svpbmt - ISA-extension (Supervisor-mode: page-based memory types) and - enable its usage. + Add support for the Svpbmt ISA-extension (Supervisor-mode: + page-based memory types) when it is detected by the kernel at + boot. The memory type for a page contains a combination of attributes that indicate the cacheability, idempotency, and ordering@@ -541,14 +541,15 @@ config TOOLCHAIN_HAS_V depends on AS_HAS_OPTION_ARCH config RISCV_ISA_V - bool "VECTOR extension support" + bool "Vector extension support" depends on TOOLCHAIN_HAS_V depends on FPU select DYNAMIC_SIGFRAME default y help Say N here if you want to disable all vector related procedure - in the kernel. + in the kernel. Without this option enabled, neither the kernel nor + userspace may use vector. If you don't know what to do here, say Y.@@ -606,8 +607,8 @@ config RISCV_ISA_ZBB depends on RISCV_ALTERNATIVE default y help - Adds support to dynamically detect the presence of the ZBB - extension (basic bit manipulation) and enable its usage. + Add support for enabling optimisations in the kernel when the + Zbb extension is detected at boot. The Zbb extension provides instructions to accelerate a number of bit-specific operations (count bit population, sign extending,@@ -623,9 +624,9 @@ config RISCV_ISA_ZICBOM select RISCV_DMA_NONCOHERENT select DMA_DIRECT_REMAP help - Adds support to dynamically detect the presence of the ZICBOM - extension (Cache Block Management Operations) and enable its - usage. + Add support for the Zicbom extension (Cache Block Management + Operations) and enable its use in the kernel when it is detected + at boot. The Zicbom extension can be used to handle for example non-coherent DMA support on devices that need it.@@ -684,7 +685,8 @@ config FPU default y help Say N here if you want to disable all floating-point related procedure - in the kernel. + in the kernel. Without this option enabled, neither the kernel nor + userspace may use vector. If you don't know what to do here, say Y.
Re: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
In reply to Conor DooleyHi Conor,
Looks good except for one typo.
Quoted 106 lines · Conor Dooley
Quoted 5 lines · Conor Dooley
As I said on IRC to you earlier, I think the
Kconfigoptions here are in need of a bit of a spring cleaning - they should be modified to explain their individual purposes, be that enabling optimisations in the kernel or being required for userspace. I'll try to send a patch for that if I remember tomorrow.Something like this:
-- >8 --
commit5125504beaedd669b082bf74b02003a77360670fAuthor: Conor Dooley <[email protected]> Date: Fri Mar 29 11:13:22 2024 +0000RISC-V: clarify what some RISCV_ISA* config options do
During some discussion on IRC yesterday and on Pu's bpf patch [1] I noticed that these RISCV_ISA*
Kconfigoptions are not really clear about their implications. Many of these options have no impact on what userspace is allowed to do, for example an application can use Zbb regardless of whether or not the kernel does. Change the help text to try and clarify whether or not an option affects just the kernel, or also userspace. None of these options actually control whether or not an extension is detected dynamically as that's done regardless ofKconfigoptions, so drop any text that implies the option is required for dynamic detection, rewording them as "do x when y is detected".Signed-off-by Conor Dooley <[email protected]>---
I did this based on top of Samuel's changes dropping the MMU requurements just in case, but I don't think there's a conflict:
https://lore.kernel.org/linux-riscv/[email protected]/arch/riscv/Kconfig +13
-12@@ -501,8 +501,8 @@ config RISCV_ISA_SVNAPOT depends on RISCV_ALTERNATIVE default y help - Allow kernel to detect the Svnapot ISA-extension dynamically at boot - time and enable its usage. + Add support for the Svnapot ISA-extension when it is detected by + the kernel at boot. The Svnapot extension is used to mark contiguous PTEs as a range of contiguous virtual-to-physical translations for a naturally@@ -520,9 +520,9 @@ config RISCV_ISA_SVPBMT depends on RISCV_ALTERNATIVE default y help - Adds support to dynamically detect the presence of the Svpbmt - ISA-extension (Supervisor-mode: page-based memory types) and - enable its usage. + Add support for the Svpbmt ISA-extension (Supervisor-mode: + page-based memory types) when it is detected by the kernel at + boot. The memory type for a page contains a combination of attributes that indicate the cacheability, idempotency, and ordering@@ -541,14 +541,15 @@ config TOOLCHAIN_HAS_V depends on AS_HAS_OPTION_ARCH config RISCV_ISA_V - bool "VECTOR extension support" + bool "Vector extension support" depends on TOOLCHAIN_HAS_V depends on FPU select DYNAMIC_SIGFRAME default y help Say N here if you want to disable all vector related procedure - in the kernel. + in the kernel. Without this option enabled, neither the kernel nor + userspace may use vector. If you don't know what to do here, say Y.@@ -606,8 +607,8 @@ config RISCV_ISA_ZBB depends on RISCV_ALTERNATIVE default y help - Adds support to dynamically detect the presence of the ZBB - extension (basic bit manipulation) and enable its usage. + Add support for enabling optimisations in the kernel when the + Zbb extension is detected at boot. The Zbb extension provides instructions to accelerate a number of bit-specific operations (count bit population, sign extending,@@ -623,9 +624,9 @@ config RISCV_ISA_ZICBOM select RISCV_DMA_NONCOHERENT select DMA_DIRECT_REMAP help - Adds support to dynamically detect the presence of the ZICBOM - extension (Cache Block Management Operations) and enable its - usage. + Add support for the Zicbom extension (Cache Block Management + Operations) and enable its use in the kernel when it is detected + at boot. The Zicbom extension can be used to handle for example non-coherent DMA support on devices that need it.
arch/riscv/Kconfig config FPU · line 689
Quoted 6 lines
arch/riscv/Kconfig +2
-1@@ -684,7 +685,8 @@ config FPU default y help Say N here if you want to disable all floating-point related procedure - in the kernel. + in the kernel. Without this option enabled, neither the kernel nor + userspace may use vector.
s/vector/floating point/ here.
Regards,
Samuel
Quoted 9 lines
arch/riscv/Kconfig +0
-0If you don't know what to do here, say Y._______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
In reply to Conor DooleyQuoted 82 lines · Conor Dooley
Quoted 5 lines · Conor Dooley
As I said on IRC to you earlier, I think the
Kconfigoptions here are in need of a bit of a spring cleaning - they should be modified to explain their individual purposes, be that enabling optimisations in the kernel or being required for userspace. I'll try to send a patch for that if I remember tomorrow.Something like this:
-- >8 --
commit5125504beaedd669b082bf74b02003a77360670fAuthor: Conor Dooley <[email protected]> Date: Fri Mar 29 11:13:22 2024 +0000RISC-V: clarify what some RISCV_ISA* config options do
During some discussion on IRC yesterday and on Pu's bpf patch [1] I noticed that these RISCV_ISA*
Kconfigoptions are not really clear about their implications. Many of these options have no impact on what userspace is allowed to do, for example an application can use Zbb regardless of whether or not the kernel does. Change the help text to try and clarify whether or not an option affects just the kernel, or also userspace. None of these options actually control whether or not an extension is detected dynamically as that's done regardless ofKconfigoptions, so drop any text that implies the option is required for dynamic detection, rewording them as "do x when y is detected".Signed-off-by Conor Dooley <[email protected]>---
I did this based on top of Samuel's changes dropping the MMU requurements just in case, but I don't think there's a conflict:
https://lore.kernel.org/linux-riscv/[email protected]/arch/riscv/Kconfig +8
-7@@ -501,8 +501,8 @@ config RISCV_ISA_SVNAPOT depends on RISCV_ALTERNATIVE default y help - Allow kernel to detect the Svnapot ISA-extension dynamically at boot - time and enable its usage. + Add support for the Svnapot ISA-extension when it is detected by + the kernel at boot. The Svnapot extension is used to mark contiguous PTEs as a range of contiguous virtual-to-physical translations for a naturally@@ -520,9 +520,9 @@ config RISCV_ISA_SVPBMT depends on RISCV_ALTERNATIVE default y help - Adds support to dynamically detect the presence of the Svpbmt - ISA-extension (Supervisor-mode: page-based memory types) and - enable its usage. + Add support for the Svpbmt ISA-extension (Supervisor-mode: + page-based memory types) when it is detected by the kernel at + boot. The memory type for a page contains a combination of attributes that indicate the cacheability, idempotency, and ordering@@ -541,14 +541,15 @@ config TOOLCHAIN_HAS_V depends on AS_HAS_OPTION_ARCH config RISCV_ISA_V - bool "VECTOR extension support" + bool "Vector extension support" depends on TOOLCHAIN_HAS_V depends on FPU select DYNAMIC_SIGFRAME default y help Say N here if you want to disable all vector related procedure - in the kernel. + in the kernel. Without this option enabled, neither the kernel nor + userspace may use vector. If you don't know what to do here, say Y.
arch/riscv/Kconfig config RISCV_ISA_ZBB · line 610
Quoted 6 lines
arch/riscv/Kconfig +1
-2@@ -606,8 +607,8 @@ config RISCV_ISA_ZBB depends on RISCV_ALTERNATIVE default y help - Adds support to dynamically detect the presence of the ZBB - extension (basic bit manipulation) and enable its usage. + Add support for enabling optimisations in the kernel when the
I don't care much, but "optimizations" here -- for consistency reasons!
[1] ;-)
Nice change!
Björn Töpel
maintainerRe: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
In reply to Pu LehuiQuoted 7 lines · Pu Lehui
From: Pu Lehui <[email protected]>
This patch relaxes the restrictions on the Zbb instructions. The hardware is capable of recognizing the Zbb instructions independently, eliminating the need for reliance on kernel compile configurations.
Signed-off-by Pu Lehui <[email protected]>
Should this patch really be part of this series?
Björn
Daniel Borkmann
maintainerRe: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
Quoted 10 lines · Björn Töpel
Quoted 7 lines · Pu Lehui
From: Pu Lehui <[email protected]>
This patch relaxes the restrictions on the Zbb instructions. The hardware is capable of recognizing the Zbb instructions independently, eliminating the need for reliance on kernel compile configurations.
Signed-off-by Pu Lehui <[email protected]>Should this patch really be part of this series?
No, that should be submitted independently.
Also, given Eduard's comment, it would be great if you could add the instructions to tools/testing/selftests/bpf/README.rst even if not in a perfect shape, but it would give developers a chance to get started.
Thanks,
Daniel
Re: [PATCH bpf-next 2/5] riscv, bpf: Relax restrictions on Zbb instructions
Quoted 8 lines · Daniel Borkmann
Quoted 7 lines · Björn Töpel
Quoted 6 lines · Pu Lehui
From: Pu Lehui <[email protected]>
This patch relaxes the restrictions on the Zbb instructions. The hardware is capable of recognizing the Zbb instructions independently, eliminating the need for reliance on kernel compile configurations.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Pu Lehui <[email protected]>Should this patch really be part of this series?
No, that should be submitted independently.
My initial thought was that I didn't enable CONFIG_RISCV_ISA_ZBB in config.riscv64, so I should loosen this restriction to enable zbb optimization. It could not be part of this series.
By the way, after reading what Conor and Björn said, I think we should align with kernel sematic, that is, emit zbb when CONFIG_RISCV_ISA_ZBB is enabled and so that if Zbb is detected they can be used.
Quoted 6 lines
Also, given Eduard's comment, it would be great if you could add the instructions to
tools/testing/selftests/bpf/README.rsteven if not in a perfect shape, but it would give developers a chance to get started.Thanks,
Daniel
PATCH 3/5 selftests/bpf: Add config.riscv64
In reply to Pu LehuiFrom: Pu Lehui <[email protected]>
Add config.riscv64 for both BPF CI and local vmtest.
--- tools/testing/selftests/bpf/config.riscv64 | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 tools/testing/selftests/bpf/config.riscv64
tools/testing/selftests/bpf/config.riscv64 new file +85 -0
@@ -0,0 +1,85 @@ +CONFIG_AUDIT=y +CONFIG_BLK_CGROUP=y +CONFIG_BLK_DEV_INITRD=y +CONFIG_BLK_DEV_RAM=y +CONFIG_BONDING=y +CONFIG_BPF_JIT_ALWAYS_ON=y +CONFIG_BPF_PRELOAD=y +CONFIG_BPF_PRELOAD_UMD=y +CONFIG_CGROUPS=y +CONFIG_CGROUP_CPUACCT=y +CONFIG_CGROUP_DEVICE=y +CONFIG_CGROUP_FREEZER=y +CONFIG_CGROUP_HUGETLB=y +CONFIG_CGROUP_NET_CLASSID=y +CONFIG_CGROUP_PERF=y +CONFIG_CGROUP_PIDS=y +CONFIG_CGROUP_SCHED=y +CONFIG_CPUSETS=y +CONFIG_DEBUG_ATOMIC_SLEEP=y +CONFIG_DEBUG_FS=y +CONFIG_DETECT_HUNG_TASK=y +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +CONFIG_EXPERT=y +CONFIG_EXT4_FS=y +CONFIG_EXT4_FS_POSIX_ACL=y +CONFIG_EXT4_FS_SECURITY=y +CONFIG_FRAME_POINTER=y +CONFIG_HARDLOCKUP_DETECTOR=y +CONFIG_HIGH_RES_TIMERS=y +CONFIG_HUGETLBFS=y +CONFIG_INET=y +CONFIG_IPV6_SEG6_LWTUNNEL=y +CONFIG_IP_ADVANCED_ROUTER=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_MULTIPLE_TABLES=y +CONFIG_IP_NF_IPTABLES=y +CONFIG_JUMP_LABEL=y +CONFIG_KALLSYMS_ALL=y +CONFIG_KPROBES=y +CONFIG_MEMCG=y +CONFIG_NAMESPACES=y +CONFIG_NET=y +CONFIG_NETDEVICES=y +CONFIG_NETFILTER_XT_MATCH_BPF=y +CONFIG_NET_ACT_BPF=y +CONFIG_NET_L3_MASTER_DEV=y +CONFIG_NET_VRF=y +CONFIG_NONPORTABLE=y +CONFIG_NO_HZ_IDLE=y +CONFIG_NR_CPUS=256 +CONFIG_PACKET=y +CONFIG_PANIC_ON_OOPS=y +CONFIG_PARTITION_ADVANCED=y +CONFIG_PCI=y +CONFIG_PCI_HOST_GENERIC=y +CONFIG_POSIX_MQUEUE=y +CONFIG_PRINTK_TIME=y +CONFIG_PROC_KCORE=y +CONFIG_PROFILING=y +CONFIG_RCU_CPU_STALL_TIMEOUT=60 +CONFIG_RISCV_EFFICIENT_UNALIGNED_ACCESS=y +CONFIG_RISCV_ISA_C=y +CONFIG_RISCV_PMU=y +CONFIG_RISCV_PMU_SBI=y +CONFIG_RT_GROUP_SCHED=y +CONFIG_SECURITY_NETWORK=y +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_SMP=y +CONFIG_SOC_VIRT=y +CONFIG_SYSVIPC=y +CONFIG_TCP_CONG_ADVANCED=y +CONFIG_TLS=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +CONFIG_TUN=y +CONFIG_UNIX=y +CONFIG_UPROBES=y +CONFIG_USER_NS=y +CONFIG_VETH=y +CONFIG_VLAN_8021Q=y +CONFIG_VSOCKETS_LOOPBACK=y +CONFIG_XFRM_USER=y
Signature · 1 line
2.34.1
PATCH 4/5 selftests/bpf: Add DENYLIST.riscv64
In reply to Pu LehuiFrom: Pu Lehui <[email protected]>
This patch adds DENYLIST.riscv64 file for riscv64. It will help BPF CI and local vmtest to mask failing and unsupported test cases.
We can use the following command to use deny list in local vmtest as previously mentioned by Manu.
tools/testing/selftests/bpf/vmtest.sh -- \
./test_progs -d \
\"$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \
| cut -d'#' -f1 \
| sed -e 's/^[[:space:]]*//' \
-e 's/[[:space:]]*$//' \
| tr -s '\n' ','\
)\"--- tools/testing/selftests/bpf/DENYLIST.riscv64 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tools/testing/selftests/bpf/DENYLIST.riscv64
tools/testing/selftests/bpf/DENYLIST.riscv64 new file +5 -0
@@ -0,0 +1,5 @@ +# riscv64 deny list for BPF CI and local vmtest +exceptions # JIT does not support exceptions +fentry_test/fentry_many_args # JIT does not support 12 args of bpf trampoline +fexit_test/fexit_many_args # JIT does not support 12 args of bpf trampoline +tailcalls/tailcall_bpf2bpf* # JIT does not support mixing bpf2bpf and tailcalls
Signature · 1 line
2.34.1
PATCH 5/5 selftests/bpf: Add riscv64 configurations to local vmtest
In reply to Pu LehuiFrom: Pu Lehui <[email protected]>
Add riscv64 configurations to local vmtest.
We can now perform cross platform testing for riscv64 bpf using the following command:
PLATFORM=riscv64 CROSS_COMPILE=riscv64-linux-gnu- \
tools/testing/selftests/bpf/vmtest.sh -- \
./test_progs -d \
\"$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \
| cut -d'#' -f1 \
| sed -e 's/^[[:space:]]*//' \
-e 's/[[:space:]]*$//' \
| tr -s '\n' ','\
)\"--- tools/testing/selftests/bpf/vmtest.sh | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/testing/selftests/bpf/vmtest.sh +8 -0
@@ -33,6 +33,14 @@ aarch64) BZIMAGE="arch/arm64/boot/Image" ARCH="arm64" ;; +riscv64) + QEMU_BINARY=qemu-system-riscv64 + QEMU_CONSOLE="ttyS0,115200" + HOST_FLAGS=(-M virt -cpu host -enable-kvm -smp 8) + CROSS_FLAGS=(-M virt -cpu rv64,sscofpmf=true -smp 8) + BZIMAGE="arch/riscv/boot/Image" + ARCH="riscv" + ;; *) echo "Unsupported architecture" exit 1
Signature · 1 line
2.34.1
Eduard Zingerman
maintainerQuoted 24 lines · Pu Lehui
Patch 1 is to enable cross platform testing for local vmtest. The remaining patch adds local vmtest support for riscv64. It relies on commit [0] [1] for better regression.
We can now perform cross platform testing for riscv64 bpf using the following command:
PLATFORM=riscv64 CROSS_COMPILE=riscv64-linux-gnu- \ tools/testing/selftests/bpf/vmtest.sh -- \ ./test_progs -d \ \"$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \ | cut -d'#' -f1 \ | sed -e 's/^[[:space:]]*//' \ -e 's/[[:space:]]*$//' \ | tr -s '\n' ','\ )\"The test platform is
x86_64architecture, and the versions of relevant components are as follows:
QEMU: 8.2.0
CLANG: 17.0.6 (align to BPF CI)
OpenSBI: 1.3.1 (default by QEMU)
ROOTFS: ubuntu jammy (generated by [2])
Quoted 3 lines
Hello,
I wanted to do a test run for this patch-set but did not figure out how to build rootfs for riscv64 system.
I modified mkrootfs_debian.sh as below, but build command fails:
$ ./rootfs/mkrootfs_debian.sh -d jammy -a riscv64 -m http://de.archive.ubuntu.com/ubuntu ... E: Couldn't download http://de.archive.ubuntu.com/ubuntu/dists/jammy/main/binary-riscv64/Packages
Apparently jammy does not have binaries built for riscv64, or I'm failing to find correct mirror. Could you please provide some instructions on how to prepare rootfs?
Thanks,
Eduard
--
rootfs/mkrootfs_debian.sh +10 -3
@@ -16,6 +16,7 @@ CPUTABLE="${CPUTABLE:-/usr/share/dpkg/cputable}" deb_arch=$(dpkg --print-architecture) distro="bullseye" +mirror="" function usage() { echo "Usage: $0 [-a | --arch architecture] [-h | --help]
@@ -25,6 +26,7 @@ By default build an image for the architecture of the host running the script. -a | --arch: architecture to build the image for. Default (${deb_arch}) -d | --distro: distribution to build. Default (${distro}) + -m | --mirror: mirror for distribution to build. Default (${mirror}) " }
@@ -44,7 +46,7 @@ function qemu_static() { # Given a Debian architecture find the location of the matching # qemu-${gnu_arch}-static binary. gnu_arch=$(debian_to_gnu "${1}") - echo "qemu-${gnu_arch}-static" + echo "qemu-${gnu_arch}" } function check_requirements() {
@@ -95,7 +97,7 @@ function check_requirements() { fi } -TEMP=$(getopt -l "arch:,distro:,help" -o "a:d:h" -- "$@") +TEMP=$(getopt -l "arch:,distro:,mirror:,help" -o "a:d:m:h" -- "$@") if [ $? -ne 0 ]; then usage fi
@@ -113,6 +115,10 @@ while true; do distro="$2" shift 2 ;; + --mirror | -m) + mirror="$2" + shift 2 + ;; --help | -h) usage exit
@@ -162,7 +168,8 @@ debootstrap --include="$packages" \ --arch="${deb_arch}" \ "$@" \ "${distro}" \ - "$root" + "$root" \ + "${mirror}" qemu=$(which $(qemu_static ${deb_arch}))
Quoted 34 lines · Eduard Zingerman
Quoted 24 lines · Pu Lehui
Patch 1 is to enable cross platform testing for local vmtest. The remaining patch adds local vmtest support for riscv64. It relies on commit [0] [1] for better regression.
We can now perform cross platform testing for riscv64 bpf using the following command:
PLATFORM=riscv64 CROSS_COMPILE=riscv64-linux-gnu- \ tools/testing/selftests/bpf/vmtest.sh -- \ ./test_progs -d \ \"$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \ | cut -d'#' -f1 \ | sed -e 's/^[[:space:]]*//' \ -e 's/[[:space:]]*$//' \ | tr -s '\n' ','\ )\"The test platform is
x86_64architecture, and the versions of relevant components are as follows:
QEMU: 8.2.0
CLANG: 17.0.6 (align to BPF CI)
OpenSBI: 1.3.1 (default by QEMU)
ROOTFS: ubuntu jammy (generated by [2])Quoted 3 lines
Hello,
I wanted to do a test run for this patch-set but did not figure out how to build rootfs for riscv64 system.
Quoted 8 lines
I modified
mkrootfs_debian.shas below, but build command fails:$ ./rootfs/mkrootfs_debian.sh -d jammy -a riscv64 -m http://de.archive.ubuntu.com/ubuntu ... E: Couldn't download http://de.archive.ubuntu.com/ubuntu/dists/jammy/main/binary-riscv64/PackagesApparently jammy does not have binaries built for riscv64, or I'm failing to find correct mirror. Could you please provide some instructions on how to prepare rootfs?
Hi Eduard, We need the mirror repository of ubuntu-ports, you could try http://de.ports.ubuntu.com/.
Quoted 65 lines
Thanks,
Eduard--
rootfs/mkrootfs_debian.sh +10
-3@@ -16,6 +16,7 @@ CPUTABLE="${CPUTABLE:-/usr/share/dpkg/cputable}" deb_arch=$(dpkg --print-architecture) distro="bullseye" +mirror="" function usage() { echo "Usage: $0 [-a | --arch architecture] [-h | --help]@@ -25,6 +26,7 @@ By default build an image for the architecture of the host running the script. -a | --arch: architecture to build the image for. Default (${deb_arch}) -d | --distro: distribution to build. Default (${distro}) + -m | --mirror: mirror for distribution to build. Default (${mirror}) " }@@ -44,7 +46,7 @@ function qemu_static() { # Given a Debian architecture find the location of the matching # qemu-${gnu_arch}-static binary. gnu_arch=$(debian_to_gnu "${1}") - echo "qemu-${gnu_arch}-static" + echo "qemu-${gnu_arch}" } function check_requirements() {@@ -95,7 +97,7 @@ function check_requirements() { fi } -TEMP=$(getopt -l "arch:,distro:,help" -o "a:d:h" -- "$@") +TEMP=$(getopt -l "arch:,distro:,mirror:,help" -o "a:d:m:h" -- "$@") if [ $? -ne 0 ]; then usage fi@@ -113,6 +115,10 @@ while true; do distro="$2" shift 2 ;; + --mirror | -m) + mirror="$2" + shift 2 + ;; --help | -h) usage exit@@ -162,7 +168,8 @@ debootstrap --include="$packages" \ --arch="${deb_arch}" \ "$@" \ "${distro}" \ - "$root" + "$root" \ + "${mirror}" qemu=$(which $(qemu_static ${deb_arch}))
Eduard Zingerman
maintainerOn Fri, 2024-03-29 at 18:10 +0800, Pu Lehui wrote:
[...]
Quoted 5 lines
Quoted 2 lines
Apparently jammy does not have binaries built for riscv64, or I'm failing to find correct mirror. Could you please provide some instructions on how to prepare rootfs?
Hi Eduard, We need the mirror repository of ubuntu-ports, you could try
http://de.ports.ubuntu.com/.
Hi Pu, thank you this mirrorm it works.
Unfortunately my local setup is still not good enough. I've installed cross-riscv64-gcc14 but it seems that a few more libraries are necessary, as I get the following compilation errors:
$ PLATFORM=riscv64 CROSS_COMPILE=riscv64-suse-linux- ./vmtest.sh -- ./test_verifier
... kernel compiles ok ...
../../../../scripts/sign-file.c:25:10: fatal error: openssl/opensslv.h: No such file or directory
25 | #include <openssl/opensslv.h>
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
CC /home/eddy/work/bpf-next/tools/testing/selftests/bpf/tools/build/host/libbpf/sharedobjs/bpf.o
In file included from nlattr.c:14:
libbpf_internal.h:19:10: fatal error: libelf.h: No such file or directory
19 | #include <libelf.h>
...Looks like I won't be able to test this patch-set, unless you have some writeup on how to create a riscv64 dev environment at hand. Sorry for the noise.
Quoted 26 lines · Eduard Zingerman
On Fri, 2024-03-29 at 18:10 +0800, Pu Lehui wrote:
[...]Quoted 5 lines
Quoted 2 lines
Apparently jammy does not have binaries built for riscv64, or I'm failing to find correct mirror. Could you please provide some instructions on how to prepare rootfs?
Hi Eduard, We need the mirror repository of ubuntu-ports, you could try
http://de.ports.ubuntu.com/.Hi Pu, thank you this mirrorm it works.
Unfortunately my local setup is still not good enough. I've installed cross-riscv64-gcc14 but it seems that a few more libraries are necessary, as I get the following compilation errors: >
$ PLATFORM=riscv64 CROSS_COMPILE=riscv64-suse-linux- ./vmtest.sh -- ./test_verifier ... kernel compiles ok ... ../../../../scripts/sign-file.c:25:10: fatal error: openssl/opensslv.h: No such file or directory 25 | #include <openssl/opensslv.h> | ^~~~~~~~~~~~~~~~~~~~ compilation terminated. CC /home/eddy/work/bpf-next/tools/testing/selftests/bpf/tools/build/host/libbpf/sharedobjs/bpf.o In file included from nlattr.c:14: libbpf_internal.h:19:10: fatal error: libelf.h: No such file or directory 19 | #include <libelf.h> ...
Quoted 3 lines
Looks like I won't be able to test this patch-set, unless you have some writeup on how to create a riscv64 dev environment at hand. Sorry for the noise
Yeah, environmental issues are indeed a developer's nightmare. I will try to do something for the newcomers of riscv64 bpf. At present, I have simply built a docker local vmtest environment [0] based on Bjorn's riscv-cross-builder. We can directly run vmtest within this environment. Hopefully it will help.
PS: Since the current rootfs of riscv64 is not in the INDEX, I simply modified vmtest.sh to support local rootfs. And we can use it by:
```
PLATFORM=riscv64 CROSS_COMPILE=riscv64-linux-gnu- \
tools/testing/selftests/bpf/vmtest.sh -l /rootfs -- \
./test_progs -d \
\"$(cat tools/testing/selftests/bpf/DENYLIST.riscv64 \
| cut -d'#' -f1 \
| sed -e 's/^[[:space:]]*//' \
-e 's/[[:space:]]*$//' \
| tr -s '\n' ','\
)\"
```tools/testing/selftests/bpf/vmtest.sh +27 -3
@@ -148,6 +148,21 @@ download_rootfs() zstd -d | sudo tar -C "$dir" -x } +load_rootfs() +{ + local image_dir="$1" + local rootfsversion="$2" + local dir="$3" + + if ! which zstd &> /dev/null; then + echo 'Could not find "zstd" on the system, please install zstd' + exit 1 + fi + + cat "${image_dir}/libbpf-vmtest-rootfs-$rootfsversion.tar.zst" | + zstd -d | sudo tar -C "$dir" -x +} + recompile_kernel() { local kernel_checkout="$1"
@@ -234,6 +249,7 @@ EOF create_vm_image() { + local local_image_dir="$1" local rootfs_img="${OUTPUT_DIR}/${ROOTFS_IMAGE}" local mount_dir="${OUTPUT_DIR}/${MOUNT_DIR}"
@@ -245,7 +261,11 @@ create_vm_image() mkfs.ext4 -q "${rootfs_img}" mount_image - download_rootfs "$(newest_rootfs_version)" "${mount_dir}" + if [[ "${local_image_dir}" == "" ]]; then + download_rootfs "$(newest_rootfs_version)" "${mount_dir}" + else + load_rootfs "${local_image_dir}" "$(newest_rootfs_version)" "${mount_dir}" + fi unmount_image }
@@ -363,12 +383,16 @@ main() local update_image="no" local exit_command="poweroff -f" local debug_shell="no" + local local_image_dir="" - while getopts ':hskid:j:' opt; do + while getopts ':hskil:d:j:' opt; do case ${opt} in i) update_image="yes" ;; + l) + local_image_dir="$OPTARG" + ;; d) OUTPUT_DIR="$OPTARG" ;;
@@ -445,7 +469,7 @@ main() fi if [[ "${update_image}" == "yes" ]]; then - create_vm_image + create_vm_image "${local_image_dir}" fi update_selftests "${kernel_checkout}" "${make_command}"
On Sat, 2024-03-30 at 18:12 +0800, Pu Lehui wrote:
[...]
Quoted 11 lines
Quoted 3 lines
Looks like I won't be able to test this patch-set, unless you have some writeup on how to create a riscv64 dev environment at hand. Sorry for the noise
Yeah, environmental issues are indeed a developer's nightmare. I will try to do something for the newcomers of riscv64 bpf. At present, I have simply built a docker local vmtest environment [0] based on Bjorn's riscv-cross-builder. We can directly run vmtest within this environment. Hopefully it will help.
Hi Pu,
Thank you for sharing the docker file, I've managed to run the tests using it. In order to avoid creating files with root permissions I had to add the following lines at the end of the Dockerfile:
+ RUN useradd --no-create-home --uid 1000 eddy
+ RUN passwd -d eddy
+ RUN echo 'eddy ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
+ # vmtest.sh does 'mount -o loop',
+ # ensure there is a loop device in the container
+ RUN mknod /dev/loop0 b 7 20
Where 'eddy' is my local user with UID 1000. Probably this should be made more generic.
I used the following command to start the container:
docker run -ti -u 1000:1000 \
--rm -v <path-to-kernel-dir>:/workspace \
-v <path-to-rootfs-image-dir>:/rootfs \
--privileged ubuntu-vmtest:latest /bin/bashAlso, I had to add '-d /rootfs/bpf_selftests' option for vmtest.sh in order to avoid polluting user directory inside the container. Maybe OUTPUT_DIR for vmtest.sh should be mounted as a separate volume.
I agree with Daniel, it would be great to document all of this somewhere in the repo (or even scripted somehow).
Using the specified DENYLIST I get the following stats for test_progs:
#3/2 arena_htab/arena_htab_asm:FAIL #3 arena_htab:FAIL #95 get_branch_snapshot:FAIL #172/1 perf_branches/perf_branches_hw:FAIL #172 perf_branches:FAIL #434/3 verifier_arena/basic_alloc3:FAIL #434 verifier_arena:FAIL
Summary: 531/3581 PASSED, 64 SKIPPED, 4 FAILED
Quoted 2 lines
PS: Since the current rootfs of riscv64 is not in the INDEX, I simply modified
vmtest.shto support local rootfs.
Could you please add this change to the patch-set?
[...]
Quoted 37 lines · Eduard Zingerman
On Sat, 2024-03-30 at 18:12 +0800, Pu Lehui wrote:
[...]Quoted 11 lines
Quoted 3 lines
Looks like I won't be able to test this patch-set, unless you have some writeup on how to create a riscv64 dev environment at hand. Sorry for the noise
Yeah, environmental issues are indeed a developer's nightmare. I will try to do something for the newcomers of riscv64 bpf. At present, I have simply built a docker local vmtest environment [0] based on Bjorn's riscv-cross-builder. We can directly run vmtest within this environment. Hopefully it will help.
Hi Pu,
Thank you for sharing the docker file, I've managed to run the tests using it. In order to avoid creating files with root permissions I had to add the following lines at the end of the Dockerfile:
+ RUN useradd --no-create-home --uid 1000 eddy
+ RUN passwd -d eddy
+ RUN echo 'eddy ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers
+ #vmtest.shdoes 'mount -o loop',
+ # ensure there is a loop device in the container
+ RUN mknod/dev/loop0b 7 20Where 'eddy' is my local user with UID 1000. Probably this should be made more generic.
I used the following command to start the container:docker run -ti -u 1000:1000 \ --rm -v <path-to-kernel-dir>:/workspace \ -v <path-to-rootfs-image-dir>:/rootfs \ --privileged ubuntu-vmtest:latest /bin/bash
Quoted 5 lines
Also, I had to add '-d /rootfs/bpf_selftests' option for
vmtest.shin order to avoid polluting user directory inside the container. MaybeOUTPUT_DIRforvmtest.shshould be mounted as a separate volume.I agree with Daniel, it would be great to document all of this
Forgot to reply to this in my last email. It my pleasure to do this.
Quoted 6 lines
somewhere in the repo (or even scripted somehow).
Using the specified DENYLIST I get the following stats for
test_progs:#3/2 arena_htab/arena_htab_asm:FAIL
#3 arena_htab:FAIL
Puranjay has submitted to riscv bpf arena and will be merged soon. So I didn't add it to DENYLIST.riscv64.
https://lore.kernel.org/bpf/[email protected]/
Quoted 3 lines
#95 get_branch_snapshot:FAIL #172/1 perf_branches/perf_branches_hw:FAIL #172 perf_branches:FAIL
riscv sbi pmu driver not support branch sampling yet. The following patch should be used for better regression.
https://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git/commit/?id=ea6873118493
Quoted 10 lines
#434/3 verifier_arena/basic_alloc3:FAIL #434 verifier_arena:FAIL Summary: 531/3581 PASSED, 64 SKIPPED, 4 FAILEDTested-by Eduard Zingerman <[email protected]>Quoted 2 lines
PS: Since the current rootfs of riscv64 is not in the INDEX, I simply modified
vmtest.shto support local rootfs.Could you please add this change to the patch-set?
yep, will try to make it more convenient.
Quoted 2 lines
[...]