From 297943b01e18bb3d1dd41a8d3e220811de25228b Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 11:49:22 -0300 Subject: ztrace probe: BPF on syscalls, scheduling, kprobes, uprobes and USDT Programs built as instruction arrays for one process (no compiler, no libbpf), writing Events into a BPF ring buffer; a drop counter in a map; task_struct offsets from the kernel's BTF; a USDT probe's arguments read in the kernel at the probe. Without CAP_BPF and CAP_PERFMON it says so; --dry-run builds and lists everything. Tested offline by running the programs in a small BPF machine, and for real by test-kernel-vm, which boots this kernel in QEMU where we are root. ztrace perf: moments are no longer cut per event unless --cut; --max-size, and a full recording stops the target and says so. perf.Sorted merges two backends' events by time. Co-Authored-By: Claude Fable 5.2 --- build/kernel_vm.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 build/kernel_vm.sh (limited to 'build/kernel_vm.sh') diff --git a/build/kernel_vm.sh b/build/kernel_vm.sh new file mode 100644 index 0000000..ac7c576 --- /dev/null +++ b/build/kernel_vm.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# usage: kernel_vm.sh INIT COMMANDS FILE... +# Boots this machine's kernel in QEMU on an initramfs of the files given +# (and the C library, for the dynamic ones): INIT is its /init and runs each +# line of COMMANDS as root. What the console says goes to stdout. +set -e +stage=$(mktemp -d) +trap 'rm -rf "$stage" "$stage.cpio"' EXIT +mkdir -p "$stage/proc" "$stage/sys" "$stage/dev" "$stage/lib64" "$stage/usr/lib" +cp "$1" "$stage/init" +cp "$2" "$stage/commands" +shift 2 +cp "$@" "$stage/" +cp /lib64/ld-linux-x86-64.so.2 "$stage/lib64/" +cp /usr/lib/libc.so.6 "$stage/usr/lib/" +(cd "$stage" && find . | cpio -o -H newc --quiet) >"$stage.cpio" +timeout 120 qemu-system-x86_64 -enable-kvm -cpu host -m 512 -display none -serial stdio -no-reboot \ + -kernel "/usr/lib/modules/$(uname -r)/vmlinuz" -initrd "$stage.cpio" \ + -append "console=ttyS0 quiet panic=-1" -- cgit v1.3