diff --git a/device/testing/linux-postmarketos-asahi/APKBUILD b/device/testing/linux-postmarketos-asahi/APKBUILD index 13f33db0c..020689c89 100644 --- a/device/testing/linux-postmarketos-asahi/APKBUILD +++ b/device/testing/linux-postmarketos-asahi/APKBUILD @@ -1,6 +1,6 @@ maintainer="Clayton Craft " pkgname=linux-postmarketos-asahi -pkgver=7.0.11_p2 +pkgver=7.0.12_p1 pkgrel=0 _rel=${pkgver#*_p} _kver=${pkgver%_p*} @@ -54,6 +54,7 @@ source=" config-postmarketos-asahi.aarch64 0001-nvmem-apple-spmi-nvmem-Fix-CFI-failures.patch + enable-dynamic-ftrace.patch " builddir="$srcdir/linux-asahi-$_asahiver" _defconfig="defconfig" @@ -88,7 +89,8 @@ package() { } sha512sums=" -c04f15e7b231d37aa14c2311eb580e56adca1bc32e718fbbf4651bd12d89a864b1b396f83640d9b57e5729390312262d35b1709c83dbdf6988fb69f3ba4663ac linux-postmarketos-asahi-7.0.11-2.tar.gz -1444f29dc22fc98419ca3fe71d9d41890597c33cf3b2befba1f14fcf970b6172abebbfac95a3bbf9229a393954864a94f181cfd7fb8cedf9ac9a51f7540ff351 config-postmarketos-asahi.aarch64 +4e054f227a9e2d6286c713a8287d434aee214b0c54773d55b37e5a781c8eec1ad97e73f761aee2e2b68aae4d989e04df9abad9c7e5598b84125d8ff4abb0c5ac linux-postmarketos-asahi-7.0.12-1.tar.gz +62de3220d7e05eed1e8f40e3fa60db2acdb43a27c8fa71bddd939b878d33d0436349b96485a19edc2f1bfcee2ba54a01f8d835187a9e9d6b4170b2c518665548 config-postmarketos-asahi.aarch64 8d205300cfabe192b53ed1cc644b087e76421eb973e1b2a31d657e4f2676badebdfcf6b0865569c43b4b904935435f6e729c3a8d4a6221fb5792e40ec1017a0f 0001-nvmem-apple-spmi-nvmem-Fix-CFI-failures.patch +e8b595f3e076896dc38f249c8908d58e2e6a858eaa77fe1e680f27db0e76d3d74c0b5dfebb7a4c57d546fee0b0f6eb81a38b20dfd72f985c9d02f28d79a5eceb enable-dynamic-ftrace.patch " diff --git a/device/testing/linux-postmarketos-asahi/config-postmarketos-asahi.aarch64 b/device/testing/linux-postmarketos-asahi/config-postmarketos-asahi.aarch64 index 88cfcdd4d..4c5d4df21 100644 --- a/device/testing/linux-postmarketos-asahi/config-postmarketos-asahi.aarch64 +++ b/device/testing/linux-postmarketos-asahi/config-postmarketos-asahi.aarch64 @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm64 7.0.11 Kernel Configuration +# Linux/arm64 7.0.12 Kernel Configuration # CONFIG_CC_VERSION_TEXT="Alpine clang version 22.1.3" CONFIG_GCC_VERSION=0 @@ -31,7 +31,7 @@ CONFIG_RUSTC_HAS_SPAN_FILE=y CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES=y CONFIG_RUSTC_HAS_FILE_WITH_NUL=y CONFIG_RUSTC_HAS_FILE_AS_C_STR=y -CONFIG_PAHOLE_VERSION=130 +CONFIG_PAHOLE_VERSION=131 CONFIG_IRQ_WORK=y CONFIG_BUILDTIME_TABLE_SORT=y CONFIG_THREAD_INFO_IN_TASK=y @@ -128,6 +128,7 @@ CONFIG_PREEMPT_COUNT=y CONFIG_PREEMPTION=y # CONFIG_PREEMPT_DYNAMIC is not set # CONFIG_SCHED_CORE is not set +# CONFIG_SCHED_CLASS_EXT is not set # # CPU/Task time and stats accounting @@ -1597,6 +1598,7 @@ CONFIG_NET_SCH_MQPRIO=m CONFIG_NET_SCH_INGRESS=m # CONFIG_NET_SCH_PLUG is not set # CONFIG_NET_SCH_ETS is not set +# CONFIG_NET_SCH_BPF is not set # CONFIG_NET_SCH_DUALPI2 is not set # CONFIG_NET_SCH_DEFAULT is not set @@ -6407,6 +6409,7 @@ CONFIG_HID_MCP2221=m # # HID-BPF support # +# CONFIG_HID_BPF is not set # end of HID-BPF support CONFIG_I2C_HID=y @@ -8876,7 +8879,7 @@ CONFIG_SECURITY=y CONFIG_HAS_SECURITY_AUDIT=y CONFIG_SECURITYFS=y # CONFIG_SECURITY_NETWORK is not set -# CONFIG_SECURITY_PATH is not set +CONFIG_SECURITY_PATH=y # CONFIG_STATIC_USERMODEHELPER is not set # CONFIG_SECURITY_SMACK is not set # CONFIG_SECURITY_TOMOYO is not set @@ -9379,16 +9382,19 @@ CONFIG_DEBUG_MISC=y CONFIG_DEBUG_INFO=y CONFIG_AS_HAS_NON_CONST_ULEB128=y # CONFIG_DEBUG_INFO_NONE is not set -CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y +# CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT is not set # CONFIG_DEBUG_INFO_DWARF4 is not set -# CONFIG_DEBUG_INFO_DWARF5 is not set -CONFIG_DEBUG_INFO_REDUCED=y +CONFIG_DEBUG_INFO_DWARF5=y +# CONFIG_DEBUG_INFO_REDUCED is not set CONFIG_DEBUG_INFO_COMPRESSED_NONE=y # CONFIG_DEBUG_INFO_COMPRESSED_ZLIB is not set # CONFIG_DEBUG_INFO_COMPRESSED_ZSTD is not set # CONFIG_DEBUG_INFO_SPLIT is not set +CONFIG_DEBUG_INFO_BTF=y CONFIG_PAHOLE_HAS_BTF_TAG=y CONFIG_PAHOLE_HAS_LANG_EXCLUDE=y +CONFIG_DEBUG_INFO_BTF_MODULES=y +# CONFIG_MODULE_ALLOW_BTF_MISMATCH is not set # CONFIG_GDB_SCRIPTS is not set CONFIG_FRAME_WARN=2048 # CONFIG_STRIP_ASM_SYMS is not set @@ -9554,6 +9560,7 @@ CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y CONFIG_HAVE_FUNCTION_GRAPH_FREGS=y CONFIG_HAVE_FTRACE_GRAPH_FUNC=y CONFIG_HAVE_DYNAMIC_FTRACE=y +CONFIG_HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=y CONFIG_HAVE_EXTRA_IPI_TRACEPOINTS=y CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS=y CONFIG_HAVE_SYSCALL_TRACEPOINTS=y @@ -9574,7 +9581,9 @@ CONFIG_FUNCTION_TRACER=y CONFIG_FUNCTION_GRAPH_TRACER=y # CONFIG_FUNCTION_GRAPH_RETVAL is not set # CONFIG_FUNCTION_GRAPH_RETADDR is not set +CONFIG_FUNCTION_TRACE_ARGS=y CONFIG_DYNAMIC_FTRACE=y +CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=y CONFIG_DYNAMIC_FTRACE_WITH_ARGS=y # CONFIG_FUNCTION_SELF_TRACING is not set # CONFIG_FPROBE is not set @@ -9592,6 +9601,7 @@ CONFIG_BRANCH_PROFILE_NONE=y # CONFIG_PROFILE_ANNOTATED_BRANCHES is not set # CONFIG_PROFILE_ALL_BRANCHES is not set # CONFIG_BLK_DEV_IO_TRACE is not set +CONFIG_PROBE_EVENTS_BTF_ARGS=y CONFIG_KPROBE_EVENTS=y # CONFIG_KPROBE_EVENTS_ON_NOTRACE is not set CONFIG_UPROBE_EVENTS=y diff --git a/device/testing/linux-postmarketos-asahi/enable-dynamic-ftrace.patch b/device/testing/linux-postmarketos-asahi/enable-dynamic-ftrace.patch new file mode 100644 index 000000000..9e98711f7 --- /dev/null +++ b/device/testing/linux-postmarketos-asahi/enable-dynamic-ftrace.patch @@ -0,0 +1,124 @@ +From d81e256317f22d08afbdd8da83cda875d058b97f Mon Sep 17 00:00:00 2001 +From: "Jose Fernandez (Anthropic)" +Date: Tue, 9 Jun 2026 05:19:26 +0000 +Subject: [PATCH 1/2] arm64: ftrace: prepare ftrace_modify_call() for use + without CALL_OPS + +ftrace_modify_call() is guarded by CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS +and calls ftrace_rec_set_ops(rec, arm64_rec_get_ops(rec)) directly, +which only exists when CALL_OPS is enabled. + +Generic ftrace also needs ftrace_modify_call() when +CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS is enabled, to retarget a +callsite between two non-FTRACE_ADDR destinations, as happens when a +direct trampoline is modified. The next patch allows DIRECT_CALLS without +CALL_OPS, so widen the guard to cover both configurations and switch +the body to the ftrace_rec_update_ops() wrapper, which already has a +stub for the !CALL_OPS case. ftrace_make_call() already uses the same +wrapper today. + +No functional change: with CALL_OPS enabled, ftrace_rec_update_ops() +expands to the exact call this replaces. + +Assisted-by: Claude:unspecified +Signed-off-by: Jose Fernandez (Anthropic) +Reviewed-by: Puranjay Mohan +--- + arch/arm64/kernel/ftrace.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c +index 5a1554a441628..e1a3c0b3a0514 100644 +--- a/arch/arm64/kernel/ftrace.c ++++ b/arch/arm64/kernel/ftrace.c +@@ -409,7 +409,8 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) + return ftrace_modify_code(pc, old, new, true); + } + +-#ifdef CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS ++#if defined(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS) || \ ++ defined(CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS) + int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, + unsigned long addr) + { +@@ -417,7 +418,7 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, + u32 old, new; + int ret; + +- ret = ftrace_rec_set_ops(rec, arm64_rec_get_ops(rec)); ++ ret = ftrace_rec_update_ops(rec); + if (ret) + return ret; + +-- +2.54.0 + +From c7d8dc4cd612aec63b954e13a2a940308d6c769e Mon Sep 17 00:00:00 2001 +From: "Jose Fernandez (Anthropic)" +Date: Tue, 9 Jun 2026 05:19:27 +0000 +Subject: [PATCH 2/2] arm64: ftrace: allow DIRECT_CALLS without CALL_OPS + +arm64 gained ftrace direct calls in commit 2aa6ac03516d ("arm64: +ftrace: Add direct call support") on top of +DYNAMIC_FTRACE_WITH_CALL_OPS, using the per-callsite ops pointer as a +fast path to reach the direct trampoline. Since commit baaf553d3bc3 +("arm64: Implement HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS"), CALL_OPS is +mutually exclusive with CFI: the pre-function NOPs would change the +offset of the pre-function kCFI type hash, and the compiler support +needed to keep that offset consistent does not exist yet. + +The result is that a CONFIG_CFI=y kernel loses CALL_OPS, and with it +DIRECT_CALLS, and with it every BPF trampoline attachment to kernel +functions: register_fentry() returns -ENOTSUPP, so fentry/fexit, +fmod_ret and BPF LSM programs cannot attach at all. This is a real +problem for hardened arm64 deployments that rely on BPF LSM for +security monitoring while keeping kCFI enabled. + +CALL_OPS is an optimization for direct calls, not a dependency. When +the direct trampoline is within BL range, the callsite branches +straight to it and ftrace_caller is not involved. When it is out of +range, ftrace_find_callable_addr() already falls back to +ftrace_caller, and the DIRECT_CALLS machinery there +(FREGS_DIRECT_TRAMP, ftrace_caller_direct_late) is gated on +DIRECT_CALLS alone, not CALL_OPS: the ops dispatch invokes +call_direct_funcs(), which stores the trampoline address in +ftrace_regs, and ftrace_caller tail-calls it. s390 and loongarch use +this same mechanism for HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS without +having CALL_OPS at all, and DYNAMIC_FTRACE_WITH_ARGS without CALL_OPS +is already a supported arm64 configuration (GCC builds with +CC_OPTIMIZE_FOR_SIZE do not satisfy the CALL_OPS select condition). + +Drop the CALL_OPS requirement from the +HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS select. Configurations that +keep CALL_OPS (!CFI clang builds, and GCC builds without +CC_OPTIMIZE_FOR_SIZE) are unchanged. CALL_OPS-less configurations +take the ftrace_caller ops-dispatch path for out-of-range direct +calls, trading the per-callsite fast path for working BPF +trampolines; in-range attachments still branch directly with no +overhead. GCC -Os builds also gain DIRECT_CALLS as a side effect. +That is intended: s390 and loongarch already ship DIRECT_CALLS +without any per-callsite fast path. + +Assisted-by: Claude:unspecified +Signed-off-by: Jose Fernandez (Anthropic) +Reviewed-by: Puranjay Mohan +--- + arch/arm64/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig +index edbaec4b6eead..532ce0d77069a 100644 +--- a/arch/arm64/Kconfig ++++ b/arch/arm64/Kconfig +@@ -214,7 +214,7 @@ config ARM64 + if (GCC_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS || \ + CLANG_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS) + select HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS \ +- if DYNAMIC_FTRACE_WITH_ARGS && DYNAMIC_FTRACE_WITH_CALL_OPS ++ if DYNAMIC_FTRACE_WITH_ARGS + select HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS \ + if (DYNAMIC_FTRACE_WITH_ARGS && !CFI && \ + (CC_IS_CLANG || !CC_OPTIMIZE_FOR_SIZE)) +-- +2.54.0 + diff --git a/device/testing/linux-postmarketos-asahi/pmos.config b/device/testing/linux-postmarketos-asahi/pmos.config index 1907f359d..c45acda2b 100644 --- a/device/testing/linux-postmarketos-asahi/pmos.config +++ b/device/testing/linux-postmarketos-asahi/pmos.config @@ -36,6 +36,10 @@ CONFIG_UDMABUF=y CONFIG_BPF=y CONFIG_BPF_JIT=y CONFIG_BPF_LSM=y +CONFIG_DEBUG_INFO_BTF=y +CONFIG_DEBUG_INFO_BTF_MODULES=y +CONFIG_DEBUG_INFO_DWARF5=y +# CONFIG_DEBUG_INFO_REDUCED is not set CONFIG_IPC_NS=y CONFIG_KPROBES=y CONFIG_KPROBE_EVENTS=y @@ -43,6 +47,7 @@ CONFIG_NET_NS=y CONFIG_PID_NS=y CONFIG_SECURITY=y CONFIG_SECURITYFS=y +CONFIG_SECURITY_PATH=y CONFIG_USER_NS=y CONFIG_UTS_NS=y