318 lines · plain
1================================================================================2K6 rootfs-model — upstream source-site snapshot3================================================================================4 5Generated by linux-wasm/tools/k6-rootfs-model-probe/snapshot-sources.sh6from Documentation/wasm/rootfs-model.rst §6.7 8Pinned at K6-A2 sub-phase close (per §13 K6-A2). Each named upstream9function lists its definition file:line (one entry per arch) plus10its call sites in the upstream tree paths K6 depends on11(`init/`, `fs/`, `usr/`). The list is the input for K6-B12implementation: any deviation between this snapshot and the13upstream tree at K6-B-time is either spec drift (refresh §614and this file), or genuine upstream movement (note the diff and15refresh both).16 17Re-run the script after an upstream tag bump (e.g. v6.12 → v6.13)18and commit the regenerated file alongside the bump.19 20Section legend:21 [DEF] the function definition (file:line + leading prose)22 [CALL] call sites in the upstream tree23 [K6-B] where K6-B will insert NEW calls into this function24 (annotation only; does not exist in upstream)25 26Snapshot taken against: v6.1227Generated: 2026-05-25 (UTC, deterministic stamp from `date -u`)28Note: snapshot file deliberately omits HH:MM:SS in the29 stamp so re-runs on the same day produce byte-identical30 output. Drift detection is at line-number granularity.31 32================================================================================331. init/initramfs.c — cpio parser + rootfs population (K6-B R1, R2)34================================================================================35 36Module: parses the initramfs cpio archive embedded at37__initramfs_start..__initramfs_end (upstream-builtin) and at38initrd_start..initrd_end (bootloader-supplied) and creates the39corresponding files in the rootfs via vfs_mkdir/vfs_create/etc.40 41K6-A1 patches/0006 removes `static` from unpack_to_rootfs() so42arch probes can invoke it on arbitrary buffers; the rest of the43file is unchanged upstream.44 45[DEF] init/initramfs.c::unpack_to_rootfs(buf, len)46 init/initramfs.c:486 char * __init unpack_to_rootfs(char *buf, unsigned long len)47 48[CALL] unpack_to_rootfs call sites:49 init/initramfs.c:695 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);50 init/initramfs.c:707 err = unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start);51 52[CALL] arch-side after K6-A1 (patches/0006 expose):53 arch/wasm32/configs/wasm32_defconfig:86 # boot. K6-A1 probe uses unpack_to_rootfs() directly on a kernel-54 arch/wasm32/kernel/init.c:58 #include <linux/initramfs.h> /* unpack_to_rootfs (patch 0006) */55 arch/wasm32/kernel/init.c:216 err = unpack_to_rootfs((char *)initrd_start, len);56 arch/wasm32/kernel/k6_a1_probes.c:12 * init/initramfs.c::unpack_to_rootfs (exposed via57 arch/wasm32/kernel/k6_a1_probes.c:93 err = unpack_to_rootfs(cpio_copy, K6_A1_PROBE_CPIO_SIZE);58 arch/wasm32/kernel/k6_b1_probes.c:14 * init/initramfs.c) has already invoked unpack_to_rootfs() on59 60[DEF] init/initramfs.c::populate_rootfs() — rootfs_initcall61 init/initramfs.c:756 static int __init populate_rootfs(void)62 63[CALL] populate_rootfs is registered via rootfs_initcall;64 no direct call sites in upstream (initcall infra runs65 it). Reference:66 init/initramfs.c:765:rootfs_initcall(populate_rootfs);67 68[DEF] init/initramfs.c::do_populate_rootfs() — async-scheduled by populate_rootfs69 init/initramfs.c:692 static void __init do_populate_rootfs(void *unused, async_cookie_t cookie)70 71[CALL] do_populate_rootfs scheduling:72 init/initramfs.c:692:static void __init do_populate_rootfs(void *unused, async_cookie_t cookie)73 init/initramfs.c:758: initramfs_cookie = async_schedule_domain(do_populate_rootfs, NULL,74 75[DEF] init/initramfs.c::write_buffer() — decompressor write path76 init/initramfs.c:449 static long __init write_buffer(char *buf, unsigned long len)77 78[DEF] init/initramfs.c::flush_buffer() — decompressor flush path79 init/initramfs.c:459 static long __init flush_buffer(void *bufv, unsigned long len)80 81================================================================================822. init/main.c — kernel_init flow (K6-B R3, R4, R7 site)83================================================================================84 85The boot path from start_kernel through kernel_init to86run_init_process and the arch hook patches/0004 added at K5-C2.87 88K6-B reuses arch_kernel_init_pre_run_init as the fallback path89(when initramfs is empty / kernel_read_file fails) and lets90kernel_init's standard /init iteration succeed on the91HardwareJS-supplied initramfs.92 93[DEF] init/main.c::start_kernel()94 init/main.c:905 void start_kernel(void)95 96[DEF] init/main.c::kernel_init() — forward declaration + body97 init/main.c:117:static int kernel_init(void *);98 init/main.c:1462:static int __ref kernel_init(void *unused)99 100[DEF] init/main.c::kernel_init_freeable() — forward declaration + body101 init/main.c:1409:static noinline void __init kernel_init_freeable(void);102 init/main.c:1471: kernel_init_freeable();103 init/main.c:1566:static noinline void __init kernel_init_freeable(void)104 105[DEF] init/main.c::run_init_process() — opens and execs a candidate /init106 init/main.c:1380 static int run_init_process(const char *init_filename)107 108[CALL] run_init_process invocations:109 init/main.c:1380:static int run_init_process(const char *init_filename)110 init/main.c:1395:static int try_to_run_init_process(const char *init_filename)111 init/main.c:1399: ret = run_init_process(init_filename);112 init/main.c:1509: ret = run_init_process(ramdisk_execute_command);113 init/main.c:1523: ret = run_init_process(execute_command);114 init/main.c:1531: ret = run_init_process(CONFIG_DEFAULT_INIT);115 init/main.c:1539: if (!try_to_run_init_process("/sbin/init") ||116 init/main.c:1540: !try_to_run_init_process("/etc/init") ||117 init/main.c:1541: !try_to_run_init_process("/bin/init") ||118 init/main.c:1542: !try_to_run_init_process("/bin/sh"))119 120[CALL] arch_kernel_init_pre_run_init (patches/0004 K5-C2)121 init/main.c:119:void arch_kernel_init_pre_run_init(void);122 init/main.c:1494: * arch_kernel_init_pre_run_init - arch-specific hook called123 init/main.c:1504: arch_kernel_init_pre_run_init();124 init/main.c:1549:void __weak arch_kernel_init_pre_run_init(void) { }125 126[K6-B] proposed insertion: nothing further in init/main.c.127 run_init_process's existing iteration over /sbin/init,128 /etc/init, /bin/init, /bin/sh is the K6 happy-path entry.129 130================================================================================1313. init/do_mounts.c — namespace preparation (K6-B D5 site)132================================================================================133 134Branch entered when init_eaccess(ramdisk_execute_command) fails135(i.e. ramdisk_execute_command isn't executable, the typical case136when initramfs sets up a real /init). Not on K6's happy path137(K6's /init IS executable), but reading it gives K6-B implementers138the picture of the alternate flow.139 140[DEF] init/do_mounts.c::prepare_namespace()141 init/do_mounts.c:464 void __init prepare_namespace(void)142 143[CALL] prepare_namespace callers:144 init/do_mounts.c:464:void __init prepare_namespace(void)145 init/main.c:1609: prepare_namespace();146 147[DEF] init/do_mounts.c::mount_root() — backing-fs mount helper148 init/do_mounts.c:388 void __init mount_root(char *root_device_name)149 150================================================================================1514. fs/exec.c — execve flow (K6-B R2 + R7 site)152================================================================================153 154K6-B's binfmt_wasm.load_wasm_binary plugs into this flow via the155formats list. The site reference snapshot below identifies where156the patch 0005 arch_post_execve hook IS inserted (K6-B2 landed:157bprm_execve success-path tail) — see fs/exec.c hits below.158 159[DEF] fs/exec.c::open_exec(name)160 fs/exec.c:929 struct file *open_exec(const char *name)161 162[DEF] fs/exec.c::prepare_binprm(bprm) — pre-reads BINPRM_BUF_SIZE bytes163 fs/exec.c:1682 static int prepare_binprm(struct linux_binprm *bprm)164 165[DEF] fs/exec.c::begin_new_exec(bprm) — task state replacement166 fs/exec.c:1222 int begin_new_exec(struct linux_binprm * bprm)167 168[DEF] fs/exec.c::setup_new_exec(bprm) — post-begin_new_exec setup169 fs/exec.c:1427 void setup_new_exec(struct linux_binprm * bprm)170 171[DEF] fs/exec.c::search_binary_handler(bprm) — iterates formats172 fs/exec.c:1730 static int search_binary_handler(struct linux_binprm *bprm)173 174[CALL] search_binary_handler — fmt->load_binary callsite within:175 fs/exec.c:1752: retval = fmt->load_binary(bprm);176 177[DEF] fs/exec.c::exec_binprm(bprm) — calls search_binary_handler in a loop178 fs/exec.c:1780 static int exec_binprm(struct linux_binprm *bprm)179 180[DEF] fs/exec.c::bprm_execve(bprm) — owns exec-success/exec-fail teardown181 fs/exec.c:1824 static int bprm_execve(struct linux_binprm *bprm)182 183[DEF] fs/exec.c::do_execveat_common() — execve entry184 fs/exec.c:549: * See do_execveat_common().185 fs/exec.c:1880:static int do_execveat_common(int fd, struct filename *filename,186 fs/exec.c:2030: return do_execveat_common(AT_FDCWD, filename, argv, envp, 0);187 fs/exec.c:2041: return do_execveat_common(fd, filename, argv, envp, flags);188 fs/exec.c:2057: return do_execveat_common(AT_FDCWD, filename, argv, envp, 0);189 fs/exec.c:2073: return do_execveat_common(fd, filename, argv, envp, flags);190 191[NOTE] §6 of the opener doc named this 'do_execve_common';192 upstream v6.12 spelling is 'do_execveat_common'. The193 opener doc should be amended on the next refresh (this194 file pins the actual upstream name).195 196[K6-B R7] proposed insertion site for arch_post_execve(bprm):197 fs/exec.c::bprm_execve, right after exec_binprm() returns198 success (line ~1850, between 'sched_mm_cid_after_execve'199 and 'current->fs->in_exec = 0'). Patch 0005 adds the200 weak default in this file; arch/wasm32/kernel/init.c201 provides the strong override.202 203================================================================================2045. fs/kernel_read_file.c — kernel_read_file (K6-B R2 site)205================================================================================206 207The function K6-B's binfmt_wasm.load_wasm_binary uses to slurp208the entire /init file into a kmalloc'd buffer for parser + spawn209ring submission. Earlier upstream versions had it inside210fs/exec.c; v6.12 has its own file.211 212[DEF] fs/kernel_read_file.c::kernel_read_file(file, ...)213 fs/kernel_read_file.c:35 ssize_t kernel_read_file(struct file *file, loff_t offset, void **buf,214 215[DEF] fs/kernel_read_file.c sibling helpers (callable variants)216 fs/kernel_read_file.c:35:ssize_t kernel_read_file(struct file *file, loff_t offset, void **buf,217 fs/kernel_read_file.c:127:ssize_t kernel_read_file_from_path(const char *path, loff_t offset, void **buf,218 fs/kernel_read_file.c:147:ssize_t kernel_read_file_from_path_initns(const char *path, loff_t offset,219 fs/kernel_read_file.c:174:ssize_t kernel_read_file_from_fd(int fd, loff_t offset, void **buf,220 221[CALL] kernel_read_file existing in-tree callers (sample):222 kernel/kexec_file.c:201: ret = kernel_read_file_from_fd(kernel_fd, 0, &image->kernel_buf,223 kernel/kexec_file.c:224: ret = kernel_read_file_from_fd(initrd_fd, 0, &image->initrd_buf,224 kernel/module/main.c:3179: len = kernel_read_file(f, 0, &buf, INT_MAX, NULL, READING_MODULE);225 kernel/module/stats.c:37: * a) memory allocated with kernel_read_file_from_fd()226 kernel/module/stats.c:39: * kernel_read_file_from_fd(), and vmap() is used to map227 kernel/module/stats.c:42: * from kernel_read_file_from_fd() is freed right away.228 kernel/module/stats.c:72: * 1) kernel_read_file_from_fd() call uses vmalloc()229 kernel/module/stats.c:121: * happen due to the initial kernel_read_file_from_fd(). kernel_read_file_from_fd()230 231================================================================================2326. fs/binfmt_elf.c — shape template (K6-B R2 reference)233================================================================================234 235NOT depended upon at runtime (CONFIG_BINFMT_ELF=n on wasm32);236read at K6-B-time as the shape template for the binfmt_wasm237load_binary path. The §4 R2 path in the opener doc enumerates238the upstream steps; the lines below give precise sites.239 240[DEF] fs/binfmt_elf.c::load_elf_binary(bprm)241 fs/binfmt_elf.c:819 static int load_elf_binary(struct linux_binprm *bprm)242 243[NOTE] read fs/binfmt_elf.c lines ~700-900 at K6-B start to244 refresh the shape-template understanding before245 binfmt_wasm.load_wasm_binary's read-file path lands.246 247================================================================================2487. arch/wasm32 surface already in place (K5 + K6-A1 reference)249================================================================================250 251Arch hooks and weak overrides the K-series has landed so far,252listed for K6-B implementers who need to see how the wasm32 port253hooks into upstream.254 255[DEF] arch/wasm32/kernel/init.c::arch_kernel_init_pre_run_init() — K5-C2 strong override256 arch/wasm32/include/asm/boot.h:80: * arch_kernel_init_pre_run_init257 arch/wasm32/kernel/binfmt_wasm.c:28: * fallback path (arch_kernel_init_pre_run_init dispatching258 arch/wasm32/kernel/builtin_init_image.h:10: * The wasm32 arch_kernel_init_pre_run_init override (in259 arch/wasm32/kernel/init.c:4: * arch_kernel_init_pre_run_init.260 arch/wasm32/kernel/init.c:14: * arch_kernel_init_pre_run_init hook.261 arch/wasm32/kernel/init.c:22: * 3. kernel_init calls arch_kernel_init_pre_run_init() — this262 arch/wasm32/kernel/init.c:35: * 6. On failure, we return from arch_kernel_init_pre_run_init.263 arch/wasm32/kernel/init.c:48: * arch_kernel_init_pre_run_init hook itself stays — it's the264 arch/wasm32/kernel/init.c:166: * arch_kernel_init_pre_run_init — wasm32 override.265 arch/wasm32/kernel/init.c:169: * patches/0004-init-add-arch_kernel_init_pre_run_init-hook.patch)266 arch/wasm32/kernel/init.c:197: * Runs at arch_kernel_init_pre_run_init time, which is inside267 arch/wasm32/kernel/init.c:223:void arch_kernel_init_pre_run_init(void)268 arch/wasm32/kernel/init.c:321: * That check runs BEFORE arch_kernel_init_pre_run_init,269 arch/wasm32/kernel/init.c:335: * arch_kernel_init_pre_run_init taking the relevant action270 arch/wasm32/kernel/k6_a1_probes.c:28: * present, arch_kernel_init_pre_run_init() in init.c dispatches to271 arch/wasm32/kernel/k6_b1_probes.c:15: * initrd_start..initrd_end. By the time arch_kernel_init_pre_run_init272 arch/wasm32/kernel/k6_b2_probes.c:63: * mirrors the patch 0004 convention for arch_kernel_init_pre_run_init.273 arch/wasm32/kernel/setup.c:183: * arch_kernel_init_pre_run_init fallback), or both are274 arch/wasm32/kernel/setup.c:435: * boot then falls through to arch_kernel_init_pre_run_init's275 arch/wasm32/kernel/setup.c:463: pr_info("wasm32: no initrd supplied (initrd_size=0); kernel_init will fall through to arch_kernel_init_pre_run_init\n");276 277[DEF] arch/wasm32/kernel/binfmt_wasm.c — current K5-B3 stub state278 arch/wasm32/kernel/binfmt_wasm.c:67:long wasm32_exec_image(const u8 *image, size_t size, const char *name);279 arch/wasm32/kernel/binfmt_wasm.c:158:static int load_wasm_binary(struct linux_binprm *bprm)280 arch/wasm32/kernel/binfmt_wasm.c:334:long wasm32_exec_image(const u8 *image, size_t size, const char *name)281 282[DEF] arch/wasm32/kernel/spawn.c::wasm32_spawn_ring + host_spawn_process_worker — K5-B2283 arch/wasm32/kernel/spawn.c:87:struct wasm_spawn_request_ring wasm32_spawn_ring __attribute__((aligned(8))) = {284 arch/wasm32/kernel/spawn.c:199:long host_spawn_process_worker(struct wasm_spawn_request *req)285 286[DEF] arch/wasm32/kernel/k6_a1_probes.c::wasm32_run_k6_a1_probes — K6-A1287 arch/wasm32/kernel/k6_a1_probes.c:29: * wasm32_run_k6_a1_probes() (this file) INSTEAD of the K5-C2288 arch/wasm32/kernel/k6_a1_probes.c:152:void __init wasm32_run_k6_a1_probes(void)289 290================================================================================2918. ABI bumps planned at K6-B (forward reference)292================================================================================293 294Annotations only — these are not present in any upstream file295yet; they describe the K6-B1 plumbing changes the next sub-phase296will land.297 298 [K6-B1] wasm_boot_info v1 → v2 (rootfs-model.rst §15):299 add initrd_offset + initrd_size, shrink reserved[6]300 to reserved[4]. C struct in301 arch/wasm32/include/asm/boot.h, JS mirror in302 hardwarejs/src/kernelWorker.mjs's wasm_boot_info303 construction block (currently lines 240-258).304 305 [K6-B3] arch/wasm32/kernel/setup.c reads boot_info.initrd_offset306 and boot_info.initrd_size, sets the global307 initrd_start = (unsigned long)kernel_memory_base +308 initrd_offset, initrd_end = initrd_start + initrd_size.309 310 [K6-B2] patches/0005-fs-add-arch_post_execve-hook.patch adds311 weak void arch_post_execve(struct linux_binprm *bprm)312 to fs/exec.c right before do_execveat_common, calls it313 from bprm_execve after exec_binprm returns success.314 315================================================================================316END OF SNAPSHOT317================================================================================318