Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.
C
Merge the application sweep: kernel side exported, prebuilt refreshed
vcvkk040d97dd6219
diff --git a/prebuilt/SHA256SUMS b/prebuilt/SHA256SUMSindex a41860e..00a79d9 100644--- a/prebuilt/SHA256SUMS+++ b/prebuilt/SHA256SUMS@@ -1,6 +1,6 @@-Built 2026-10-12 17:57 from this tree.+Built 2026-10-12 18:12 from this tree.-e2b05f0cd843eb801b047d5a512ba6c713365134d37e893f06c6adef831b9ee1 prebuilt/mach.development.bcm2837+0439a8605c0830be4b6c13bb59205b44e18bc3ea77af53bdb19434d8e2cbb375 prebuilt/mach.development.bcm28371332a598d2dec00a1d8e930044e4f00a12ad44c6e5e50eecf4b7fe7fae803bf2 prebuilt/loader.efid2a35a4a1d6658ffb3696914f727661b52c9333de8a3af8a31642b8023ce03ac prebuilt/userland/child1a413befd511384052e1962c1394adce20f718e1f2657ce63ab09828ebc4bd1b prebuilt/userland/cpu_test@@ -8,7 +8,7 @@ db564073effc31e7ab1679a7ffe0631ec22c3030ad347c927028f3e53c8583c3 prebuilt/userla8baa9ab38333280369b0824aafaf92c7aa6a85851ff0b2551a4c711dbe59cfd prebuilt/userland/hello_dyn9d951ac5274c2f0868b5eeeb7589616301f3d8893a592ad49c3f4a5001230def prebuilt/userland/init0e745603f8e5e65867631133efe54311670d09b58ff04ceed86c7a94040303e1 prebuilt/userland/libredwood.dylib-8a3eb47519e80f6edb97580e8f7a9d9aafc25e88374dd00bf07cfde66acadce2 prebuilt/userland/libredwood-sb.dylib+edbe8848a2c7556ca2a7c1d1e64c5af1cbff228e967b1bd01f6dc5cdc5623730 prebuilt/userland/libredwood-sb.dylibb540c061fc5909e9c640cccf4f6f84fd15b58337caa4f95a3610aa694d198346 prebuilt/userland/mg_teste9dd4a78e3f61d5001fd4745cbc3dd6d498850a4140b3e90eeb8592e9dccf349 prebuilt/userland/rwtouch298ac69d2e70ec14b86493e31a6592826fd9bff6cddc8b5821da2d01c84954fc prebuilt/userland/stage0diff --git a/prebuilt/mach.development.bcm2837 b/prebuilt/mach.development.bcm2837index bd81efa..7fa6a34 100755Binary files a/prebuilt/mach.development.bcm2837 and b/prebuilt/mach.development.bcm2837 differdiff --git a/prebuilt/userland/libredwood-sb.dylib b/prebuilt/userland/libredwood-sb.dylibindex 3aa9311..169766e 100755Binary files a/prebuilt/userland/libredwood-sb.dylib and b/prebuilt/userland/libredwood-sb.dylib differdiff --git a/xnu/files/bsd/kern/kern_minimac.c b/xnu/files/bsd/kern/kern_minimac.cindex ff4ab9d..eb6ef5c 100644--- a/xnu/files/bsd/kern/kern_minimac.c+++ b/xnu/files/bsd/kern/kern_minimac.c@@ -64,6 +64,22 @@ miniamfi_vnode_check_signature(__unused struct vnode *vp, __unused struct label#define AMFI_SYSCALL_CHECK_DYLD_POLICY 0x5a#define AMFI_DYLD_OUTPUT_ALLOW_ALL 0xffULL+/*+ * Request 0x60, "query boot-arg state" (amfi_interface_query_bootarg_state() in libamfi): the+ * argument points to 64 bits of flags, one for each boot-arg that switches a part of AMFI off+ * (amfi_get_out_of_my_way and its kin). ExtensionKit asks, and unless one of the bits 0x86 is set+ * it wants the signature of the system's table of extension points+ * (/System/Library/xpc/extensions.plist.sig) verified by AMFI's IOKit service. There is no such+ * service here ("Unable to find AMFI"); the table is then not read and LaunchServices knows no+ * extension point: every application extension is refused when the applications are registered+ * ("does not correspond to a known extension point"), pkd cannot make a record for any extension+ * point, and Shortcuts dies on a nil one. Nothing is enforced by this kernel, so that is what it+ * says. (Which of the three bits stands for which boot-arg is not known; ExtensionKit takes any+ * of them.)+ */+#define AMFI_SYSCALL_QUERY_BOOTARG_STATE 0x60+#define AMFI_BOOTARG_STATE_NOT_ENFORCING 0x86ULL+static intminiamfi_policy_syscall(__unused struct proc *p, int call, user_addr_t arg){@@ -72,8 +88,12 @@ miniamfi_policy_syscall(__unused struct proc *p, int call, user_addr_t arg)user_addr_t output_flags;} args;uint64_t flags = AMFI_DYLD_OUTPUT_ALLOW_ALL;+ uint64_t state = AMFI_BOOTARG_STATE_NOT_ENFORCING;int error;+ if (call == AMFI_SYSCALL_QUERY_BOOTARG_STATE) {+ return copyout(&state, arg, sizeof(state));+ }if (call != AMFI_SYSCALL_CHECK_DYLD_POLICY) {return ENOPOLICY; /* what user space got before there was a handler */}diff --git a/xnu/files/bsd/miscfs/packfs/packfs_vnops.c b/xnu/files/bsd/miscfs/packfs/packfs_vnops.cindex 0d82e88..af1eb33 100644--- a/xnu/files/bsd/miscfs/packfs/packfs_vnops.c+++ b/xnu/files/bsd/miscfs/packfs/packfs_vnops.c@@ -620,6 +620,26 @@ packfs_ioctl(__unused struct vnop_ioctl_args *ap)return ENOTTY;}+/*+ * Extended attributes: nothing in the image has one. The answer to a question about one is+ * therefore "no such attribute" (ENOATTR); the default, ENOTSUP, is taken for a failure.+ * Security.framework asks every bundle for the attributes a code signature may be kept in, and+ * with ENOTSUP MobileInstallation could not validate a single application or extension+ * ("Failed to verify code signature of ... POSIX error 45") when LaunchServices registered them.+ */+static int+packfs_getxattr(__unused struct vnop_getxattr_args *ap)+{+ return ENOATTR;+}++static int+packfs_listxattr(struct vnop_listxattr_args *ap)+{+ *ap->a_size = 0;+ return 0;+}+static intpackfs_mmap(__unused struct vnop_mmap_args *ap){@@ -714,6 +734,8 @@ const struct vnodeopv_entry_desc packfs_vnodeop_entries[] = {{ .opve_op = &vnop_getattr_desc, .opve_impl = (VOPFUNC)packfs_getattr },{ .opve_op = &vnop_read_desc, .opve_impl = (VOPFUNC)packfs_read },{ .opve_op = &vnop_ioctl_desc, .opve_impl = (VOPFUNC)packfs_ioctl },+ { .opve_op = &vnop_getxattr_desc, .opve_impl = (VOPFUNC)packfs_getxattr },+ { .opve_op = &vnop_listxattr_desc, .opve_impl = (VOPFUNC)packfs_listxattr },{ .opve_op = &vnop_fsync_desc, .opve_impl = (VOPFUNC)nop_fsync },{ .opve_op = &vnop_readdir_desc, .opve_impl = (VOPFUNC)packfs_readdir },{ .opve_op = &vnop_readlink_desc, .opve_impl = (VOPFUNC)packfs_readlink },diff --git a/xnu/files/osfmk/arm64/user_exception_trace.c b/xnu/files/osfmk/arm64/user_exception_trace.cindex 72dab39..22889d5 100644--- a/xnu/files/osfmk/arm64/user_exception_trace.c+++ b/xnu/files/osfmk/arm64/user_exception_trace.c@@ -150,7 +150,9 @@ user_abort_trace(void)* and the return addresses up the stack. Shows what a daemon that "does nothing" waits for.* ustacks_now(NAME) does it at once: under QEMU, "qemu/touch.py stacks NAME" on the host.* The addresses are symbolized on the host (qemu/symstack.py).+ * The name "top" asks for something else: who has had the processor (see ustacks_top()).*/+#include <kern/recount.h>#include <kern/thread_call.h>#include <kern/clock.h>#include <kern/queue.h>@@ -233,6 +235,88 @@ ustacks_task(task_t task, struct proc *proc)vm_map_deallocate(map);}+/*+ * ustacks_now("top"): the processes that have had the processor since this was last asked (the+ * first time: since boot), each with its share of that time. A system that feels slow is either+ * busy -- this says with what -- or waiting for something, and the two look the same on the screen.+ */+#define USTACKS_TOP_TASKS 512+#define USTACKS_TOP_LINES 12++static void+ustacks_top(void)+{+ static struct {+ int pid;+ uint64_t total; /* user + system time so far, in Mach time units */+ uint64_t used; /* ... of it since the last time */+ char name[33]; /* as long as a process name gets (2 * MAXCOMLEN + 1) */+ } now[USTACKS_TOP_TASKS];+ static struct {+ int pid;+ uint64_t total;+ } before[USTACKS_TOP_TASKS];+ static unsigned before_count;+ static uint64_t before_when;+ uint64_t when = mach_absolute_time(), elapsed = when - before_when, elapsed_ns, busy = 0;+ unsigned count = 0;+ task_t task;++ lck_mtx_lock(&tasks_threads_lock);+ queue_iterate(&tasks, task, task_t, tasks) {+ struct proc *proc = get_bsdtask_info(task);+ struct recount_times_mach times;++ if (count == USTACKS_TOP_TASKS || proc == NULL) {+ continue;+ }+ times = recount_task_times(task);+ now[count].pid = proc_pid(proc);+ now[count].total = times.rtm_user + times.rtm_system;+ strlcpy(now[count].name, proc_name_address(proc), sizeof(now[count].name));+ count++;+ }+ lck_mtx_unlock(&tasks_threads_lock);++ /* a process that was not there the last time has used all it has since */+ for (unsigned i = 0; i < count; i++) {+ uint64_t earlier = 0;++ for (unsigned j = 0; j < before_count; j++) {+ if (before[j].pid == now[i].pid) {+ earlier = before[j].total;+ break;+ }+ }+ now[i].used = now[i].total - MIN(earlier, now[i].total);+ busy += now[i].used;+ }+ absolutetime_to_nanoseconds(elapsed, &elapsed_ns);+ printf("top: in the last %llu ms the processor was busy %llu%% of the time\n", elapsed_ns / NSEC_PER_MSEC,+ elapsed ? busy * 100 / elapsed : 0);+ for (unsigned i = 0; i < count; i++) {+ before[i].pid = now[i].pid;+ before[i].total = now[i].total;+ }+ before_count = count;+ before_when = when;+ for (unsigned line = 0; line < USTACKS_TOP_LINES && count != 0 && elapsed != 0; line++) {+ unsigned most = 0;++ for (unsigned i = 1; i < count; i++) {+ if (now[i].used > now[most].used) {+ most = i;+ }+ }+ if (now[most].used * 1000 / elapsed == 0) {+ break;+ }+ printf("top: %3llu.%llu%% %s[%d]\n", now[most].used * 100 / elapsed, now[most].used * 1000 / elapsed % 10,+ now[most].name, now[most].pid);+ now[most].used = 0;+ }+}+static voidustacks_fire(__unused thread_call_param_t p0, __unused thread_call_param_t p1){@@ -240,6 +324,10 @@ ustacks_fire(__unused thread_call_param_t p0, __unused thread_call_param_t p1)unsigned count = 0;task_t task;+ if (strcmp(ustacks_name, "top") == 0) {+ ustacks_top();+ return;+ }lck_mtx_lock(&tasks_threads_lock);queue_iterate(&tasks, task, task_t, tasks) {struct proc *proc = get_bsdtask_info(task);diff --git a/xnu/redwood.patch b/xnu/redwood.patchindex e209e73..b01d62e 100644--- a/xnu/redwood.patch+++ b/xnu/redwood.patch@@ -128,19 +128,22 @@ index fd7a94b20794..69eaceedd248 100644if (cc > 1) {console_write((char *)buf, cc);diff --git a/bsd/dev/arm/systemcalls.c b/bsd/dev/arm/systemcalls.c-index 7fd9be1a5f38..f158f323a071 100644+index 7fd9be1a5f38..231a58c622db 100644--- a/bsd/dev/arm/systemcalls.c+++ b/bsd/dev/arm/systemcalls.c-@@ -36,6 +36,52 @@+@@ -36,6 +36,58 @@#include <security/mac_framework.h>#endif+/*+ * Bring-up aid: boot-arg systrace=1 logs every BSD system call that fails,+ * systrace=2 logs all of them (to the kernel message buffer). For calls that-+ * take a path, the path is shown.++ * take a path, the path is shown. systrace_name=NAME keeps it to the processes++ * of that name: with a whole system running, everybody's failed calls are++ * megabytes a minute.+ */+static TUNABLE(uint32_t, systrace_level, "systrace", 0);++static TUNABLE_STR(systrace_name, MAXCOMLEN + 1, "systrace_name", "");+extern const char *syscallnames[];++static void@@ -163,6 +166,9 @@ index 7fd9be1a5f38..f158f323a071 100644+ if (systrace_level < 2 && (error == 0 || error == EJUSTRETURN || error == ERESTART)) {+ return;+ }++ if (systrace_name[0] != 0 && strncmp(proc->p_comm, systrace_name, MAXCOMLEN) != 0) {++ return;++ }+ for (unsigned i = 0; i < sizeof(path_arg0) / sizeof(path_arg0[0]); i++) {+ if (path_arg0[i] == syscode) {+ (void)copyinstr((user_addr_t)uthread->uu_arg[0], path, sizeof(path), &done);@@ -184,7 +190,7 @@ index 7fd9be1a5f38..f158f323a071 100644#if CONFIG_DTRACEextern int32_t dtrace_systrace_syscall(struct proc *, void *, int *);extern void dtrace_systrace_syscall_return(unsigned short, int, int *);-@@ -181,6 +227,10 @@ unix_syscall(+@@ -181,6 +233,10 @@ unix_syscall(error = (*(callp->sy_call))(proc, &uthread->uu_arg[0], &(uthread->uu_rval[0]));AUDIT_SYSCALL_EXIT(code, proc, uthread, error);