brintos

brintos / linux-shallow public Read only

0
0
Text · 31.4 KiB · 5b0f80b Raw
618 lines · plain
1================================================================================2K8 signals-model — source-site snapshot3================================================================================4 5Generated by linux-wasm/tools/k8-signals-model-probe/snapshot-sources.sh6from Documentation/wasm/signals-model.rst §8.7 8Pinned at K8-A2 sub-phase close (per §11 K8-A2). Snapshots9across five trees:10 11  [LIN]   upstream linux/ tree (kernel/signal.c, kernel/entry/, x86 ref)12  [WAS]   our wasm32-port/ tree (kernel/signal.c K0 stub,13          include/asm/signal.h K0 stub, include/asm/clone.h14          spawn-ring ABI, kernel/spawn.c kernel-side producer)15  [UPS]   wackywasm-tools/musl-1.2.5/src/signal/ (upstream musl16          signal surface)17  [OVR]   wackywasm-tools/musl-src/src_overrides/ (existing18          K7-pattern src_overrides; K8-B3 will add signal/wasm32/)19  [HWJ]   hardwarejs/src/ (worker.mjs handleFutex insertion site,20          spawnRingConsumer.ts mirror, kernelSpawnHandler.ts21          registry to extend)22 23Section legend:24  [DEF]   the function definition (file:line + leading prose)25  [CALL]  call sites in the relevant tree26  [SITE]  inline excerpt of a load-bearing site (no function27          definition but a code shape we depend on)28  [K8-B]  where K8-B-phases will insert NEW code (annotation29          only; does not exist in any tree yet)30 31Snapshot taken against:32  upstream linux: v6.1233  upstream musl: 1.2.534  wackywasm-tools/musl-src: K7 src_overrides state (no K8-B3 signal/ override yet)35Generated: 2026-05-25 (UTC, deterministic stamp from `date -u`)36Note: snapshot file deliberately omits HH:MM:SS in the37      stamp so re-runs on the same day produce byte-identical38      output. Drift detection is at line-number granularity.39 40================================================================================411. linux/kernel/signal.c — upstream send/receive + sigaction (K8-B1/K8-B5)42================================================================================43 44Module: upstream signal-delivery core. K8-B1 lands the45arch_signal_wake_target hook into __send_signal_locked (after46the bit is set in t->pending.signal but before the existing47signal_wake_up call). K8-B5 reuses do_sigaction unchanged.48get_signal is the load-bearing receiver-side function called49from do_signal/arch_do_signal_or_restart on syscall exit.50 51[DEF] linux/kernel/signal.c::__send_signal_locked(...)52  kernel/signal.c:1073  static int __send_signal_locked(int sig, struct kernel_siginfo *info,53 54[DEF] linux/kernel/signal.c::complete_signal(int, struct task_struct *, enum pid_type)55  kernel/signal.c:994  static void complete_signal(int sig, struct task_struct *p, enum pid_type type)56 57[DEF] linux/kernel/signal.c::signal_wake_up_state(struct task_struct *t, unsigned int state)58  kernel/signal.c:759  void signal_wake_up_state(struct task_struct *t, unsigned int state)59 60[CALL] signal_wake_up_state call sites in linux/kernel/signal.c:61 62[DEF] linux/kernel/signal.c::get_signal(struct ksignal *)63  kernel/signal.c:2683  bool get_signal(struct ksignal *ksig)64 65[DEF] linux/kernel/signal.c::do_sigaction(int sig, struct k_sigaction *, struct k_sigaction *)66  kernel/signal.c:4170  int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)67 68[DEF] linux/kernel/signal.c::SYSCALL_DEFINEx(rt_sigaction|rt_sigprocmask|rt_sigsuspend|rt_sigtimedwait):69  kernel/signal.c:3202:SYSCALL_DEFINE4(rt_sigprocmask, int, how, sigset_t __user *, nset,70  kernel/signal.c:3233:COMPAT_SYSCALL_DEFINE4(rt_sigprocmask, int, how, compat_sigset_t __user *, nset,71  kernel/signal.c:3688:SYSCALL_DEFINE4(rt_sigtimedwait, const sigset_t __user *, uthese,72  kernel/signal.c:4493:SYSCALL_DEFINE4(rt_sigaction, int, sig,73  kernel/signal.c:4518:COMPAT_SYSCALL_DEFINE4(rt_sigaction, int, sig,74  kernel/signal.c:4716:SYSCALL_DEFINE2(rt_sigsuspend, sigset_t __user *, unewset, size_t, sigsetsize)75  kernel/signal.c:4730:COMPAT_SYSCALL_DEFINE2(rt_sigsuspend, compat_sigset_t __user *, unewset, compat_size_t, sigsetsize)76 77================================================================================782. linux/kernel/entry/common.c — TIF_SIGPENDING exit-to-user loop (K8-B1 ref)79================================================================================80 81Module: upstream syscall-exit hook. The loop checks82_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL and calls83arch_do_signal_or_restart. K8 does NOT modify this path84directly — wasm32 syscall exit is on the JS-Worker side85(per signals-model.rst §2(a)+(b)) — but the upstream shape is86the spec we must mirror semantically.87 88[DEF] linux/kernel/entry/common.c::exit_to_user_mode_loop(struct pt_regs *, unsigned long ti_work)89  kernel/entry/common.c:90  __always_inline unsigned long exit_to_user_mode_loop(struct pt_regs *regs,90 91[SITE] linux/kernel/entry/common.c — TIF_SIGPENDING branch:92  kernel/entry/common.c:83:void __weak arch_do_signal_or_restart(struct pt_regs *regs) { }93  kernel/entry/common.c:110:		if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))94  kernel/entry/common.c:111:			arch_do_signal_or_restart(regs);95 96================================================================================973. linux/arch/x86/kernel/signal*.c — setup_rt_frame reference (K8-B3 shape ref)98================================================================================99 100Reference shape: x86 builds a signal frame on the user stack101with siginfo_t, sigcontext, and the rt_sigreturn trampoline.102On wasm32 we cannot construct frames "on top of" the wasm103shadow stack (signals-model.rst §4); the K8-B3 trampoline104__wasm_signal_dispatch is the wasm32-shaped equivalent.105 106[DEF] linux/arch/x86/kernel/signal.c::arch_do_signal_or_restart(struct pt_regs *)107  arch/x86/kernel/signal.c:333  void arch_do_signal_or_restart(struct pt_regs *regs)108 109[SITE] linux/arch/x86/kernel/signal.c — setup_rt_frame dispatch:110  arch/x86/kernel/signal.c:236:setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)111  arch/x86/kernel/signal.c:294:	failed = (setup_rt_frame(ksig, regs) < 0);112 113[DEF] linux/arch/x86/kernel/signal_64.c::x64_setup_rt_frame(...)114  arch/x86/kernel/signal_64.c:164  int x64_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)115 116================================================================================1174. wasm32-port/kernel/signal.c — K0 stub (K8-B1 fills in)118================================================================================119 120The K0 scaffold. The body is a TODO placeholder. K8-B1 turns121this into a real arch_signal_wake_target implementation that122composes a wasm_signal_request (mirror of wasm_spawn_request123shape from include/asm/clone.h) and submits it through a new124signal ring sibling of the spawn ring.125 126[SITE] wasm32-port/kernel/signal.c — full file (K0 stub):127  kernel/signal.c:1  // SPDX-License-Identifier: GPL-2.0128  kernel/signal.c:2  /*129  kernel/signal.c:3   * arch/wasm32: signal delivery on syscall exit. v0.1 scaffold; real130  kernel/signal.c:4   * implementation is filled in here in later phases (see plan U1+).131  kernel/signal.c:5   */132  kernel/signal.c:6  #include <linux/sched.h>133  kernel/signal.c:7  #include <linux/signal.h>134  kernel/signal.c:8  135  kernel/signal.c:9  void do_signal(struct pt_regs *regs)136  kernel/signal.c:10  {137  kernel/signal.c:11  	(void)regs;138  kernel/signal.c:12  	/* TODO: walk current->pending; invoke registered handler via139  kernel/signal.c:13  	 * call_indirect into user's sigaction.sa_handler (a WASM function140  kernel/signal.c:14  	 * table index); save/restore arch state. */141  kernel/signal.c:15  }142 143================================================================================1445. wasm32-port/include/asm/signal.h — K0 stub (K8-B1 extends)145================================================================================146 147The K0 scaffold. Pulls in uapi + asm-generic. K8-B1 extends148this header with:149  * struct wasm_signal_pending_region (40 bytes per Worker)150  * static_asserts pinning offsets vs hardwarejs/test/k8-a1151    SR_OFF_* constants152  * wasm_signal_request layout (K8-B2 ring payload)153  * arch_signal_wake_target prototype154 155[SITE] wasm32-port/include/asm/signal.h — full file (K0 stub):156  include/asm/signal.h:1  /* SPDX-License-Identifier: GPL-2.0 */157  include/asm/signal.h:2  #ifndef _ASM_WASM32_SIGNAL_H158  include/asm/signal.h:3  #define _ASM_WASM32_SIGNAL_H159  include/asm/signal.h:4  160  include/asm/signal.h:5  #include <uapi/asm/signal.h>161  include/asm/signal.h:6  #include <asm-generic/signal.h>162  include/asm/signal.h:7  163  include/asm/signal.h:8  #endif164 165================================================================================1666. wasm32-port/include/asm/clone.h — spawn-ring ABI (K8-B2 ABI mirror)167================================================================================168 169K5-frozen ABI: wasm_thread_arg_region, wasm_spawn_request,170wasm_spawn_request_ring, WASM_THREAD_ARG_MAGIC. K8-B2's signal171ring follows the IDENTICAL shape (header layout, slot index172seq+ack pattern, magic-number framing). K8 does not modify173this header; it mirrors it for the signal channel.174 175[DEF] wasm32-port/include/asm/clone.h — load-bearing structs/enums:176  include/asm/clone.h:87:struct wasm_clone_fn_arg {177  include/asm/clone.h:123:struct wasm_thread_arg_region {178  include/asm/clone.h:153:enum wasm_spawn_mode {179  include/asm/clone.h:186:struct wasm_spawn_request {180  include/asm/clone.h:257:struct wasm_spawn_request_ring {181 182[DEF] wasm32-port/include/asm/clone.h — magic + size pins:183  include/asm/clone.h:60:#define WASM_THREAD_ARG_MAGIC  0x4441455252485457ULL184  include/asm/clone.h:99:#define WASM_THREAD_ARG_VERSION  1u185  include/asm/clone.h:226:#define WASM_SPAWN_RING_SLOTS  16186  include/asm/clone.h:273:#define WASM_THREAD_ARG_REGION_V1_SIZE  112187  include/asm/clone.h:274:#define WASM_SPAWN_REQUEST_V1_SIZE      64188  include/asm/clone.h:275:#define WASM_SPAWN_RING_HEADER_V1_SIZE  32189 190================================================================================1917. wasm32-port/kernel/spawn.c — kernel-side ring producer (K8-B2 mirror site)192================================================================================193 194The K5-pattern producer. K8-B2's signal-ring producer follows195the IDENTICAL submit-and-bump shape (slot allocation by atomic196seq increment, payload write, ack-wait by Atomics.wait on the197ack word). The producer signature for K8 is:198  int wasm_signal_submit(pid_t tid, int sig, pid_t sender_pid)199 200[DEF] wasm32-port/kernel/spawn.c — exported submit functions:201 202[SITE] wasm32-port/kernel/spawn.c — first 80 lines (header + slot acquire):203  kernel/spawn.c:1  // SPDX-License-Identifier: GPL-2.0204  kernel/spawn.c:2  /*205  kernel/spawn.c:3   * arch/wasm32/kernel/spawn.c — kernel→HardwareJS Worker-spawn upcall.206  kernel/spawn.c:4   *207  kernel/spawn.c:5   * Documentation/wasm/threading-model.rst §§3-6 + §11 R7. The kernel208  kernel/spawn.c:6   * communicates with HardwareJS via a shared ring in env.kernel_memory:209  kernel/spawn.c:7   *210  kernel/spawn.c:8   *   - Kernel side (this file): producer. Allocates a slot, fills211  kernel/spawn.c:9   *     mode + tid + image fields, advances head, increments212  kernel/spawn.c:10   *     spawn_notify_word + Atomics.notify. Blocks on213  kernel/spawn.c:11   *     result_notify_word until HardwareJS writes the result.214  kernel/spawn.c:12   *215  kernel/spawn.c:13   *   - HardwareJS side (hardwarejs/src/spawnRingConsumer.ts):216  kernel/spawn.c:14   *     consumer. Atomics.wait on spawn_notify_word, processes217  kernel/spawn.c:15   *     slot[tail], writes result, increments result_notify_word218  kernel/spawn.c:16   *     + Atomics.notify.219  kernel/spawn.c:17   *220  kernel/spawn.c:18   * The ring lives in static .bss so wasm-ld can emit a Global export221  kernel/spawn.c:19   * containing its env.kernel_memory offset. HardwareJS reads the222  kernel/spawn.c:20   * offset from the exports map at instantiation time (see223  kernel/spawn.c:21   * hardwarejs/src/kernelWorker.mjs's wasm32_spawn_ring lookup) and224  kernel/spawn.c:22   * starts a consumer loop that runs for the lifetime of the kernel225  kernel/spawn.c:23   * Worker.226  kernel/spawn.c:24   *227  kernel/spawn.c:25   * K5 producer surface: host_spawn_process_worker() is the only228  kernel/spawn.c:26   * issuer; binfmt_wasm.c::load_wasm_binary calls it with fork-mode229  kernel/spawn.c:27   * requests for execve. K6+ adds clone(CLONE_VM, ...) → thread-mode230  kernel/spawn.c:28   * via arch_clone (not yet implemented).231  kernel/spawn.c:29   *232  kernel/spawn.c:30   * K5 consumer surface: HardwareJS-side consumer handles BOTH233  kernel/spawn.c:31   * fork-mode and thread-mode requests, even though K5 kernel C234  kernel/spawn.c:32   * never produces thread-mode. The R1 sub-test bypasses kernel C235  kernel/spawn.c:33   * and constructs a thread-mode request by hand to verify the236  kernel/spawn.c:34   * HardwareJS path works in isolation (this is the237  kernel/spawn.c:35   * no-precluding-K6 verification from §3 K5-enforcement).238  kernel/spawn.c:36   */239  kernel/spawn.c:37  240  kernel/spawn.c:38  #include <linux/types.h>241  kernel/spawn.c:39  #include <linux/init.h>242  kernel/spawn.c:40  #include <linux/kernel.h>243  kernel/spawn.c:41  #include <linux/printk.h>244  kernel/spawn.c:42  #include <linux/string.h>245  kernel/spawn.c:43  #include <linux/sched.h>246  kernel/spawn.c:44  #include <linux/errno.h>247  kernel/spawn.c:45  #include <linux/atomic.h>248  kernel/spawn.c:46  249  kernel/spawn.c:47  #include <asm/clone.h>250  kernel/spawn.c:48  251  kernel/spawn.c:49  /*252  kernel/spawn.c:50   * Atomic wait/notify wrappers. These use the WASM intrinsics253  kernel/spawn.c:51   * directly (not the linux.atomic_wait_i32 host import, which in254  kernel/spawn.c:52   * the current K4/K5 wiring is a stub returning 0). The intrinsics255  kernel/spawn.c:53   * route through V8's futex table on a SharedArrayBuffer, which is256  kernel/spawn.c:54   * exactly what we need to coordinate with HardwareJS-main's257  kernel/spawn.c:55   * Atomics.wait / Atomics.notify on the same SAB-backed memory.258  kernel/spawn.c:56   *259  kernel/spawn.c:57   * Mirrors the idle-path helpers in arch/wasm32/kernel/asyncify.c260  kernel/spawn.c:58   * (private to that file). Duplicated here rather than moved into261  kernel/spawn.c:59   * a shared header to keep arch/wasm32/include layering clean262  kernel/spawn.c:60   * (asyncify.c's are local concerns; spawn.c's are independent263  kernel/spawn.c:61   * concerns; only converge if a third consumer appears).264  kernel/spawn.c:62   */265  kernel/spawn.c:63  static __always_inline int wasm_atomic_wait32(volatile u32 *addr,266  kernel/spawn.c:64  					      u32 expected,267  kernel/spawn.c:65  					      long long timeout_ns)268  kernel/spawn.c:66  {269  kernel/spawn.c:67  	return __builtin_wasm_memory_atomic_wait32((int *)addr,270  kernel/spawn.c:68  						   (int)expected,271  kernel/spawn.c:69  						   (int64_t)timeout_ns);272  kernel/spawn.c:70  }273  kernel/spawn.c:71  274  kernel/spawn.c:72  static __always_inline u32 wasm_atomic_notify(volatile u32 *addr, u32 count)275  kernel/spawn.c:73  {276  kernel/spawn.c:74  	return __builtin_wasm_memory_atomic_notify((int *)addr, count);277  kernel/spawn.c:75  }278  kernel/spawn.c:76  279  kernel/spawn.c:77  /*280  kernel/spawn.c:78   * The ring itself. .bss-allocated so wasm-ld can give us a stable281  kernel/spawn.c:79   * env.kernel_memory offset to export. Aligned to 8 bytes for clean282  kernel/spawn.c:80   * u64 access (in case K6+ extends slot fields to u64).283 284================================================================================2858. wasm32-port/kernel/ — surface inventory (what exists at K8-A2 time)286================================================================================287 288[SITE] wasm32-port/kernel/ files at K8-A2:289  wasm32-port/kernel/asm-offsets.c290  wasm32-port/kernel/asyncify.c291  wasm32-port/kernel/binfmt_wasm.c292  wasm32-port/kernel/clone.c293  wasm32-port/kernel/entry.c294  wasm32-port/kernel/fork.c295  wasm32-port/kernel/head.c296  wasm32-port/kernel/init.c297  wasm32-port/kernel/k6_a1_probes.c298  wasm32-port/kernel/k6_b1_probes.c299  wasm32-port/kernel/k6_b2_probes.c300  wasm32-port/kernel/k6_b4_probes.c301  wasm32-port/kernel/k7_u4b_probes.c302  wasm32-port/kernel/percpu.c303  wasm32-port/kernel/percpu_anchors.c304  wasm32-port/kernel/process.c305  wasm32-port/kernel/sched.c306  wasm32-port/kernel/sections.c307  wasm32-port/kernel/setup.c308  wasm32-port/kernel/signal.c309  wasm32-port/kernel/smp.c310  wasm32-port/kernel/spawn.c311  wasm32-port/kernel/switch_to.c312  wasm32-port/kernel/syscall_table.c313  wasm32-port/kernel/time.c314  wasm32-port/kernel/traps.c315  wasm32-port/kernel/wasm_module.c316 317[SITE] wasm32-port/include/asm/ files at K8-A2:318  wasm32-port/include/asm/asyncify.h319  wasm32-port/include/asm/atomic.h320  wasm32-port/include/asm/barrier.h321  wasm32-port/include/asm/boot.h322  wasm32-port/include/asm/bug.h323  wasm32-port/include/asm/cache.h324  wasm32-port/include/asm/clone.h325  wasm32-port/include/asm/cmpxchg.h326  wasm32-port/include/asm/current.h327  wasm32-port/include/asm/elf.h328  wasm32-port/include/asm/futex.h329  wasm32-port/include/asm/host.h330  wasm32-port/include/asm/io.h331  wasm32-port/include/asm/irq.h332  wasm32-port/include/asm/irqflags.h333  wasm32-port/include/asm/linkage.h334  wasm32-port/include/asm/mmu_context.h335  wasm32-port/include/asm/page.h336  wasm32-port/include/asm/pgalloc.h337  wasm32-port/include/asm/pgtable.h338  wasm32-port/include/asm/processor.h339  wasm32-port/include/asm/ptrace.h340  wasm32-port/include/asm/signal.h341  wasm32-port/include/asm/smp.h342  wasm32-port/include/asm/switch_to.h343  wasm32-port/include/asm/syscall.h344  wasm32-port/include/asm/thread_info.h345  wasm32-port/include/asm/tlbflush.h346  wasm32-port/include/asm/uaccess.h347  wasm32-port/include/asm/vmalloc.h348  wasm32-port/include/asm/wasm_module.h349 350================================================================================3519. wackywasm-tools/musl-1.2.5/src/signal/ — upstream musl signal surface352================================================================================353 354Module: the musl-side signal sources we link against. K8-B3's355src_override targets the per-arch restore.s shape (every real356arch has a restore.s emitting an SYS_rt_sigreturn syscall stub).357wasm32 cannot use a .s file — the wasm assembly model has no358syscall return instruction. K8-B3 provides359src_overrides/signal/wasm32/restore.c that calls the trampoline360__wasm_signal_dispatch.361 362[SITE] wackywasm-tools/musl-1.2.5/src/signal/ — top-level files:363  ../wackywasm-tools/musl-1.2.5/src/signal/block.c364  ../wackywasm-tools/musl-1.2.5/src/signal/getitimer.c365  ../wackywasm-tools/musl-1.2.5/src/signal/kill.c366  ../wackywasm-tools/musl-1.2.5/src/signal/killpg.c367  ../wackywasm-tools/musl-1.2.5/src/signal/psiginfo.c368  ../wackywasm-tools/musl-1.2.5/src/signal/psignal.c369  ../wackywasm-tools/musl-1.2.5/src/signal/raise.c370  ../wackywasm-tools/musl-1.2.5/src/signal/restore.c371  ../wackywasm-tools/musl-1.2.5/src/signal/setitimer.c372  ../wackywasm-tools/musl-1.2.5/src/signal/sigaction.c373  ../wackywasm-tools/musl-1.2.5/src/signal/sigaddset.c374  ../wackywasm-tools/musl-1.2.5/src/signal/sigaltstack.c375  ../wackywasm-tools/musl-1.2.5/src/signal/sigandset.c376  ../wackywasm-tools/musl-1.2.5/src/signal/sigdelset.c377  ../wackywasm-tools/musl-1.2.5/src/signal/sigemptyset.c378  ../wackywasm-tools/musl-1.2.5/src/signal/sigfillset.c379  ../wackywasm-tools/musl-1.2.5/src/signal/sighold.c380  ../wackywasm-tools/musl-1.2.5/src/signal/sigignore.c381  ../wackywasm-tools/musl-1.2.5/src/signal/siginterrupt.c382  ../wackywasm-tools/musl-1.2.5/src/signal/sigisemptyset.c383  ../wackywasm-tools/musl-1.2.5/src/signal/sigismember.c384  ../wackywasm-tools/musl-1.2.5/src/signal/siglongjmp.c385  ../wackywasm-tools/musl-1.2.5/src/signal/signal.c386  ../wackywasm-tools/musl-1.2.5/src/signal/sigorset.c387  ../wackywasm-tools/musl-1.2.5/src/signal/sigpause.c388  ../wackywasm-tools/musl-1.2.5/src/signal/sigpending.c389  ../wackywasm-tools/musl-1.2.5/src/signal/sigprocmask.c390  ../wackywasm-tools/musl-1.2.5/src/signal/sigqueue.c391  ../wackywasm-tools/musl-1.2.5/src/signal/sigrelse.c392  ../wackywasm-tools/musl-1.2.5/src/signal/sigrtmax.c393  ../wackywasm-tools/musl-1.2.5/src/signal/sigrtmin.c394  ../wackywasm-tools/musl-1.2.5/src/signal/sigset.c395  ../wackywasm-tools/musl-1.2.5/src/signal/sigsetjmp.c396  ../wackywasm-tools/musl-1.2.5/src/signal/sigsetjmp_tail.c397  ../wackywasm-tools/musl-1.2.5/src/signal/sigsuspend.c398  ../wackywasm-tools/musl-1.2.5/src/signal/sigtimedwait.c399  ../wackywasm-tools/musl-1.2.5/src/signal/sigwait.c400  ../wackywasm-tools/musl-1.2.5/src/signal/sigwaitinfo.c401 402[SITE] wackywasm-tools/musl-1.2.5/src/signal/ — per-arch restore.s shapes:403  ../wackywasm-tools/musl-1.2.5/src/signal/aarch64/restore.s404  ../wackywasm-tools/musl-1.2.5/src/signal/arm/restore.s405  ../wackywasm-tools/musl-1.2.5/src/signal/i386/restore.s406  ../wackywasm-tools/musl-1.2.5/src/signal/loongarch64/restore.s407  ../wackywasm-tools/musl-1.2.5/src/signal/microblaze/restore.s408  ../wackywasm-tools/musl-1.2.5/src/signal/powerpc/restore.s409  ../wackywasm-tools/musl-1.2.5/src/signal/powerpc64/restore.s410  ../wackywasm-tools/musl-1.2.5/src/signal/riscv32/restore.s411  ../wackywasm-tools/musl-1.2.5/src/signal/riscv64/restore.s412  ../wackywasm-tools/musl-1.2.5/src/signal/s390x/restore.s413  ../wackywasm-tools/musl-1.2.5/src/signal/sh/restore.s414  ../wackywasm-tools/musl-1.2.5/src/signal/x32/restore.s415  ../wackywasm-tools/musl-1.2.5/src/signal/x86_64/restore.s416 417[DEF] musl-1.2.5/src/signal/sigaction.c — __libc_sigaction + __sigaction:418  src/signal/sigaction.c:20  int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)419  src/signal/sigaction.c:63  int __sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)420 421[DEF] musl-1.2.5/src/signal/raise.c — raise():422  src/signal/raise.c:6  int raise(int sig)423 424[DEF] musl-1.2.5/src/signal/kill.c — kill():425  src/signal/kill.c:4  int kill(pid_t pid, int sig)426 427[CALL] musl-1.2.5 sigprocmask call sites (K8-B5 surface):428  src/signal/block.c:33:	__syscall(SYS_rt_sigprocmask, SIG_BLOCK, &all_mask, set, _NSIG/8);429  src/signal/block.c:38:	__syscall(SYS_rt_sigprocmask, SIG_BLOCK, &app_mask, set, _NSIG/8);430  src/signal/block.c:43:	__syscall(SYS_rt_sigprocmask, SIG_SETMASK, set, 0, _NSIG/8);431  src/signal/sigaction.c:37:				__syscall(SYS_rt_sigprocmask, SIG_UNBLOCK,432  src/signal/sigsetjmp_tail.c:8:	__syscall(SYS_rt_sigprocmask, SIG_SETMASK, ret?p:0, ret?0:p, _NSIG/8);433 434================================================================================43510. wackywasm-tools/musl-src/src_overrides/ — K7-state overrides (K8-B3 extends)436================================================================================437 438Existing src_overrides at K8-A2 (K7's state). K8-B3 adds a439new signal/wasm32/ subtree:440  [K8-B] musl-src/src_overrides/signal/wasm32/restore.c441         (replaces upstream restore.s for wasm32; calls442         __wasm_signal_dispatch)443  [K8-B] musl-src/src_overrides/internal/wasm32/__wasm_signal_dispatch.c444         (the trampoline itself; called from worker.mjs after a445         syscall returns when pending_signals != 0)446 447The K8-B3 overrides land alongside the existing K7448thread/wasm32/{__set_thread_area.c,clone.c} and449env/wasm32/__init_tls.c overrides; same disposition table450(toolchain-model.rst §5).451 452[SITE] wackywasm-tools/musl-src/src_overrides/ — files at K8-A2:453  ../wackywasm-tools/musl-src/src_overrides/env/wasm32/__init_tls.c454  ../wackywasm-tools/musl-src/src_overrides/thread/wasm32/__set_thread_area.c455  ../wackywasm-tools/musl-src/src_overrides/thread/wasm32/clone.c456 457[SITE] wackywasm-tools/musl-src/arch/wasm32/ — arch port files at K8-A2:458  ../wackywasm-tools/musl-src/arch/wasm32/atomic_arch.h459  ../wackywasm-tools/musl-src/arch/wasm32/bits/alltypes.h.in460  ../wackywasm-tools/musl-src/arch/wasm32/bits/fenv.h461  ../wackywasm-tools/musl-src/arch/wasm32/bits/float.h462  ../wackywasm-tools/musl-src/arch/wasm32/bits/ipcstat.h463  ../wackywasm-tools/musl-src/arch/wasm32/bits/msg.h464  ../wackywasm-tools/musl-src/arch/wasm32/bits/posix.h465  ../wackywasm-tools/musl-src/arch/wasm32/bits/reg.h466  ../wackywasm-tools/musl-src/arch/wasm32/bits/sem.h467  ../wackywasm-tools/musl-src/arch/wasm32/bits/setjmp.h468  ../wackywasm-tools/musl-src/arch/wasm32/bits/shm.h469  ../wackywasm-tools/musl-src/arch/wasm32/bits/signal.h470  ../wackywasm-tools/musl-src/arch/wasm32/bits/stat.h471  ../wackywasm-tools/musl-src/arch/wasm32/bits/stdint.h472  ../wackywasm-tools/musl-src/arch/wasm32/bits/syscall.h.in473  ../wackywasm-tools/musl-src/arch/wasm32/bits/user.h474  ../wackywasm-tools/musl-src/arch/wasm32/bits/wasm_thread.h475  ../wackywasm-tools/musl-src/arch/wasm32/crt1.c476  ../wackywasm-tools/musl-src/arch/wasm32/crt1_musl.c477  ../wackywasm-tools/musl-src/arch/wasm32/crt_arch.h478  ../wackywasm-tools/musl-src/arch/wasm32/kstat.h479  ../wackywasm-tools/musl-src/arch/wasm32/pthread_arch.h480  ../wackywasm-tools/musl-src/arch/wasm32/pthread_stub.c481  ../wackywasm-tools/musl-src/arch/wasm32/reloc.h482  ../wackywasm-tools/musl-src/arch/wasm32/runtime.c483  ../wackywasm-tools/musl-src/arch/wasm32/syscall_arch.h484  ../wackywasm-tools/musl-src/arch/wasm32/syscall_nr.h485  ../wackywasm-tools/musl-src/arch/wasm32/wasm_thread.S486 487================================================================================48811. hardwarejs/src/worker.mjs — handleFutex (K8-B1 EINTR insertion site)489================================================================================490 491The K7-U4e in-Worker SYS_futex dispatch. K8-B1 extends492handleFutex with pre/post-check of pending_signals (per493signals-model.rst §7 race-resolution shape). The insertion is494two atomic loads and two early-returns; no other K7-U4e logic495changes.496 497[DEF] hardwarejs/src/worker.mjs::handleFutex(...)498  worker.mjs:133  function handleFutex(uaddr, futex_op, val, timeout_ptr, _uaddr2, _val3) {499 500[SITE] hardwarejs/src/worker.mjs — FUTEX_WAIT body (K8-B1 wraps this):501  worker.mjs:75:   * Atomics.wait / Atomics.notify against env.user_memory. The502  worker.mjs:83:   *   (b) Correctness — Atomics.wait on the MAIN thread is503  worker.mjs:87:   *       of which break the wasm-level Atomics.wait blocking504  worker.mjs:91:   *   (c) Same-SAB semantic — Atomics.wait/notify against a shared505  worker.mjs:94:   *       contract maps SYS_futex(FUTEX_WAIT/WAKE) → this primitive506  worker.mjs:98:   *   FUTEX_WAIT  = 0507  worker.mjs:106:   * Atomics.wait's relative-timeout semantics).508  worker.mjs:109:  const FUTEX_WAIT = 0;509  worker.mjs:116:   *   -EAGAIN     = -11 (FUTEX_WAIT saw mismatched value — caller's510  worker.mjs:127:   * imports as env.user_memory. Atomics.wait/notify operate on511  worker.mjs:136:    /* uaddr must be 4-byte-aligned for Atomics.wait. Misalignment512  worker.mjs:141:    if (op === FUTEX_WAIT) {513  worker.mjs:154:      const result = Atomics.wait(userI32, i32_idx, val | 0, timeout_ms);514  worker.mjs:158:      /* Defensive: unknown return from Atomics.wait. */515  worker.mjs:164:       * Atomics.notify returns the number actually woken. */516  worker.mjs:166:      const woken = Atomics.notify(userI32, i32_idx, count);517  worker.mjs:225:      Atomics.wait(ctrl, C.STATE, REQUEST);518 519================================================================================52012. hardwarejs/src/spawnRingConsumer.ts — ring consumer pattern (K8-B2 mirror)521================================================================================522 523The K5-pattern consumer. K8-B2's signalRingConsumer.ts follows524the IDENTICAL poll-and-dispatch shape; only the slot payload525type and the dispatched handler change.526 527[DEF] hardwarejs/src/spawnRingConsumer.ts — exported types/classes:528  spawnRingConsumer.ts:76:export interface SpawnRequest {529  spawnRingConsumer.ts:109:export interface SpawnRingConsumerOptions {530  spawnRingConsumer.ts:139:export class SpawnRingConsumer {531 532================================================================================53313. hardwarejs/src/kernelSpawnHandler.ts — per-pid registry (K8-B2 extends)534================================================================================535 536The K7-U4c registry: tid → { wasmBytes, userMemory }. K8-B2537either extends this map (adding a signalPendingOffset field538per record) or adds a sibling per-tid signal registry. K8-B2539picks the cleanest variant; either way, the lookup happens by540the same tid that wasm_signal_submit publishes through the541signal ring.542 543[DEF] hardwarejs/src/kernelSpawnHandler.ts — exported types/functions:544  kernelSpawnHandler.ts:172:export interface KernelSpawnParentRecord {545  kernelSpawnHandler.ts:199:export type KernelSpawnHandler = SpawnHandler & {546  kernelSpawnHandler.ts:205:export interface KernelSpawnHandlerOptions {547  kernelSpawnHandler.ts:255:export function makeKernelSpawnHandler(548 549[SITE] hardwarejs/src/kernelSpawnHandler.ts — registry data structures:550  kernelSpawnHandler.ts:186: * spawnHandler option directly). Also exposes a small registry-551  kernelSpawnHandler.ts:197: * the registry automatically.552  kernelSpawnHandler.ts:258:  /* Parent-process registry: tid → { wasmBytes, userMemory }.553  kernelSpawnHandler.ts:263:  const parents = new Map<number, KernelSpawnParentRecord>();554  kernelSpawnHandler.ts:265:  /* CLONE_CHILD_CLEARTID registry: tid → { ctid, userMemory }.555  kernelSpawnHandler.ts:269:  const cloneCleartidMap = new Map<number, { ctid: number; userMemory: WebAssembly.Memory }>();556  kernelSpawnHandler.ts:363:    /* Tracking only — not awaited here. K6+ pid registry uses557  kernelSpawnHandler.ts:475:         * process group — so we reuse the parent registry.558 559================================================================================56014. K8-B insertion-point summary (annotation only; no code yet)561================================================================================562 563  [K8-B1] linux-wasm/patches/0008-signal-add-arch_signal_wake_target-hook.patch564          Upstream weak-hook in kernel/signal.c::__send_signal_locked,565          invoked AFTER the bit-set in t->pending.signal.566 567  [K8-B1] arch/wasm32/include/asm/signal.h — extend with568          struct wasm_signal_pending_region (40 bytes, layout569          per signals-model.rst §3) + static_asserts pinning570          SR_OFF_PENDING_LO/HI/WAKE_WORD/SIGMASK_LO/HI.571 572  [K8-B1] arch/wasm32/kernel/signal.c — replace K0 stub with573          arch_signal_wake_target(struct task_struct *t)574          implementation. Composes a wasm_signal_request575          payload, submits via the new signal ring.576 577  [K8-B1] hardwarejs/src/worker.mjs::handleFutex —578          pre-Atomics.wait check on signal-pending region;579          post-Atomics.wait re-check; both return -EINTR (-4)580          when set.581 582  [K8-B2] arch/wasm32/include/asm/signal.h — extend with583          struct wasm_signal_request + wasm_signal_request_ring584          (mirror of clone.h spawn-ring shape).585 586  [K8-B2] arch/wasm32/kernel/spawn.c (or new signal_ring.c)587          — kernel-side ring producer.588 589  [K8-B2] hardwarejs/src/signalRingConsumer.ts (NEW)590          — JS-side ring consumer.591 592  [K8-B2] hardwarejs/src/signalHandler.ts (NEW)593          — per-tid registry lookup + Worker594          signal-pending-region update + wake_word595          Atomics.notify.596 597  [K8-B3] musl-src/src_overrides/internal/wasm32/__wasm_signal_dispatch.c598          (NEW) — Worker-side trampoline; saves sigmask, applies599          sa_mask, indirect-calls sa_handler, restores sigmask,600          clears the dispatched bit in pending_signals.601 602  [K8-B3] musl-src/src_overrides/signal/wasm32/restore.c (NEW)603          — replaces upstream restore.s; calls604          __wasm_signal_dispatch.605 606  [K8-B4] musl-src/src_overrides/signal/wasm32/default_disp.c607          (NEW) — SIG_DFL terminate-vs-ignore-vs-stop disposition608          dispatch; SIGKILL/SIGSTOP non-catchability check.609 610  [K8-B5] musl-src/src_overrides/signal/wasm32/sigsuspend.c611          (NEW or upstream-direct) — sigsuspend / sigprocmask /612          rt_sigtimedwait surface against the per-Worker sigmask613          slot in the pending region.614 615================================================================================616END OF SNAPSHOT617================================================================================618