Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: test on arm64 #266

Closed
shrkamat opened this issue Mar 25, 2021 · 9 comments · Fixed by #304 or #1245
Closed

CI: test on arm64 #266

shrkamat opened this issue Mar 25, 2021 · 9 comments · Fixed by #304 or #1245
Assignees
Labels
enhancement New feature or request

Comments

@shrkamat
Copy link

I see failure in running kprobe example for aarch64 kernel version 4.19.113

GOOS=linux GOARCH=arm64 go build -o ebpf-kprobe

./ebpf-kprobe 
2021/03/25 22:03:40 error while loading objects: field KprobeExecve: program kprobe_execve: load program without BTF: invalid argument

looks like BPF_PROG_LOAD is failing

@lmb
Copy link
Collaborator

lmb commented Mar 26, 2021

We don't have arm64 on CI, so the support is best effort. I think the real cause of the error is that loading BTF is bailing out for some reason. Without access to arm64 it'll be hard to debug.

@lmb lmb added bug Something isn't working enhancement New feature or request labels Mar 26, 2021
@lmb lmb changed the title Is aarch64 CPU supported by ebpf ? aarch64 / arm64 support Mar 26, 2021
@ti-mo
Copy link
Collaborator

ti-mo commented Apr 20, 2021

Thanks for reporting. I have some Pi4's laying around that I still need to set up, but we'll likely only be able to support this properly once we can build and test on arm64 CI kernels. There's some experimental arm64 support in virtme, but haven't tried it yet. Might be on the roadmap at some point, will leave this open to keep track.

@lmb
Copy link
Collaborator

lmb commented Apr 29, 2021

FWIW I suspect that this particular error is because ./ebpf-kprobe was run without root privileged.

@ti-mo
Copy link
Collaborator

ti-mo commented Jun 11, 2021

Reopening as #304 was only kprobe-related.

@ti-mo ti-mo reopened this Jun 11, 2021
@ti-mo ti-mo self-assigned this Aug 9, 2021
@ti-mo
Copy link
Collaborator

ti-mo commented Aug 19, 2021

Finally had the chance to look at this. Have ALARM set up on a rpi4, and this is the test output: https://gist.github.com/ti-mo/033e7de02d58da9abc6a2bac91458291

Everything seems to work for the most part, but it seems like the following map/prog types just don't work on this kernel build:

--- FAIL: TestHaveMapType (0.10s)
    --- FAIL: TestHaveMapType/XSKMap (0.00s)
        map_test.go:64: Map type XSKMap isn't supported even though kernel is at least 4.18: not supported
    --- FAIL: TestHaveMapType/InodeStorage (0.00s)
        map_test.go:64: Map type InodeStorage isn't supported even though kernel is at least 5.10: not supported
    --- FAIL: TestHaveMapType/TaskStorage (0.00s)
        map_test.go:64: Map type TaskStorage isn't supported even though kernel is at least 5.11: not supported
--- FAIL: TestHaveProgType (0.00s)
    --- FAIL: TestHaveProgType/RawTracepointWritable (0.00s)
        prog_test.go:76: Program type RawTracepointWritable isn't supported even though kernel is at least 5.2: not supported
    --- FAIL: TestHaveProgType/RawTracepoint (0.00s)
        prog_test.go:76: Program type RawTracepoint isn't supported even though kernel is at least 4.17: not supported
    --- FAIL: TestHaveProgType/PerfEvent (0.00s)
        prog_test.go:76: Program type PerfEvent isn't supported even though kernel is at least 4.9: not supported
    --- FAIL: TestHaveProgType/Kprobe (0.00s)
        prog_test.go:76: Program type Kprobe isn't supported even though kernel is at least 4.1: not supported
    --- FAIL: TestHaveProgType/TracePoint (0.00s)
        prog_test.go:76: Program type TracePoint isn't supported even though kernel is at least 4.7: not supported

This matches bpftool output:

[timo@alarm-rpi4 ebpf]$ sudo bpftool feature probe | grep NOT
eBPF program_type kprobe is NOT available
eBPF program_type tracepoint is NOT available
eBPF program_type perf_event is NOT available
eBPF program_type raw_tracepoint is NOT available
eBPF program_type lirc_mode2 is NOT available
eBPF program_type raw_tracepoint_writable is NOT available
eBPF program_type cgroup_sockopt is NOT available
eBPF program_type tracing is NOT available
eBPF program_type ext is NOT available
eBPF program_type lsm is NOT available
eBPF map_type xskmap is NOT available
eBPF map_type struct_ops is NOT available
eBPF map_type inode_storage is NOT available
eBPF map_type task_storage is NOT available

It seems like, for now, the error reported here is expected. I've played around with arm32 on an older Pi before, and attempting to use kprobes/tracepoints there resulted in consistent kernel panics. I think it's just been disabled in recent builds, or the kernel support is just not ready.

I'll slowly investigate some of the other failures too, but they all look related to either u/kprobes, perf, or missing vmlinux BTF somehow.

@lmb lmb removed the bug Something isn't working label Aug 24, 2021
@lmb
Copy link
Collaborator

lmb commented Mar 31, 2022

I'm now developing on an m1 in a VM, and I see a bunch of errno 524 for unimplemented stuff. Is that the case on your rpi as well?

@ti-mo
Copy link
Collaborator

ti-mo commented Mar 31, 2022

Yes, this was the case back when I was briefly testing this. Don't have the Pi's handy atm, and iirc the one running on it didn't have a bunch of kernel options enabled.

My idea was to (eventually) build kernel and userspace images for something like https://github.com/weaveworks/ignite, but QEMU-driven instead of Firecracker, since it doesn't support 9pfs/virtiofs. Not sure if we can get more mileage out of virtme, at least not with arm guests on a x86 host.

@florianl
Copy link
Contributor

florianl commented Apr 2, 2022

I don't have access to ARM64 hardware either and so fall back to virtual environments for testing low level Kernel APIs like netlink or ebpf.
This is the approach I use so far:

# Cross compile a Linux kernel for arm64
$ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make defconfig
$ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -j $(nproc)


# Create a statically linked executable from the tests in github.com/cilium/ebpf
$ GOARCH=arm64 GOOS=linux go test -ldflags='-extldflags=-static' -trimpath -tags 'osusergo netgo static_build linux' -c
$ file ebpf.test 
ebpf.test: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=WY90hJx458GNGAub3oIg/dTyiwLPimJ2BRRTReGBd/iVHqsVdn5p0icxIQlPF9/auBWq5LKg0Fr0xpEELk_, not stripped

# Embedd the statically linked executable with the tests into a minimal initramfs
$ bluebox -a arm64 -e ebpf.test:"-test.v"

# Run the tests in a virtual environment
$ qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic -smp 2 -m 4096 -kernel ./src/git.kernel.org/torvalds/linux/arch/arm64/boot/Image -initrd ./go/src/github.com/cilium/ebpf/initramfs.cpio

The limitation of bluebox is that one can execute/test only statically linked executables as it does not provide a full Unix environment. On the other hand it can be integrated into a CI/CD pipeline quite easy and comes without dependencies (except for Go) that are hard to manage.

@lmb
Copy link
Collaborator

lmb commented Apr 4, 2022

Thanks for the link to bluebox, that is a cool idea!

@lmb lmb unassigned ti-mo Jul 5, 2023
@lmb lmb changed the title aarch64 / arm64 support CI: test on arm64 Jul 5, 2023
@lmb lmb assigned lmb and unassigned lmb Aug 7, 2023
@lmb lmb self-assigned this Dec 6, 2023
@lmb lmb closed this as completed in #1245 Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
4 participants