Message ID | 111a64c3e6ccda6b8a2826491715d4e8a645e384.1698431765.git.dxu@dxuuu.xyz (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | Add bpf_xdp_get_xfrm_state() kfunc | expand |
Context | Check | Description |
---|---|---|
bpf/vmtest-bpf-next-VM_Test-1 | success | Logs for ShellCheck |
bpf/vmtest-bpf-next-VM_Test-4 | success | Logs for aarch64-gcc / test |
bpf/vmtest-bpf-next-VM_Test-2 | success | Logs for Validate matrix.py |
bpf/vmtest-bpf-next-VM_Test-0 | success | Logs for Lint |
bpf/vmtest-bpf-next-VM_Test-5 | success | Logs for aarch64-gcc / veristat |
bpf/vmtest-bpf-next-VM_Test-3 | fail | Logs for aarch64-gcc / build / build for aarch64 with gcc |
bpf/vmtest-bpf-next-PR | fail | PR summary |
bpf/vmtest-bpf-next-VM_Test-6 | fail | Logs for s390x-gcc / build / build for s390x with gcc |
bpf/vmtest-bpf-next-VM_Test-7 | success | Logs for s390x-gcc / test |
bpf/vmtest-bpf-next-VM_Test-8 | success | Logs for s390x-gcc / veristat |
bpf/vmtest-bpf-next-VM_Test-9 | success | Logs for set-matrix |
bpf/vmtest-bpf-next-VM_Test-10 | fail | Logs for x86_64-gcc / build / build for x86_64 with gcc |
bpf/vmtest-bpf-next-VM_Test-11 | success | Logs for x86_64-gcc / test |
bpf/vmtest-bpf-next-VM_Test-12 | success | Logs for x86_64-gcc / veristat |
bpf/vmtest-bpf-next-VM_Test-13 | fail | Logs for x86_64-llvm-16 / build / build for x86_64 with llvm-16 |
bpf/vmtest-bpf-next-VM_Test-14 | success | Logs for x86_64-llvm-16 / test |
bpf/vmtest-bpf-next-VM_Test-15 | success | Logs for x86_64-llvm-16 / veristat |
On Fri, Oct 27, 2023 at 11:46 AM Daniel Xu <dxu@dxuuu.xyz> wrote: > > Switching to vmlinux.h definitions seems to make the verifier very > unhappy with bitfield accesses. The error is: > > ; md.u.md2.dir = direction; > 33: (69) r1 = *(u16 *)(r2 +11) > misaligned stack access off (0x0; 0x0)+-64+11 size 2 > > It looks like disabling CO-RE relocations seem to make the error go > away. > for accessing bitfields libbpf provides BPF_CORE_READ_BITFIELD_PROBED() and BPF_CORE_READ_BITFIELD() macros > Signed-off-by: Daniel Xu <dxu@dxuuu.xyz> > --- > tools/testing/selftests/bpf/progs/test_tunnel_kern.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c > index 3065a716544d..ec7e04e012ae 100644 > --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c > +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c > @@ -6,6 +6,7 @@ > * modify it under the terms of version 2 of the GNU General Public > * License as published by the Free Software Foundation. > */ > +#define BPF_NO_PRESERVE_ACCESS_INDEX > #include "vmlinux.h" > #include <bpf/bpf_helpers.h> > #include <bpf/bpf_endian.h> > -- > 2.42.0 >
On Fri, Oct 27, 2023 at 01:33:09PM -0700, Andrii Nakryiko wrote: > On Fri, Oct 27, 2023 at 11:46 AM Daniel Xu <dxu@dxuuu.xyz> wrote: > > > > Switching to vmlinux.h definitions seems to make the verifier very > > unhappy with bitfield accesses. The error is: > > > > ; md.u.md2.dir = direction; > > 33: (69) r1 = *(u16 *)(r2 +11) > > misaligned stack access off (0x0; 0x0)+-64+11 size 2 > > > > It looks like disabling CO-RE relocations seem to make the error go > > away. > > > > for accessing bitfields libbpf provides > BPF_CORE_READ_BITFIELD_PROBED() and BPF_CORE_READ_BITFIELD() macros In this case the code in question is: __u8 direction = 0; md.u.md2.dir = direction; IOW the problem is assigning to bitfields, not reading from them. Is that something that libbpf needs to support as well? Thanks, Daniel
On Sun, Oct 29, 2023 at 4:22 PM Daniel Xu <dxu@dxuuu.xyz> wrote: > > On Fri, Oct 27, 2023 at 01:33:09PM -0700, Andrii Nakryiko wrote: > > On Fri, Oct 27, 2023 at 11:46 AM Daniel Xu <dxu@dxuuu.xyz> wrote: > > > > > > Switching to vmlinux.h definitions seems to make the verifier very > > > unhappy with bitfield accesses. The error is: > > > > > > ; md.u.md2.dir = direction; > > > 33: (69) r1 = *(u16 *)(r2 +11) > > > misaligned stack access off (0x0; 0x0)+-64+11 size 2 > > > > > > It looks like disabling CO-RE relocations seem to make the error go > > > away. > > > > > > > for accessing bitfields libbpf provides > > BPF_CORE_READ_BITFIELD_PROBED() and BPF_CORE_READ_BITFIELD() macros > > In this case the code in question is: > > __u8 direction = 0; > md.u.md2.dir = direction; > > IOW the problem is assigning to bitfields, not reading from them. > > Is that something that libbpf needs to support as well? Ah, I missed that this is a write into a struct. I think we can support BPF_CORE_WRITE_BITFIELD() (not the PROBED version, though) using all the same CO-RE relocations. It's probably a very niche case, but BPF_CORE_READ_BITFIELD() is niche as well (though an absolute necessity when the need does come up). > > Thanks, > Daniel
diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c index 3065a716544d..ec7e04e012ae 100644 --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c @@ -6,6 +6,7 @@ * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. */ +#define BPF_NO_PRESERVE_ACCESS_INDEX #include "vmlinux.h" #include <bpf/bpf_helpers.h> #include <bpf/bpf_endian.h>
Switching to vmlinux.h definitions seems to make the verifier very unhappy with bitfield accesses. The error is: ; md.u.md2.dir = direction; 33: (69) r1 = *(u16 *)(r2 +11) misaligned stack access off (0x0; 0x0)+-64+11 size 2 It looks like disabling CO-RE relocations seem to make the error go away. Signed-off-by: Daniel Xu <dxu@dxuuu.xyz> --- tools/testing/selftests/bpf/progs/test_tunnel_kern.c | 1 + 1 file changed, 1 insertion(+)