interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

GitHub aien-dev/aienux#224 (code only)

closed derived 8694a8d9c30c5d45 #224

Imported from GitHub aien-dev/aienux#224 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 2f393a4e1af17cb9ba2f1445771bcd64024fe9aa · Head ca53f582a211b0a8d425108c937cfe7c1b161923

Apply it

git checkout -b patch-8694a8d9c30c5d45 2f393a4e1af17cb9ba2f1445771bcd64024fe9aa
curl -fsSL https://interplane.io/drakestapleton/aienux/patches/8694a8d9c30c5d45.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aienux
224
ca53f582a211b0a8d425108c937cfe7c1b161923
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":224,"url":"https://github.com/aien-dev/aienux/pull/224","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:35:59Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/native/kernel/GATES.md b/native/kernel/GATES.md
index f82e9f95..5fe6c724 100644
--- a/native/kernel/GATES.md
+++ b/native/kernel/GATES.md
@@ -23,7 +23,7 @@ C gates (one line each from `ck_gates.sh`): `M1` and `M3` (from
 96-101 were checked against its exact grep patterns), `P2_ARTIFACT` (from
 `scripts/qemu_ck_artifact_test.sh`, rows 33-41), `NET` (C-only, from
 `scripts/qemu_ck_net_test.sh`; rows 102-106 and 110-112; the script now also checks the virtio-net SMMU fence (ACCESS_PLATFORM required, out-of-window device DMA refused), rows 102 and 110-112 are QEMU PASS on this branch from the committed forge log `evidence/ck_net_qemu_8bdbc2e46b85d04c422f9d2830c1c4b263e254b3cfecfe21ff0063c9e33c86e8.log`, hardware NOT_RUN), the kernel entropy rows 107-109 (M1 via `scripts/lib_ck_m1_checks.sh`, ARGUS1_REVOKE and M4_STORE via the Store gate boot 7), and the NOT_RUN gates
-`M0_ROLLBACK`, `M4_STORE_CRASH`,
+`SMP` (C-only, from `scripts/qemu_ck_smp_test.sh`, rows 113-117, NOT_RUN pending forge receipt), `M0_ROLLBACK`, `M4_STORE_CRASH`,
 `M4_CONTINUITY`, `M4_RECOVERY`, `KEYBOARD`.
 
 `M4_NVME` and `SMMU` PASS in the SMMU-confined mode (default `make full`
@@ -424,9 +424,33 @@ complete.
 | 111 | virtio-net recovers inside the window after the refused DMA | NET | QEMU PASS (receipt `evidence/ck_net_qemu_8bdbc2e46b85d04c422f9d2830c1c4b263e254b3cfecfe21ff0063c9e33c86e8.log`, forge log of `scripts/qemu_ck_net_test.sh` at 6816358, ends `AIENOS_CK_NET: PASS`; hardware NOT_RUN: no physical NIC or SMMU. Receipt lines 36-38. C-only, boot 1, what the script checks: `net_smmu_recovery: device reset + reinit ok (Ok) access_platform=yes late_probe_faults=N` (status 0 written and read back before the rings are rebuilt; probe events that land after the negative test are drained and reported here) and `net_smmu_recovery: round trip after the fault ok (rc=0 new_faults=0)`, a second ARP + UDP round trip with this run's helper token, then the normal release order of row 105. To be shown: recovery by device reset + re-init; not covered even when run: a NIC that keeps running through the fault (the kernel discards the redirected descriptors and resets)) |
 | 112 | virtio-net without ACCESS_PLATFORM refused (fail closed) | NET | QEMU PASS (receipt `evidence/ck_net_qemu_8bdbc2e46b85d04c422f9d2830c1c4b263e254b3cfecfe21ff0063c9e33c86e8.log`, forge log of `scripts/qemu_ck_net_test.sh` at 6816358, ends `AIENOS_CK_NET: PASS`; hardware NOT_RUN: no physical NIC or SMMU. Receipt lines 86-93 (boot net-noap). C-only, boot 3, what the script checks: `iommu=smmuv3` but the NIC modern-only (`disable-legacy=on`) without `iommu_platform=on`, so QEMU offers no ACCESS_PLATFORM and would DMA around the vIOMMU: `virtio_net: init FAIL (NoAccessPlatform)` before FEATURES_OK, absent `virtio_net: attached` and `net: udp tx`, stream returned to abort, host helper receives nothing) |
 
+## SMP: secondary cores through PSCI CPU_ON -> CK `SMP` (scripts/qemu_ck_smp_test.sh)
+
+C-only: the Rust kernel starts no secondary core, so there is no Rust row to
+match. QEMU `-M virt,virtualization=on,gic-version=3 -cpu max -smp 4`, single
+threaded TCG, the default core image (`make`), same machine as `M1`. The
+kernel (`core/smp.c`, `arch/smp_entry.S`) reads the MPIDR of every enabled or
+online-capable core from the ACPI MADT GICC entries (`ck_madt_mpidrs`, host
+test in `tests/test_acpi.c`), calls PSCI CPU_ON (SMC64 0xC4000003) on the
+conduit the FADT names (SMC under `virtualization=on`), and each secondary
+goes through the boot core's own EL2 -> EL1h path (`ck_enter_el1`; QEMU 8.2.2
+`target/arm/tcg/psci.c:144` starts it at EL2 when EL2 exists). The boot core
+waits at most 5 s and never panics; the script re-checks every line itself.
+No PASS without a forge receipt; hardware NOT_RUN (no GB10 core was started).
+
+| # | C check | CK gate | Status |
+| --- | --- | --- | --- |
+| 113 | PSCI CPU_ON issued once per secondary core and returns SUCCESS (`smp_cpu_on: target=0x.. psci_rc=0 (SUCCESS)`, N-1 lines; any PSCI error code or a skipped call FAILs) | SMP | NOT_RUN (pending forge receipt) |
+| 114 | every secondary checks in on EL1 with the MMU on the boot core's tables and its own stack, then parks in WFE (`smp_cpu: target=0x.. checked_in=yes seen_mpidr=0x.. el=1 mmu=on ttbr0_match=yes stack_ok=yes parked=wfe`); a core that never checks in within the bounded wait (`checked_in=no`) FAILs | SMP | NOT_RUN (pending forge receipt) |
+| 115 | per-core MPIDRs distinct and complete: MADT core count equals `-smp N`, each secondary reports the MPIDR it was started for, boot + secondaries give N distinct values (duplicate or missing MPIDR FAILs) | SMP | NOT_RUN (pending forge receipt) |
+| 116 | summary `smp: cpus=N started=N checked_in=N psci_errors=0 distinct_mpidrs=N wait_us=.. result=ok`, no `smp: FAIL`, kernel reaches `report_kind: final`, no panic or fault, QEMU exit 0, image is not the TEST-ONLY mutation | SMP | NOT_RUN (pending forge receipt) |
+| 117 | mutation: `make CK_TEST_SMP_SKIP_CPU=1` (TEST-ONLY, own OUT, announces itself, never calls CPU_ON for the last MADT secondary) must make the gate checks FAIL (`scripts/qemu_ck_smp_test.sh --mutation` ends `AIENOS_CK_SMP_MUTATION: PASS` when they do); the flag is refused with `CK_HARDWARE_STAGING` (Makefile `$(error)` and a `#error` in `core/smp.c`) and default images are checked to carry no trace of it (Makefile `smp_check`); canned-log failure modes in `scripts/qemu_ck_smp_test.sh --self-test` | SMP | NOT_RUN (pending forge receipt) |
+
 ## Summary counts
 
-**C kernel receipt tally (QEMU only, no physical run):** 9 of 14 CK gates PASS, 5 NOT_RUN (M0_ROLLBACK, M4_STORE_CRASH, M4_CONTINUITY, M4_RECOVERY, KEYBOARD), 0 FAIL, matching `evidence/ck_gates_929f287e9c950c45c7dcd569c7caa03709ea62ecfe393635b435058afa969c54.json` (run at 41aa0e6, which adds the kernel entropy rows 107-109; that commit was then rebased onto #210, which changed only README.md and CONTRIBUTING.md). The row counts below are per Rust-parity row, not per gate.
+**C kernel receipt tally (QEMU only, no physical run):** 9 of 15 CK gates PASS, 6 NOT_RUN (M0_ROLLBACK, M4_STORE_CRASH, M4_CONTINUITY, M4_RECOVERY, KEYBOARD; and SMP, added after that receipt, NOT_RUN pending forge receipt), 0 FAIL. The 9 PASS match `evidence/ck_gates_929f287e9c950c45c7dcd569c7caa03709ea62ecfe393635b435058afa969c54.json` (run at 41aa0e6, which adds the kernel entropy rows 107-109; that commit was then rebased onto #210, which changed only README.md and CONTRIBUTING.md). The row counts below are per Rust-parity row, not per gate.
+
+Rows 113-117 (SMP, C-only, new in this change): 5 NOT_RUN (pending forge receipt), so rows 1-117 plus the M4 continuity/recovery sub-rows: IDENTICAL 28, DIFFERS 39, NOT_RUN 91 (86 from the line below plus these 5).
 
 Rows 1-112 plus the M4 continuity/recovery sub-rows 83a-87i and 88a-91p: IDENTICAL 28, DIFFERS 39, NOT_RUN 86, counted from the table (the CK-5 contract branch split rows 81-91, 11 NOT_RUN rows, into 52 NOT_RUN rows, one per Rust QEMU check and host test, see `native/kernel/CONTINUITY_RECOVERY_CONTRACT.md`; that adds 41 NOT_RUN rows and changes no other row or gate; the CK gate tally is unchanged; recounted again after merging the KEYBOARD DMA-fence branch: 28 IDENTICAL, 39 DIFFERS, 82 NOT_RUN and 4 QEMU PASS rows (102, 110-112) counted as NOT_RUN as below, so 86, unchanged, with sub-rows 24a and 24b (C only) not counted; rows 25-28, 31 and 32 now have a C implementation and a child script, scripts/qemu_ck_keyboard_test.sh, but stay NOT_RUN (pending forge receipt), rows 29-30 stay NOT_RUN (MISSING_IMPLEMENTATION: no USB HID driver, no console shell), and the KEYBOARD gate stays NOT_RUN; rows 107-109, kernel entropy, are C-only and DIFFERS; row 102, virtio-net attach with ACCESS_PLATFORM, and rows 110-112, virtio-net SMMU fence, recovery and ACCESS_PLATFORM fail-closed, are C-only and NOT_RUN on this branch until a forge receipt covers them; the CK gate tally above and its receipt `ck_gates_929f...` predate them; no full `ck_gates.sh` run happened on this branch, only `scripts/qemu_ck_net_test.sh` alone, so rows 102 and 110-112 are shown as QEMU PASS (receipt `evidence/ck_net_qemu_8bdbc2e46b85d04c422f9d2830c1c4b263e254b3cfecfe21ff0063c9e33c86e8.log`, hardware NOT_RUN) and the NOT_RUN count still includes them as originally counted, not recounted); rows 34 and 39 now also cover the NVMe boot-disk source and its hostile disk cases (statuses unchanged) (the previous summary, 20/30/56, was miscounted: the table on main had 21/35/50; rows 33-41 then moved from NOT_RUN to 7 IDENTICAL + 2 DIFFERS with the C artifact loader; rows 92-95 have no CK gate at all; rows 96-112 are C-only). Rows 33-41 were checked against scripts/qemu_ck_artifact_test.sh. Rows 102-106 and 110-112 were checked against scripts/qemu_ck_net_test.sh (text only; rows 102 and 110-112 then run by the forge, see their rows). Rows 13, 24, 47-72, 76 and 96-101 were re-verified against scripts/qemu_ck_store_test.sh and scripts/lib_ck_m1_checks.sh at the commit that adds this line.
 
diff --git a/native/kernel/Makefile b/native/kernel/Makefile
index 0f06202a..a0d43cdd 100644
--- a/native/kernel/Makefile
+++ b/native/kernel/Makefile
@@ -29,6 +29,11 @@
 #                        (target/native-kernel-test-fwcfg); announces itself and
 #                        never counts toward a PASS. Default images are checked
 #                        to contain no fw_cfg artifact code.
+#   make CK_TEST_SMP_SKIP_CPU=1
+#                        TEST-ONLY SMP mutation: CPU_ON skipped for one secondary
+#                        core (core/smp.c); own OUT (target/native-kernel-test-smp-skip);
+#                        the SMP gate must FAIL on it (scripts/qemu_ck_smp_test.sh
+#                        --mutation); refused with CK_HARDWARE_STAGING
 #   make store-image     host tool $(OUT)/host/ck_store_image: signed artifacts
 #                        into the sealed Store on a raw NVMe disk image
 #   make test            host unit tests            -> CK_CORE_HOST: PASS
@@ -85,6 +90,29 @@ $(error CK_TEST_FWCFG_ARTIFACTS (QEMU fw_cfg test source) cannot be combined wit
 endif
 OUT ?= $(REPO)/target/native-kernel-test-fwcfg
 endif
+
+# TEST-ONLY SMP mutation: CK_TEST_SMP_SKIP_CPU=1 builds a kernel that never
+# calls PSCI CPU_ON for one secondary core (core/smp.c) but still waits for
+# it, so the SMP gate must FAIL on it (scripts/qemu_ck_smp_test.sh
+# --mutation). Own OUT; announces itself; refused with CK_HARDWARE_STAGING
+# and with the fw_cfg test source. Default images are checked to carry no
+# trace of it (smp_check).
+CK_TEST_SMP_SKIP_CPU ?=
+ifneq ($(strip $(CK_TEST_SMP_SKIP_CPU)),)
+ifneq ($(strip $(CK_TEST_SMP_SKIP_CPU)),1)
+$(error CK_TEST_SMP_SKIP_CPU must be empty or 1)
+endif
+ifneq ($(strip $(CK_HARDWARE_STAGING)),)
+$(error CK_TEST_SMP_SKIP_CPU (TEST-only SMP mutation) cannot be combined with CK_HARDWARE_STAGING)
+endif
+ifneq ($(strip $(CK_TEST_FWCFG_ARTIFACTS)),)
+$(error CK_TEST_SMP_SKIP_CPU cannot be combined with CK_TEST_FWCFG_ARTIFACTS)
+endif
+OUT ?= $(REPO)/target/native-kernel-test-smp-skip
+SMP_TEST_FLAGS := -DCK_TEST_SMP_SKIP_CPU=1
+else
+SMP_TEST_FLAGS :=
+endif
 OUT ?= $(REPO)/target/native-kernel
 AIENOS_COMMIT ?= $(shell git -C $(REPO) rev-parse HEAD 2>/dev/null || echo unknown)
 
@@ -177,7 +205,7 @@ MODULE_INC := -I$(NATIVE)/disk -I$(NATIVE)/store -I$(NATIVE)/m5 -I$(NATIVE)/cryp
 KCFLAGS := -std=gnu11 -O2 -Wall -Wextra -Werror -ffreestanding -nostdlib -fno-builtin \
 	-fno-stack-protector -fno-tree-loop-distribute-patterns -mstrict-align \
 	-mgeneral-regs-only -mno-outline-atomics -fno-asynchronous-unwind-tables -fpie \
-	-fvisibility=hidden -fno-plt $(KINC) $(CK_EXTRA_CFLAGS)
+	-fvisibility=hidden -fno-plt $(KINC) $(SMP_TEST_FLAGS) $(CK_EXTRA_CFLAGS)
 KLDFLAGS := -nostdlib -pie --no-dynamic-linker -z norelro -z noexecstack -z max-page-size=4096 --no-warn-rwx-segments \
 	-T $(BOOT)/image.ld
 
@@ -186,7 +214,7 @@ CORE_C := $(BOOT)/efi_main.c \
 	$(KDIR)/core/acpi.c $(KDIR)/core/console.c $(KDIR)/core/fmt.c \
 	$(KDIR)/core/kmain.c $(KDIR)/core/handoff_check.c $(KDIR)/core/libc_min.c $(KDIR)/core/report.c \
 	$(KDIR)/core/smmu.c $(KDIR)/core/smmu_svc.c $(KDIR)/core/sched.c $(KDIR)/core/ipc.c \
-	$(KDIR)/core/m3.c $(KDIR)/core/entropy.c $(KDIR)/arch/rndr.c \
+	$(KDIR)/core/m3.c $(KDIR)/core/entropy.c $(KDIR)/arch/rndr.c $(KDIR)/core/smp.c \
 	$(KDIR)/mm/frames.c $(KDIR)/mm/heap.c $(KDIR)/mm/mmu.c $(KDIR)/mm/pt.c
 # P2 sealed-artifact loader: format/admission/receipt (artifact/), SHA-256
 # (argus), Ed25519/SHA-512 (sig). Built into the core so every image carries
@@ -196,7 +224,7 @@ ART_C := $(KDIR)/core/artifact_loader.c $(KDIR)/artifact/format.c $(KDIR)/artifa
 	$(NATIVE)/sig/ed25519.c $(NATIVE)/sig/ct.c
 ART_INC := -I$(KDIR)/svc/compat -I$(KDIR)/artifact -I$(NATIVE)/sig -I$(NATIVE)/argus
 CORE_C += $(ART_C)
-CORE_S := $(BOOT)/efi_entry.S $(KDIR)/arch/vectors.S $(KDIR)/arch/m3.S
+CORE_S := $(BOOT)/efi_entry.S $(KDIR)/arch/vectors.S $(KDIR)/arch/m3.S $(KDIR)/arch/smp_entry.S
 HDRS := $(wildcard $(KDIR)/include/*.h $(KDIR)/*/*.h $(BOOT)/*.h)
 
 KOBJ := $(OUT)/obj
@@ -320,6 +348,16 @@ define owner_check
 	fi
 endef
 
+# smp_check(elf): only a CK_TEST_SMP_SKIP_CPU image may carry the SMP mutation
+# announcement, and such an image must carry it.
+define smp_check
+	@if [ "$(strip $(CK_TEST_SMP_SKIP_CPU))" = 1 ]; then \
+	  grep -aqF "TEST-ONLY SMP mutation" $(1) || { echo "SMP mutation image lacks its TEST-ONLY announcement"; rm -f $(1); exit 1; }; \
+	else \
+	  if grep -aqF "TEST-ONLY SMP mutation" $(1); then echo "default image carries the TEST-ONLY SMP mutation"; rm -f $(1); exit 1; fi; \
+	fi
+endef
+
 # link_image(output elf, objects): refuses undefined symbols (weak stage
 # references excepted) and any relocation other than R_AARCH64_RELATIVE.
 define link_image
@@ -343,6 +381,7 @@ $(ELF): $(CORE_OBJS) $(BOOT)/image.ld
 	@s=$$($(KNM) $@ | grep -E ' [TtDdBbWwVv] ck_stage_(devices|security|store|quiesce)$$' || true); \
 	if [ -n "$$s" ]; then echo "core image defines stage symbols: $$s"; rm -f $@; exit 1; fi
 	$(call fwcfg_check,$@)
+	$(call smp_check,$@)
 
 $(FULL_ELF): $(CORE_OBJS) $(STAGE_BUILT) $(BOOT)/image.ld
 	$(call link_image,$@,$(CORE_OBJS) $(STAGE_LINK))
@@ -351,6 +390,7 @@ $(FULL_ELF): $(CORE_OBJS) $(STAGE_BUILT) $(BOOT)/image.ld
 	$(call fwcfg_check,$@)
 	$(call owner_check,$@)
 	$(call xhci_mut_check,$@)
+	$(call smp_check,$@)
 
 $(EFI): $(ELF)
 	$(call pe_image,$<,$@)
diff --git a/native/kernel/arch/smp_entry.S b/native/kernel/arch/smp_entry.S
new file mode 100644
index 00000000..c96acafc
--- /dev/null
+++ b/native/kernel/arch/smp_entry.S
@@ -0,0 +1,38 @@
+/* smp_entry.S -- PSCI CPU_ON entry point for secondary cores (core/smp.c).
+ *
+ * Entered with the MMU and caches off, x0 = context_id = the core's
+ * struct ck_smp_cpu (identity mapped, cleaned to PoC by the boot core), at
+ * the EL PSCI chose: EL2 when EL2 exists (QEMU 8.2.2 target/arm/tcg/psci.c:144),
+ * else EL1. Only aligned 8-byte loads from the context happen before the MMU
+ * is on. EL2: fatal-only EL2 vectors, then the boot core's own EL2 -> EL1h
+ * path ck_enter_el1 (ADR 0009: HCR_EL2.RW, VMPIDR_EL2 = this core's MPIDR,
+ * timer and GIC system register access, MMU on with the boot core's tables).
+ * EL1: ck_switch_el1. Both land in ck_smp_secondary_main(ctx) on the core's
+ * own stack. Any other EL parks here. Context offsets: core/smp.c. */
+    .text
+    .global ck_smp_entry
+    .type ck_smp_entry, %function
+    .balign 8
+ck_smp_entry:
+    msr daifset, #0xf
+    mov x19, x0
+    mrs x9, CurrentEL
+    ubfx x9, x9, #2, #2
+    ldp x0, x1, [x19, #0]          /* root, mair */
+    ldp x2, x3, [x19, #16]         /* tcr, sctlr */
+    ldr x4, [x19, #32]             /* stack top */
+    adrp x5, ck_smp_secondary_main
+    add x5, x5, :lo12:ck_smp_secondary_main
+    mov x6, x19
+    cmp x9, #2
+    b.ne 1f
+    adrp x10, ck_vectors_el2
+    add x10, x10, :lo12:ck_vectors_el2
+    msr vbar_el2, x10
+    isb
+    b ck_enter_el1
+1:  cmp x9, #1
+    b.eq ck_switch_el1
+2:  wfe
+    b 2b
+    .size ck_smp_entry, . - ck_smp_entry
diff --git a/native/kernel/core/acpi.c b/native/kernel/core/acpi.c
index 0e9838e0..f214d38d 100644
--- a/native/kernel/core/acpi.c
+++ b/native/kernel/core/acpi.c
@@ -147,6 +147,36 @@ int ck_madt_parse(const void *madt, struct ck_madt_gic *out)
 }
 
 
+int ck_madt_mpidrs(const void *madt, uint64_t *out, unsigned max, unsigned *n)
+{
+    const uint8_t *m = madt;
+    uint32_t len = rd32(m + 4);
+    unsigned count = 0;
+    *n = 0;
+    if (!sig_eq(m, "APIC", 4) || len < 44)
+        return -1;
+    for (uint32_t at = 44; at < len;) {
+        if (at + 2 > len)
+            return -1;
+        uint8_t type = m[at], elen = m[at + 1];
+        if (elen < 2 || at + elen > len)
+            return -1;
+        const uint8_t *e = m + at;
+        if (type == 0x0b) { /* GICC */
+            if (elen < 76)
+                return -1;
+            if (rd32(e + 12) & (1u | 8u)) {
+                if (count < max)
+                    out[count] = rd64(e + 68) & CK_MPIDR_AFF_MASK;
+                count++;
+            }
+        }
+        at += elen;
+    }
+    *n = count;
+    return count > max ? -2 : 0;
+}
+
 static void topo_add(struct ck_cpu_topology *t, uint8_t cls)
 {
     for (unsigned i = 0; i < t->distinct_classes; i++)
diff --git a/native/kernel/core/acpi.h b/native/kernel/core/acpi.h
index 04817114..137d33f8 100644
--- a/native/kernel/core/acpi.h
+++ b/native/kernel/core/acpi.h
@@ -60,6 +60,13 @@ struct ck_cpu_topology {
     uint64_t first_mpidr;
 };
 int ck_madt_cpu_topology(const void *madt, struct ck_cpu_topology *out);
+/* MPIDR affinity fields of every enabled or online-capable GICC entry (offset
+ * 68, masked to Aff3 [39:32] and Aff2..Aff0 [23:0]), in table order, for the
+ * SMP bring-up (core/smp.c). *n gets the number of such entries even when it
+ * exceeds max (only the first max are stored). 0 ok, -1 malformed (bad entry
+ * length, truncation, a GICC entry shorter than 76 bytes), -2 more than max. */
+#define CK_MPIDR_AFF_MASK 0xff00ffffffull
+int ck_madt_mpidrs(const void *madt, uint64_t *out, unsigned max, unsigned *n);
 /* thread.rs place_task: task_index modulo the classified cores, walked class
  * by class. 0 and (class, index within class), or -1 if no core is classified. */
 int ck_place_task(const struct ck_cpu_topology *t, uint32_t task_index, uint8_t *class_id,
diff --git a/native/kernel/core/ck_internal.h b/native/kernel/core/ck_internal.h
index 1e900e77..ef5b6441 100644
--- a/native/kernel/core/ck_internal.h
+++ b/native/kernel/core/ck_internal.h
@@ -29,6 +29,11 @@ void ck_report_header(const char *kind);
 __attribute__((noreturn)) void ck_reset(void);
 /* PSCI conduit from the FADT; default SMC. */
 void ck_psci_configure(const void *fadt);
+/* One PSCI call (SMC32/SMC64 calling convention, x0-x3 in, x0 out) on the
+ * configured conduit: HVC only at EL1 when the FADT says HVC, else SMC. */
+int64_t ck_psci_call(uint64_t fn, uint64_t a1, uint64_t a2, uint64_t a3);
+/* "hvc" or "smc": the conduit ck_psci_call uses at the current EL. */
+const char *ck_psci_conduit(void);
 __attribute__((noreturn)) void ck_fault_report(const char *what, uint64_t esr, uint64_t far,
                                                uint64_t elr, unsigned el);
 
@@ -94,5 +99,9 @@ void ck_m3_run(void);
  * Returns CK_RNG_OK or the refusal (see core/entropy.h). */
 int ck_entropy_init(void);
 uint64_t ck_entropy_retries(void);
+/* core/smp.c: secondary cores through PSCI CPU_ON, each on its own stack with
+ * the MMU on the boot core's tables, checked in and parked in WFE. Prints
+ * the smp: lines scripts/qemu_ck_smp_test.sh judges; never panics. */
+void ck_smp_run(void);
 
 #endif
diff --git a/native/kernel/core/kmain.c b/native/kernel/core/kmain.c
index 156cf7c7..64d81223 100644
--- a/native/kernel/core/kmain.c
+++ b/native/kernel/core/kmain.c
@@ -4,7 +4,8 @@
  * vectors, PSCI conduit, own address space, then EL2 -> EL1h (ADR 0009) with
  * the MMU on our tables. ck_el1_main then reports the MMU switch from live
  * registers, proves the guard pages, brings up GICv3 and the EL1 physical
- * timer, runs the M3 isolation checks (core/m3.c) and the linked boot stages,
+ * timer, starts and parks the secondary cores (core/smp.c), runs the M3
+ * isolation checks (core/m3.c) and the linked boot stages,
  * and ends with the final report and a PSCI reset. QEMU runs of this path
  * qualify nothing physical. */
 #include "arch.h"
@@ -132,6 +133,11 @@ static __attribute__((noreturn)) void ck_el1_main(void *arg)
                   : ent == CK_RNG_STUCK ? "RNDR repeated a 64-bit word"
                                         : "probe error");
 
+    /* Secondary cores (core/smp.c): PSCI CPU_ON, check in, park in WFE with
+     * interrupts masked; the boot core goes on alone. Lines judged by
+     * scripts/qemu_ck_smp_test.sh (CK gate SMP). */
+    ck_smp_run();
+
     /* M3 isolation checks (core/m3.c), before any stage registers an IRQ. */
     ck_m3_run();
 
diff --git a/native/kernel/core/report.c b/native/kernel/core/report.c
index 9e08a711..2a8aee01 100644
--- a/native/kernel/core/report.c
+++ b/native/kernel/core/report.c
@@ -30,14 +30,32 @@ void ck_psci_configure(const void *fadt)
         psci_hvc = (flags & 2) != 0;
 }
 
-static void psci_call(uint64_t fn)
+/* SMCCC v1.0: x4-x17 may be corrupted by the callee. */
+#define PSCI_CLOBBERS "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x11", "x12", "x13", "x14", \
+                      "x15", "x16", "x17", "memory"
+
+int64_t ck_psci_call(uint64_t fn, uint64_t a1, uint64_t a2, uint64_t a3)
 {
     register uint64_t x0 __asm__("x0") = fn;
+    register uint64_t x1 __asm__("x1") = a1;
+    register uint64_t x2 __asm__("x2") = a2;
+    register uint64_t x3 __asm__("x3") = a3;
     /* HVC would land in our own EL2 vectors while still at EL2. */
     if (psci_hvc && ck_current_el() == 1)
-        __asm__ volatile("hvc #0" : "+r"(x0)::"x1", "x2", "x3", "memory");
+        __asm__ volatile("hvc #0" : "+r"(x0), "+r"(x1), "+r"(x2), "+r"(x3) : : PSCI_CLOBBERS);
     else
-        __asm__ volatile("smc #0" : "+r"(x0)::"x1", "x2", "x3", "memory");
+        __asm__ volatile("smc #0" : "+r"(x0), "+r"(x1), "+r"(x2), "+r"(x3) : : PSCI_CLOBBERS);
+    return (int64_t)x0;
+}
+
+const char *ck_psci_conduit(void)
+{
+    return (psci_hvc && ck_current_el() == 1) ? "hvc" : "smc";
+}
+
+static void psci_call(uint64_t fn)
+{
+    (void)ck_psci_call(fn, 0, 0, 0);
 }
 
 void ck_reset(void)
diff --git a/native/kernel/core/smp.c b/native/kernel/core/smp.c
new file mode 100644
index 00000000..89e1bca1
--- /dev/null
+++ b/native/kernel/core/smp.c
@@ -0,0 +1,241 @@
+/* smp.c -- secondary core bring-up through PSCI CPU_ON (CK gate SMP).
+ *
+ * The boot core reads the MPIDR of every enabled or online-capable core from
+ * the ACPI MADT GICC entries (the firmware's own CPU list; QEMU virt with
+ * AAVMF gives ACPI, not a device tree, to this kernel), then for each
+ * secondary core: takes a 16 KiB stack from the frame allocator, fills a
+ * per-core context (our page-table root, MAIR, TCR, SCTLR, stack top), cleans
+ * it to the point of coherency (the core reads it with its MMU off) and calls
+ * PSCI CPU_ON (SMC64 function 0xC4000003) on the conduit the FADT names
+ * (report.c ck_psci_call). The core starts in arch/smp_entry.S at the
+ * firmware's EL (QEMU 8.2.2 target/arm/tcg/psci.c:144 starts it at EL2 when
+ * EL2 exists, else EL1), goes through the same EL2 -> EL1h path as the boot
+ * core (ck_enter_el1, ADR 0009) or the EL1 table switch (ck_switch_el1), and
+ * lands in ck_smp_secondary_main at EL1 with the MMU on our tables. There it
+ * records what it sees (MPIDR, EL, SCTLR, TTBR0, SP), publishes "checked in"
+ * with a release store and parks in WFE with all interrupts masked.
+ *
+ * The boot core waits at most CK_SMP_TIMEOUT_US for every started core and
+ * prints one line per core and a summary. It never panics: a core that never
+ * checks in, a PSCI error code, a duplicate or missing MPIDR, or a core that
+ * reports the wrong EL/MMU/tables/stack is printed and the summary says
+ * result=FAIL. scripts/qemu_ck_smp_test.sh judges the lines itself.
+ *
+ * TEST-ONLY mutation: a build with -DCK_TEST_SMP_SKIP_CPU=1 (make
+ * CK_TEST_SMP_SKIP_CPU=1, own OUT, refused with CK_HARDWARE_STAGING) never
+ * calls CPU_ON for the last secondary core in the MADT but still waits for
+ * it, so the gate must FAIL on that image. QEMU qualifies nothing physical. */
+#include "arch.h"
+#include "ck_internal.h"
+
+#if defined(CK_TEST_SMP_SKIP_CPU) && defined(CK_HARDWARE_STAGING)
+#error "CK_TEST_SMP_SKIP_CPU (TEST-only SMP mutation) cannot be combined with CK_HARDWARE_STAGING"
+#endif
+
+#define CK_SMP_MAX 16u
+#define CK_SMP_STACK_PAGES 4u
+#define CK_SMP_TIMEOUT_US 5000000ull
+#define PSCI_VERSION 0x84000000u
+#define PSCI_CPU_ON_64 0xC4000003u
+#define TTBR_BADDR_MASK 0x0000fffffffffffeull
+
+enum { SMP_IDLE = 0, SMP_ON_CALLED = 1, SMP_CHECKED_IN = 2 };
+
+/* Field offsets 0..40 are read by arch/smp_entry.S with the MMU off. */
+struct ck_smp_cpu {
+    uint64_t root, mair, tcr, sctlr, sp; /* 0, 8, 16, 24, 32 */
+    uint64_t target;                     /* 40: MPIDR from the MADT */
+    uint64_t state;                      /* 48: SMP_* (atomic) */
+    uint64_t seen_mpidr, seen_el, seen_sctlr, seen_ttbr0, seen_sp;
+    uint64_t stack_lo, stack_hi;
+} __attribute__((aligned(64)));
+_Static_assert(__builtin_offsetof(struct ck_smp_cpu, sp) == 32, "smp_entry.S offsets");
+_Static_assert(__builtin_offsetof(struct ck_smp_cpu, state) == 48, "smp_entry.S offsets");
+
+static struct ck_smp_cpu cpus[CK_SMP_MAX];
+
+/* arch/smp_entry.S: PSCI CPU_ON entry point, x0 = &cpus[i]. */
+extern char ck_smp_entry[];
+void ck_smp_secondary_main(void *arg);
+
+/* Runs on the secondary core at EL1, MMU on, its own stack, DAIF masked. */
+__attribute__((noreturn)) void ck_smp_secondary_main(void *arg)
+{
+    struct ck_smp_cpu *c = arg;
+    uint64_t sp;
+    __asm__ volatile("mov %0, sp" : "=r"(sp));
+    c->seen_mpidr = ck_rd(mpidr_el1) & CK_MPIDR_AFF_MASK;
+    c->seen_el = ck_current_el();
+    c->seen_sctlr = ck_rd(sctlr_el1);
+    c->seen_ttbr0 = ck_rd(ttbr0_el1) & TTBR_BADDR_MASK;
+    c->seen_sp = sp;
+    __atomic_store_n(&c->state, (uint64_t)SMP_CHECKED_IN, __ATOMIC_RELEASE);
+    __asm__ volatile("dsb ish\n\tsev" ::: "memory");
+    for (;;)
+        __asm__ volatile("wfe" ::: "memory");
+}
+
+static void clean_to_poc(const void *p, size_t len)
+{
+    uint64_t line = 4ull << ((ck_rd(ctr_el0) >> 16) & 0xf);
+    uint64_t a = (uint64_t)(uintptr_t)p & ~(line - 1), end = (uint64_t)(uintptr_t)p + len;
+    for (; a < end; a += line)
+        __asm__ volatile("dc cvac, %0" ::"r"(a) : "memory");
+    __asm__ volatile("dsb sy" ::: "memory");
+}
+
+static const char *psci_err(int64_t rc)
+{
+    switch (rc) {
+    case 0: return "SUCCESS";
+    case -1: return "NOT_SUPPORTED";
+    case -2: return "INVALID_PARAMETERS";
+    case -3: return "DENIED";
+    case -4: return "ALREADY_ON";
+    case -5: return "ON_PENDING";
+    case -6: return "INTERNAL_FAILURE";
+    case -9: return "INVALID_ADDRESS";
+    default: return "UNKNOWN";
+    }
+}
+
+void ck_smp_run(void)
+{
+    ck_set_stage("smp");
+    uint64_t self = ck_rd(mpidr_el1) & CK_MPIDR_AFF_MASK;
+    const struct ck_mm_report *mm = ck_mm_report();
+    int fail = 0;
+#ifdef CK_TEST_SMP_SKIP_CPU
+    ck_puts("smp: TEST-ONLY SMP mutation build: CPU_ON is skipped for one core; this image never counts toward a PASS\n");
+#endif
+
+    const void *madt = ck_acpi_find("APIC");
+    uint64_t mp[CK_SMP_MAX];
+    unsigned n = 0;
+    int prc = madt ? ck_madt_mpidrs(madt, mp, CK_SMP_MAX, &n) : -1;
+    int64_t ver = ck_psci_call(PSCI_VERSION, 0, 0, 0);
+    unsigned vmaj = ver < 0 ? 0 : (unsigned)((uint64_t)ver >> 16) & 0x7fff;
+    unsigned vmin = ver < 0 ? 0 : (unsigned)((uint64_t)ver & 0xffff);
+    ck_printf("smp: boot_mpidr=0x%llx madt_cpus=%u conduit=%s psci_version=%u.%u\n",
+              (unsigned long long)self, n, ck_psci_conduit(), vmaj, vmin);
+    if (prc != 0) {
+        ck_printf("smp: FAIL madt %s (rc=%d, %u cores, max %u)\n",
+                  !madt ? "absent" : prc == -2 ? "lists more cores than supported" : "malformed", prc,
+                  n, CK_SMP_MAX);
+        ck_printf("smp: cpus=%u checked_in=0 psci_errors=0 distinct_mpidrs=0 wait_us=0 result=FAIL\n", n);
+        return;
+    }
+    if (ver < 0 || (vmaj == 0 && vmin < 2)) {
+        ck_printf("smp: FAIL psci version %lld has no 64-bit CPU_ON\n", (long long)ver);
+        fail = 1;
+    }
+
+    /* Distinct MPIDRs, and the boot core among them. */
+    unsigned distinct = 0, boot_listed = 0;
+    for (unsigned i = 0; i < n; i++) {
+        unsigned dup = 0;
+        for (unsigned j = 0; j < i; j++)
+            if (mp[j] == mp[i])
+                dup = 1;
+        if (dup) {
+            ck_printf("smp: FAIL duplicate mpidr=0x%llx in the MADT\n", (unsigned long long)mp[i]);
+            fail = 1;
+        } else {
+            distinct++;
+        }
+        if (mp[i] == self)
+            boot_listed = 1;
+    }
+    if (!boot_listed) {
+        ck_printf("smp: FAIL boot core mpidr=0x%llx missing from the MADT\n", (unsigned long long)self);
+        fail = 1;
+    }
+
+    /* Start every secondary core. */
+    unsigned started = 0, psci_errors = 0, last = n;
+    for (unsigned i = 0; i < n; i++)
+        if (mp[i] != self)
+            last = i;
+    for (unsigned i = 0; i < n && !fail; i++) {
+        struct ck_smp_cpu *c = &cpus[i];
+        if (mp[i] == self)
+            continue;
+        uint64_t pa = 0;
+        if (ck_mm_frames_alloc(CK_SMP_STACK_PAGES, &pa) || !ck_mm_mapped(pa, CK_SMP_STACK_PAGES * 4096ull)) {
+            ck_printf("smp_cpu_on: target=0x%llx stack=unavailable\n", (unsigned long long)mp[i]);
+            fail = 1;
+            continue;
+        }
+        memset(c, 0, sizeof *c);
+        c->root = mm->root;
+        c->mair = ck_mm_mair();
+        c->tcr = ck_mm_tcr();
+        c->sctlr = ck_mm_sctlr();
+        c->stack_lo = pa;
+        c->stack_hi = pa + CK_SMP_STACK_PAGES * 4096ull;
+        c->sp = c->stack_hi;
+        c->target = mp[i];
+        c->state = SMP_ON_CALLED;
+        clean_to_poc(c, sizeof *c);
+#ifdef CK_TEST_SMP_SKIP_CPU
+        if (i == last) {
+            ck_printf("smp_cpu_on: target=0x%llx psci_rc=SKIPPED (TEST-ONLY SMP mutation)\n",
+                      (unsigned long long)mp[i]);
+            started++;
+            continue;
+        }
+#endif
+        int64_t rc = ck_psci_call(PSCI_CPU_ON_64, mp[i], (uint64_t)(uintptr_t)ck_smp_entry,
+                                  (uint64_t)(uintptr_t)c);
+        ck_printf("smp_cpu_on: target=0x%llx psci_rc=%d (%s)\n", (unsigned long long)mp[i], (int)rc,
+                  psci_err(rc));
+        if (rc != 0) {
+            psci_errors++;
+            c->state = SMP_IDLE;
+            continue;
+        }
+        started++;
+    }
+    (void)last;
+
+    /* Bounded wait for every started core. */
+    uint64_t t0 = ck_time_us(), waited = 0;
+    for (;;) {
+        unsigned pending = 0;
+        for (unsigned i = 0; i < n; i++)
+            if (mp[i] != self && __atomic_load_n(&cpus[i].state, __ATOMIC_ACQUIRE) == SMP_ON_CALLED)
+                pending++;
+        waited = ck_time_us() - t0;
+        if (!pending || waited >= CK_SMP_TIMEOUT_US)
+            break;
+        ck_udelay(100);
+    }
+
+    /* One line per secondary core, then the summary. */
+    unsigned checked = 1; /* the boot core */
+    for (unsigned i = 0; i < n; i++) {
+        struct ck_smp_cpu *c = &cpus[i];
+        if (mp[i] == self)
+            continue;
+        if (__atomic_load_n(&c->state, __ATOMIC_ACQUIRE) != SMP_CHECKED_IN) {
+            ck_printf("smp_cpu: target=0x%llx checked_in=no\n", (unsigned long long)mp[i]);
+            fail = 1;
+            continue;
+        }
+        int el_ok = c->seen_el == 1, mmu_ok = (c->seen_sctlr & 1) != 0;
+        int tt_ok = c->seen_ttbr0 == mm->root;
+        int sp_ok = c->seen_sp > c->stack_lo && c->seen_sp <= c->stack_hi;
+        int id_ok = c->seen_mpidr == mp[i];
+        ck_printf("smp_cpu: target=0x%llx checked_in=yes seen_mpidr=0x%llx el=%u mmu=%s ttbr0_match=%s "
+                  "stack_ok=%s parked=wfe\n",
+                  (unsigned long long)mp[i], (unsigned long long)c->seen_mpidr, (unsigned)c->seen_el,
+                  mmu_ok ? "on" : "off", tt_ok ? "yes" : "no", sp_ok ? "yes" : "no");
+        if (!(el_ok && mmu_ok && tt_ok && sp_ok && id_ok))
+            fail = 1;
+        checked++;
+    }
+    if (checked != n || psci_errors)
+        fail = 1;
+    ck_printf("smp: cpus=%u started=%u checked_in=%u psci_errors=%u distinct_mpidrs=%u wait_us=%llu result=%s\n", n,
+              started + 1, checked, psci_errors, distinct, (unsigned long long)waited, fail ? "FAIL" : "ok");
+}
diff --git a/native/kernel/tests/test_acpi.c b/native/kernel/tests/test_acpi.c
index fe8fe7e9..dd391894 100644
--- a/native/kernel/tests/test_acpi.c
+++ b/native/kernel/tests/test_acpi.c
@@ -206,6 +206,18 @@ int main(void)
     static const uint32_t wn[8] = { 0, 1, 0, 1, 0, 1, 0, 1 };
     for (uint32_t i = 0; i < 8; i++)
         CHECK(ck_place_task(&tp, i, &pc, &pn) == 0 && pc == wc[i] && pn == wn[i]);
+    /* MPIDR list for the SMP bring-up (core/smp.c). */
+    uint64_t mp[4];
+    unsigned mn = 99;
+    CHECK(ck_madt_mpidrs(madt, mp, 4, &mn) == 0 && mn == 1 && mp[0] == 0); /* disabled GICC skipped */
+    memcpy(m2, madt, sizeof m2);
+    w32(m2 + 44 + 80 + 12, 8); /* second GICC online-capable */
+    w64(m2 + 44 + 80 + 68, 0xffffffffff000102ull); /* RES0 bits masked off */
+    CHECK(ck_madt_mpidrs(m2, mp, 4, &mn) == 0 && mn == 2 && mp[0] == 0 && mp[1] == 0xff00000102ull);
+    CHECK(ck_madt_mpidrs(m2, mp, 1, &mn) == -2 && mn == 2); /* more cores than slots */
+    m2[44 + 80 + 1] = 72; /* GICC too short to carry the MPIDR */
+    CHECK(ck_madt_mpidrs(m2, mp, 4, &mn) == -1);
+    CHECK(ck_madt_mpidrs(fadt, mp, 4, &mn) == -1); /* not a MADT */
     test_spans();
     return ck_t_verdict("CK_ACPI");
 }
diff --git a/scripts/ck_gates.sh b/scripts/ck_gates.sh
index 3a78e90d..7362e4b2 100755
--- a/scripts/ck_gates.sh
+++ b/scripts/ck_gates.sh
@@ -4,11 +4,12 @@
 #
 # It refuses a dirty tree, runs the C kernel QEMU scripts that exist
 # (scripts/qemu_ck_boot_test.sh, scripts/qemu_ck_store_test.sh,
-# scripts/qemu_ck_net_test.sh, scripts/qemu_ck_artifact_test.sh), and prints
+# scripts/qemu_ck_net_test.sh, scripts/qemu_ck_artifact_test.sh,
+# scripts/qemu_ck_smp_test.sh), and prints
 # one line per gate:
 #     AIENOS_CK_<gate>: PASS|FAIL|NOT_RUN [(reason)]
 # for M1 M3 SMMU NVME_SHUTDOWN P2_ARTIFACT M0_ROLLBACK M4_NVME M4_STORE M4_STORE_CRASH
-# M4_CONTINUITY M4_RECOVERY ARGUS1_REVOKE KEYBOARD NET. Gates with no C
+# M4_CONTINUITY M4_RECOVERY ARGUS1_REVOKE KEYBOARD NET SMP. Gates with no C
 # implementation print NOT_RUN (MISSING_IMPLEMENTATION: <reason>) and never
 # run anything. A missing child script, a child that reports NOT_RUN, a child
 # that prints no verdict line, or a PASS line contradicted by the child's exit
@@ -40,6 +41,7 @@ set -uo pipefail
 #         store -> verdict line from scripts/qemu_ck_store_test.sh
 #         net   -> verdict line from scripts/qemu_ck_net_test.sh
 #         artifact -> verdict line from scripts/qemu_ck_artifact_test.sh
+#         smp   -> verdict line from scripts/qemu_ck_smp_test.sh
 #         missing -> NOT_RUN (MISSING_IMPLEMENTATION), never run, never PASS
 # ===========================================================================
 CK_GATE_TABLE='
@@ -57,8 +59,9 @@ M4_RECOVERY|missing|no Recovery Core (ADR 0006) in the C kernel
 ARGUS1_REVOKE|store|-
 KEYBOARD|missing|no xHCI/USB HID keyboard driver in the C kernel
 NET|net|-
+SMP|smp|-
 '
-CHILDREN=(boot store net artifact)
+CHILDREN=(boot store net artifact smp)
 # ===========================================================================
 
 repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -100,6 +103,7 @@ set_default_children() {
         [store]="${repo_root}/scripts/qemu_ck_store_test.sh"
         [net]="${repo_root}/scripts/qemu_ck_net_test.sh"
         [artifact]="${repo_root}/scripts/qemu_ck_artifact_test.sh"
+        [smp]="${repo_root}/scripts/qemu_ck_smp_test.sh"
     )
 }
 
@@ -331,9 +335,9 @@ self_test() {
         local g
         for g in P2_ARTIFACT M0_ROLLBACK M4_STORE_CRASH M4_CONTINUITY M4_RECOVERY KEYBOARD; do expect "${g}" NOT_RUN; done  # P2_ARTIFACT: no artifact child in A..G
     }
-    scenario() { # NAME BOOT_SCRIPT STORE_SCRIPT [NET_SCRIPT] [ARTIFACT_SCRIPT] (absent: missing)
+    scenario() { # NAME BOOT_SCRIPT STORE_SCRIPT [NET_SCRIPT] [ARTIFACT_SCRIPT] [SMP_SCRIPT] (absent: missing)
         scen="$1"
-        declare -gA child_script=([boot]="$2" [store]="$3" [net]="${4:-${tmp}/kids/net_not_present.sh}" [artifact]="${5:-${tmp}/kids/no_artifact_child.sh}")
+        declare -gA child_script=([boot]="$2" [store]="$3" [net]="${4:-${tmp}/kids/net_not_present.sh}" [artifact]="${5:-${tmp}/kids/no_artifact_child.sh}" [smp]="${6:-${tmp}/kids/no_smp_child.sh}")
         run_children 2>/dev/null
         evaluate_table >"${tmp}/${scen}.out"
     }
@@ -345,11 +349,12 @@ self_test() {
             'AIENOS_CK_SMMU: PASS' 'AIENOS_CK_NVME_SHUTDOWN: PASS' 'AIENOS_CK_KEYBOARD: PASS' 'PASS  NVMe DMA granted confined' \
             'PASS  DMA outside the window faulted, page intact, controller still usable (differs)' 'PASS  NVMe DMA denied without an SMMU' \
             'PASS  NVMe DMA granted through the TEST-ONLY bypass')" \
-        "$(fake netA 0 'PASS  UDP reply received' 'AIENOS_CK_NET: PASS')"
-    expect M1 PASS; expect M3 PASS; expect M4_NVME PASS; expect M4_STORE PASS; expect ARGUS1_REVOKE PASS; expect SMMU PASS; expect NVME_SHUTDOWN PASS; expect NET PASS; expect_missing_all
+        "$(fake netA 0 'PASS  UDP reply received' 'AIENOS_CK_NET: PASS')" "" \
+        "$(fake smpA 0 'PASS  3 secondary cores checked in' 'AIENOS_CK_SMP_MUTATION: FAIL' 'AIENOS_CK_SMP: PASS')"
+    expect M1 PASS; expect M3 PASS; expect M4_NVME PASS; expect M4_STORE PASS; expect ARGUS1_REVOKE PASS; expect SMMU PASS; expect NVME_SHUTDOWN PASS; expect NET PASS; expect SMP PASS; expect_missing_all
     count_rows
-    [[ "${n_pass}/${n_fail}/${n_notrun}/${n_total}" == "8/0/6/14" && ${overall} == NOT_ALL_GATES_PASS ]] \
-        && ok "A: counts 8/0/6 of 14, verdict NOT_ALL_GATES_PASS" || bad "A: counts ${n_pass}/${n_fail}/${n_notrun}/${n_total} ${overall}"
+    [[ "${n_pass}/${n_fail}/${n_notrun}/${n_total}" == "9/0/6/15" && ${overall} == NOT_ALL_GATES_PASS ]] \
+        && ok "A: counts 9/0/6 of 15, verdict NOT_ALL_GATES_PASS" || bad "A: counts ${n_pass}/${n_fail}/${n_notrun}/${n_total} ${overall}"
     [[ "$(nvme_dma_mode)" == "Confined (QEMU SMMUv3 stage 1, out-of-window DMA faulted); no-SMMU boot denied (NoSmmu); TEST-ONLY bypass image checked separately" ]] && ok "A: confined DMA mode recorded from the store PASS lines" || bad "A: dma mode '$(nvme_dma_mode)'"
     grep -qxF "AIENOS_CK_M4_NVME: PASS (${M4_NVME_PASS_NOTE})" "${tmp}/A.out" \
         && ok "A: M4_NVME PASS line carries the confined-mode note" || bad "A: M4_NVME PASS line lacks the note"
@@ -357,11 +362,11 @@ self_test() {
         && ok "A: NET PASS line carries the QEMU slirp / SMMU fence note" || bad "A: NET PASS line lacks the note"
     grep -qx 'AIENOS_CK_KEYBOARD: NOT_RUN (MISSING_IMPLEMENTATION: no xHCI/USB HID keyboard driver in the C kernel)' "${tmp}/A.out" \
         && ok "A: missing gate prints NOT_RUN (MISSING_IMPLEMENTATION: reason)" || bad "A: KEYBOARD line wrong"
-    [[ "$(grep -c '^AIENOS_CK_[A-Z0-9_]*: ' "${tmp}/A.out")" == 14 ]] && ok "A: exactly 14 verdict lines" || bad "A: verdict line count"
+    [[ "$(grep -c '^AIENOS_CK_[A-Z0-9_]*: ' "${tmp}/A.out")" == 15 ]] && ok "A: exactly 15 verdict lines" || bad "A: verdict line count"
 
     # B: boot FAIL; store script missing -> its three gates NOT_RUN, never PASS.
     scenario B "$(fake bootB 1 'FAIL  kernel: alive' 'AIENOS_CK_M3: FAIL' 'AIENOS_CK_M1: FAIL')" "${tmp}/kids/does_not_exist.sh"
-    expect M1 FAIL; expect M3 FAIL; expect M4_NVME NOT_RUN; expect M4_STORE NOT_RUN; expect ARGUS1_REVOKE NOT_RUN; expect SMMU NOT_RUN; expect NVME_SHUTDOWN NOT_RUN; expect NET NOT_RUN; expect_missing_all
+    expect M1 FAIL; expect M3 FAIL; expect M4_NVME NOT_RUN; expect M4_STORE NOT_RUN; expect ARGUS1_REVOKE NOT_RUN; expect SMMU NOT_RUN; expect NVME_SHUTDOWN NOT_RUN; expect NET NOT_RUN; expect SMP NOT_RUN; expect_missing_all
     [[ "$(nvme_dma_mode)" == "not run" ]] && ok "B: dma mode 'not run' when the store script is missing" || bad "B: dma mode"
 
     # C: boot NOT_RUN (quiet flag held, exit 3); store mixed with exit 1.
@@ -403,6 +408,23 @@ self_test() {
         "$(fake artJ 1 'FAIL  P25WX' 'AIENOS_CK_P2_ARTIFACT: FAIL')"
     expect P2_ARTIFACT FAIL
 
+    # K: SMP child FAIL (a core never checked in) -> FAIL; L: quiet flag held
+    # (exit 3) -> NOT_RUN; M: PASS line with an unexplained exit 2 -> FAIL;
+    # N: only the mutation verdict line (AIENOS_CK_SMP_MUTATION) -> no SMP
+    # verdict -> FAIL, never PASS.
+    scenario K "$(fake bootK 0 'AIENOS_CK_M1: PASS')" "$(fake storeK 0 'AIENOS_CK_M4_NVME: PASS')" "" "" \
+        "$(fake smpK 1 'FAIL  core never checked in: smp_cpu: target=0x3 checked_in=no' 'AIENOS_CK_SMP: FAIL')"
+    expect SMP FAIL; expect M1 PASS
+    scenario L "$(fake bootL 0 'AIENOS_CK_M1: PASS')" "$(fake storeL 0 'AIENOS_CK_M4_NVME: PASS')" "" "" \
+        "$(fake smpL 3 'NOT_RUN  quiet flag held' 'AIENOS_CK_SMP: NOT_RUN')"
+    expect SMP NOT_RUN
+    scenario M "$(fake bootM 0 'AIENOS_CK_M1: PASS')" "$(fake storeM 0 'AIENOS_CK_M4_NVME: PASS')" "" "" \
+        "$(fake smpM 2 'AIENOS_CK_SMP: PASS')"
+    expect SMP FAIL
+    scenario N "$(fake bootN 0 'AIENOS_CK_M1: PASS')" "$(fake storeN 0 'AIENOS_CK_M4_NVME: PASS')" "" "" \
+        "$(fake smpN 0 'AIENOS_CK_SMP_MUTATION: PASS (gate checks FAIL on the CPU_ON-skip image; mutation killed)')"
+    expect SMP FAIL
+
     # Receipt: named by its content hash, valid JSON, physical NOT_RUN, never overwritten.
     scenario R "$(fake bootR 0 'AIENOS_CK_M1: PASS')" "$(fake storeR 0 'AIENOS_CK_M4_NVME: PASS')"
     count_rows
@@ -416,10 +438,10 @@ self_test() {
         bad "receipt name does not match its content hash"
     fi
     if command -v jq >/dev/null; then
-        jq -e '.physical == "NOT_RUN" and (.gates | length) == 14 and .verdict == "NOT_ALL_GATES_PASS"
+        jq -e '.physical == "NOT_RUN" and (.gates | length) == 15 and .verdict == "NOT_ALL_GATES_PASS"
                and ([.gates[] | select(.id == "M1")][0].verdict == "PASS")
                and ([.gates[] | select(.id == "ARGUS1_REVOKE")][0].verdict == "FAIL")
-               and (.children | length) == 4 and .commit_subject == "quote \" backslash \\ tab\tend"' "${receipt_path}" >/dev/null \
+               and (.children | length) == 5 and .commit_subject == "quote \" backslash \\ tab\tend"' "${receipt_path}" >/dev/null \
             && ok "receipt is valid JSON (jq) with expected fields" || bad "receipt JSON invalid or fields wrong"
     else
         echo "SKIP  jq not installed; JSON validity not machine-checked"
@@ -432,18 +454,18 @@ self_test() {
         bad "an existing receipt was overwritten or the clash was not refused"
     fi
 
-    # The gate table parses: 14 rows, known sources, reasons only on missing rows.
+    # The gate table parses: 15 rows, known sources, reasons only on missing rows.
     local g s w rows=0 tbad=0
     while IFS='|' read -r g s w; do
         [[ -n "${g}" ]] || continue
         rows=$((rows + 1))
         case "${s}" in
-            boot|store|net|artifact) [[ "${w}" == - ]] || tbad=1 ;;
+            boot|store|net|artifact|smp) [[ "${w}" == - ]] || tbad=1 ;;
             missing) [[ -n "${w}" && "${w}" != - ]] || tbad=1 ;;
             *) tbad=1 ;;
         esac
     done <<<"${CK_GATE_TABLE}"
-    [[ ${tbad} == 0 && ${rows} == 14 ]] && ok "gate table: 14 rows well-formed" || bad "gate table malformed (${rows} rows)"
+    [[ ${tbad} == 0 && ${rows} == 15 ]] && ok "gate table: 15 rows well-formed" || bad "gate table malformed (${rows} rows)"
 
     # Dirty-tree refusal, end to end, on a private clone (never this tree).
     # Both runs stop before any child script (no QEMU).
@@ -477,7 +499,7 @@ main() {
         case "$1" in
             --out) [[ $# -ge 2 ]] || die "--out needs a directory"; out_arg="$2"; shift ;;
             --self-test) mode=self ;;
-            -h|--help) sed -n '2,34p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
+            -h|--help) sed -n '2,35p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
             *) die "unknown argument: $1" ;;
         esac
         shift
diff --git a/scripts/qemu_ck_smp_test.sh b/scripts/qemu_ck_smp_test.sh
new file mode 100755
index 00000000..f60386cf
--- /dev/null
+++ b/scripts/qemu_ck_smp_test.sh
@@ -0,0 +1,308 @@
+#!/usr/bin/env bash
+# Boot the AIENOS C kernel core image in QEMU AArch64 (UEFI/AAVMF, EL2 like
+# Machine 1, -smp 4) and check the secondary-core bring-up of core/smp.c:
+# PSCI CPU_ON for every MADT core except the boot core, each core on its own
+# stack with the MMU on the boot core's tables, checked in (its own MPIDR
+# reported) and parked in WFE; the boot core waits with a bounded timeout.
+# Last line: AIENOS_CK_SMP: PASS|FAIL|NOT_RUN (read by scripts/ck_gates.sh).
+# QEMU is not hardware: a PASS here qualifies nothing physical.
+#
+# FAIL when (the script re-checks the lines itself, it does not trust the
+# kernel's result=ok): a core never checks in; PSCI CPU_ON returns any error
+# code; an MPIDR is duplicated or missing (boot + secondaries must be exactly
+# the -smp N distinct values, each secondary must report the MPIDR it was
+# started for); a secondary reports EL != 1, MMU off, other tables or a stack
+# outside its own; the MADT core count differs from -smp N; the summary line
+# is missing or not ok; the TEST-ONLY mutation image was booted; the boot
+# panics or faults; QEMU exits non-zero.
+#
+# Usage: bash scripts/qemu_ck_smp_test.sh               the gate (default image)
+#        bash scripts/qemu_ck_smp_test.sh --mutation    TEST-ONLY image built with
+#            CK_TEST_SMP_SKIP_CPU=1 (CPU_ON skipped for one core): the gate
+#            checks must FAIL on it; ends AIENOS_CK_SMP_MUTATION: PASS when
+#            they do (the mutation is killed), FAIL when they pass
+#        bash scripts/qemu_ck_smp_test.sh --self-test   canned serial logs for
+#            every failure mode above, plus the Makefile refusals of the
+#            mutation flag (with CK_HARDWARE_STAGING, bad value); no QEMU,
+#            no compile (make -n stops at parse time). Ends
+#            AIENOS_CK_SMP_SELF_TEST: PASS|FAIL
+# Environment: AIENOS_CK_SMP_CPUS (default 4), AIENOS_QEMU_TIMEOUT (180 s),
+# AIENOS_QUIET_FLAG / AIENOS_QUIET_TAG (as scripts/qemu_ck_boot_test.sh),
+# AIENOS_LOG_DIR (copy of the serial log), AIENOS_QEMU_VERBOSE.
+# Takes the machine quiet flag itself and prints NOT_RUN if another run holds
+# it (exit 3). Needs qemu-system-aarch64 and AAVMF.
+set -euo pipefail
+
+repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+cd "${repo_root}"
+
+mode=gate
+case "${1:-}" in
+    "") ;;
+    --mutation) mode=mutation ;;
+    --self-test) mode=self ;;
+    *) echo "usage: $0 [--mutation|--self-test]" >&2; exit 2 ;;
+esac
+ncpus="${AIENOS_CK_SMP_CPUS:-4}"
+[[ "${ncpus}" =~ ^[0-9]+$ && "${ncpus}" -ge 2 && "${ncpus}" -le 16 ]] || { echo "AIENOS_CK_SMP_CPUS must be 2..16" >&2; exit 2; }
+mut_marker="TEST-ONLY SMP mutation"
+
+# smp_check_log FILE N: one PASS/FAIL line per check; sets smp_failed=1 on
+# any failure (never resets it). Pure text checks, used by the gate, the
+# mutation run and the self-test alike.
+smp_check_log() {
+    local f="$1" n="$2" line boot_re cpu_re sum_re tgt seen
+    ok()  { echo "PASS  $*"; }
+    bad() { echo "FAIL  $*"; smp_failed=1; }
+    boot_re='^smp: boot_mpidr=0x([0-9a-f]+) madt_cpus=([0-9]+) conduit=(smc|hvc) psci_version=([0-9]+)\.([0-9]+)$'
+    if [[ "$(grep -cE "${boot_re}" "${f}" || true)" != 1 ]]; then
+        bad "exactly one smp: boot_mpidr line"
+        return
+    fi
+    line="$(grep -E "${boot_re}" "${f}")"
+    local boot_mpidr madt
+    boot_mpidr="$(sed -E "s/${boot_re}/\\1/" <<<"${line}")"
+    madt="$(sed -E "s/${boot_re}/\\2/" <<<"${line}")"
+    [[ "${madt}" == "${n}" ]] && ok "MADT lists ${n} cores (-smp ${n})" || bad "MADT lists ${madt} cores, QEMU has ${n}"
+    if grep -qE '^smp: FAIL' "${f}"; then bad "kernel reported $(grep -E '^smp: FAIL' "${f}" | head -1)"; else ok "no smp: FAIL line"; fi
+
+    # PSCI CPU_ON: one call per secondary, every one SUCCESS.
+    local on_n on_ok
+    on_n="$(grep -cE '^smp_cpu_on: target=0x[0-9a-f]+ ' "${f}" || true)"
+    on_ok="$(grep -cE '^smp_cpu_on: target=0x[0-9a-f]+ psci_rc=0 \(SUCCESS\)$' "${f}" || true)"
+    [[ "${on_n}" == $((n - 1)) ]] && ok "CPU_ON issued for ${on_n} secondary cores" || bad "CPU_ON lines ${on_n}, expected $((n - 1))"
+    if [[ "${on_ok}" == "${on_n}" && "${on_n}" -gt 0 ]]; then
+        ok "PSCI CPU_ON returned SUCCESS for every core"
+    else
+        bad "PSCI CPU_ON error or skip: $(grep -E '^smp_cpu_on: ' "${f}" | grep -vE 'psci_rc=0 \(SUCCESS\)$' | head -3 | paste -sd';' -)"
+    fi
+
+    # Check-in: every secondary on EL1, MMU on our tables, its own stack,
+    # reporting the MPIDR it was started for.
+    cpu_re='^smp_cpu: target=0x([0-9a-f]+) checked_in=yes seen_mpidr=0x([0-9a-f]+) el=1 mmu=on ttbr0_match=yes stack_ok=yes parked=wfe$'
+    local in_n mism=0 mpidrs="${boot_mpidr}"
+    in_n="$(grep -cE "${cpu_re}" "${f}" || true)"
+    if grep -qE '^smp_cpu: target=0x[0-9a-f]+ checked_in=no' "${f}"; then
+        bad "core never checked in: $(grep -E '^smp_cpu: .*checked_in=no' "${f}" | head -3 | paste -sd';' -)"
+    fi
+    if grep -E '^smp_cpu: ' "${f}" | grep -qvE "${cpu_re}|checked_in=no"; then
+        bad "secondary state wrong: $(grep -E '^smp_cpu: ' "${f}" | grep -vE "${cpu_re}|checked_in=no" | head -2 | paste -sd';' -)"
+    fi
+    [[ "${in_n}" == $((n - 1)) ]] && ok "${in_n} secondary cores checked in on EL1, MMU on our tables, own stack, parked in WFE" \
+        || bad "checked-in secondaries ${in_n}, expected $((n - 1))"
+    while IFS= read -r line; do
+        [[ -n "${line}" ]] || continue
+        tgt="$(sed -E "s/${cpu_re}/\\1/" <<<"${line}")"
+        seen="$(sed -E "s/${cpu_re}/\\2/" <<<"${line}")"
+        [[ "${tgt}" == "${seen}" ]] || mism=1
+        grep -qE "^smp_cpu_on: target=0x${tgt} psci_rc=0 \\(SUCCESS\\)$" "${f}" || mism=1
+        mpidrs+=$'\n'"${seen}"
+    done < <(grep -E "${cpu_re}" "${f}" || true)
+    [[ "${mism}" == 0 ]] && ok "each secondary reports the MPIDR it was started for" || bad "a secondary reported another MPIDR or was not started by CPU_ON"
+    local total distinct
+    total="$(grep -c . <<<"${mpidrs}")"
+    distinct="$(sort -u <<<"${mpidrs}" | grep -c .)"
+    if [[ "${total}" == "${n}" && "${distinct}" == "${n}" ]]; then
+        ok "per-core MPIDRs distinct and complete: $(paste -sd, - <<<"${mpidrs}" | sed 's/[0-9a-f]\+/0x&/g')"
+    else
+        bad "MPIDRs duplicated or missing: ${total} reported, ${distinct} distinct, ${n} expected"
+    fi
+
+    sum_re="^smp: cpus=${n} started=${n} checked_in=${n} psci_errors=0 distinct_mpidrs=${n} wait_us=[0-9]+ result=ok$"
+    [[ "$(grep -cE "${sum_re}" "${f}" || true)" == 1 ]] && ok "summary: all ${n} cores, no PSCI error, bounded wait, result=ok" \
+        || bad "summary line missing or not ok: $(grep -E '^smp: cpus=' "${f}" | head -1)"
+
+    grep -q "kernel: alive" "${f}" && ok "kernel alive" || bad "kernel never reached kernel: alive"
+    grep -q "report_kind: final" "${f}" && ok "final report reached" || bad "no final report"
+    if grep -qE 'report_kind: (panic|fault)' "${f}"; then bad "panic or fault report"; else ok "no panic or fault"; fi
+}
+
+# ----------------------------------------------------------------- self-test
+self_test() {
+    local tmp st_fail=0 f
+    tmp="$(mktemp -d "${TMPDIR:-/tmp}/ck-smp-selftest.XXXXXX")"
+    trap 'rm -rf --one-file-system "${tmp}"' EXIT
+    # good_log N: what a correct boot prints (MPIDRs 0..N-1 as QEMU virt gives).
+    good_log() {
+        local n="$1" i
+        echo "kernel: alive"
+        echo "smp: boot_mpidr=0x0 madt_cpus=${n} conduit=smc psci_version=1.1"
+        for ((i = 1; i < n; i++)); do echo "smp_cpu_on: target=0x${i} psci_rc=0 (SUCCESS)"; done
+        for ((i = 1; i < n; i++)); do
+            echo "smp_cpu: target=0x${i} checked_in=yes seen_mpidr=0x${i} el=1 mmu=on ttbr0_match=yes stack_ok=yes parked=wfe"
+        done
+        echo "smp: cpus=${n} started=${n} checked_in=${n} psci_errors=0 distinct_mpidrs=${n} wait_us=1234 result=ok"
+        echo "report_kind: final"
+    }
+    expect() { # NAME pass|fail FILE
+        local out
+        smp_failed=0
+        out="$(smp_check_log "$3" 4)"
+        smp_failed=0
+        grep -q '^FAIL' <<<"${out}" && smp_failed=1
+        if [[ "$2" == pass && "${smp_failed}" == 0 ]] || [[ "$2" == fail && "${smp_failed}" == 1 ]]; then
+            echo "PASS  self-test $1 -> $2"
+        else
+            echo "FAIL  self-test $1: expected $2"; printf '%s\n' "${out}" | sed 's/^/      /'; st_fail=1
+        fi
+    }
+    good_log 4 >"${tmp}/good"; expect good pass "${tmp}/good"
+    # A core that never checks in (kernel honest).
+    sed -e 's/^smp_cpu: target=0x3 .*/smp_cpu: target=0x3 checked_in=no/' \
+        -e 's/checked_in=4 psci_errors=0 distinct_mpidrs=4 wait_us=1234 result=ok/checked_in=3 psci_errors=0 distinct_mpidrs=4 wait_us=5000000 result=FAIL/' \
+        "${tmp}/good" >"${tmp}/nocheckin"; expect never-checks-in fail "${tmp}/nocheckin"
+    # A core line missing while the kernel summary still claims ok.
+    grep -v '^smp_cpu: target=0x2 ' "${tmp}/good" >"${tmp}/missingline"; expect missing-core-line fail "${tmp}/missingline"
+    # Duplicate MPIDR: two cores report 0x1 (summary forged ok).
+    sed 's/^smp_cpu: target=0x2 checked_in=yes seen_mpidr=0x2/smp_cpu: target=0x2 checked_in=yes seen_mpidr=0x1/' \
+        "${tmp}/good" >"${tmp}/dup"; expect duplicate-mpidr fail "${tmp}/dup"
+    # Secondary reports the boot core's MPIDR (duplicate with boot).
+    sed 's/^smp_cpu: target=0x3 checked_in=yes seen_mpidr=0x3/smp_cpu: target=0x3 checked_in=yes seen_mpidr=0x0/' \
+        "${tmp}/good" >"${tmp}/dupboot"; expect duplicate-boot-mpidr fail "${tmp}/dupboot"
+    # MADT lists fewer cores than QEMU has (a missing MPIDR), lines consistent with 3.
+    good_log 3 >"${tmp}/three"; expect madt-missing-core fail "${tmp}/three"
+    # PSCI error code (ALREADY_ON), check-in line forged yes.
+    sed 's/^smp_cpu_on: target=0x2 psci_rc=0 (SUCCESS)$/smp_cpu_on: target=0x2 psci_rc=-4 (ALREADY_ON)/' \
+        "${tmp}/good" >"${tmp}/psci"; expect psci-error fail "${tmp}/psci"
+    # The mutation image's skip line.
+    sed 's/^smp_cpu_on: target=0x3 psci_rc=0 (SUCCESS)$/smp_cpu_on: target=0x3 psci_rc=SKIPPED (TEST-ONLY SMP mutation)/' \
+        "${tmp}/good" >"${tmp}/skip"; expect cpu-on-skipped fail "${tmp}/skip"
+    # Secondary on the wrong tables / MMU off / EL2.
+    sed 's/^\(smp_cpu: target=0x1 .*\) ttbr0_match=yes/\1 ttbr0_match=no/' "${tmp}/good" >"${tmp}/ttbr"; expect wrong-tables fail "${tmp}/ttbr"
+    sed 's/^\(smp_cpu: target=0x1 .*\) mmu=on/\1 mmu=off/' "${tmp}/good" >"${tmp}/mmu"; expect mmu-off fail "${tmp}/mmu"
+    sed 's/^\(smp_cpu: target=0x1 .*\) el=1/\1 el=2/' "${tmp}/good" >"${tmp}/el"; expect wrong-el fail "${tmp}/el"
+    # Kernel says FAIL somewhere, or no summary, or no smp lines at all.
+    { cat "${tmp}/good"; echo "smp: FAIL duplicate mpidr=0x1 in the MADT"; } >"${tmp}/kfail"; expect kernel-fail-line fail "${tmp}/kfail"
+    grep -v '^smp: cpus=' "${tmp}/good" >"${tmp}/nosum"; expect no-summary fail "${tmp}/nosum"
+    printf 'kernel: alive\nreport_kind: final\n' >"${tmp}/none"; expect no-smp-lines fail "${tmp}/none"
+    { cat "${tmp}/good"; echo "report_kind: panic"; } >"${tmp}/panic"; expect panic fail "${tmp}/panic"
+
+    # Makefile refusals: parse-time $(error), nothing is compiled (make -n).
+    local out rc
+    out="$(make -n -s -C native/kernel CK_TEST_SMP_SKIP_CPU=1 CK_HARDWARE_STAGING=1 OUT="${tmp}/o1" 2>&1)"; rc=$?
+    if [[ ${rc} != 0 ]] && grep -qF "CK_TEST_SMP_SKIP_CPU (TEST-only SMP mutation) cannot be combined with CK_HARDWARE_STAGING" <<<"${out}"; then
+        echo "PASS  self-test mutation flag refused with CK_HARDWARE_STAGING"
+    else
+        echo "FAIL  self-test mutation flag not refused with CK_HARDWARE_STAGING (rc=${rc}): ${out:0:200}"; st_fail=1
+    fi
+    out="$(make -n -s -C native/kernel CK_TEST_SMP_SKIP_CPU=2 OUT="${tmp}/o2" 2>&1)"; rc=$?
+    if [[ ${rc} != 0 ]] && grep -qF "CK_TEST_SMP_SKIP_CPU must be empty or 1" <<<"${out}"; then
+        echo "PASS  self-test mutation flag value other than 1 refused"
+    else
+        echo "FAIL  self-test bad mutation flag value accepted (rc=${rc})"; st_fail=1
+    fi
+    [[ ! -e "${tmp}/o1" && ! -e "${tmp}/o2" ]] && echo "PASS  self-test refusals built nothing" || { echo "FAIL  self-test a refused build wrote output"; st_fail=1; }
+    if grep -qE '^#if defined\(CK_TEST_SMP_SKIP_CPU\) && defined\(CK_HARDWARE_STAGING\)$' native/kernel/core/smp.c; then
+        echo "PASS  self-test core/smp.c also refuses the mutation in a hardware staging compile"
+    else
+        echo "FAIL  self-test core/smp.c lacks the #error guard"; st_fail=1
+    fi
+
+    [[ ${st_fail} == 0 ]] && { echo "AIENOS_CK_SMP_SELF_TEST: PASS"; exit 0; }
+    echo "AIENOS_CK_SMP_SELF_TEST: FAIL"; exit 1
+}
+if [[ "${mode}" == self ]]; then
+    set +e
+    self_test
+fi
+
+# --------------------------------------------------------------- QEMU boot
+verdict_name=AIENOS_CK_SMP
+[[ "${mode}" == mutation ]] && verdict_name=AIENOS_CK_SMP_MUTATION
+
+code_fd="${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}"
+vars_fd="${AAVMF_VARS:-/usr/share/AAVMF/AAVMF_VARS.fd}"
+command -v qemu-system-aarch64 >/dev/null || { echo "qemu-system-aarch64 not installed"; echo "${verdict_name}: NOT_RUN"; exit 2; }
+[[ -r "${code_fd}" && -r "${vars_fd}" ]] || { echo "AAVMF firmware not found"; echo "${verdict_name}: NOT_RUN"; exit 2; }
+
+cross=""
+if [ "$(uname -m)" != "aarch64" ]; then cross="aarch64-linux-gnu-"; fi
+commit="$(git rev-parse HEAD 2>/dev/null || echo unknown)"
+if [[ "${mode}" == mutation ]]; then
+    out="${repo_root}/target/native-kernel-test-smp-skip"
+    make -s -C native/kernel CROSS="${cross}" OUT="${out}" AIENOS_COMMIT="${commit}" CK_TEST_SMP_SKIP_CPU=1 >/dev/null
+else
+    out="${repo_root}/target/native-kernel"
+    make -s -C native/kernel CROSS="${cross}" OUT="${out}" AIENOS_COMMIT="${commit}" >/dev/null
+fi
+
+# Machine quiet flag: one heavy run at a time on the Spark.
+quiet_flag="${AIENOS_QUIET_FLAG:-${HOME}/workspace/.spark-quiet}"
+quiet_tag="${AIENOS_QUIET_TAG:-qemu_ck_smp_test $$}"
+if ! ( set -C; echo "${quiet_tag}" > "${quiet_flag}" ) 2>/dev/null; then
+    echo "NOT_RUN  quiet flag ${quiet_flag} is held: $(head -c 200 "${quiet_flag}" 2>/dev/null || true)"
+    echo "${verdict_name}: NOT_RUN"
+    exit 3
+fi
+own_flag=1
+release_flag() {
+    if [[ "${own_flag}" == 1 ]]; then
+        own_flag=0
+        if [[ -f "${quiet_flag}" ]] && grep -qxF -- "${quiet_tag}" "${quiet_flag}"; then rm -f "${quiet_flag}"; fi
+    fi
+}
+work="$(mktemp -d)"
+cleanup() {
+    rm -rf "${work}"
+    release_flag
+}
+trap cleanup EXIT
+mkdir -p "${work}/esp/EFI/BOOT" "${work}/esp/EFI/AIENOS"
+touch "${work}/esp/EFI/AIENOS/BOOTREPORT.TXT"
+cp "${out}/BOOTAA64.EFI" "${work}/esp/EFI/BOOT/BOOTAA64.EFI"
+cp "${vars_fd}" "${work}/vars.fd"
+log="${work}/serial.log"
+
+# Same machine as scripts/qemu_ck_boot_test.sh (issue #61: single-threaded TCG).
+started=$(date +%s)
+set +e
+timeout "${AIENOS_QEMU_TIMEOUT:-180}" qemu-system-aarch64 \
+    -M virt,virtualization=on,gic-version=3 -accel tcg,thread=single -cpu max -smp "${ncpus}" -m 2048 \
+    -drive if=pflash,format=raw,readonly=on,file="${code_fd}" \
+    -drive if=pflash,format=raw,file="${work}/vars.fd" \
+    -drive if=none,id=esp,format=raw,file=fat:rw:"${work}/esp" \
+    -device virtio-blk-pci,drive=esp \
+    -device ramfb -display none -nic none \
+    -serial file:"${log}" -no-reboot
+qemu_status=$?
+set -e
+elapsed=$(( $(date +%s) - started ))
+release_flag
+
+tr -d '\r' <"${log}" >"${work}/serial.txt"
+[[ -z "${AIENOS_LOG_DIR:-}" ]] || cp "${work}/serial.txt" "${AIENOS_LOG_DIR}/qemu_ck_smp_${mode}_serial.log"
+echo "qemu exit ${qemu_status} after ${elapsed} s (commit ${commit:0:12}, -smp ${ncpus}, ${mode})"
+
+smp_failed=0
+results="$(smp_check_log "${work}/serial.txt" "${ncpus}")" || true
+grep -q '^FAIL' <<<"${results}" && smp_failed=1
+printf '%s\n' "${results}"
+if [[ "${qemu_status}" == 0 ]]; then echo "PASS  QEMU exit 0 (PSCI reset)"; else echo "FAIL  QEMU exit ${qemu_status}"; smp_failed=1; fi
+
+if [[ "${mode}" == mutation ]]; then
+    # The mutation must be the reason: the TEST-ONLY image announced itself,
+    # skipped one CPU_ON, and that core never checked in.
+    killed=1
+    grep -qF "${mut_marker} build" "${work}/serial.txt" && echo "PASS  mutation image announced itself" || { echo "FAIL  mutation image did not announce itself"; killed=0; }
+    grep -qE '^smp_cpu_on: target=0x[0-9a-f]+ psci_rc=SKIPPED' "${work}/serial.txt" && echo "PASS  one CPU_ON skipped" || { echo "FAIL  no CPU_ON was skipped"; killed=0; }
+    grep -qE '^smp_cpu: target=0x[0-9a-f]+ checked_in=no$' "${work}/serial.txt" && echo "PASS  the skipped core never checked in" || { echo "FAIL  no core reported missing"; killed=0; }
+    if [[ -n "${AIENOS_QEMU_VERBOSE:-}" ]]; then echo "---- serial console ----"; cat "${work}/serial.txt"; fi
+    if [[ "${killed}" == 1 && "${smp_failed}" == 1 ]]; then
+        echo "AIENOS_CK_SMP_MUTATION: PASS (gate checks FAIL on the CPU_ON-skip image; mutation killed)"
+        exit 0
+    fi
+    echo "AIENOS_CK_SMP_MUTATION: FAIL (mutation survived or did not run as built)"
+    exit 1
+fi
+
+if grep -qF "${mut_marker}" "${work}/serial.txt"; then echo "FAIL  gate image is the TEST-ONLY mutation build"; smp_failed=1; else echo "PASS  default image (no TEST-ONLY mutation)"; fi
+if [[ "${smp_failed}" != 0 || -n "${AIENOS_QEMU_VERBOSE:-}" ]]; then
+    echo "---- serial console ----"
+    cat "${work}/serial.txt"
+fi
+if [[ "${smp_failed}" == 0 ]]; then
+    echo "AIENOS_CK_SMP: PASS"
+    exit 0
+fi
+echo "AIENOS_CK_SMP: FAIL"
+exit 1