From ab38afe95d16226f5a703bbb37c7842ee441c364 Mon Sep 17 00:00:00 2001 From: Friday Ortiz Date: Fri, 10 Oct 2025 18:03:00 +0000 Subject: [PATCH] perf_event: support hardware breakpoints Implement `PerfEventConfig::Breakpoint`, allowing users to attach hardware breakpoints. Generate `HW_BREAKPOINT_*` and `struct bpf_perf_event_data` in support of this feature and update the type of `PerfEventContext` accordingly. Add a test exercising R, W, RW, and X breakpoints. Note that R breakpoints are unsupported on x86, and this is asserted in the test. Extend the VM integration test harness and supporting infrastructure (e.g. `download_kernel_images.sh`) to download kernel debug packages and mount `System.map` in initramfs. This is needed (at least) on the aarch 6.1 Debian kernel which was not compiled with `CONFIG_KALLSYMS_ALL=y` for some reason, and the locations of globals are not available in kallsyms. To attach breakpoints to these symbols in the test pipeline, we need to read them from System.map and apply the KASLR offset to get their real address. The `System.map` file is not provided in the kernel package by default, so we need to extract it from the corresponding debug package. The KASLR offset is computed using `gunzip` which appears in kallsyms on all Debian kernels tested. Co-authored-by: Tamir Duberstein --- .github/scripts/download_kernel_images.sh | 25 ++ aya-ebpf-macros/src/perf_event.rs | 4 +- aya-obj/include/linux_wrapper.h | 1 + .../src/generated/linux_bindings_aarch64.rs | 124 ++++--- aya-obj/src/generated/linux_bindings_armv7.rs | 124 ++++--- .../generated/linux_bindings_loongarch64.rs | 124 ++++--- aya-obj/src/generated/linux_bindings_mips.rs | 124 ++++--- .../src/generated/linux_bindings_powerpc64.rs | 124 ++++--- .../src/generated/linux_bindings_riscv64.rs | 124 ++++--- aya-obj/src/generated/linux_bindings_s390x.rs | 124 ++++--- .../src/generated/linux_bindings_x86_64.rs | 124 ++++--- aya/src/programs/perf_event.rs | 93 ++++- aya/src/sys/perf_event.rs | 47 ++- ebpf/aya-ebpf-bindings/include/bindings.h | 1 + .../aya-ebpf-bindings/src/aarch64/bindings.rs | 13 +- ebpf/aya-ebpf-bindings/src/armv7/bindings.rs | 13 +- .../src/loongarch64/bindings.rs | 13 +- ebpf/aya-ebpf-bindings/src/mips/bindings.rs | 13 +- .../src/powerpc64/bindings.rs | 13 +- .../aya-ebpf-bindings/src/riscv64/bindings.rs | 13 +- ebpf/aya-ebpf-bindings/src/s390x/bindings.rs | 13 +- ebpf/aya-ebpf-bindings/src/x86_64/bindings.rs | 13 +- ebpf/aya-ebpf/src/programs/perf_event.rs | 8 +- test/integration-ebpf/Cargo.toml | 4 + test/integration-ebpf/src/perf_event_bp.rs | 24 ++ test/integration-test/src/lib.rs | 1 + test/integration-test/src/tests.rs | 1 + .../src/tests/perf_event_bp.rs | 320 ++++++++++++++++++ xtask/public-api/aya-ebpf-bindings.txt | 4 + xtask/public-api/aya-ebpf.txt | 6 +- xtask/public-api/aya-obj.txt | 124 ++++--- xtask/public-api/aya.txt | 119 ++++++- xtask/src/codegen/aya.rs | 3 + xtask/src/run.rs | 166 +++++++-- 34 files changed, 1457 insertions(+), 590 deletions(-) create mode 100644 test/integration-ebpf/src/perf_event_bp.rs create mode 100644 test/integration-test/src/tests/perf_event_bp.rs diff --git a/.github/scripts/download_kernel_images.sh b/.github/scripts/download_kernel_images.sh index da827460..7868953f 100755 --- a/.github/scripts/download_kernel_images.sh +++ b/.github/scripts/download_kernel_images.sh @@ -8,6 +8,12 @@ if [ "$#" -lt 3 ]; then exit 1 fi +escape_regex() { + # Escape characters that have special meaning in extended regular expressions so that + # we can safely interpolate package names into grep patterns. + printf '%s\n' "$1" | sed 's/[][(){}.^$*+?|\\-]/\\&/g' +} + OUTPUT_DIR=$1 ARCHITECTURE=$2 shift 2 @@ -25,6 +31,25 @@ for VERSION in "${VERSIONS[@]}"; do exit 1 } FILES+=("$match") + + # The debug package contains the actual System.map. Debian has transitioned + # between -dbg and -dbgsym suffixes, so match either for the specific kernel + # we just selected. + kernel_basename=$(basename "$match") + kernel_prefix=${kernel_basename%%_*} + kernel_suffix=${kernel_basename#${kernel_prefix}_} + base_prefix=${kernel_prefix%-unsigned} + + base_prefix_regex=$(escape_regex "$base_prefix") + kernel_suffix_regex=$(escape_regex "$kernel_suffix") + + DEBUG_REGEX="${base_prefix_regex}-dbg(sym)?_${kernel_suffix_regex}" + debug_match=$(printf '%s\n' "$URLS" | grep -E "$DEBUG_REGEX" | sort -V | tail -n1) || { + printf 'Failed to locate debug package matching %s\n%s\nVERSION=%s\nREGEX=%s\n' \ + "$kernel_basename" "$URLS" "$VERSION" "$DEBUG_REGEX" >&2 + exit 1 + } + FILES+=("$debug_match") done # Note: `--etag-{compare,save}` are not idempotent until curl 8.9.0 which included diff --git a/aya-ebpf-macros/src/perf_event.rs b/aya-ebpf-macros/src/perf_event.rs index 6b693f5a..1575495a 100644 --- a/aya-ebpf-macros/src/perf_event.rs +++ b/aya-ebpf-macros/src/perf_event.rs @@ -29,7 +29,7 @@ impl PerfEvent { #[unsafe(no_mangle)] #[unsafe(link_section = "perf_event")] #vis fn #fn_name(ctx: *mut ::core::ffi::c_void) -> u32 { - let _ = #fn_name(::aya_ebpf::programs::PerfEventContext::new(ctx)); + let _ = #fn_name(::aya_ebpf::programs::PerfEventContext::new(ctx.cast())); return 0; #item @@ -60,7 +60,7 @@ mod tests { #[unsafe(no_mangle)] #[unsafe(link_section = "perf_event")] fn foo(ctx: *mut ::core::ffi::c_void) -> u32 { - let _ = foo(::aya_ebpf::programs::PerfEventContext::new(ctx)); + let _ = foo(::aya_ebpf::programs::PerfEventContext::new(ctx.cast())); return 0; fn foo(ctx: PerfEventContext) -> i32 { diff --git a/aya-obj/include/linux_wrapper.h b/aya-obj/include/linux_wrapper.h index fe9498f8..9123cf02 100644 --- a/aya-obj/include/linux_wrapper.h +++ b/aya-obj/include/linux_wrapper.h @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/aya-obj/src/generated/linux_bindings_aarch64.rs b/aya-obj/src/generated/linux_bindings_aarch64.rs index b76ed850..aff50e13 100644 --- a/aya-obj/src/generated/linux_bindings_aarch64.rs +++ b/aya-obj/src/generated/linux_bindings_aarch64.rs @@ -2105,6 +2105,22 @@ pub struct btf_var_secinfo { pub struct btf_decl_tag { pub component_idx: __s32, } +pub const HW_BREAKPOINT_LEN_1: _bindgen_ty_44 = 1; +pub const HW_BREAKPOINT_LEN_2: _bindgen_ty_44 = 2; +pub const HW_BREAKPOINT_LEN_3: _bindgen_ty_44 = 3; +pub const HW_BREAKPOINT_LEN_4: _bindgen_ty_44 = 4; +pub const HW_BREAKPOINT_LEN_5: _bindgen_ty_44 = 5; +pub const HW_BREAKPOINT_LEN_6: _bindgen_ty_44 = 6; +pub const HW_BREAKPOINT_LEN_7: _bindgen_ty_44 = 7; +pub const HW_BREAKPOINT_LEN_8: _bindgen_ty_44 = 8; +pub type _bindgen_ty_44 = ::core::ffi::c_uint; +pub const HW_BREAKPOINT_EMPTY: _bindgen_ty_45 = 0; +pub const HW_BREAKPOINT_R: _bindgen_ty_45 = 1; +pub const HW_BREAKPOINT_W: _bindgen_ty_45 = 2; +pub const HW_BREAKPOINT_RW: _bindgen_ty_45 = 3; +pub const HW_BREAKPOINT_X: _bindgen_ty_45 = 4; +pub const HW_BREAKPOINT_INVALID: _bindgen_ty_45 = 7; +pub type _bindgen_ty_45 = ::core::ffi::c_uint; impl nlmsgerr_attrs { pub const NLMSGERR_ATTR_MAX: nlmsgerr_attrs = nlmsgerr_attrs::NLMSGERR_ATTR_COOKIE; } @@ -2117,17 +2133,17 @@ pub enum nlmsgerr_attrs { NLMSGERR_ATTR_COOKIE = 3, __NLMSGERR_ATTR_MAX = 4, } -pub const IFLA_XDP_UNSPEC: _bindgen_ty_92 = 0; -pub const IFLA_XDP_FD: _bindgen_ty_92 = 1; -pub const IFLA_XDP_ATTACHED: _bindgen_ty_92 = 2; -pub const IFLA_XDP_FLAGS: _bindgen_ty_92 = 3; -pub const IFLA_XDP_PROG_ID: _bindgen_ty_92 = 4; -pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_92 = 5; -pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_92 = 6; -pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_92 = 7; -pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_92 = 8; -pub const __IFLA_XDP_MAX: _bindgen_ty_92 = 9; -pub type _bindgen_ty_92 = ::core::ffi::c_uint; +pub const IFLA_XDP_UNSPEC: _bindgen_ty_94 = 0; +pub const IFLA_XDP_FD: _bindgen_ty_94 = 1; +pub const IFLA_XDP_ATTACHED: _bindgen_ty_94 = 2; +pub const IFLA_XDP_FLAGS: _bindgen_ty_94 = 3; +pub const IFLA_XDP_PROG_ID: _bindgen_ty_94 = 4; +pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_94 = 5; +pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_94 = 6; +pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_94 = 7; +pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_94 = 8; +pub const __IFLA_XDP_MAX: _bindgen_ty_94 = 9; +pub type _bindgen_ty_94 = ::core::ffi::c_uint; impl nf_inet_hooks { pub const NF_INET_INGRESS: nf_inet_hooks = nf_inet_hooks::NF_INET_NUMHOOKS; } @@ -2141,16 +2157,16 @@ pub enum nf_inet_hooks { NF_INET_POST_ROUTING = 4, NF_INET_NUMHOOKS = 5, } -pub const NFPROTO_UNSPEC: _bindgen_ty_99 = 0; -pub const NFPROTO_INET: _bindgen_ty_99 = 1; -pub const NFPROTO_IPV4: _bindgen_ty_99 = 2; -pub const NFPROTO_ARP: _bindgen_ty_99 = 3; -pub const NFPROTO_NETDEV: _bindgen_ty_99 = 5; -pub const NFPROTO_BRIDGE: _bindgen_ty_99 = 7; -pub const NFPROTO_IPV6: _bindgen_ty_99 = 10; -pub const NFPROTO_DECNET: _bindgen_ty_99 = 12; -pub const NFPROTO_NUMPROTO: _bindgen_ty_99 = 13; -pub type _bindgen_ty_99 = ::core::ffi::c_uint; +pub const NFPROTO_UNSPEC: _bindgen_ty_101 = 0; +pub const NFPROTO_INET: _bindgen_ty_101 = 1; +pub const NFPROTO_IPV4: _bindgen_ty_101 = 2; +pub const NFPROTO_ARP: _bindgen_ty_101 = 3; +pub const NFPROTO_NETDEV: _bindgen_ty_101 = 5; +pub const NFPROTO_BRIDGE: _bindgen_ty_101 = 7; +pub const NFPROTO_IPV6: _bindgen_ty_101 = 10; +pub const NFPROTO_DECNET: _bindgen_ty_101 = 12; +pub const NFPROTO_NUMPROTO: _bindgen_ty_101 = 13; +pub type _bindgen_ty_101 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum perf_type_id { @@ -4111,20 +4127,20 @@ pub enum perf_event_type { PERF_RECORD_AUX_OUTPUT_HW_ID = 21, PERF_RECORD_MAX = 22, } -pub const TCA_BPF_UNSPEC: _bindgen_ty_154 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_154 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_154 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_154 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_154 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_154 = 5; -pub const TCA_BPF_FD: _bindgen_ty_154 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_154 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_154 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_154 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_154 = 10; -pub const TCA_BPF_ID: _bindgen_ty_154 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_154 = 12; -pub type _bindgen_ty_154 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; +pub const TCA_BPF_FD: _bindgen_ty_156 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; +pub const TCA_BPF_ID: _bindgen_ty_156 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; +pub type _bindgen_ty_156 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { @@ -4146,22 +4162,22 @@ pub struct tcmsg { pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_174 = 0; -pub const TCA_KIND: _bindgen_ty_174 = 1; -pub const TCA_OPTIONS: _bindgen_ty_174 = 2; -pub const TCA_STATS: _bindgen_ty_174 = 3; -pub const TCA_XSTATS: _bindgen_ty_174 = 4; -pub const TCA_RATE: _bindgen_ty_174 = 5; -pub const TCA_FCNT: _bindgen_ty_174 = 6; -pub const TCA_STATS2: _bindgen_ty_174 = 7; -pub const TCA_STAB: _bindgen_ty_174 = 8; -pub const TCA_PAD: _bindgen_ty_174 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_174 = 10; -pub const TCA_CHAIN: _bindgen_ty_174 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_174 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_174 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_174 = 14; -pub const TCA_DUMP_FLAGS: _bindgen_ty_174 = 15; -pub const TCA_EXT_WARN_MSG: _bindgen_ty_174 = 16; -pub const __TCA_MAX: _bindgen_ty_174 = 17; -pub type _bindgen_ty_174 = ::core::ffi::c_uint; +pub const TCA_UNSPEC: _bindgen_ty_176 = 0; +pub const TCA_KIND: _bindgen_ty_176 = 1; +pub const TCA_OPTIONS: _bindgen_ty_176 = 2; +pub const TCA_STATS: _bindgen_ty_176 = 3; +pub const TCA_XSTATS: _bindgen_ty_176 = 4; +pub const TCA_RATE: _bindgen_ty_176 = 5; +pub const TCA_FCNT: _bindgen_ty_176 = 6; +pub const TCA_STATS2: _bindgen_ty_176 = 7; +pub const TCA_STAB: _bindgen_ty_176 = 8; +pub const TCA_PAD: _bindgen_ty_176 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_176 = 10; +pub const TCA_CHAIN: _bindgen_ty_176 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_176 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_176 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_176 = 14; +pub const TCA_DUMP_FLAGS: _bindgen_ty_176 = 15; +pub const TCA_EXT_WARN_MSG: _bindgen_ty_176 = 16; +pub const __TCA_MAX: _bindgen_ty_176 = 17; +pub type _bindgen_ty_176 = ::core::ffi::c_uint; diff --git a/aya-obj/src/generated/linux_bindings_armv7.rs b/aya-obj/src/generated/linux_bindings_armv7.rs index 08b3a162..ae0a1da4 100644 --- a/aya-obj/src/generated/linux_bindings_armv7.rs +++ b/aya-obj/src/generated/linux_bindings_armv7.rs @@ -2105,6 +2105,22 @@ pub struct btf_var_secinfo { pub struct btf_decl_tag { pub component_idx: __s32, } +pub const HW_BREAKPOINT_LEN_1: _bindgen_ty_44 = 1; +pub const HW_BREAKPOINT_LEN_2: _bindgen_ty_44 = 2; +pub const HW_BREAKPOINT_LEN_3: _bindgen_ty_44 = 3; +pub const HW_BREAKPOINT_LEN_4: _bindgen_ty_44 = 4; +pub const HW_BREAKPOINT_LEN_5: _bindgen_ty_44 = 5; +pub const HW_BREAKPOINT_LEN_6: _bindgen_ty_44 = 6; +pub const HW_BREAKPOINT_LEN_7: _bindgen_ty_44 = 7; +pub const HW_BREAKPOINT_LEN_8: _bindgen_ty_44 = 8; +pub type _bindgen_ty_44 = ::core::ffi::c_uint; +pub const HW_BREAKPOINT_EMPTY: _bindgen_ty_45 = 0; +pub const HW_BREAKPOINT_R: _bindgen_ty_45 = 1; +pub const HW_BREAKPOINT_W: _bindgen_ty_45 = 2; +pub const HW_BREAKPOINT_RW: _bindgen_ty_45 = 3; +pub const HW_BREAKPOINT_X: _bindgen_ty_45 = 4; +pub const HW_BREAKPOINT_INVALID: _bindgen_ty_45 = 7; +pub type _bindgen_ty_45 = ::core::ffi::c_uint; impl nlmsgerr_attrs { pub const NLMSGERR_ATTR_MAX: nlmsgerr_attrs = nlmsgerr_attrs::NLMSGERR_ATTR_COOKIE; } @@ -2117,17 +2133,17 @@ pub enum nlmsgerr_attrs { NLMSGERR_ATTR_COOKIE = 3, __NLMSGERR_ATTR_MAX = 4, } -pub const IFLA_XDP_UNSPEC: _bindgen_ty_92 = 0; -pub const IFLA_XDP_FD: _bindgen_ty_92 = 1; -pub const IFLA_XDP_ATTACHED: _bindgen_ty_92 = 2; -pub const IFLA_XDP_FLAGS: _bindgen_ty_92 = 3; -pub const IFLA_XDP_PROG_ID: _bindgen_ty_92 = 4; -pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_92 = 5; -pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_92 = 6; -pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_92 = 7; -pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_92 = 8; -pub const __IFLA_XDP_MAX: _bindgen_ty_92 = 9; -pub type _bindgen_ty_92 = ::core::ffi::c_uint; +pub const IFLA_XDP_UNSPEC: _bindgen_ty_94 = 0; +pub const IFLA_XDP_FD: _bindgen_ty_94 = 1; +pub const IFLA_XDP_ATTACHED: _bindgen_ty_94 = 2; +pub const IFLA_XDP_FLAGS: _bindgen_ty_94 = 3; +pub const IFLA_XDP_PROG_ID: _bindgen_ty_94 = 4; +pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_94 = 5; +pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_94 = 6; +pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_94 = 7; +pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_94 = 8; +pub const __IFLA_XDP_MAX: _bindgen_ty_94 = 9; +pub type _bindgen_ty_94 = ::core::ffi::c_uint; impl nf_inet_hooks { pub const NF_INET_INGRESS: nf_inet_hooks = nf_inet_hooks::NF_INET_NUMHOOKS; } @@ -2141,16 +2157,16 @@ pub enum nf_inet_hooks { NF_INET_POST_ROUTING = 4, NF_INET_NUMHOOKS = 5, } -pub const NFPROTO_UNSPEC: _bindgen_ty_99 = 0; -pub const NFPROTO_INET: _bindgen_ty_99 = 1; -pub const NFPROTO_IPV4: _bindgen_ty_99 = 2; -pub const NFPROTO_ARP: _bindgen_ty_99 = 3; -pub const NFPROTO_NETDEV: _bindgen_ty_99 = 5; -pub const NFPROTO_BRIDGE: _bindgen_ty_99 = 7; -pub const NFPROTO_IPV6: _bindgen_ty_99 = 10; -pub const NFPROTO_DECNET: _bindgen_ty_99 = 12; -pub const NFPROTO_NUMPROTO: _bindgen_ty_99 = 13; -pub type _bindgen_ty_99 = ::core::ffi::c_uint; +pub const NFPROTO_UNSPEC: _bindgen_ty_101 = 0; +pub const NFPROTO_INET: _bindgen_ty_101 = 1; +pub const NFPROTO_IPV4: _bindgen_ty_101 = 2; +pub const NFPROTO_ARP: _bindgen_ty_101 = 3; +pub const NFPROTO_NETDEV: _bindgen_ty_101 = 5; +pub const NFPROTO_BRIDGE: _bindgen_ty_101 = 7; +pub const NFPROTO_IPV6: _bindgen_ty_101 = 10; +pub const NFPROTO_DECNET: _bindgen_ty_101 = 12; +pub const NFPROTO_NUMPROTO: _bindgen_ty_101 = 13; +pub type _bindgen_ty_101 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum perf_type_id { @@ -4111,20 +4127,20 @@ pub enum perf_event_type { PERF_RECORD_AUX_OUTPUT_HW_ID = 21, PERF_RECORD_MAX = 22, } -pub const TCA_BPF_UNSPEC: _bindgen_ty_154 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_154 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_154 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_154 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_154 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_154 = 5; -pub const TCA_BPF_FD: _bindgen_ty_154 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_154 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_154 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_154 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_154 = 10; -pub const TCA_BPF_ID: _bindgen_ty_154 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_154 = 12; -pub type _bindgen_ty_154 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; +pub const TCA_BPF_FD: _bindgen_ty_156 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; +pub const TCA_BPF_ID: _bindgen_ty_156 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; +pub type _bindgen_ty_156 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { @@ -4146,22 +4162,22 @@ pub struct tcmsg { pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_174 = 0; -pub const TCA_KIND: _bindgen_ty_174 = 1; -pub const TCA_OPTIONS: _bindgen_ty_174 = 2; -pub const TCA_STATS: _bindgen_ty_174 = 3; -pub const TCA_XSTATS: _bindgen_ty_174 = 4; -pub const TCA_RATE: _bindgen_ty_174 = 5; -pub const TCA_FCNT: _bindgen_ty_174 = 6; -pub const TCA_STATS2: _bindgen_ty_174 = 7; -pub const TCA_STAB: _bindgen_ty_174 = 8; -pub const TCA_PAD: _bindgen_ty_174 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_174 = 10; -pub const TCA_CHAIN: _bindgen_ty_174 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_174 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_174 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_174 = 14; -pub const TCA_DUMP_FLAGS: _bindgen_ty_174 = 15; -pub const TCA_EXT_WARN_MSG: _bindgen_ty_174 = 16; -pub const __TCA_MAX: _bindgen_ty_174 = 17; -pub type _bindgen_ty_174 = ::core::ffi::c_uint; +pub const TCA_UNSPEC: _bindgen_ty_176 = 0; +pub const TCA_KIND: _bindgen_ty_176 = 1; +pub const TCA_OPTIONS: _bindgen_ty_176 = 2; +pub const TCA_STATS: _bindgen_ty_176 = 3; +pub const TCA_XSTATS: _bindgen_ty_176 = 4; +pub const TCA_RATE: _bindgen_ty_176 = 5; +pub const TCA_FCNT: _bindgen_ty_176 = 6; +pub const TCA_STATS2: _bindgen_ty_176 = 7; +pub const TCA_STAB: _bindgen_ty_176 = 8; +pub const TCA_PAD: _bindgen_ty_176 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_176 = 10; +pub const TCA_CHAIN: _bindgen_ty_176 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_176 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_176 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_176 = 14; +pub const TCA_DUMP_FLAGS: _bindgen_ty_176 = 15; +pub const TCA_EXT_WARN_MSG: _bindgen_ty_176 = 16; +pub const __TCA_MAX: _bindgen_ty_176 = 17; +pub type _bindgen_ty_176 = ::core::ffi::c_uint; diff --git a/aya-obj/src/generated/linux_bindings_loongarch64.rs b/aya-obj/src/generated/linux_bindings_loongarch64.rs index b76ed850..aff50e13 100644 --- a/aya-obj/src/generated/linux_bindings_loongarch64.rs +++ b/aya-obj/src/generated/linux_bindings_loongarch64.rs @@ -2105,6 +2105,22 @@ pub struct btf_var_secinfo { pub struct btf_decl_tag { pub component_idx: __s32, } +pub const HW_BREAKPOINT_LEN_1: _bindgen_ty_44 = 1; +pub const HW_BREAKPOINT_LEN_2: _bindgen_ty_44 = 2; +pub const HW_BREAKPOINT_LEN_3: _bindgen_ty_44 = 3; +pub const HW_BREAKPOINT_LEN_4: _bindgen_ty_44 = 4; +pub const HW_BREAKPOINT_LEN_5: _bindgen_ty_44 = 5; +pub const HW_BREAKPOINT_LEN_6: _bindgen_ty_44 = 6; +pub const HW_BREAKPOINT_LEN_7: _bindgen_ty_44 = 7; +pub const HW_BREAKPOINT_LEN_8: _bindgen_ty_44 = 8; +pub type _bindgen_ty_44 = ::core::ffi::c_uint; +pub const HW_BREAKPOINT_EMPTY: _bindgen_ty_45 = 0; +pub const HW_BREAKPOINT_R: _bindgen_ty_45 = 1; +pub const HW_BREAKPOINT_W: _bindgen_ty_45 = 2; +pub const HW_BREAKPOINT_RW: _bindgen_ty_45 = 3; +pub const HW_BREAKPOINT_X: _bindgen_ty_45 = 4; +pub const HW_BREAKPOINT_INVALID: _bindgen_ty_45 = 7; +pub type _bindgen_ty_45 = ::core::ffi::c_uint; impl nlmsgerr_attrs { pub const NLMSGERR_ATTR_MAX: nlmsgerr_attrs = nlmsgerr_attrs::NLMSGERR_ATTR_COOKIE; } @@ -2117,17 +2133,17 @@ pub enum nlmsgerr_attrs { NLMSGERR_ATTR_COOKIE = 3, __NLMSGERR_ATTR_MAX = 4, } -pub const IFLA_XDP_UNSPEC: _bindgen_ty_92 = 0; -pub const IFLA_XDP_FD: _bindgen_ty_92 = 1; -pub const IFLA_XDP_ATTACHED: _bindgen_ty_92 = 2; -pub const IFLA_XDP_FLAGS: _bindgen_ty_92 = 3; -pub const IFLA_XDP_PROG_ID: _bindgen_ty_92 = 4; -pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_92 = 5; -pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_92 = 6; -pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_92 = 7; -pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_92 = 8; -pub const __IFLA_XDP_MAX: _bindgen_ty_92 = 9; -pub type _bindgen_ty_92 = ::core::ffi::c_uint; +pub const IFLA_XDP_UNSPEC: _bindgen_ty_94 = 0; +pub const IFLA_XDP_FD: _bindgen_ty_94 = 1; +pub const IFLA_XDP_ATTACHED: _bindgen_ty_94 = 2; +pub const IFLA_XDP_FLAGS: _bindgen_ty_94 = 3; +pub const IFLA_XDP_PROG_ID: _bindgen_ty_94 = 4; +pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_94 = 5; +pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_94 = 6; +pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_94 = 7; +pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_94 = 8; +pub const __IFLA_XDP_MAX: _bindgen_ty_94 = 9; +pub type _bindgen_ty_94 = ::core::ffi::c_uint; impl nf_inet_hooks { pub const NF_INET_INGRESS: nf_inet_hooks = nf_inet_hooks::NF_INET_NUMHOOKS; } @@ -2141,16 +2157,16 @@ pub enum nf_inet_hooks { NF_INET_POST_ROUTING = 4, NF_INET_NUMHOOKS = 5, } -pub const NFPROTO_UNSPEC: _bindgen_ty_99 = 0; -pub const NFPROTO_INET: _bindgen_ty_99 = 1; -pub const NFPROTO_IPV4: _bindgen_ty_99 = 2; -pub const NFPROTO_ARP: _bindgen_ty_99 = 3; -pub const NFPROTO_NETDEV: _bindgen_ty_99 = 5; -pub const NFPROTO_BRIDGE: _bindgen_ty_99 = 7; -pub const NFPROTO_IPV6: _bindgen_ty_99 = 10; -pub const NFPROTO_DECNET: _bindgen_ty_99 = 12; -pub const NFPROTO_NUMPROTO: _bindgen_ty_99 = 13; -pub type _bindgen_ty_99 = ::core::ffi::c_uint; +pub const NFPROTO_UNSPEC: _bindgen_ty_101 = 0; +pub const NFPROTO_INET: _bindgen_ty_101 = 1; +pub const NFPROTO_IPV4: _bindgen_ty_101 = 2; +pub const NFPROTO_ARP: _bindgen_ty_101 = 3; +pub const NFPROTO_NETDEV: _bindgen_ty_101 = 5; +pub const NFPROTO_BRIDGE: _bindgen_ty_101 = 7; +pub const NFPROTO_IPV6: _bindgen_ty_101 = 10; +pub const NFPROTO_DECNET: _bindgen_ty_101 = 12; +pub const NFPROTO_NUMPROTO: _bindgen_ty_101 = 13; +pub type _bindgen_ty_101 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum perf_type_id { @@ -4111,20 +4127,20 @@ pub enum perf_event_type { PERF_RECORD_AUX_OUTPUT_HW_ID = 21, PERF_RECORD_MAX = 22, } -pub const TCA_BPF_UNSPEC: _bindgen_ty_154 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_154 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_154 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_154 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_154 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_154 = 5; -pub const TCA_BPF_FD: _bindgen_ty_154 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_154 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_154 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_154 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_154 = 10; -pub const TCA_BPF_ID: _bindgen_ty_154 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_154 = 12; -pub type _bindgen_ty_154 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; +pub const TCA_BPF_FD: _bindgen_ty_156 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; +pub const TCA_BPF_ID: _bindgen_ty_156 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; +pub type _bindgen_ty_156 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { @@ -4146,22 +4162,22 @@ pub struct tcmsg { pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_174 = 0; -pub const TCA_KIND: _bindgen_ty_174 = 1; -pub const TCA_OPTIONS: _bindgen_ty_174 = 2; -pub const TCA_STATS: _bindgen_ty_174 = 3; -pub const TCA_XSTATS: _bindgen_ty_174 = 4; -pub const TCA_RATE: _bindgen_ty_174 = 5; -pub const TCA_FCNT: _bindgen_ty_174 = 6; -pub const TCA_STATS2: _bindgen_ty_174 = 7; -pub const TCA_STAB: _bindgen_ty_174 = 8; -pub const TCA_PAD: _bindgen_ty_174 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_174 = 10; -pub const TCA_CHAIN: _bindgen_ty_174 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_174 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_174 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_174 = 14; -pub const TCA_DUMP_FLAGS: _bindgen_ty_174 = 15; -pub const TCA_EXT_WARN_MSG: _bindgen_ty_174 = 16; -pub const __TCA_MAX: _bindgen_ty_174 = 17; -pub type _bindgen_ty_174 = ::core::ffi::c_uint; +pub const TCA_UNSPEC: _bindgen_ty_176 = 0; +pub const TCA_KIND: _bindgen_ty_176 = 1; +pub const TCA_OPTIONS: _bindgen_ty_176 = 2; +pub const TCA_STATS: _bindgen_ty_176 = 3; +pub const TCA_XSTATS: _bindgen_ty_176 = 4; +pub const TCA_RATE: _bindgen_ty_176 = 5; +pub const TCA_FCNT: _bindgen_ty_176 = 6; +pub const TCA_STATS2: _bindgen_ty_176 = 7; +pub const TCA_STAB: _bindgen_ty_176 = 8; +pub const TCA_PAD: _bindgen_ty_176 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_176 = 10; +pub const TCA_CHAIN: _bindgen_ty_176 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_176 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_176 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_176 = 14; +pub const TCA_DUMP_FLAGS: _bindgen_ty_176 = 15; +pub const TCA_EXT_WARN_MSG: _bindgen_ty_176 = 16; +pub const __TCA_MAX: _bindgen_ty_176 = 17; +pub type _bindgen_ty_176 = ::core::ffi::c_uint; diff --git a/aya-obj/src/generated/linux_bindings_mips.rs b/aya-obj/src/generated/linux_bindings_mips.rs index 349653d7..f3ae9b95 100644 --- a/aya-obj/src/generated/linux_bindings_mips.rs +++ b/aya-obj/src/generated/linux_bindings_mips.rs @@ -2105,6 +2105,22 @@ pub struct btf_var_secinfo { pub struct btf_decl_tag { pub component_idx: __s32, } +pub const HW_BREAKPOINT_LEN_1: _bindgen_ty_44 = 1; +pub const HW_BREAKPOINT_LEN_2: _bindgen_ty_44 = 2; +pub const HW_BREAKPOINT_LEN_3: _bindgen_ty_44 = 3; +pub const HW_BREAKPOINT_LEN_4: _bindgen_ty_44 = 4; +pub const HW_BREAKPOINT_LEN_5: _bindgen_ty_44 = 5; +pub const HW_BREAKPOINT_LEN_6: _bindgen_ty_44 = 6; +pub const HW_BREAKPOINT_LEN_7: _bindgen_ty_44 = 7; +pub const HW_BREAKPOINT_LEN_8: _bindgen_ty_44 = 8; +pub type _bindgen_ty_44 = ::core::ffi::c_uint; +pub const HW_BREAKPOINT_EMPTY: _bindgen_ty_45 = 0; +pub const HW_BREAKPOINT_R: _bindgen_ty_45 = 1; +pub const HW_BREAKPOINT_W: _bindgen_ty_45 = 2; +pub const HW_BREAKPOINT_RW: _bindgen_ty_45 = 3; +pub const HW_BREAKPOINT_X: _bindgen_ty_45 = 4; +pub const HW_BREAKPOINT_INVALID: _bindgen_ty_45 = 7; +pub type _bindgen_ty_45 = ::core::ffi::c_uint; impl nlmsgerr_attrs { pub const NLMSGERR_ATTR_MAX: nlmsgerr_attrs = nlmsgerr_attrs::NLMSGERR_ATTR_COOKIE; } @@ -2117,17 +2133,17 @@ pub enum nlmsgerr_attrs { NLMSGERR_ATTR_COOKIE = 3, __NLMSGERR_ATTR_MAX = 4, } -pub const IFLA_XDP_UNSPEC: _bindgen_ty_92 = 0; -pub const IFLA_XDP_FD: _bindgen_ty_92 = 1; -pub const IFLA_XDP_ATTACHED: _bindgen_ty_92 = 2; -pub const IFLA_XDP_FLAGS: _bindgen_ty_92 = 3; -pub const IFLA_XDP_PROG_ID: _bindgen_ty_92 = 4; -pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_92 = 5; -pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_92 = 6; -pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_92 = 7; -pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_92 = 8; -pub const __IFLA_XDP_MAX: _bindgen_ty_92 = 9; -pub type _bindgen_ty_92 = ::core::ffi::c_uint; +pub const IFLA_XDP_UNSPEC: _bindgen_ty_94 = 0; +pub const IFLA_XDP_FD: _bindgen_ty_94 = 1; +pub const IFLA_XDP_ATTACHED: _bindgen_ty_94 = 2; +pub const IFLA_XDP_FLAGS: _bindgen_ty_94 = 3; +pub const IFLA_XDP_PROG_ID: _bindgen_ty_94 = 4; +pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_94 = 5; +pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_94 = 6; +pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_94 = 7; +pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_94 = 8; +pub const __IFLA_XDP_MAX: _bindgen_ty_94 = 9; +pub type _bindgen_ty_94 = ::core::ffi::c_uint; impl nf_inet_hooks { pub const NF_INET_INGRESS: nf_inet_hooks = nf_inet_hooks::NF_INET_NUMHOOKS; } @@ -2141,16 +2157,16 @@ pub enum nf_inet_hooks { NF_INET_POST_ROUTING = 4, NF_INET_NUMHOOKS = 5, } -pub const NFPROTO_UNSPEC: _bindgen_ty_99 = 0; -pub const NFPROTO_INET: _bindgen_ty_99 = 1; -pub const NFPROTO_IPV4: _bindgen_ty_99 = 2; -pub const NFPROTO_ARP: _bindgen_ty_99 = 3; -pub const NFPROTO_NETDEV: _bindgen_ty_99 = 5; -pub const NFPROTO_BRIDGE: _bindgen_ty_99 = 7; -pub const NFPROTO_IPV6: _bindgen_ty_99 = 10; -pub const NFPROTO_DECNET: _bindgen_ty_99 = 12; -pub const NFPROTO_NUMPROTO: _bindgen_ty_99 = 13; -pub type _bindgen_ty_99 = ::core::ffi::c_uint; +pub const NFPROTO_UNSPEC: _bindgen_ty_101 = 0; +pub const NFPROTO_INET: _bindgen_ty_101 = 1; +pub const NFPROTO_IPV4: _bindgen_ty_101 = 2; +pub const NFPROTO_ARP: _bindgen_ty_101 = 3; +pub const NFPROTO_NETDEV: _bindgen_ty_101 = 5; +pub const NFPROTO_BRIDGE: _bindgen_ty_101 = 7; +pub const NFPROTO_IPV6: _bindgen_ty_101 = 10; +pub const NFPROTO_DECNET: _bindgen_ty_101 = 12; +pub const NFPROTO_NUMPROTO: _bindgen_ty_101 = 13; +pub type _bindgen_ty_101 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum perf_type_id { @@ -4111,20 +4127,20 @@ pub enum perf_event_type { PERF_RECORD_AUX_OUTPUT_HW_ID = 21, PERF_RECORD_MAX = 22, } -pub const TCA_BPF_UNSPEC: _bindgen_ty_154 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_154 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_154 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_154 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_154 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_154 = 5; -pub const TCA_BPF_FD: _bindgen_ty_154 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_154 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_154 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_154 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_154 = 10; -pub const TCA_BPF_ID: _bindgen_ty_154 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_154 = 12; -pub type _bindgen_ty_154 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; +pub const TCA_BPF_FD: _bindgen_ty_156 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; +pub const TCA_BPF_ID: _bindgen_ty_156 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; +pub type _bindgen_ty_156 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { @@ -4146,22 +4162,22 @@ pub struct tcmsg { pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_174 = 0; -pub const TCA_KIND: _bindgen_ty_174 = 1; -pub const TCA_OPTIONS: _bindgen_ty_174 = 2; -pub const TCA_STATS: _bindgen_ty_174 = 3; -pub const TCA_XSTATS: _bindgen_ty_174 = 4; -pub const TCA_RATE: _bindgen_ty_174 = 5; -pub const TCA_FCNT: _bindgen_ty_174 = 6; -pub const TCA_STATS2: _bindgen_ty_174 = 7; -pub const TCA_STAB: _bindgen_ty_174 = 8; -pub const TCA_PAD: _bindgen_ty_174 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_174 = 10; -pub const TCA_CHAIN: _bindgen_ty_174 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_174 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_174 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_174 = 14; -pub const TCA_DUMP_FLAGS: _bindgen_ty_174 = 15; -pub const TCA_EXT_WARN_MSG: _bindgen_ty_174 = 16; -pub const __TCA_MAX: _bindgen_ty_174 = 17; -pub type _bindgen_ty_174 = ::core::ffi::c_uint; +pub const TCA_UNSPEC: _bindgen_ty_176 = 0; +pub const TCA_KIND: _bindgen_ty_176 = 1; +pub const TCA_OPTIONS: _bindgen_ty_176 = 2; +pub const TCA_STATS: _bindgen_ty_176 = 3; +pub const TCA_XSTATS: _bindgen_ty_176 = 4; +pub const TCA_RATE: _bindgen_ty_176 = 5; +pub const TCA_FCNT: _bindgen_ty_176 = 6; +pub const TCA_STATS2: _bindgen_ty_176 = 7; +pub const TCA_STAB: _bindgen_ty_176 = 8; +pub const TCA_PAD: _bindgen_ty_176 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_176 = 10; +pub const TCA_CHAIN: _bindgen_ty_176 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_176 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_176 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_176 = 14; +pub const TCA_DUMP_FLAGS: _bindgen_ty_176 = 15; +pub const TCA_EXT_WARN_MSG: _bindgen_ty_176 = 16; +pub const __TCA_MAX: _bindgen_ty_176 = 17; +pub type _bindgen_ty_176 = ::core::ffi::c_uint; diff --git a/aya-obj/src/generated/linux_bindings_powerpc64.rs b/aya-obj/src/generated/linux_bindings_powerpc64.rs index 50d01b86..7d8294f7 100644 --- a/aya-obj/src/generated/linux_bindings_powerpc64.rs +++ b/aya-obj/src/generated/linux_bindings_powerpc64.rs @@ -2105,6 +2105,22 @@ pub struct btf_var_secinfo { pub struct btf_decl_tag { pub component_idx: __s32, } +pub const HW_BREAKPOINT_LEN_1: _bindgen_ty_44 = 1; +pub const HW_BREAKPOINT_LEN_2: _bindgen_ty_44 = 2; +pub const HW_BREAKPOINT_LEN_3: _bindgen_ty_44 = 3; +pub const HW_BREAKPOINT_LEN_4: _bindgen_ty_44 = 4; +pub const HW_BREAKPOINT_LEN_5: _bindgen_ty_44 = 5; +pub const HW_BREAKPOINT_LEN_6: _bindgen_ty_44 = 6; +pub const HW_BREAKPOINT_LEN_7: _bindgen_ty_44 = 7; +pub const HW_BREAKPOINT_LEN_8: _bindgen_ty_44 = 8; +pub type _bindgen_ty_44 = ::core::ffi::c_uint; +pub const HW_BREAKPOINT_EMPTY: _bindgen_ty_45 = 0; +pub const HW_BREAKPOINT_R: _bindgen_ty_45 = 1; +pub const HW_BREAKPOINT_W: _bindgen_ty_45 = 2; +pub const HW_BREAKPOINT_RW: _bindgen_ty_45 = 3; +pub const HW_BREAKPOINT_X: _bindgen_ty_45 = 4; +pub const HW_BREAKPOINT_INVALID: _bindgen_ty_45 = 7; +pub type _bindgen_ty_45 = ::core::ffi::c_uint; impl nlmsgerr_attrs { pub const NLMSGERR_ATTR_MAX: nlmsgerr_attrs = nlmsgerr_attrs::NLMSGERR_ATTR_COOKIE; } @@ -2117,17 +2133,17 @@ pub enum nlmsgerr_attrs { NLMSGERR_ATTR_COOKIE = 3, __NLMSGERR_ATTR_MAX = 4, } -pub const IFLA_XDP_UNSPEC: _bindgen_ty_92 = 0; -pub const IFLA_XDP_FD: _bindgen_ty_92 = 1; -pub const IFLA_XDP_ATTACHED: _bindgen_ty_92 = 2; -pub const IFLA_XDP_FLAGS: _bindgen_ty_92 = 3; -pub const IFLA_XDP_PROG_ID: _bindgen_ty_92 = 4; -pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_92 = 5; -pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_92 = 6; -pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_92 = 7; -pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_92 = 8; -pub const __IFLA_XDP_MAX: _bindgen_ty_92 = 9; -pub type _bindgen_ty_92 = ::core::ffi::c_uint; +pub const IFLA_XDP_UNSPEC: _bindgen_ty_94 = 0; +pub const IFLA_XDP_FD: _bindgen_ty_94 = 1; +pub const IFLA_XDP_ATTACHED: _bindgen_ty_94 = 2; +pub const IFLA_XDP_FLAGS: _bindgen_ty_94 = 3; +pub const IFLA_XDP_PROG_ID: _bindgen_ty_94 = 4; +pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_94 = 5; +pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_94 = 6; +pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_94 = 7; +pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_94 = 8; +pub const __IFLA_XDP_MAX: _bindgen_ty_94 = 9; +pub type _bindgen_ty_94 = ::core::ffi::c_uint; impl nf_inet_hooks { pub const NF_INET_INGRESS: nf_inet_hooks = nf_inet_hooks::NF_INET_NUMHOOKS; } @@ -2141,16 +2157,16 @@ pub enum nf_inet_hooks { NF_INET_POST_ROUTING = 4, NF_INET_NUMHOOKS = 5, } -pub const NFPROTO_UNSPEC: _bindgen_ty_99 = 0; -pub const NFPROTO_INET: _bindgen_ty_99 = 1; -pub const NFPROTO_IPV4: _bindgen_ty_99 = 2; -pub const NFPROTO_ARP: _bindgen_ty_99 = 3; -pub const NFPROTO_NETDEV: _bindgen_ty_99 = 5; -pub const NFPROTO_BRIDGE: _bindgen_ty_99 = 7; -pub const NFPROTO_IPV6: _bindgen_ty_99 = 10; -pub const NFPROTO_DECNET: _bindgen_ty_99 = 12; -pub const NFPROTO_NUMPROTO: _bindgen_ty_99 = 13; -pub type _bindgen_ty_99 = ::core::ffi::c_uint; +pub const NFPROTO_UNSPEC: _bindgen_ty_101 = 0; +pub const NFPROTO_INET: _bindgen_ty_101 = 1; +pub const NFPROTO_IPV4: _bindgen_ty_101 = 2; +pub const NFPROTO_ARP: _bindgen_ty_101 = 3; +pub const NFPROTO_NETDEV: _bindgen_ty_101 = 5; +pub const NFPROTO_BRIDGE: _bindgen_ty_101 = 7; +pub const NFPROTO_IPV6: _bindgen_ty_101 = 10; +pub const NFPROTO_DECNET: _bindgen_ty_101 = 12; +pub const NFPROTO_NUMPROTO: _bindgen_ty_101 = 13; +pub type _bindgen_ty_101 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum perf_type_id { @@ -4111,20 +4127,20 @@ pub enum perf_event_type { PERF_RECORD_AUX_OUTPUT_HW_ID = 21, PERF_RECORD_MAX = 22, } -pub const TCA_BPF_UNSPEC: _bindgen_ty_154 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_154 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_154 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_154 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_154 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_154 = 5; -pub const TCA_BPF_FD: _bindgen_ty_154 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_154 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_154 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_154 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_154 = 10; -pub const TCA_BPF_ID: _bindgen_ty_154 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_154 = 12; -pub type _bindgen_ty_154 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; +pub const TCA_BPF_FD: _bindgen_ty_156 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; +pub const TCA_BPF_ID: _bindgen_ty_156 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; +pub type _bindgen_ty_156 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { @@ -4146,22 +4162,22 @@ pub struct tcmsg { pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_174 = 0; -pub const TCA_KIND: _bindgen_ty_174 = 1; -pub const TCA_OPTIONS: _bindgen_ty_174 = 2; -pub const TCA_STATS: _bindgen_ty_174 = 3; -pub const TCA_XSTATS: _bindgen_ty_174 = 4; -pub const TCA_RATE: _bindgen_ty_174 = 5; -pub const TCA_FCNT: _bindgen_ty_174 = 6; -pub const TCA_STATS2: _bindgen_ty_174 = 7; -pub const TCA_STAB: _bindgen_ty_174 = 8; -pub const TCA_PAD: _bindgen_ty_174 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_174 = 10; -pub const TCA_CHAIN: _bindgen_ty_174 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_174 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_174 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_174 = 14; -pub const TCA_DUMP_FLAGS: _bindgen_ty_174 = 15; -pub const TCA_EXT_WARN_MSG: _bindgen_ty_174 = 16; -pub const __TCA_MAX: _bindgen_ty_174 = 17; -pub type _bindgen_ty_174 = ::core::ffi::c_uint; +pub const TCA_UNSPEC: _bindgen_ty_176 = 0; +pub const TCA_KIND: _bindgen_ty_176 = 1; +pub const TCA_OPTIONS: _bindgen_ty_176 = 2; +pub const TCA_STATS: _bindgen_ty_176 = 3; +pub const TCA_XSTATS: _bindgen_ty_176 = 4; +pub const TCA_RATE: _bindgen_ty_176 = 5; +pub const TCA_FCNT: _bindgen_ty_176 = 6; +pub const TCA_STATS2: _bindgen_ty_176 = 7; +pub const TCA_STAB: _bindgen_ty_176 = 8; +pub const TCA_PAD: _bindgen_ty_176 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_176 = 10; +pub const TCA_CHAIN: _bindgen_ty_176 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_176 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_176 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_176 = 14; +pub const TCA_DUMP_FLAGS: _bindgen_ty_176 = 15; +pub const TCA_EXT_WARN_MSG: _bindgen_ty_176 = 16; +pub const __TCA_MAX: _bindgen_ty_176 = 17; +pub type _bindgen_ty_176 = ::core::ffi::c_uint; diff --git a/aya-obj/src/generated/linux_bindings_riscv64.rs b/aya-obj/src/generated/linux_bindings_riscv64.rs index b76ed850..aff50e13 100644 --- a/aya-obj/src/generated/linux_bindings_riscv64.rs +++ b/aya-obj/src/generated/linux_bindings_riscv64.rs @@ -2105,6 +2105,22 @@ pub struct btf_var_secinfo { pub struct btf_decl_tag { pub component_idx: __s32, } +pub const HW_BREAKPOINT_LEN_1: _bindgen_ty_44 = 1; +pub const HW_BREAKPOINT_LEN_2: _bindgen_ty_44 = 2; +pub const HW_BREAKPOINT_LEN_3: _bindgen_ty_44 = 3; +pub const HW_BREAKPOINT_LEN_4: _bindgen_ty_44 = 4; +pub const HW_BREAKPOINT_LEN_5: _bindgen_ty_44 = 5; +pub const HW_BREAKPOINT_LEN_6: _bindgen_ty_44 = 6; +pub const HW_BREAKPOINT_LEN_7: _bindgen_ty_44 = 7; +pub const HW_BREAKPOINT_LEN_8: _bindgen_ty_44 = 8; +pub type _bindgen_ty_44 = ::core::ffi::c_uint; +pub const HW_BREAKPOINT_EMPTY: _bindgen_ty_45 = 0; +pub const HW_BREAKPOINT_R: _bindgen_ty_45 = 1; +pub const HW_BREAKPOINT_W: _bindgen_ty_45 = 2; +pub const HW_BREAKPOINT_RW: _bindgen_ty_45 = 3; +pub const HW_BREAKPOINT_X: _bindgen_ty_45 = 4; +pub const HW_BREAKPOINT_INVALID: _bindgen_ty_45 = 7; +pub type _bindgen_ty_45 = ::core::ffi::c_uint; impl nlmsgerr_attrs { pub const NLMSGERR_ATTR_MAX: nlmsgerr_attrs = nlmsgerr_attrs::NLMSGERR_ATTR_COOKIE; } @@ -2117,17 +2133,17 @@ pub enum nlmsgerr_attrs { NLMSGERR_ATTR_COOKIE = 3, __NLMSGERR_ATTR_MAX = 4, } -pub const IFLA_XDP_UNSPEC: _bindgen_ty_92 = 0; -pub const IFLA_XDP_FD: _bindgen_ty_92 = 1; -pub const IFLA_XDP_ATTACHED: _bindgen_ty_92 = 2; -pub const IFLA_XDP_FLAGS: _bindgen_ty_92 = 3; -pub const IFLA_XDP_PROG_ID: _bindgen_ty_92 = 4; -pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_92 = 5; -pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_92 = 6; -pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_92 = 7; -pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_92 = 8; -pub const __IFLA_XDP_MAX: _bindgen_ty_92 = 9; -pub type _bindgen_ty_92 = ::core::ffi::c_uint; +pub const IFLA_XDP_UNSPEC: _bindgen_ty_94 = 0; +pub const IFLA_XDP_FD: _bindgen_ty_94 = 1; +pub const IFLA_XDP_ATTACHED: _bindgen_ty_94 = 2; +pub const IFLA_XDP_FLAGS: _bindgen_ty_94 = 3; +pub const IFLA_XDP_PROG_ID: _bindgen_ty_94 = 4; +pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_94 = 5; +pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_94 = 6; +pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_94 = 7; +pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_94 = 8; +pub const __IFLA_XDP_MAX: _bindgen_ty_94 = 9; +pub type _bindgen_ty_94 = ::core::ffi::c_uint; impl nf_inet_hooks { pub const NF_INET_INGRESS: nf_inet_hooks = nf_inet_hooks::NF_INET_NUMHOOKS; } @@ -2141,16 +2157,16 @@ pub enum nf_inet_hooks { NF_INET_POST_ROUTING = 4, NF_INET_NUMHOOKS = 5, } -pub const NFPROTO_UNSPEC: _bindgen_ty_99 = 0; -pub const NFPROTO_INET: _bindgen_ty_99 = 1; -pub const NFPROTO_IPV4: _bindgen_ty_99 = 2; -pub const NFPROTO_ARP: _bindgen_ty_99 = 3; -pub const NFPROTO_NETDEV: _bindgen_ty_99 = 5; -pub const NFPROTO_BRIDGE: _bindgen_ty_99 = 7; -pub const NFPROTO_IPV6: _bindgen_ty_99 = 10; -pub const NFPROTO_DECNET: _bindgen_ty_99 = 12; -pub const NFPROTO_NUMPROTO: _bindgen_ty_99 = 13; -pub type _bindgen_ty_99 = ::core::ffi::c_uint; +pub const NFPROTO_UNSPEC: _bindgen_ty_101 = 0; +pub const NFPROTO_INET: _bindgen_ty_101 = 1; +pub const NFPROTO_IPV4: _bindgen_ty_101 = 2; +pub const NFPROTO_ARP: _bindgen_ty_101 = 3; +pub const NFPROTO_NETDEV: _bindgen_ty_101 = 5; +pub const NFPROTO_BRIDGE: _bindgen_ty_101 = 7; +pub const NFPROTO_IPV6: _bindgen_ty_101 = 10; +pub const NFPROTO_DECNET: _bindgen_ty_101 = 12; +pub const NFPROTO_NUMPROTO: _bindgen_ty_101 = 13; +pub type _bindgen_ty_101 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum perf_type_id { @@ -4111,20 +4127,20 @@ pub enum perf_event_type { PERF_RECORD_AUX_OUTPUT_HW_ID = 21, PERF_RECORD_MAX = 22, } -pub const TCA_BPF_UNSPEC: _bindgen_ty_154 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_154 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_154 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_154 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_154 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_154 = 5; -pub const TCA_BPF_FD: _bindgen_ty_154 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_154 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_154 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_154 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_154 = 10; -pub const TCA_BPF_ID: _bindgen_ty_154 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_154 = 12; -pub type _bindgen_ty_154 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; +pub const TCA_BPF_FD: _bindgen_ty_156 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; +pub const TCA_BPF_ID: _bindgen_ty_156 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; +pub type _bindgen_ty_156 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { @@ -4146,22 +4162,22 @@ pub struct tcmsg { pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_174 = 0; -pub const TCA_KIND: _bindgen_ty_174 = 1; -pub const TCA_OPTIONS: _bindgen_ty_174 = 2; -pub const TCA_STATS: _bindgen_ty_174 = 3; -pub const TCA_XSTATS: _bindgen_ty_174 = 4; -pub const TCA_RATE: _bindgen_ty_174 = 5; -pub const TCA_FCNT: _bindgen_ty_174 = 6; -pub const TCA_STATS2: _bindgen_ty_174 = 7; -pub const TCA_STAB: _bindgen_ty_174 = 8; -pub const TCA_PAD: _bindgen_ty_174 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_174 = 10; -pub const TCA_CHAIN: _bindgen_ty_174 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_174 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_174 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_174 = 14; -pub const TCA_DUMP_FLAGS: _bindgen_ty_174 = 15; -pub const TCA_EXT_WARN_MSG: _bindgen_ty_174 = 16; -pub const __TCA_MAX: _bindgen_ty_174 = 17; -pub type _bindgen_ty_174 = ::core::ffi::c_uint; +pub const TCA_UNSPEC: _bindgen_ty_176 = 0; +pub const TCA_KIND: _bindgen_ty_176 = 1; +pub const TCA_OPTIONS: _bindgen_ty_176 = 2; +pub const TCA_STATS: _bindgen_ty_176 = 3; +pub const TCA_XSTATS: _bindgen_ty_176 = 4; +pub const TCA_RATE: _bindgen_ty_176 = 5; +pub const TCA_FCNT: _bindgen_ty_176 = 6; +pub const TCA_STATS2: _bindgen_ty_176 = 7; +pub const TCA_STAB: _bindgen_ty_176 = 8; +pub const TCA_PAD: _bindgen_ty_176 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_176 = 10; +pub const TCA_CHAIN: _bindgen_ty_176 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_176 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_176 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_176 = 14; +pub const TCA_DUMP_FLAGS: _bindgen_ty_176 = 15; +pub const TCA_EXT_WARN_MSG: _bindgen_ty_176 = 16; +pub const __TCA_MAX: _bindgen_ty_176 = 17; +pub type _bindgen_ty_176 = ::core::ffi::c_uint; diff --git a/aya-obj/src/generated/linux_bindings_s390x.rs b/aya-obj/src/generated/linux_bindings_s390x.rs index b76ed850..aff50e13 100644 --- a/aya-obj/src/generated/linux_bindings_s390x.rs +++ b/aya-obj/src/generated/linux_bindings_s390x.rs @@ -2105,6 +2105,22 @@ pub struct btf_var_secinfo { pub struct btf_decl_tag { pub component_idx: __s32, } +pub const HW_BREAKPOINT_LEN_1: _bindgen_ty_44 = 1; +pub const HW_BREAKPOINT_LEN_2: _bindgen_ty_44 = 2; +pub const HW_BREAKPOINT_LEN_3: _bindgen_ty_44 = 3; +pub const HW_BREAKPOINT_LEN_4: _bindgen_ty_44 = 4; +pub const HW_BREAKPOINT_LEN_5: _bindgen_ty_44 = 5; +pub const HW_BREAKPOINT_LEN_6: _bindgen_ty_44 = 6; +pub const HW_BREAKPOINT_LEN_7: _bindgen_ty_44 = 7; +pub const HW_BREAKPOINT_LEN_8: _bindgen_ty_44 = 8; +pub type _bindgen_ty_44 = ::core::ffi::c_uint; +pub const HW_BREAKPOINT_EMPTY: _bindgen_ty_45 = 0; +pub const HW_BREAKPOINT_R: _bindgen_ty_45 = 1; +pub const HW_BREAKPOINT_W: _bindgen_ty_45 = 2; +pub const HW_BREAKPOINT_RW: _bindgen_ty_45 = 3; +pub const HW_BREAKPOINT_X: _bindgen_ty_45 = 4; +pub const HW_BREAKPOINT_INVALID: _bindgen_ty_45 = 7; +pub type _bindgen_ty_45 = ::core::ffi::c_uint; impl nlmsgerr_attrs { pub const NLMSGERR_ATTR_MAX: nlmsgerr_attrs = nlmsgerr_attrs::NLMSGERR_ATTR_COOKIE; } @@ -2117,17 +2133,17 @@ pub enum nlmsgerr_attrs { NLMSGERR_ATTR_COOKIE = 3, __NLMSGERR_ATTR_MAX = 4, } -pub const IFLA_XDP_UNSPEC: _bindgen_ty_92 = 0; -pub const IFLA_XDP_FD: _bindgen_ty_92 = 1; -pub const IFLA_XDP_ATTACHED: _bindgen_ty_92 = 2; -pub const IFLA_XDP_FLAGS: _bindgen_ty_92 = 3; -pub const IFLA_XDP_PROG_ID: _bindgen_ty_92 = 4; -pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_92 = 5; -pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_92 = 6; -pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_92 = 7; -pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_92 = 8; -pub const __IFLA_XDP_MAX: _bindgen_ty_92 = 9; -pub type _bindgen_ty_92 = ::core::ffi::c_uint; +pub const IFLA_XDP_UNSPEC: _bindgen_ty_94 = 0; +pub const IFLA_XDP_FD: _bindgen_ty_94 = 1; +pub const IFLA_XDP_ATTACHED: _bindgen_ty_94 = 2; +pub const IFLA_XDP_FLAGS: _bindgen_ty_94 = 3; +pub const IFLA_XDP_PROG_ID: _bindgen_ty_94 = 4; +pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_94 = 5; +pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_94 = 6; +pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_94 = 7; +pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_94 = 8; +pub const __IFLA_XDP_MAX: _bindgen_ty_94 = 9; +pub type _bindgen_ty_94 = ::core::ffi::c_uint; impl nf_inet_hooks { pub const NF_INET_INGRESS: nf_inet_hooks = nf_inet_hooks::NF_INET_NUMHOOKS; } @@ -2141,16 +2157,16 @@ pub enum nf_inet_hooks { NF_INET_POST_ROUTING = 4, NF_INET_NUMHOOKS = 5, } -pub const NFPROTO_UNSPEC: _bindgen_ty_99 = 0; -pub const NFPROTO_INET: _bindgen_ty_99 = 1; -pub const NFPROTO_IPV4: _bindgen_ty_99 = 2; -pub const NFPROTO_ARP: _bindgen_ty_99 = 3; -pub const NFPROTO_NETDEV: _bindgen_ty_99 = 5; -pub const NFPROTO_BRIDGE: _bindgen_ty_99 = 7; -pub const NFPROTO_IPV6: _bindgen_ty_99 = 10; -pub const NFPROTO_DECNET: _bindgen_ty_99 = 12; -pub const NFPROTO_NUMPROTO: _bindgen_ty_99 = 13; -pub type _bindgen_ty_99 = ::core::ffi::c_uint; +pub const NFPROTO_UNSPEC: _bindgen_ty_101 = 0; +pub const NFPROTO_INET: _bindgen_ty_101 = 1; +pub const NFPROTO_IPV4: _bindgen_ty_101 = 2; +pub const NFPROTO_ARP: _bindgen_ty_101 = 3; +pub const NFPROTO_NETDEV: _bindgen_ty_101 = 5; +pub const NFPROTO_BRIDGE: _bindgen_ty_101 = 7; +pub const NFPROTO_IPV6: _bindgen_ty_101 = 10; +pub const NFPROTO_DECNET: _bindgen_ty_101 = 12; +pub const NFPROTO_NUMPROTO: _bindgen_ty_101 = 13; +pub type _bindgen_ty_101 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum perf_type_id { @@ -4111,20 +4127,20 @@ pub enum perf_event_type { PERF_RECORD_AUX_OUTPUT_HW_ID = 21, PERF_RECORD_MAX = 22, } -pub const TCA_BPF_UNSPEC: _bindgen_ty_154 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_154 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_154 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_154 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_154 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_154 = 5; -pub const TCA_BPF_FD: _bindgen_ty_154 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_154 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_154 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_154 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_154 = 10; -pub const TCA_BPF_ID: _bindgen_ty_154 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_154 = 12; -pub type _bindgen_ty_154 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; +pub const TCA_BPF_FD: _bindgen_ty_156 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; +pub const TCA_BPF_ID: _bindgen_ty_156 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; +pub type _bindgen_ty_156 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { @@ -4146,22 +4162,22 @@ pub struct tcmsg { pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_174 = 0; -pub const TCA_KIND: _bindgen_ty_174 = 1; -pub const TCA_OPTIONS: _bindgen_ty_174 = 2; -pub const TCA_STATS: _bindgen_ty_174 = 3; -pub const TCA_XSTATS: _bindgen_ty_174 = 4; -pub const TCA_RATE: _bindgen_ty_174 = 5; -pub const TCA_FCNT: _bindgen_ty_174 = 6; -pub const TCA_STATS2: _bindgen_ty_174 = 7; -pub const TCA_STAB: _bindgen_ty_174 = 8; -pub const TCA_PAD: _bindgen_ty_174 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_174 = 10; -pub const TCA_CHAIN: _bindgen_ty_174 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_174 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_174 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_174 = 14; -pub const TCA_DUMP_FLAGS: _bindgen_ty_174 = 15; -pub const TCA_EXT_WARN_MSG: _bindgen_ty_174 = 16; -pub const __TCA_MAX: _bindgen_ty_174 = 17; -pub type _bindgen_ty_174 = ::core::ffi::c_uint; +pub const TCA_UNSPEC: _bindgen_ty_176 = 0; +pub const TCA_KIND: _bindgen_ty_176 = 1; +pub const TCA_OPTIONS: _bindgen_ty_176 = 2; +pub const TCA_STATS: _bindgen_ty_176 = 3; +pub const TCA_XSTATS: _bindgen_ty_176 = 4; +pub const TCA_RATE: _bindgen_ty_176 = 5; +pub const TCA_FCNT: _bindgen_ty_176 = 6; +pub const TCA_STATS2: _bindgen_ty_176 = 7; +pub const TCA_STAB: _bindgen_ty_176 = 8; +pub const TCA_PAD: _bindgen_ty_176 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_176 = 10; +pub const TCA_CHAIN: _bindgen_ty_176 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_176 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_176 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_176 = 14; +pub const TCA_DUMP_FLAGS: _bindgen_ty_176 = 15; +pub const TCA_EXT_WARN_MSG: _bindgen_ty_176 = 16; +pub const __TCA_MAX: _bindgen_ty_176 = 17; +pub type _bindgen_ty_176 = ::core::ffi::c_uint; diff --git a/aya-obj/src/generated/linux_bindings_x86_64.rs b/aya-obj/src/generated/linux_bindings_x86_64.rs index b76ed850..aff50e13 100644 --- a/aya-obj/src/generated/linux_bindings_x86_64.rs +++ b/aya-obj/src/generated/linux_bindings_x86_64.rs @@ -2105,6 +2105,22 @@ pub struct btf_var_secinfo { pub struct btf_decl_tag { pub component_idx: __s32, } +pub const HW_BREAKPOINT_LEN_1: _bindgen_ty_44 = 1; +pub const HW_BREAKPOINT_LEN_2: _bindgen_ty_44 = 2; +pub const HW_BREAKPOINT_LEN_3: _bindgen_ty_44 = 3; +pub const HW_BREAKPOINT_LEN_4: _bindgen_ty_44 = 4; +pub const HW_BREAKPOINT_LEN_5: _bindgen_ty_44 = 5; +pub const HW_BREAKPOINT_LEN_6: _bindgen_ty_44 = 6; +pub const HW_BREAKPOINT_LEN_7: _bindgen_ty_44 = 7; +pub const HW_BREAKPOINT_LEN_8: _bindgen_ty_44 = 8; +pub type _bindgen_ty_44 = ::core::ffi::c_uint; +pub const HW_BREAKPOINT_EMPTY: _bindgen_ty_45 = 0; +pub const HW_BREAKPOINT_R: _bindgen_ty_45 = 1; +pub const HW_BREAKPOINT_W: _bindgen_ty_45 = 2; +pub const HW_BREAKPOINT_RW: _bindgen_ty_45 = 3; +pub const HW_BREAKPOINT_X: _bindgen_ty_45 = 4; +pub const HW_BREAKPOINT_INVALID: _bindgen_ty_45 = 7; +pub type _bindgen_ty_45 = ::core::ffi::c_uint; impl nlmsgerr_attrs { pub const NLMSGERR_ATTR_MAX: nlmsgerr_attrs = nlmsgerr_attrs::NLMSGERR_ATTR_COOKIE; } @@ -2117,17 +2133,17 @@ pub enum nlmsgerr_attrs { NLMSGERR_ATTR_COOKIE = 3, __NLMSGERR_ATTR_MAX = 4, } -pub const IFLA_XDP_UNSPEC: _bindgen_ty_92 = 0; -pub const IFLA_XDP_FD: _bindgen_ty_92 = 1; -pub const IFLA_XDP_ATTACHED: _bindgen_ty_92 = 2; -pub const IFLA_XDP_FLAGS: _bindgen_ty_92 = 3; -pub const IFLA_XDP_PROG_ID: _bindgen_ty_92 = 4; -pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_92 = 5; -pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_92 = 6; -pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_92 = 7; -pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_92 = 8; -pub const __IFLA_XDP_MAX: _bindgen_ty_92 = 9; -pub type _bindgen_ty_92 = ::core::ffi::c_uint; +pub const IFLA_XDP_UNSPEC: _bindgen_ty_94 = 0; +pub const IFLA_XDP_FD: _bindgen_ty_94 = 1; +pub const IFLA_XDP_ATTACHED: _bindgen_ty_94 = 2; +pub const IFLA_XDP_FLAGS: _bindgen_ty_94 = 3; +pub const IFLA_XDP_PROG_ID: _bindgen_ty_94 = 4; +pub const IFLA_XDP_DRV_PROG_ID: _bindgen_ty_94 = 5; +pub const IFLA_XDP_SKB_PROG_ID: _bindgen_ty_94 = 6; +pub const IFLA_XDP_HW_PROG_ID: _bindgen_ty_94 = 7; +pub const IFLA_XDP_EXPECTED_FD: _bindgen_ty_94 = 8; +pub const __IFLA_XDP_MAX: _bindgen_ty_94 = 9; +pub type _bindgen_ty_94 = ::core::ffi::c_uint; impl nf_inet_hooks { pub const NF_INET_INGRESS: nf_inet_hooks = nf_inet_hooks::NF_INET_NUMHOOKS; } @@ -2141,16 +2157,16 @@ pub enum nf_inet_hooks { NF_INET_POST_ROUTING = 4, NF_INET_NUMHOOKS = 5, } -pub const NFPROTO_UNSPEC: _bindgen_ty_99 = 0; -pub const NFPROTO_INET: _bindgen_ty_99 = 1; -pub const NFPROTO_IPV4: _bindgen_ty_99 = 2; -pub const NFPROTO_ARP: _bindgen_ty_99 = 3; -pub const NFPROTO_NETDEV: _bindgen_ty_99 = 5; -pub const NFPROTO_BRIDGE: _bindgen_ty_99 = 7; -pub const NFPROTO_IPV6: _bindgen_ty_99 = 10; -pub const NFPROTO_DECNET: _bindgen_ty_99 = 12; -pub const NFPROTO_NUMPROTO: _bindgen_ty_99 = 13; -pub type _bindgen_ty_99 = ::core::ffi::c_uint; +pub const NFPROTO_UNSPEC: _bindgen_ty_101 = 0; +pub const NFPROTO_INET: _bindgen_ty_101 = 1; +pub const NFPROTO_IPV4: _bindgen_ty_101 = 2; +pub const NFPROTO_ARP: _bindgen_ty_101 = 3; +pub const NFPROTO_NETDEV: _bindgen_ty_101 = 5; +pub const NFPROTO_BRIDGE: _bindgen_ty_101 = 7; +pub const NFPROTO_IPV6: _bindgen_ty_101 = 10; +pub const NFPROTO_DECNET: _bindgen_ty_101 = 12; +pub const NFPROTO_NUMPROTO: _bindgen_ty_101 = 13; +pub type _bindgen_ty_101 = ::core::ffi::c_uint; #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum perf_type_id { @@ -4111,20 +4127,20 @@ pub enum perf_event_type { PERF_RECORD_AUX_OUTPUT_HW_ID = 21, PERF_RECORD_MAX = 22, } -pub const TCA_BPF_UNSPEC: _bindgen_ty_154 = 0; -pub const TCA_BPF_ACT: _bindgen_ty_154 = 1; -pub const TCA_BPF_POLICE: _bindgen_ty_154 = 2; -pub const TCA_BPF_CLASSID: _bindgen_ty_154 = 3; -pub const TCA_BPF_OPS_LEN: _bindgen_ty_154 = 4; -pub const TCA_BPF_OPS: _bindgen_ty_154 = 5; -pub const TCA_BPF_FD: _bindgen_ty_154 = 6; -pub const TCA_BPF_NAME: _bindgen_ty_154 = 7; -pub const TCA_BPF_FLAGS: _bindgen_ty_154 = 8; -pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_154 = 9; -pub const TCA_BPF_TAG: _bindgen_ty_154 = 10; -pub const TCA_BPF_ID: _bindgen_ty_154 = 11; -pub const __TCA_BPF_MAX: _bindgen_ty_154 = 12; -pub type _bindgen_ty_154 = ::core::ffi::c_uint; +pub const TCA_BPF_UNSPEC: _bindgen_ty_156 = 0; +pub const TCA_BPF_ACT: _bindgen_ty_156 = 1; +pub const TCA_BPF_POLICE: _bindgen_ty_156 = 2; +pub const TCA_BPF_CLASSID: _bindgen_ty_156 = 3; +pub const TCA_BPF_OPS_LEN: _bindgen_ty_156 = 4; +pub const TCA_BPF_OPS: _bindgen_ty_156 = 5; +pub const TCA_BPF_FD: _bindgen_ty_156 = 6; +pub const TCA_BPF_NAME: _bindgen_ty_156 = 7; +pub const TCA_BPF_FLAGS: _bindgen_ty_156 = 8; +pub const TCA_BPF_FLAGS_GEN: _bindgen_ty_156 = 9; +pub const TCA_BPF_TAG: _bindgen_ty_156 = 10; +pub const TCA_BPF_ID: _bindgen_ty_156 = 11; +pub const __TCA_BPF_MAX: _bindgen_ty_156 = 12; +pub type _bindgen_ty_156 = ::core::ffi::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ifinfomsg { @@ -4146,22 +4162,22 @@ pub struct tcmsg { pub tcm_parent: __u32, pub tcm_info: __u32, } -pub const TCA_UNSPEC: _bindgen_ty_174 = 0; -pub const TCA_KIND: _bindgen_ty_174 = 1; -pub const TCA_OPTIONS: _bindgen_ty_174 = 2; -pub const TCA_STATS: _bindgen_ty_174 = 3; -pub const TCA_XSTATS: _bindgen_ty_174 = 4; -pub const TCA_RATE: _bindgen_ty_174 = 5; -pub const TCA_FCNT: _bindgen_ty_174 = 6; -pub const TCA_STATS2: _bindgen_ty_174 = 7; -pub const TCA_STAB: _bindgen_ty_174 = 8; -pub const TCA_PAD: _bindgen_ty_174 = 9; -pub const TCA_DUMP_INVISIBLE: _bindgen_ty_174 = 10; -pub const TCA_CHAIN: _bindgen_ty_174 = 11; -pub const TCA_HW_OFFLOAD: _bindgen_ty_174 = 12; -pub const TCA_INGRESS_BLOCK: _bindgen_ty_174 = 13; -pub const TCA_EGRESS_BLOCK: _bindgen_ty_174 = 14; -pub const TCA_DUMP_FLAGS: _bindgen_ty_174 = 15; -pub const TCA_EXT_WARN_MSG: _bindgen_ty_174 = 16; -pub const __TCA_MAX: _bindgen_ty_174 = 17; -pub type _bindgen_ty_174 = ::core::ffi::c_uint; +pub const TCA_UNSPEC: _bindgen_ty_176 = 0; +pub const TCA_KIND: _bindgen_ty_176 = 1; +pub const TCA_OPTIONS: _bindgen_ty_176 = 2; +pub const TCA_STATS: _bindgen_ty_176 = 3; +pub const TCA_XSTATS: _bindgen_ty_176 = 4; +pub const TCA_RATE: _bindgen_ty_176 = 5; +pub const TCA_FCNT: _bindgen_ty_176 = 6; +pub const TCA_STATS2: _bindgen_ty_176 = 7; +pub const TCA_STAB: _bindgen_ty_176 = 8; +pub const TCA_PAD: _bindgen_ty_176 = 9; +pub const TCA_DUMP_INVISIBLE: _bindgen_ty_176 = 10; +pub const TCA_CHAIN: _bindgen_ty_176 = 11; +pub const TCA_HW_OFFLOAD: _bindgen_ty_176 = 12; +pub const TCA_INGRESS_BLOCK: _bindgen_ty_176 = 13; +pub const TCA_EGRESS_BLOCK: _bindgen_ty_176 = 14; +pub const TCA_DUMP_FLAGS: _bindgen_ty_176 = 15; +pub const TCA_EXT_WARN_MSG: _bindgen_ty_176 = 16; +pub const __TCA_MAX: _bindgen_ty_176 = 17; +pub type _bindgen_ty_176 = ::core::ffi::c_uint; diff --git a/aya/src/programs/perf_event.rs b/aya/src/programs/perf_event.rs index 0b52bd04..93421ba7 100644 --- a/aya/src/programs/perf_event.rs +++ b/aya/src/programs/perf_event.rs @@ -3,7 +3,9 @@ use std::os::fd::AsFd as _; use aya_obj::generated::{ - bpf_link_type, bpf_prog_type::BPF_PROG_TYPE_PERF_EVENT, perf_hw_cache_id, perf_hw_cache_op_id, + HW_BREAKPOINT_LEN_1, HW_BREAKPOINT_LEN_2, HW_BREAKPOINT_LEN_4, HW_BREAKPOINT_LEN_8, + HW_BREAKPOINT_R, HW_BREAKPOINT_RW, HW_BREAKPOINT_W, bpf_link_type, + bpf_prog_type::BPF_PROG_TYPE_PERF_EVENT, perf_hw_cache_id, perf_hw_cache_op_id, perf_hw_cache_op_result_id, perf_hw_id, perf_sw_ids, perf_type_id, }; @@ -11,8 +13,8 @@ use crate::{ programs::{ FdLink, LinkError, ProgramData, ProgramError, ProgramType, impl_try_into_fdlink, links::define_link_wrapper, - load_program, perf_attach, - perf_attach::{PerfLinkIdInner, PerfLinkInner}, + load_program, + perf_attach::{PerfLinkIdInner, PerfLinkInner, perf_attach}, }, sys::{SyscallError, bpf_link_get_info_by_fd, perf_event_open}, }; @@ -52,12 +54,8 @@ pub enum PerfEventConfig { event_id: u64, }, /// A hardware breakpoint. - /// - /// Note: this variant is not fully implemented at the moment. - // TODO: Variant not fully implemented due to additional `perf_event_attr` fields like - // `bp_type`, `bp_addr`, etc. #[doc(alias = "PERF_TYPE_BREAKPOINT")] - Breakpoint, + Breakpoint(BreakpointConfig), /// The dynamic PMU (Performance Monitor Unit) event to report. /// /// Available PMU's may be found under `/sys/bus/event_source/devices`. @@ -276,6 +274,74 @@ impl HwCacheResult { } } +/// The breakpoint type. +#[repr(u32)] +#[derive(Debug, Clone, Copy)] +pub enum PerfBreakpointType { + /// HW_BREAKPOINT_R, trigger when we read the memory location. + #[doc(alias = "HW_BREAKPOINT_R")] + Read = HW_BREAKPOINT_R, + /// HW_BREAKPOINT_W, trigger when we write the memory location. + #[doc(alias = "HW_BREAKPOINT_W")] + Write = HW_BREAKPOINT_W, + /// HW_BREAKPOINT_RW, trigger when we read or write the memory location. + #[doc(alias = "HW_BREAKPOINT_RW")] + ReadWrite = HW_BREAKPOINT_RW, +} + +impl PerfBreakpointType { + pub(crate) const fn into_primitive(self) -> u32 { + const _: [(); 4] = [(); std::mem::size_of::()]; + self as u32 + } +} + +/// The number of bytes covered by a data breakpoint. +#[repr(u32)] +#[derive(Debug, Clone, Copy)] +pub enum PerfBreakpointLength { + /// HW_BREAKPOINT_LEN_1 + #[doc(alias = "HW_BREAKPOINT_LEN_1")] + Len1 = HW_BREAKPOINT_LEN_1, + /// HW_BREAKPOINT_LEN_2 + #[doc(alias = "HW_BREAKPOINT_LEN_2")] + Len2 = HW_BREAKPOINT_LEN_2, + /// HW_BREAKPOINT_LEN_4 + #[doc(alias = "HW_BREAKPOINT_LEN_4")] + Len4 = HW_BREAKPOINT_LEN_4, + /// HW_BREAKPOINT_LEN_8 + #[doc(alias = "HW_BREAKPOINT_LEN_8")] + Len8 = HW_BREAKPOINT_LEN_8, +} + +impl PerfBreakpointLength { + pub(crate) const fn into_primitive(self) -> u32 { + const _: [(); 4] = [(); std::mem::size_of::()]; + self as u32 + } +} + +/// Type of hardware breakpoint, determines if we break on read, write, or +/// execute, or if there should be no breakpoint on the given address. +#[derive(Debug, Clone, Copy)] +pub enum BreakpointConfig { + /// A memory access breakpoint. + Data { + /// The type of the breakpoint. + r#type: PerfBreakpointType, + /// The address of the breakpoint. + address: u64, + /// The contiguous byte window to monitor starting at `address`. + length: PerfBreakpointLength, + }, + /// A code execution breakpoint. + #[doc(alias = "HW_BREAKPOINT_X")] + Instruction { + /// The address of the breakpoint. + address: u64, + }, +} + /// Sample Policy #[derive(Debug, Clone, Copy)] pub enum SamplePolicy { @@ -306,7 +372,7 @@ pub enum PerfEventScope { /// one process OneProcess { /// process id - pid: i32, + pid: u32, /// cpu id or any cpu if None cpu: Option, }, @@ -376,13 +442,10 @@ impl PerfEvent { /// Attaches to the given perf event. /// - /// [`perf_type`](PerfEventConfig) defines the event `type` and `config` of interest. - /// - /// [`scope`](PerfEventScope) determines which processes are sampled. If `inherit` is - /// `true`, any new processes spawned by those processes will also automatically be - /// sampled. + /// If `inherit` is `true`, any new processes spawned by those processes + /// will also automatically be sampled. /// - /// The returned value can be used to detach, see [PerfEvent::detach]. + /// The returned value can be used to detach, see [`Self::detach`]. pub fn attach( &mut self, config: PerfEventConfig, diff --git a/aya/src/sys/perf_event.rs b/aya/src/sys/perf_event.rs index 3514ef4e..b9de4c71 100644 --- a/aya/src/sys/perf_event.rs +++ b/aya/src/sys/perf_event.rs @@ -1,11 +1,12 @@ use std::{ - ffi::{CString, OsStr, c_int}, + ffi::{CString, OsStr, c_int, c_long, c_uint}, io, mem, os::fd::{BorrowedFd, FromRawFd as _}, }; use aya_obj::generated::{ - PERF_FLAG_FD_CLOEXEC, perf_event_attr, + HW_BREAKPOINT_LEN_1, HW_BREAKPOINT_LEN_2, HW_BREAKPOINT_LEN_4, HW_BREAKPOINT_LEN_8, + HW_BREAKPOINT_X, PERF_FLAG_FD_CLOEXEC, perf_event_attr, perf_event_sample_format::PERF_SAMPLE_RAW, perf_type_id::{ PERF_TYPE_BREAKPOINT, PERF_TYPE_HARDWARE, PERF_TYPE_HW_CACHE, PERF_TYPE_RAW, @@ -16,7 +17,8 @@ use libc::pid_t; use super::{PerfEventIoctlRequest, Syscall, syscall}; use crate::programs::perf_event::{ - PerfEventConfig, PerfEventScope, SamplePolicy, SoftwareEvent, WakeupPolicy, perf_type_id_to_u32, + BreakpointConfig, PerfEventConfig, PerfEventScope, SamplePolicy, SoftwareEvent, WakeupPolicy, + perf_type_id_to_u32, }; pub(crate) fn perf_event_open( @@ -53,7 +55,42 @@ pub(crate) fn perf_event_open( | (u64::from(result.into_primitive()) << 16), ), PerfEventConfig::Raw { event_id } => (perf_type_id_to_u32(PERF_TYPE_RAW), event_id), - PerfEventConfig::Breakpoint => (perf_type_id_to_u32(PERF_TYPE_BREAKPOINT), 0), + PerfEventConfig::Breakpoint(breakpoint) => { + let (type_, address, length) = match breakpoint { + BreakpointConfig::Data { + r#type, + address, + length, + } => ( + r#type.into_primitive(), + address, + u64::from(length.into_primitive()), + ), + BreakpointConfig::Instruction { address } => { + const fn length(size: usize) -> c_uint { + match size { + 1 => HW_BREAKPOINT_LEN_1, + 2 => HW_BREAKPOINT_LEN_2, + 4 => HW_BREAKPOINT_LEN_4, + 8 => HW_BREAKPOINT_LEN_8, + // NB: cannot emit the value because: + // + // error[E0015]: cannot call non-const formatting macro in constant functions + _ => panic!("invalid hardware breakpoint size"), + } + } + const LENGTH: c_uint = length(std::mem::size_of::()); + (HW_BREAKPOINT_X, address, u64::from(LENGTH)) + } + }; + + attr.bp_type = type_; + attr.__bindgen_anon_3.bp_addr = address; + attr.__bindgen_anon_4.bp_len = length; + attr.set_precise_ip(2); + + (perf_type_id_to_u32(PERF_TYPE_BREAKPOINT), 0) + } }; attr.config = config; @@ -84,7 +121,7 @@ pub(crate) fn perf_event_open( let (pid, cpu) = match scope { PerfEventScope::CallingProcess { cpu } => (0, cpu.map_or(-1, |cpu| cpu as i32)), - PerfEventScope::OneProcess { pid, cpu } => (pid, cpu.map_or(-1, |cpu| cpu as i32)), + PerfEventScope::OneProcess { pid, cpu } => (pid as i32, cpu.map_or(-1, |cpu| cpu as i32)), PerfEventScope::AllProcessesOneCpu { cpu } => (-1, cpu as i32), }; diff --git a/ebpf/aya-ebpf-bindings/include/bindings.h b/ebpf/aya-ebpf-bindings/include/bindings.h index aa831c57..ba2f9183 100644 --- a/ebpf/aya-ebpf-bindings/include/bindings.h +++ b/ebpf/aya-ebpf-bindings/include/bindings.h @@ -6,6 +6,7 @@ typedef __u32 __bitwise __wsum; #include #include +#include // needed for TC_ACT_* #include #include diff --git a/ebpf/aya-ebpf-bindings/src/aarch64/bindings.rs b/ebpf/aya-ebpf-bindings/src/aarch64/bindings.rs index 87ef0587..473db3c6 100644 --- a/ebpf/aya-ebpf-bindings/src/aarch64/bindings.rs +++ b/ebpf/aya-ebpf-bindings/src/aarch64/bindings.rs @@ -365,11 +365,6 @@ pub type __be32 = __u32; pub type __wsum = __u32; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct bpf_perf_event_data { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] pub struct linux_binprm { _unused: [u8; 0], } @@ -2887,6 +2882,14 @@ pub struct user_pt_regs { pub pc: __u64, pub pstate: __u64, } +pub type bpf_user_pt_regs_t = user_pt_regs; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_perf_event_data { + pub regs: bpf_user_pt_regs_t, + pub sample_period: __u64, + pub addr: __u64, +} pub type sa_family_t = ::aya_ebpf_cty::c_ushort; #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/ebpf/aya-ebpf-bindings/src/armv7/bindings.rs b/ebpf/aya-ebpf-bindings/src/armv7/bindings.rs index 54140c49..50c1d6f7 100644 --- a/ebpf/aya-ebpf-bindings/src/armv7/bindings.rs +++ b/ebpf/aya-ebpf-bindings/src/armv7/bindings.rs @@ -365,11 +365,6 @@ pub type __be32 = __u32; pub type __wsum = __u32; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct bpf_perf_event_data { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] pub struct linux_binprm { _unused: [u8; 0], } @@ -2896,6 +2891,14 @@ pub struct bpf_iter_num { pub struct pt_regs { pub uregs: [::aya_ebpf_cty::c_long; 18usize], } +pub type bpf_user_pt_regs_t = pt_regs; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_perf_event_data { + pub regs: bpf_user_pt_regs_t, + pub sample_period: __u64, + pub addr: __u64, +} pub type sa_family_t = ::aya_ebpf_cty::c_ushort; #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/ebpf/aya-ebpf-bindings/src/loongarch64/bindings.rs b/ebpf/aya-ebpf-bindings/src/loongarch64/bindings.rs index f769d7b9..4ffb76ce 100644 --- a/ebpf/aya-ebpf-bindings/src/loongarch64/bindings.rs +++ b/ebpf/aya-ebpf-bindings/src/loongarch64/bindings.rs @@ -365,11 +365,6 @@ pub type __be32 = __u32; pub type __wsum = __u32; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct bpf_perf_event_data { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] pub struct linux_binprm { _unused: [u8; 0], } @@ -2888,6 +2883,14 @@ pub struct user_pt_regs { pub csr_badv: ::aya_ebpf_cty::c_ulong, pub reserved: [::aya_ebpf_cty::c_ulong; 10usize], } +pub type bpf_user_pt_regs_t = user_pt_regs; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_perf_event_data { + pub regs: bpf_user_pt_regs_t, + pub sample_period: __u64, + pub addr: __u64, +} pub type sa_family_t = ::aya_ebpf_cty::c_ushort; #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/ebpf/aya-ebpf-bindings/src/mips/bindings.rs b/ebpf/aya-ebpf-bindings/src/mips/bindings.rs index 65333c5c..1bacaa53 100644 --- a/ebpf/aya-ebpf-bindings/src/mips/bindings.rs +++ b/ebpf/aya-ebpf-bindings/src/mips/bindings.rs @@ -366,11 +366,6 @@ pub type __be32 = __u32; pub type __wsum = __u32; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct bpf_perf_event_data { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] pub struct linux_binprm { _unused: [u8; 0], } @@ -2903,6 +2898,14 @@ pub struct pt_regs { pub cp0_status: __u64, pub cp0_cause: __u64, } +pub type bpf_user_pt_regs_t = pt_regs; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_perf_event_data { + pub regs: bpf_user_pt_regs_t, + pub sample_period: __u64, + pub addr: __u64, +} pub type sa_family_t = ::aya_ebpf_cty::c_ushort; #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/ebpf/aya-ebpf-bindings/src/powerpc64/bindings.rs b/ebpf/aya-ebpf-bindings/src/powerpc64/bindings.rs index bc1388bf..7e46bcb7 100644 --- a/ebpf/aya-ebpf-bindings/src/powerpc64/bindings.rs +++ b/ebpf/aya-ebpf-bindings/src/powerpc64/bindings.rs @@ -365,11 +365,6 @@ pub type __be32 = __u32; pub type __wsum = __u32; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct bpf_perf_event_data { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] pub struct linux_binprm { _unused: [u8; 0], } @@ -2891,6 +2886,14 @@ pub struct pt_regs { pub dsisr: ::aya_ebpf_cty::c_ulong, pub result: ::aya_ebpf_cty::c_ulong, } +pub type bpf_user_pt_regs_t = pt_regs; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_perf_event_data { + pub regs: bpf_user_pt_regs_t, + pub sample_period: __u64, + pub addr: __u64, +} pub type sa_family_t = ::aya_ebpf_cty::c_ushort; #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/ebpf/aya-ebpf-bindings/src/riscv64/bindings.rs b/ebpf/aya-ebpf-bindings/src/riscv64/bindings.rs index 98b85819..c90a7d2a 100644 --- a/ebpf/aya-ebpf-bindings/src/riscv64/bindings.rs +++ b/ebpf/aya-ebpf-bindings/src/riscv64/bindings.rs @@ -365,11 +365,6 @@ pub type __be32 = __u32; pub type __wsum = __u32; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct bpf_perf_event_data { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] pub struct linux_binprm { _unused: [u8; 0], } @@ -2915,6 +2910,14 @@ pub struct user_regs_struct { pub t5: ::aya_ebpf_cty::c_ulong, pub t6: ::aya_ebpf_cty::c_ulong, } +pub type bpf_user_pt_regs_t = user_regs_struct; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_perf_event_data { + pub regs: bpf_user_pt_regs_t, + pub sample_period: __u64, + pub addr: __u64, +} pub type sa_family_t = ::aya_ebpf_cty::c_ushort; #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/ebpf/aya-ebpf-bindings/src/s390x/bindings.rs b/ebpf/aya-ebpf-bindings/src/s390x/bindings.rs index 15804301..015cafe7 100644 --- a/ebpf/aya-ebpf-bindings/src/s390x/bindings.rs +++ b/ebpf/aya-ebpf-bindings/src/s390x/bindings.rs @@ -365,11 +365,6 @@ pub type __be32 = __u32; pub type __wsum = __u32; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct bpf_perf_event_data { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] pub struct linux_binprm { _unused: [u8; 0], } @@ -3848,6 +3843,14 @@ pub struct user_regs_struct { pub per_info: per_struct, pub ieee_instruction_pointer: ::aya_ebpf_cty::c_ulong, } +pub type bpf_user_pt_regs_t = user_pt_regs; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_perf_event_data { + pub regs: bpf_user_pt_regs_t, + pub sample_period: __u64, + pub addr: __u64, +} pub type sa_family_t = ::aya_ebpf_cty::c_ushort; #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/ebpf/aya-ebpf-bindings/src/x86_64/bindings.rs b/ebpf/aya-ebpf-bindings/src/x86_64/bindings.rs index 89fec488..72c24b75 100644 --- a/ebpf/aya-ebpf-bindings/src/x86_64/bindings.rs +++ b/ebpf/aya-ebpf-bindings/src/x86_64/bindings.rs @@ -365,11 +365,6 @@ pub type __be32 = __u32; pub type __wsum = __u32; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct bpf_perf_event_data { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] pub struct linux_binprm { _unused: [u8; 0], } @@ -2899,6 +2894,14 @@ pub struct pt_regs { pub rsp: ::aya_ebpf_cty::c_ulong, pub ss: ::aya_ebpf_cty::c_ulong, } +pub type bpf_user_pt_regs_t = pt_regs; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_perf_event_data { + pub regs: bpf_user_pt_regs_t, + pub sample_period: __u64, + pub addr: __u64, +} pub type sa_family_t = ::aya_ebpf_cty::c_ushort; #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/ebpf/aya-ebpf/src/programs/perf_event.rs b/ebpf/aya-ebpf/src/programs/perf_event.rs index d847fc31..f8de1c0a 100644 --- a/ebpf/aya-ebpf/src/programs/perf_event.rs +++ b/ebpf/aya-ebpf/src/programs/perf_event.rs @@ -1,19 +1,21 @@ use core::ffi::c_void; +use aya_ebpf_bindings::bindings::bpf_perf_event_data; + use crate::EbpfContext; pub struct PerfEventContext { - ctx: *mut c_void, + pub ctx: *mut bpf_perf_event_data, } impl PerfEventContext { - pub fn new(ctx: *mut c_void) -> Self { + pub fn new(ctx: *mut bpf_perf_event_data) -> Self { Self { ctx } } } impl EbpfContext for PerfEventContext { fn as_ptr(&self) -> *mut c_void { - self.ctx + self.ctx.cast() } } diff --git a/test/integration-ebpf/Cargo.toml b/test/integration-ebpf/Cargo.toml index cb52e728..33715cfb 100644 --- a/test/integration-ebpf/Cargo.toml +++ b/test/integration-ebpf/Cargo.toml @@ -103,3 +103,7 @@ path = "src/xdp_sec.rs" [[bin]] name = "uprobe_cookie" path = "src/uprobe_cookie.rs" + +[[bin]] +name = "perf_event_bp" +path = "src/perf_event_bp.rs" diff --git a/test/integration-ebpf/src/perf_event_bp.rs b/test/integration-ebpf/src/perf_event_bp.rs new file mode 100644 index 00000000..f6928c01 --- /dev/null +++ b/test/integration-ebpf/src/perf_event_bp.rs @@ -0,0 +1,24 @@ +#![no_std] +#![no_main] +#![expect(unused_crate_dependencies, reason = "used in other bins")] + +use aya_ebpf::{ + EbpfContext as _, + macros::{map, perf_event}, + maps::HashMap, + programs::PerfEventContext, +}; + +#[cfg(not(test))] +extern crate ebpf_panic; + +#[map] +static READERS: HashMap = HashMap::with_max_entries(1, 0); + +#[perf_event] +fn perf_event_bp(ctx: PerfEventContext) -> u32 { + let tgid = ctx.tgid(); + let addr = unsafe { (*ctx.ctx).addr }; + let _ = READERS.insert(tgid, addr, 0); + 0 +} diff --git a/test/integration-test/src/lib.rs b/test/integration-test/src/lib.rs index 64f37d18..01e26f03 100644 --- a/test/integration-test/src/lib.rs +++ b/test/integration-test/src/lib.rs @@ -46,6 +46,7 @@ bpf_file!( MEMMOVE_TEST => "memmove_test", NAME_TEST => "name_test", PASS => "pass", + PERF_EVENT_BP => "perf_event_bp", RAW_TRACEPOINT => "raw_tracepoint", REDIRECT => "redirect", RELOCATIONS => "relocations", diff --git a/test/integration-test/src/tests.rs b/test/integration-test/src/tests.rs index 8c605313..4de831aa 100644 --- a/test/integration-test/src/tests.rs +++ b/test/integration-test/src/tests.rs @@ -11,6 +11,7 @@ mod log; mod lsm; mod map_pin; mod maps_disjoint; +mod perf_event_bp; mod raw_tracepoint; mod rbpf; mod relocations; diff --git a/test/integration-test/src/tests/perf_event_bp.rs b/test/integration-test/src/tests/perf_event_bp.rs new file mode 100644 index 00000000..5667fdc5 --- /dev/null +++ b/test/integration-test/src/tests/perf_event_bp.rs @@ -0,0 +1,320 @@ +use std::{collections::HashMap, fs, io::ErrorKind, num::ParseIntError, path::PathBuf}; + +use assert_matches::assert_matches; +use aya::{ + Ebpf, maps, + programs::{ + ProgramError, + perf_event::{ + BreakpointConfig, PerfBreakpointLength, PerfBreakpointType, PerfEventConfig, + PerfEventScope, SamplePolicy, + }, + }, + sys::SyscallError, + util::online_cpus, +}; +use scopeguard::defer; + +fn find_system_map() -> Vec { + const BOOT_PATH: &str = "/boot/"; + const SYSTEM_MAP_PREFIX: &str = "System.map-"; + let mut system_maps = Vec::new(); + for (i, entry) in fs::read_dir(BOOT_PATH) + .unwrap_or_else(|error| panic!("fs::read_dir({BOOT_PATH}): {error:?}")) + .enumerate() + { + let entry = entry.unwrap_or_else(|error| { + panic!("fs::read_dir({BOOT_PATH}).enumerate().nth({i}): {error:?}") + }); + if !entry + .file_name() + .as_encoded_bytes() + .starts_with(SYSTEM_MAP_PREFIX.as_bytes()) + { + continue; + } + system_maps.push(entry.path()); + } + system_maps +} + +struct KernelSymbol<'a> { + address: u64, + #[expect(dead_code)] + r#type: &'a str, + name: &'a str, + #[expect(dead_code)] + module: Option<&'a str>, +} + +fn parse_kernel_symbol(line: &str) -> Option> { + let mut parts = line.splitn(4, char::is_whitespace); + let address = parts.next()?; + let r#type = parts.next()?; + let name = parts.next()?; + let module = parts.next(); + // TODO(https://github.com/rust-lang/rust-clippy/issues/14112): Remove this allowance + // when the lint behaves more sensibly. + #[expect(clippy::manual_ok_err)] + let address = match u64::from_str_radix(address, 16) { + Ok(address) => Some(address), + Err(ParseIntError { .. }) => None, + }?; + Some(KernelSymbol { + address, + r#type, + name, + module, + }) +} + +fn parse_kernel_symbols(content: &str) -> HashMap<&str, Vec> { + let mut kernel_symbols = HashMap::<_, Vec<_>>::new(); + for line in content.lines() { + let KernelSymbol { + address, + r#type: _, + name, + module: _, + } = parse_kernel_symbol(line).unwrap_or_else(|| panic!("parse_kernel_symbol({line})")); + kernel_symbols.entry(name).or_default().push(address); + } + kernel_symbols +} + +#[track_caller] +fn run_breakpoint_case(config: BreakpointConfig, mut trigger: F, expected_addr: u64) +where + F: FnMut(), +{ + let mut bpf = Ebpf::load(crate::PERF_EVENT_BP).unwrap(); + + let map: maps::HashMap<_, u32, u64> = bpf.take_map("READERS").unwrap().try_into().unwrap(); + + let prog: &mut aya::programs::PerfEvent = bpf + .program_mut("perf_event_bp") + .unwrap() + .try_into() + .unwrap(); + prog.load().unwrap(); + + // x86 debug registers cannot trigger on read-only watchpoints, so the + // kernel rejects `HW_BREAKPOINT_R` outright, see + // https://github.com/torvalds/linux/blob/v6.12/arch/x86/kernel/hw_breakpoint.c#L345-L377. + let type_supported = !(cfg!(target_arch = "x86_64") + && matches!( + config, + BreakpointConfig::Data { + r#type: PerfBreakpointType::Read, + .. + } + )); + + let mut calling_process_scopes = Vec::new(); + let mut one_process_scopes = Vec::new(); + let mut all_processes_one_cpu_scopes = Vec::new(); + + let pid = std::process::id(); + for cpu in online_cpus().unwrap() { + calling_process_scopes.push(PerfEventScope::CallingProcess { cpu: Some(cpu) }); + one_process_scopes.push(PerfEventScope::OneProcess { + pid, + cpu: Some(cpu), + }); + all_processes_one_cpu_scopes.push(PerfEventScope::AllProcessesOneCpu { cpu }); + } + + let scope_groups = &[ + &[PerfEventScope::CallingProcess { cpu: None }][..], + &[PerfEventScope::OneProcess { pid, cpu: None }][..], + calling_process_scopes.as_slice(), + one_process_scopes.as_slice(), + all_processes_one_cpu_scopes.as_slice(), + ]; + + for scope_group in scope_groups { + let mut link_ids = Vec::new(); + for scope in *scope_group { + // arm64 rejects per-task kernel breakpoints (the scopes that carry + // a PID) to avoid single-step bookkeeping, see + // https://github.com/torvalds/linux/blob/v6.12/arch/arm64/kernel/hw_breakpoint.c#L566-L571. + let scope_supported = type_supported + && (!cfg!(target_arch = "aarch64") + || matches!(scope, PerfEventScope::AllProcessesOneCpu { cpu: _ })); + let attach = prog.attach( + PerfEventConfig::Breakpoint(config), + *scope, + SamplePolicy::Period(1), + true, + ); + if scope_supported { + let link_id = attach.unwrap_or_else(|error| { + panic!("{config:?} {scope:?} attach failed: {error:?}") + }); + link_ids.push(link_id); + } else { + assert_matches!( + attach.unwrap_err(), + ProgramError::SyscallError(SyscallError { + call: "perf_event_open", + io_error, + }) => io_error.kind() == ErrorKind::InvalidInput + ); + } + } + let attached = !link_ids.is_empty(); + defer! { + for link_id in link_ids { + prog.detach(link_id).unwrap(); + } + } + + trigger(); + + let lookup = map.get(&pid, 0); + if attached { + let recorded = + lookup.unwrap_or_else(|error| panic!("{config:?} map lookup failed: {error:?}")); + assert_eq!( + recorded, expected_addr, + "{config:?} recorded unexpected address" + ); + } else { + assert_matches!(lookup.unwrap_err(), maps::MapError::KeyNotFound); + } + } +} + +fn get_address(symbols: &HashMap<&str, Vec>, name: &str) -> Option { + symbols.get(name).map(|addrs| match addrs.as_slice() { + [addr] => *addr, + [] => panic!("no address found for {name} in {symbols:?}"), + addrs => panic!("multiple addresses found for {name}: {addrs:?}"), + }) +} + +#[test_log::test] +fn perf_event_bp() { + // Search for the address of modprobe_path. Prefer to grab it directly from + // kallsyms, but if it's not there we can grab it from System.map and apply + // the kaslr offset. + const KALLSYMS_PATH: &str = "/proc/kallsyms"; + let kernel_symbols = fs::read_to_string(KALLSYMS_PATH) + .unwrap_or_else(|error| panic!("fs::read_to_string({KALLSYMS_PATH}): {error:?}")); + let kernel_symbols = parse_kernel_symbols(&kernel_symbols); + + let attach_addr = if let Some(addr) = get_address(&kernel_symbols, "modprobe_path") { + addr + } else { + let gunzip_addr = get_address(&kernel_symbols, "gunzip") + .unwrap_or_else(|| panic!("gunzip not found in {kernel_symbols:?}")); + + let system_map = find_system_map(); + let system_map = match system_map.as_slice() { + [system_map] => system_map, + [] => panic!("no system map found"), + system_maps => panic!("multiple system maps found: {:?}", system_maps), + }; + let system_map = fs::read_to_string(system_map).unwrap_or_else(|error| { + panic!("fs::read_to_string({}): {error:?}", system_map.display()) + }); + let system_map = parse_kernel_symbols(&system_map); + + let gunzip_debug_addr = get_address(&system_map, "gunzip") + .unwrap_or_else(|| panic!("gunzip not found in {system_map:?}")); + let modprobe_path_debug_addr = get_address(&system_map, "modprobe_path") + .unwrap_or_else(|| panic!("modprobe_path not found in {system_map:?}")); + + let kaslr_offset = gunzip_addr.wrapping_sub(gunzip_debug_addr); + modprobe_path_debug_addr.wrapping_add(kaslr_offset) + }; + + // Trigger the hardware breakpoint by reading or writing + // /proc/sys/kernel/modprobe, the sysctl connected to modprobe_path. + // + // See https://github.com/torvalds/linux/blob/v6.17/kernel/module/main.c#L132-L150. + const MODPROBE_PATH: &str = "/proc/sys/kernel/modprobe"; + + let read = |modprobe_contents: &mut Option| { + let contents = fs::read_to_string(MODPROBE_PATH) + .unwrap_or_else(|error| panic!("fs::read_to_string({MODPROBE_PATH}): {error:?}")); + if let Some(modprobe_contents) = modprobe_contents { + assert_eq!(*modprobe_contents, contents); + } + *modprobe_contents = Some(contents); + }; + + let write = |contents: &str| { + fs::write(MODPROBE_PATH, contents.as_bytes()) + .unwrap_or_else(|error| panic!("fs::write({MODPROBE_PATH}, ..): {error:?}")); + }; + + let mut modprobe_contents_before = None; + run_breakpoint_case( + BreakpointConfig::Data { + r#type: PerfBreakpointType::Read, + address: attach_addr, + length: PerfBreakpointLength::Len1, + }, + || read(&mut modprobe_contents_before), + attach_addr, + ); + let modprobe_contents_before = modprobe_contents_before.unwrap(); + + run_breakpoint_case( + BreakpointConfig::Data { + r#type: PerfBreakpointType::Write, + address: attach_addr, + length: PerfBreakpointLength::Len1, + }, + || write(&modprobe_contents_before), + attach_addr, + ); + + let mut modprobe_contents_after = None; + run_breakpoint_case( + BreakpointConfig::Data { + r#type: PerfBreakpointType::ReadWrite, + address: attach_addr, + length: PerfBreakpointLength::Len1, + }, + || read(&mut modprobe_contents_after), + attach_addr, + ); + let modprobe_contents_after = modprobe_contents_after.unwrap(); + + run_breakpoint_case( + BreakpointConfig::Data { + r#type: PerfBreakpointType::ReadWrite, + address: attach_addr, + length: PerfBreakpointLength::Len1, + }, + || write(&modprobe_contents_after), + attach_addr, + ); + + // Just for fun. + assert_eq!(modprobe_contents_before, modprobe_contents_after); + + let execute_addr = { + let getpgid_symbol = if cfg!(target_arch = "x86_64") { + "__x64_sys_getpgid" + } else if cfg!(target_arch = "aarch64") { + "__arm64_sys_getpgid" + } else { + panic!("unsupported architecture"); + }; + get_address(&kernel_symbols, getpgid_symbol) + .unwrap_or_else(|| panic!("{getpgid_symbol} not found in {kernel_symbols:?}")) + }; + + run_breakpoint_case( + BreakpointConfig::Instruction { + address: execute_addr, + }, + || { + nix::unistd::getpgid(None).unwrap(); + }, + execute_addr, + ); +} diff --git a/xtask/public-api/aya-ebpf-bindings.txt b/xtask/public-api/aya-ebpf-bindings.txt index 7a38ec39..00a60f70 100644 --- a/xtask/public-api/aya-ebpf-bindings.txt +++ b/xtask/public-api/aya-ebpf-bindings.txt @@ -4972,6 +4972,9 @@ pub unsafe fn aya_ebpf_bindings::bindings::bpf_map_info::clone_to_uninit(&self, impl core::convert::From for aya_ebpf_bindings::bindings::bpf_map_info pub fn aya_ebpf_bindings::bindings::bpf_map_info::from(t: T) -> T #[repr(C)] pub struct aya_ebpf_bindings::bindings::bpf_perf_event_data +pub aya_ebpf_bindings::bindings::bpf_perf_event_data::addr: aya_ebpf_bindings::bindings::__u64 +pub aya_ebpf_bindings::bindings::bpf_perf_event_data::regs: aya_ebpf_bindings::bindings::bpf_user_pt_regs_t +pub aya_ebpf_bindings::bindings::bpf_perf_event_data::sample_period: aya_ebpf_bindings::bindings::__u64 impl core::clone::Clone for aya_ebpf_bindings::bindings::bpf_perf_event_data pub fn aya_ebpf_bindings::bindings::bpf_perf_event_data::clone(&self) -> aya_ebpf_bindings::bindings::bpf_perf_event_data impl core::fmt::Debug for aya_ebpf_bindings::bindings::bpf_perf_event_data @@ -7057,6 +7060,7 @@ pub type aya_ebpf_bindings::bindings::_bindgen_ty_6 = aya_ebpf_cty::ad::c_uint pub type aya_ebpf_bindings::bindings::_bindgen_ty_7 = aya_ebpf_cty::ad::c_uint pub type aya_ebpf_bindings::bindings::_bindgen_ty_8 = aya_ebpf_cty::ad::c_uint pub type aya_ebpf_bindings::bindings::_bindgen_ty_9 = aya_ebpf_cty::ad::c_uint +pub type aya_ebpf_bindings::bindings::bpf_user_pt_regs_t = aya_ebpf_bindings::bindings::pt_regs pub type aya_ebpf_bindings::bindings::sa_family_t = aya_ebpf_cty::c_ushort pub mod aya_ebpf_bindings::helpers pub unsafe fn aya_ebpf_bindings::helpers::bpf_bind(ctx: *mut aya_ebpf_bindings::bindings::bpf_sock_addr, addr: *mut aya_ebpf_bindings::bindings::sockaddr, addr_len: aya_ebpf_cty::ad::c_int) -> aya_ebpf_cty::od::c_long diff --git a/xtask/public-api/aya-ebpf.txt b/xtask/public-api/aya-ebpf.txt index a78b1758..b8e672ee 100644 --- a/xtask/public-api/aya-ebpf.txt +++ b/xtask/public-api/aya-ebpf.txt @@ -1723,8 +1723,9 @@ impl core::convert::From for aya_ebpf::programs::lsm::LsmContext pub fn aya_ebpf::programs::lsm::LsmContext::from(t: T) -> T pub mod aya_ebpf::programs::perf_event pub struct aya_ebpf::programs::perf_event::PerfEventContext +pub aya_ebpf::programs::perf_event::PerfEventContext::ctx: *mut aya_ebpf_bindings::x86_64::bindings::bpf_perf_event_data impl aya_ebpf::programs::perf_event::PerfEventContext -pub fn aya_ebpf::programs::perf_event::PerfEventContext::new(ctx: *mut core::ffi::c_void) -> Self +pub fn aya_ebpf::programs::perf_event::PerfEventContext::new(ctx: *mut aya_ebpf_bindings::x86_64::bindings::bpf_perf_event_data) -> Self impl aya_ebpf::EbpfContext for aya_ebpf::programs::perf_event::PerfEventContext pub fn aya_ebpf::programs::perf_event::PerfEventContext::as_ptr(&self) -> *mut core::ffi::c_void impl core::marker::Freeze for aya_ebpf::programs::perf_event::PerfEventContext @@ -2461,8 +2462,9 @@ pub fn aya_ebpf::programs::lsm::LsmContext::borrow_mut(&mut self) -> &mut T impl core::convert::From for aya_ebpf::programs::lsm::LsmContext pub fn aya_ebpf::programs::lsm::LsmContext::from(t: T) -> T pub struct aya_ebpf::programs::PerfEventContext +pub aya_ebpf::programs::PerfEventContext::ctx: *mut aya_ebpf_bindings::x86_64::bindings::bpf_perf_event_data impl aya_ebpf::programs::perf_event::PerfEventContext -pub fn aya_ebpf::programs::perf_event::PerfEventContext::new(ctx: *mut core::ffi::c_void) -> Self +pub fn aya_ebpf::programs::perf_event::PerfEventContext::new(ctx: *mut aya_ebpf_bindings::x86_64::bindings::bpf_perf_event_data) -> Self impl aya_ebpf::EbpfContext for aya_ebpf::programs::perf_event::PerfEventContext pub fn aya_ebpf::programs::perf_event::PerfEventContext::as_ptr(&self) -> *mut core::ffi::c_void impl core::marker::Freeze for aya_ebpf::programs::perf_event::PerfEventContext diff --git a/xtask/public-api/aya-obj.txt b/xtask/public-api/aya-obj.txt index 8406f83a..5e59c5ea 100644 --- a/xtask/public-api/aya-obj.txt +++ b/xtask/public-api/aya-obj.txt @@ -8057,24 +8057,38 @@ pub const aya_obj::generated::BTF_KIND_VOLATILE: aya_obj::generated::_bindgen_ty pub const aya_obj::generated::BTF_VAR_GLOBAL_ALLOCATED: aya_obj::generated::_bindgen_ty_43 pub const aya_obj::generated::BTF_VAR_GLOBAL_EXTERN: aya_obj::generated::_bindgen_ty_43 pub const aya_obj::generated::BTF_VAR_STATIC: aya_obj::generated::_bindgen_ty_43 -pub const aya_obj::generated::IFLA_XDP_ATTACHED: aya_obj::generated::_bindgen_ty_92 -pub const aya_obj::generated::IFLA_XDP_DRV_PROG_ID: aya_obj::generated::_bindgen_ty_92 -pub const aya_obj::generated::IFLA_XDP_EXPECTED_FD: aya_obj::generated::_bindgen_ty_92 -pub const aya_obj::generated::IFLA_XDP_FD: aya_obj::generated::_bindgen_ty_92 -pub const aya_obj::generated::IFLA_XDP_FLAGS: aya_obj::generated::_bindgen_ty_92 -pub const aya_obj::generated::IFLA_XDP_HW_PROG_ID: aya_obj::generated::_bindgen_ty_92 -pub const aya_obj::generated::IFLA_XDP_PROG_ID: aya_obj::generated::_bindgen_ty_92 -pub const aya_obj::generated::IFLA_XDP_SKB_PROG_ID: aya_obj::generated::_bindgen_ty_92 -pub const aya_obj::generated::IFLA_XDP_UNSPEC: aya_obj::generated::_bindgen_ty_92 -pub const aya_obj::generated::NFPROTO_ARP: aya_obj::generated::_bindgen_ty_99 -pub const aya_obj::generated::NFPROTO_BRIDGE: aya_obj::generated::_bindgen_ty_99 -pub const aya_obj::generated::NFPROTO_DECNET: aya_obj::generated::_bindgen_ty_99 -pub const aya_obj::generated::NFPROTO_INET: aya_obj::generated::_bindgen_ty_99 -pub const aya_obj::generated::NFPROTO_IPV4: aya_obj::generated::_bindgen_ty_99 -pub const aya_obj::generated::NFPROTO_IPV6: aya_obj::generated::_bindgen_ty_99 -pub const aya_obj::generated::NFPROTO_NETDEV: aya_obj::generated::_bindgen_ty_99 -pub const aya_obj::generated::NFPROTO_NUMPROTO: aya_obj::generated::_bindgen_ty_99 -pub const aya_obj::generated::NFPROTO_UNSPEC: aya_obj::generated::_bindgen_ty_99 +pub const aya_obj::generated::HW_BREAKPOINT_EMPTY: aya_obj::generated::_bindgen_ty_45 +pub const aya_obj::generated::HW_BREAKPOINT_INVALID: aya_obj::generated::_bindgen_ty_45 +pub const aya_obj::generated::HW_BREAKPOINT_LEN_1: aya_obj::generated::_bindgen_ty_44 +pub const aya_obj::generated::HW_BREAKPOINT_LEN_2: aya_obj::generated::_bindgen_ty_44 +pub const aya_obj::generated::HW_BREAKPOINT_LEN_3: aya_obj::generated::_bindgen_ty_44 +pub const aya_obj::generated::HW_BREAKPOINT_LEN_4: aya_obj::generated::_bindgen_ty_44 +pub const aya_obj::generated::HW_BREAKPOINT_LEN_5: aya_obj::generated::_bindgen_ty_44 +pub const aya_obj::generated::HW_BREAKPOINT_LEN_6: aya_obj::generated::_bindgen_ty_44 +pub const aya_obj::generated::HW_BREAKPOINT_LEN_7: aya_obj::generated::_bindgen_ty_44 +pub const aya_obj::generated::HW_BREAKPOINT_LEN_8: aya_obj::generated::_bindgen_ty_44 +pub const aya_obj::generated::HW_BREAKPOINT_R: aya_obj::generated::_bindgen_ty_45 +pub const aya_obj::generated::HW_BREAKPOINT_RW: aya_obj::generated::_bindgen_ty_45 +pub const aya_obj::generated::HW_BREAKPOINT_W: aya_obj::generated::_bindgen_ty_45 +pub const aya_obj::generated::HW_BREAKPOINT_X: aya_obj::generated::_bindgen_ty_45 +pub const aya_obj::generated::IFLA_XDP_ATTACHED: aya_obj::generated::_bindgen_ty_94 +pub const aya_obj::generated::IFLA_XDP_DRV_PROG_ID: aya_obj::generated::_bindgen_ty_94 +pub const aya_obj::generated::IFLA_XDP_EXPECTED_FD: aya_obj::generated::_bindgen_ty_94 +pub const aya_obj::generated::IFLA_XDP_FD: aya_obj::generated::_bindgen_ty_94 +pub const aya_obj::generated::IFLA_XDP_FLAGS: aya_obj::generated::_bindgen_ty_94 +pub const aya_obj::generated::IFLA_XDP_HW_PROG_ID: aya_obj::generated::_bindgen_ty_94 +pub const aya_obj::generated::IFLA_XDP_PROG_ID: aya_obj::generated::_bindgen_ty_94 +pub const aya_obj::generated::IFLA_XDP_SKB_PROG_ID: aya_obj::generated::_bindgen_ty_94 +pub const aya_obj::generated::IFLA_XDP_UNSPEC: aya_obj::generated::_bindgen_ty_94 +pub const aya_obj::generated::NFPROTO_ARP: aya_obj::generated::_bindgen_ty_101 +pub const aya_obj::generated::NFPROTO_BRIDGE: aya_obj::generated::_bindgen_ty_101 +pub const aya_obj::generated::NFPROTO_DECNET: aya_obj::generated::_bindgen_ty_101 +pub const aya_obj::generated::NFPROTO_INET: aya_obj::generated::_bindgen_ty_101 +pub const aya_obj::generated::NFPROTO_IPV4: aya_obj::generated::_bindgen_ty_101 +pub const aya_obj::generated::NFPROTO_IPV6: aya_obj::generated::_bindgen_ty_101 +pub const aya_obj::generated::NFPROTO_NETDEV: aya_obj::generated::_bindgen_ty_101 +pub const aya_obj::generated::NFPROTO_NUMPROTO: aya_obj::generated::_bindgen_ty_101 +pub const aya_obj::generated::NFPROTO_UNSPEC: aya_obj::generated::_bindgen_ty_101 pub const aya_obj::generated::NLMSG_ALIGNTO: u32 pub const aya_obj::generated::NR_BTF_KINDS: aya_obj::generated::_bindgen_ty_42 pub const aya_obj::generated::PERF_EVENT_IOC_DISABLE: u32 @@ -8097,36 +8111,36 @@ pub const aya_obj::generated::PERF_MAX_CONTEXTS_PER_STACK: u32 pub const aya_obj::generated::PERF_MAX_STACK_DEPTH: u32 pub const aya_obj::generated::SO_ATTACH_BPF: u32 pub const aya_obj::generated::SO_DETACH_BPF: u32 -pub const aya_obj::generated::TCA_BPF_ACT: aya_obj::generated::_bindgen_ty_154 -pub const aya_obj::generated::TCA_BPF_CLASSID: aya_obj::generated::_bindgen_ty_154 -pub const aya_obj::generated::TCA_BPF_FD: aya_obj::generated::_bindgen_ty_154 -pub const aya_obj::generated::TCA_BPF_FLAGS: aya_obj::generated::_bindgen_ty_154 -pub const aya_obj::generated::TCA_BPF_FLAGS_GEN: aya_obj::generated::_bindgen_ty_154 +pub const aya_obj::generated::TCA_BPF_ACT: aya_obj::generated::_bindgen_ty_156 +pub const aya_obj::generated::TCA_BPF_CLASSID: aya_obj::generated::_bindgen_ty_156 +pub const aya_obj::generated::TCA_BPF_FD: aya_obj::generated::_bindgen_ty_156 +pub const aya_obj::generated::TCA_BPF_FLAGS: aya_obj::generated::_bindgen_ty_156 +pub const aya_obj::generated::TCA_BPF_FLAGS_GEN: aya_obj::generated::_bindgen_ty_156 pub const aya_obj::generated::TCA_BPF_FLAG_ACT_DIRECT: u32 -pub const aya_obj::generated::TCA_BPF_ID: aya_obj::generated::_bindgen_ty_154 -pub const aya_obj::generated::TCA_BPF_NAME: aya_obj::generated::_bindgen_ty_154 -pub const aya_obj::generated::TCA_BPF_OPS: aya_obj::generated::_bindgen_ty_154 -pub const aya_obj::generated::TCA_BPF_OPS_LEN: aya_obj::generated::_bindgen_ty_154 -pub const aya_obj::generated::TCA_BPF_POLICE: aya_obj::generated::_bindgen_ty_154 -pub const aya_obj::generated::TCA_BPF_TAG: aya_obj::generated::_bindgen_ty_154 -pub const aya_obj::generated::TCA_BPF_UNSPEC: aya_obj::generated::_bindgen_ty_154 -pub const aya_obj::generated::TCA_CHAIN: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_DUMP_FLAGS: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_DUMP_INVISIBLE: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_EGRESS_BLOCK: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_EXT_WARN_MSG: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_FCNT: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_HW_OFFLOAD: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_INGRESS_BLOCK: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_KIND: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_OPTIONS: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_PAD: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_RATE: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_STAB: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_STATS: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_STATS2: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_UNSPEC: aya_obj::generated::_bindgen_ty_174 -pub const aya_obj::generated::TCA_XSTATS: aya_obj::generated::_bindgen_ty_174 +pub const aya_obj::generated::TCA_BPF_ID: aya_obj::generated::_bindgen_ty_156 +pub const aya_obj::generated::TCA_BPF_NAME: aya_obj::generated::_bindgen_ty_156 +pub const aya_obj::generated::TCA_BPF_OPS: aya_obj::generated::_bindgen_ty_156 +pub const aya_obj::generated::TCA_BPF_OPS_LEN: aya_obj::generated::_bindgen_ty_156 +pub const aya_obj::generated::TCA_BPF_POLICE: aya_obj::generated::_bindgen_ty_156 +pub const aya_obj::generated::TCA_BPF_TAG: aya_obj::generated::_bindgen_ty_156 +pub const aya_obj::generated::TCA_BPF_UNSPEC: aya_obj::generated::_bindgen_ty_156 +pub const aya_obj::generated::TCA_CHAIN: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_DUMP_FLAGS: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_DUMP_INVISIBLE: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_EGRESS_BLOCK: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_EXT_WARN_MSG: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_FCNT: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_HW_OFFLOAD: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_INGRESS_BLOCK: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_KIND: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_OPTIONS: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_PAD: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_RATE: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_STAB: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_STATS: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_STATS2: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_UNSPEC: aya_obj::generated::_bindgen_ty_176 +pub const aya_obj::generated::TCA_XSTATS: aya_obj::generated::_bindgen_ty_176 pub const aya_obj::generated::TC_H_CLSACT: u32 pub const aya_obj::generated::TC_H_INGRESS: u32 pub const aya_obj::generated::TC_H_MAJ_MASK: u32 @@ -8143,10 +8157,10 @@ pub const aya_obj::generated::XDP_FLAGS_MODES: u32 pub const aya_obj::generated::XDP_FLAGS_REPLACE: u32 pub const aya_obj::generated::XDP_FLAGS_SKB_MODE: u32 pub const aya_obj::generated::XDP_FLAGS_UPDATE_IF_NOEXIST: u32 -pub const aya_obj::generated::__IFLA_XDP_MAX: aya_obj::generated::_bindgen_ty_92 +pub const aya_obj::generated::__IFLA_XDP_MAX: aya_obj::generated::_bindgen_ty_94 pub const aya_obj::generated::__MAX_BPF_REG: aya_obj::generated::_bindgen_ty_1 -pub const aya_obj::generated::__TCA_BPF_MAX: aya_obj::generated::_bindgen_ty_154 -pub const aya_obj::generated::__TCA_MAX: aya_obj::generated::_bindgen_ty_174 +pub const aya_obj::generated::__TCA_BPF_MAX: aya_obj::generated::_bindgen_ty_156 +pub const aya_obj::generated::__TCA_MAX: aya_obj::generated::_bindgen_ty_176 pub type aya_obj::generated::__s16 = core::ffi::primitives::c_short pub type aya_obj::generated::__s32 = core::ffi::primitives::c_int pub type aya_obj::generated::__s64 = core::ffi::primitives::c_longlong @@ -8155,14 +8169,15 @@ pub type aya_obj::generated::__u32 = core::ffi::primitives::c_uint pub type aya_obj::generated::__u64 = core::ffi::primitives::c_ulonglong pub type aya_obj::generated::__u8 = core::ffi::primitives::c_uchar pub type aya_obj::generated::_bindgen_ty_10 = core::ffi::primitives::c_uint +pub type aya_obj::generated::_bindgen_ty_101 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_11 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_12 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_13 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_14 = core::ffi::primitives::c_ulong pub type aya_obj::generated::_bindgen_ty_15 = core::ffi::primitives::c_int -pub type aya_obj::generated::_bindgen_ty_154 = core::ffi::primitives::c_uint +pub type aya_obj::generated::_bindgen_ty_156 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_17 = core::ffi::primitives::c_uint -pub type aya_obj::generated::_bindgen_ty_174 = core::ffi::primitives::c_uint +pub type aya_obj::generated::_bindgen_ty_176 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_19 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_2 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_21 = core::ffi::primitives::c_uint @@ -8174,13 +8189,14 @@ pub type aya_obj::generated::_bindgen_ty_4 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_41 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_42 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_43 = core::ffi::primitives::c_uint +pub type aya_obj::generated::_bindgen_ty_44 = core::ffi::primitives::c_uint +pub type aya_obj::generated::_bindgen_ty_45 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_5 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_6 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_7 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_8 = core::ffi::primitives::c_uint pub type aya_obj::generated::_bindgen_ty_9 = core::ffi::primitives::c_uint -pub type aya_obj::generated::_bindgen_ty_92 = core::ffi::primitives::c_uint -pub type aya_obj::generated::_bindgen_ty_99 = core::ffi::primitives::c_uint +pub type aya_obj::generated::_bindgen_ty_94 = core::ffi::primitives::c_uint pub mod aya_obj::links pub mod aya_obj::maps pub enum aya_obj::maps::Map diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt index 27a51ec5..8690f622 100644 --- a/xtask/public-api/aya.txt +++ b/xtask/public-api/aya.txt @@ -5299,6 +5299,46 @@ pub fn aya::programs::perf_attach::PerfLinkId::borrow_mut(&mut self) -> &mut T impl core::convert::From for aya::programs::perf_attach::PerfLinkId pub fn aya::programs::perf_attach::PerfLinkId::from(t: T) -> T pub mod aya::programs::perf_event +pub enum aya::programs::perf_event::BreakpointConfig +pub aya::programs::perf_event::BreakpointConfig::Data +pub aya::programs::perf_event::BreakpointConfig::Data::address: u64 +pub aya::programs::perf_event::BreakpointConfig::Data::length: aya::programs::perf_event::PerfBreakpointLength +pub aya::programs::perf_event::BreakpointConfig::Data::type: aya::programs::perf_event::PerfBreakpointType +pub aya::programs::perf_event::BreakpointConfig::Instruction +pub aya::programs::perf_event::BreakpointConfig::Instruction::address: u64 +impl core::clone::Clone for aya::programs::perf_event::BreakpointConfig +pub fn aya::programs::perf_event::BreakpointConfig::clone(&self) -> aya::programs::perf_event::BreakpointConfig +impl core::fmt::Debug for aya::programs::perf_event::BreakpointConfig +pub fn aya::programs::perf_event::BreakpointConfig::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result +impl core::marker::Copy for aya::programs::perf_event::BreakpointConfig +impl core::marker::Freeze for aya::programs::perf_event::BreakpointConfig +impl core::marker::Send for aya::programs::perf_event::BreakpointConfig +impl core::marker::Sync for aya::programs::perf_event::BreakpointConfig +impl core::marker::Unpin for aya::programs::perf_event::BreakpointConfig +impl core::panic::unwind_safe::RefUnwindSafe for aya::programs::perf_event::BreakpointConfig +impl core::panic::unwind_safe::UnwindSafe for aya::programs::perf_event::BreakpointConfig +impl core::convert::Into for aya::programs::perf_event::BreakpointConfig where U: core::convert::From +pub fn aya::programs::perf_event::BreakpointConfig::into(self) -> U +impl core::convert::TryFrom for aya::programs::perf_event::BreakpointConfig where U: core::convert::Into +pub type aya::programs::perf_event::BreakpointConfig::Error = core::convert::Infallible +pub fn aya::programs::perf_event::BreakpointConfig::try_from(value: U) -> core::result::Result>::Error> +impl core::convert::TryInto for aya::programs::perf_event::BreakpointConfig where U: core::convert::TryFrom +pub type aya::programs::perf_event::BreakpointConfig::Error = >::Error +pub fn aya::programs::perf_event::BreakpointConfig::try_into(self) -> core::result::Result>::Error> +impl alloc::borrow::ToOwned for aya::programs::perf_event::BreakpointConfig where T: core::clone::Clone +pub type aya::programs::perf_event::BreakpointConfig::Owned = T +pub fn aya::programs::perf_event::BreakpointConfig::clone_into(&self, target: &mut T) +pub fn aya::programs::perf_event::BreakpointConfig::to_owned(&self) -> T +impl core::any::Any for aya::programs::perf_event::BreakpointConfig where T: 'static + ?core::marker::Sized +pub fn aya::programs::perf_event::BreakpointConfig::type_id(&self) -> core::any::TypeId +impl core::borrow::Borrow for aya::programs::perf_event::BreakpointConfig where T: ?core::marker::Sized +pub fn aya::programs::perf_event::BreakpointConfig::borrow(&self) -> &T +impl core::borrow::BorrowMut for aya::programs::perf_event::BreakpointConfig where T: ?core::marker::Sized +pub fn aya::programs::perf_event::BreakpointConfig::borrow_mut(&mut self) -> &mut T +impl core::clone::CloneToUninit for aya::programs::perf_event::BreakpointConfig where T: core::clone::Clone +pub unsafe fn aya::programs::perf_event::BreakpointConfig::clone_to_uninit(&self, dest: *mut u8) +impl core::convert::From for aya::programs::perf_event::BreakpointConfig +pub fn aya::programs::perf_event::BreakpointConfig::from(t: T) -> T #[repr(u32)] pub enum aya::programs::perf_event::HardwareEvent pub aya::programs::perf_event::HardwareEvent::BranchInstructions = 4 pub aya::programs::perf_event::HardwareEvent::BranchMisses = 5 @@ -5457,8 +5497,83 @@ impl core::clone::CloneToUninit for aya::programs::perf_event::HwCacheResult pub unsafe fn aya::programs::perf_event::HwCacheResult::clone_to_uninit(&self, dest: *mut u8) impl core::convert::From for aya::programs::perf_event::HwCacheResult pub fn aya::programs::perf_event::HwCacheResult::from(t: T) -> T +#[repr(u32)] pub enum aya::programs::perf_event::PerfBreakpointLength +pub aya::programs::perf_event::PerfBreakpointLength::Len1 = 1 +pub aya::programs::perf_event::PerfBreakpointLength::Len2 = 2 +pub aya::programs::perf_event::PerfBreakpointLength::Len4 = 4 +pub aya::programs::perf_event::PerfBreakpointLength::Len8 = 8 +impl core::clone::Clone for aya::programs::perf_event::PerfBreakpointLength +pub fn aya::programs::perf_event::PerfBreakpointLength::clone(&self) -> aya::programs::perf_event::PerfBreakpointLength +impl core::fmt::Debug for aya::programs::perf_event::PerfBreakpointLength +pub fn aya::programs::perf_event::PerfBreakpointLength::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result +impl core::marker::Copy for aya::programs::perf_event::PerfBreakpointLength +impl core::marker::Freeze for aya::programs::perf_event::PerfBreakpointLength +impl core::marker::Send for aya::programs::perf_event::PerfBreakpointLength +impl core::marker::Sync for aya::programs::perf_event::PerfBreakpointLength +impl core::marker::Unpin for aya::programs::perf_event::PerfBreakpointLength +impl core::panic::unwind_safe::RefUnwindSafe for aya::programs::perf_event::PerfBreakpointLength +impl core::panic::unwind_safe::UnwindSafe for aya::programs::perf_event::PerfBreakpointLength +impl core::convert::Into for aya::programs::perf_event::PerfBreakpointLength where U: core::convert::From +pub fn aya::programs::perf_event::PerfBreakpointLength::into(self) -> U +impl core::convert::TryFrom for aya::programs::perf_event::PerfBreakpointLength where U: core::convert::Into +pub type aya::programs::perf_event::PerfBreakpointLength::Error = core::convert::Infallible +pub fn aya::programs::perf_event::PerfBreakpointLength::try_from(value: U) -> core::result::Result>::Error> +impl core::convert::TryInto for aya::programs::perf_event::PerfBreakpointLength where U: core::convert::TryFrom +pub type aya::programs::perf_event::PerfBreakpointLength::Error = >::Error +pub fn aya::programs::perf_event::PerfBreakpointLength::try_into(self) -> core::result::Result>::Error> +impl alloc::borrow::ToOwned for aya::programs::perf_event::PerfBreakpointLength where T: core::clone::Clone +pub type aya::programs::perf_event::PerfBreakpointLength::Owned = T +pub fn aya::programs::perf_event::PerfBreakpointLength::clone_into(&self, target: &mut T) +pub fn aya::programs::perf_event::PerfBreakpointLength::to_owned(&self) -> T +impl core::any::Any for aya::programs::perf_event::PerfBreakpointLength where T: 'static + ?core::marker::Sized +pub fn aya::programs::perf_event::PerfBreakpointLength::type_id(&self) -> core::any::TypeId +impl core::borrow::Borrow for aya::programs::perf_event::PerfBreakpointLength where T: ?core::marker::Sized +pub fn aya::programs::perf_event::PerfBreakpointLength::borrow(&self) -> &T +impl core::borrow::BorrowMut for aya::programs::perf_event::PerfBreakpointLength where T: ?core::marker::Sized +pub fn aya::programs::perf_event::PerfBreakpointLength::borrow_mut(&mut self) -> &mut T +impl core::clone::CloneToUninit for aya::programs::perf_event::PerfBreakpointLength where T: core::clone::Clone +pub unsafe fn aya::programs::perf_event::PerfBreakpointLength::clone_to_uninit(&self, dest: *mut u8) +impl core::convert::From for aya::programs::perf_event::PerfBreakpointLength +pub fn aya::programs::perf_event::PerfBreakpointLength::from(t: T) -> T +#[repr(u32)] pub enum aya::programs::perf_event::PerfBreakpointType +pub aya::programs::perf_event::PerfBreakpointType::Read = 1 +pub aya::programs::perf_event::PerfBreakpointType::ReadWrite = 3 +pub aya::programs::perf_event::PerfBreakpointType::Write = 2 +impl core::clone::Clone for aya::programs::perf_event::PerfBreakpointType +pub fn aya::programs::perf_event::PerfBreakpointType::clone(&self) -> aya::programs::perf_event::PerfBreakpointType +impl core::fmt::Debug for aya::programs::perf_event::PerfBreakpointType +pub fn aya::programs::perf_event::PerfBreakpointType::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result +impl core::marker::Copy for aya::programs::perf_event::PerfBreakpointType +impl core::marker::Freeze for aya::programs::perf_event::PerfBreakpointType +impl core::marker::Send for aya::programs::perf_event::PerfBreakpointType +impl core::marker::Sync for aya::programs::perf_event::PerfBreakpointType +impl core::marker::Unpin for aya::programs::perf_event::PerfBreakpointType +impl core::panic::unwind_safe::RefUnwindSafe for aya::programs::perf_event::PerfBreakpointType +impl core::panic::unwind_safe::UnwindSafe for aya::programs::perf_event::PerfBreakpointType +impl core::convert::Into for aya::programs::perf_event::PerfBreakpointType where U: core::convert::From +pub fn aya::programs::perf_event::PerfBreakpointType::into(self) -> U +impl core::convert::TryFrom for aya::programs::perf_event::PerfBreakpointType where U: core::convert::Into +pub type aya::programs::perf_event::PerfBreakpointType::Error = core::convert::Infallible +pub fn aya::programs::perf_event::PerfBreakpointType::try_from(value: U) -> core::result::Result>::Error> +impl core::convert::TryInto for aya::programs::perf_event::PerfBreakpointType where U: core::convert::TryFrom +pub type aya::programs::perf_event::PerfBreakpointType::Error = >::Error +pub fn aya::programs::perf_event::PerfBreakpointType::try_into(self) -> core::result::Result>::Error> +impl alloc::borrow::ToOwned for aya::programs::perf_event::PerfBreakpointType where T: core::clone::Clone +pub type aya::programs::perf_event::PerfBreakpointType::Owned = T +pub fn aya::programs::perf_event::PerfBreakpointType::clone_into(&self, target: &mut T) +pub fn aya::programs::perf_event::PerfBreakpointType::to_owned(&self) -> T +impl core::any::Any for aya::programs::perf_event::PerfBreakpointType where T: 'static + ?core::marker::Sized +pub fn aya::programs::perf_event::PerfBreakpointType::type_id(&self) -> core::any::TypeId +impl core::borrow::Borrow for aya::programs::perf_event::PerfBreakpointType where T: ?core::marker::Sized +pub fn aya::programs::perf_event::PerfBreakpointType::borrow(&self) -> &T +impl core::borrow::BorrowMut for aya::programs::perf_event::PerfBreakpointType where T: ?core::marker::Sized +pub fn aya::programs::perf_event::PerfBreakpointType::borrow_mut(&mut self) -> &mut T +impl core::clone::CloneToUninit for aya::programs::perf_event::PerfBreakpointType where T: core::clone::Clone +pub unsafe fn aya::programs::perf_event::PerfBreakpointType::clone_to_uninit(&self, dest: *mut u8) +impl core::convert::From for aya::programs::perf_event::PerfBreakpointType +pub fn aya::programs::perf_event::PerfBreakpointType::from(t: T) -> T pub enum aya::programs::perf_event::PerfEventConfig -pub aya::programs::perf_event::PerfEventConfig::Breakpoint +pub aya::programs::perf_event::PerfEventConfig::Breakpoint(aya::programs::perf_event::BreakpointConfig) pub aya::programs::perf_event::PerfEventConfig::Hardware(aya::programs::perf_event::HardwareEvent) pub aya::programs::perf_event::PerfEventConfig::HwCache pub aya::programs::perf_event::PerfEventConfig::HwCache::event: aya::programs::perf_event::HwCacheEvent @@ -5512,7 +5627,7 @@ pub aya::programs::perf_event::PerfEventScope::CallingProcess pub aya::programs::perf_event::PerfEventScope::CallingProcess::cpu: core::option::Option pub aya::programs::perf_event::PerfEventScope::OneProcess pub aya::programs::perf_event::PerfEventScope::OneProcess::cpu: core::option::Option -pub aya::programs::perf_event::PerfEventScope::OneProcess::pid: i32 +pub aya::programs::perf_event::PerfEventScope::OneProcess::pid: u32 impl core::clone::Clone for aya::programs::perf_event::PerfEventScope pub fn aya::programs::perf_event::PerfEventScope::clone(&self) -> aya::programs::perf_event::PerfEventScope impl core::fmt::Debug for aya::programs::perf_event::PerfEventScope diff --git a/xtask/src/codegen/aya.rs b/xtask/src/codegen/aya.rs index b8330e83..042ea9d5 100644 --- a/xtask/src/codegen/aya.rs +++ b/xtask/src/codegen/aya.rs @@ -67,6 +67,8 @@ fn codegen_bindings(opts: &SysrootOptions, libbpf_dir: &Path) -> Result<()> { .constified_enum("IFLA_.*") .constified_enum("TCA_.*") .constified_enum("BPF_RINGBUF_.*") + // PERF + .constified_enum("HW_BREAKPOINT_.*") // NETFILTER .constified_enum("NFPROTO_.*"); @@ -141,6 +143,7 @@ fn codegen_bindings(opts: &SysrootOptions, libbpf_dir: &Path) -> Result<()> { "PERF_FLAG_.*", "PERF_EVENT_.*", "PERF_MAX_.*", + "HW_BREAKPOINT_.*", // NETLINK "NLMSG_ALIGNTO", "IFLA_XDP_FD", diff --git a/xtask/src/run.rs b/xtask/src/run.rs index 2580f26d..fe1ed92d 100644 --- a/xtask/src/run.rs +++ b/xtask/src/run.rs @@ -1,6 +1,7 @@ use std::{ - ffi::OsString, - fmt::Write as _, + collections::BTreeMap, + ffi::{OsStr, OsString}, + fmt::{Debug, Write as _}, fs::{self, File, OpenOptions}, io::{BufRead as _, BufReader, Write as _}, ops::Deref as _, @@ -112,13 +113,18 @@ enum Disposition { Unpack(T), } +enum ControlFlow { + Continue, + Break, +} + fn with_deb(archive: &Path, dest: &Path, mut state: S, mut select: F) -> Result where F: for<'state> FnMut( &'state mut S, &Path, tar::EntryType, - ) -> Disposition>>, + ) -> Disposition<(Option<&'state mut Vec>, ControlFlow)>, { fs::create_dir_all(dest).with_context(|| format!("failed to create {}", dest.display()))?; @@ -154,9 +160,9 @@ where ) })?; let entry_type = entry.header().entry_type(); - let selected = match select(&mut state, path.as_ref(), entry_type) { + let (selected, control_flow) = match select(&mut state, path.as_ref(), entry_type) { Disposition::Skip => continue, - Disposition::Unpack(selected) => selected, + Disposition::Unpack(unpack) => unpack, }; if let Some(selected) = selected { println!( @@ -180,6 +186,10 @@ where archive.display(), dest.display(), ); + match control_flow { + ControlFlow::Continue => continue, + ControlFlow::Break => break, + } } } println!("{} in {:?}", archive.display(), start.elapsed()); @@ -187,6 +197,14 @@ where Ok(state) } +fn one(slice: &[T]) -> Result<&T> { + if let [item] = slice { + Ok(item) + } else { + bail!("expected [{}], got {slice:?}", std::any::type_name::()) + } +} + /// Build and run the project. pub(crate) fn run(opts: Options) -> Result<()> { let Options { @@ -372,13 +390,63 @@ pub(crate) fn run(opts: Options) -> Result<()> { } let extraction_root = tempfile::tempdir().context("tempdir failed")?; + + #[derive(Eq, PartialEq, Ord, PartialOrd)] + struct KernelPackageKey<'a> { + base: &'a [u8], + } + + #[derive(Default)] + struct KernelPackageGroup<'a> { + kernel: Vec<&'a Path>, + debug: Vec<&'a Path>, + } + + let mut package_groups = BTreeMap::new(); + for archive in &kernel_archives { + let file_name = archive.file_name().ok_or_else(|| { + anyhow!("archive path missing filename: {}", archive.display()) + })?; + let file_name = file_name.as_encoded_bytes(); + // TODO(https://github.com/rust-lang/rust/issues/112811): use split_once when stable. + let package_name = file_name + .split(|&byte| byte == b'_') + .next() + .ok_or_else(|| anyhow!("unexpected archive filename: {}", archive.display()))?; + let (base, is_debug) = if let Some(base) = package_name.strip_suffix(b"-dbg") { + (base, true) + } else if let Some(base) = package_name.strip_suffix(b"-dbgsym") { + (base, true) + } else if let Some(base) = package_name.strip_suffix(b"-unsigned") { + (base, false) + } else { + bail!("unexpected archive filename: {}", archive.display()) + }; + let KernelPackageGroup { kernel, debug } = + package_groups.entry(KernelPackageKey { base }).or_default(); + let dst = if is_debug { debug } else { kernel }; + dst.push(archive.as_path()); + } + let mut errors = Vec::new(); - for (index, archive) in kernel_archives.iter().enumerate() { + for (index, (KernelPackageKey { base }, KernelPackageGroup { kernel, debug })) in + package_groups.into_iter().enumerate() + { + let base = { + use std::os::unix::ffi::OsStrExt as _; + OsStr::from_bytes(base) + }; + + let kernel_archive = one(kernel.as_slice()) + .with_context(|| format!("kernel archive for {}", base.display()))?; + let debug_archive = one(debug.as_slice()) + .with_context(|| format!("debug archive for {}", base.display()))?; + let (kernel_images, configs, modules_dirs) = with_deb( - archive, + kernel_archive, &extraction_root .path() - .join(format!("kernel-archive-{index}")), + .join(format!("kernel-archive-{index}-image")), (Vec::new(), Vec::new(), Vec::new()), |(kernel_images, configs, modules_dirs), path, entry_type| { if let Some(path) = ["./lib/modules/", "./usr/lib/modules/"] @@ -393,9 +461,10 @@ pub(crate) fn run(opts: Options) -> Result<()> { } }) { - return Disposition::Unpack( + return Disposition::Unpack(( (path.iter().count() == 1).then_some(modules_dirs), - ); + ControlFlow::Continue, + )); } if !entry_type.is_file() { return Disposition::Skip; @@ -414,37 +483,59 @@ pub(crate) fn run(opts: Options) -> Result<()> { }; let name = name.as_encoded_bytes(); if name.starts_with(b"vmlinuz-") { - Disposition::Unpack(Some(kernel_images)) + Disposition::Unpack((Some(kernel_images), ControlFlow::Continue)) } else if name.starts_with(b"config-") { - Disposition::Unpack(Some(configs)) + Disposition::Unpack((Some(configs), ControlFlow::Continue)) } else { Disposition::Skip } }, )?; - let kernel_image = match kernel_images.as_slice() { - [kernel_image] => kernel_image, - [] => bail!("no kernel images in {}", archive.display()), - kernel_images => bail!( - "multiple kernel images in {}: {:?}", - archive.display(), - kernel_images - ), - }; - let config = match configs.as_slice() { - [config] => config, - [] => bail!("no configs in {}", archive.display()), - configs => bail!("multiple configs in {}: {:?}", archive.display(), configs), - }; - let modules_dir = match modules_dirs.as_slice() { - [modules_dir] => modules_dir, - [] => bail!("no modules directories in {}", archive.display()), - modules_dirs => bail!( - "multiple modules directories in {}: {:?}", - archive.display(), - modules_dirs - ), - }; + let kernel_image = one(kernel_images.as_slice()) + .with_context(|| format!("kernel image in {}", kernel_archive.display()))?; + let config = one(configs.as_slice()) + .with_context(|| format!("config in {}", kernel_archive.display()))?; + let modules_dir = one(modules_dirs.as_slice()).with_context(|| { + format!("modules directory in {}", kernel_archive.display()) + })?; + + let system_maps = with_deb( + debug_archive, + &extraction_root + .path() + .join(format!("kernel-archive-{index}-debug")), + Vec::new(), + |system_maps: &mut Vec, path, entry_type| { + if entry_type != tar::EntryType::Regular { + return Disposition::Skip; + } + let name = match path.strip_prefix("./usr/lib/debug/boot/") { + Ok(path) => { + if let Some(path::Component::Normal(name)) = + path.components().next() + { + name + } else { + return Disposition::Skip; + } + } + Err(path::StripPrefixError { .. }) => { + return Disposition::Skip; + } + }; + if name.as_encoded_bytes().starts_with(b"System.map-") { + // We only expect one System.map in the debug archive; ordinarily + // we'd walk the whole archive to assert this fact but it turns out + // that doing so takes around 10 seconds while stopping early takes + // around 1ms. + Disposition::Unpack((Some(system_maps), ControlFlow::Break)) + } else { + Disposition::Skip + } + }, + )?; + let system_map = one(system_maps.as_slice()) + .with_context(|| format!("System.map in {}", debug_archive.display()))?; // Guess the guest architecture. let mut file = Command::new("file"); @@ -580,6 +671,11 @@ pub(crate) fn run(opts: Options) -> Result<()> { write_file(&Path::new("/boot").join(name), config, "644 0 0"); } + write_file(Path::new("/boot/System.map"), system_map, "644 0 0"); + if let Some(name) = system_map.file_name() { + write_file(&Path::new("/boot").join(name), system_map, "644 0 0"); + } + test_distro.iter().for_each(|(name, path)| { if name == "init" { write_file(Path::new("/init"), path, "755 0 0");