Repository navigation
Conversation
Establish the JeremySu0818/unkernel fork infrastructure on x64-main while keeping upstream main isolated. Add .agents/skills/unkernel-upstream-sync/SKILL.md defining the upstream sync, linux-x64 patch rebase, regression verification, and release pin workflow, and add .github/workflows/release-x64.yml scaffolding the x86-64 CI and GitHub Release pipeline.
…ecoded tier Add include/kw_emu_x64.h (KW_ABI_VERSION 5, 896-byte kw_regs with YMM, XCR0, GDT TLS slots, and x87 state), dual-mode x86-64-v3 + IA32_EMULATION instruction decoder/interpreter/decoded-op tier in src/x64/, 80-bit extended-precision x87 + MMX, AES-NI/SHA-NI/PCLMULQDQ/FMA3/F16C/BMI1/BMI2 semantics, ELF64+ELF32 harness and syscall translation in src/emu/harness_x64.zig, and differential guest + unit tests comparing bit-for-bit against physical x86-64 hardware.
…suite Add the x64 single-tier Wasm SIMD JIT implementing jitcore.Jit across alu, mem, branch, vec, and emit modules, wire lazy RFLAGS, data-TLB fast paths, cross-page regions, SMP epoch polling, AES-NI/SHA-256 Wasm codegen, and KWEMU_JIT_SIMD=0 scalar fallback, and pass all native, wasm64+jit, nosimd, guest lockstep, and upstream A64 regression gates.
…8, and shift saturation
…ntial audit suite Broaden x86-64-v3 and i386 architectural conformance across the reference interpreter, decoded tier, Wasm SIMD JIT, and Linux x64/ia32 kernel ABI (KW_ABI_VERSION 6; AArch64 ABI unchanged): - SIMD, AVX, MMX, and FP: implement VTESTPS/VTESTPD (including the reported llama.cpp c4 e2 79 0e c9 form), PHMINPOSUW, DPPS/DPPD, MPSADBW, CVTDQ2PD, CVTPD2DQ/CVTTPD2DQ, and MOVNTDQ; fix MMX 64-bit lanes, SSSE3 MMX dispatch, immediate shift saturation, INSERTPS, VMOVSS/VMOVSD register merging, PCMPxSTRx equal-ordered/mask rules, all 32 AVX comparison predicates, COMI/UCOMI NaN signaling, DAZ/FTZ and unmasked MXCSR preservation, FMA NaN sign/payload, ROUND, VCVTPS2PH, RCP/RSQRT special values, scalar/widening memory operand widths, and precise AVX2 gather fault restart. - x87: fix pending-exception retirement vs WAIT/FNSTSW, memory-fault precedence, environment save/restore, stack faults, precision/rounding controls, integer/BCD conversions, constants, and 160-digit-verified transcendental argument reduction and status flags. - Scalar, segmentation, control flow, and exceptions: fix zero-count 32-bit shift zero-extension and memory write checks, read-only RMW flag preservation on fault, #AC scalar alignment checks with vector exemptions, noncanonical #GP on data/branches/FSGSBASE, overlength #GP, UD0 page-boundary decode, PROT_NONE fault error codes, POPF NT, REX.W/66 branch/stack widths, INT1/INT3 retirement, SYSCALL/SYSRET mode rules, BOUND/INTO, XSAVE/XRSTOR component isolation and XGETBV(1), i386 segment caches/limits/rights (src/x64/segment.zig) and REP partial progress, and fresh kernel/host entropy for RDRAND/RDSEED. - Single-step and SS interrupt shadow: track RFLAGS.TF transitions and MOV/POP SS / LSS interrupt_shadow across runRef, tier/opexec, JIT reload/region exits, and Linux user_mode_loop (updated in kernel/patches/linux-x64/0003-wasm-implement-x86-64-and-ia32-user-mode-kernel-ABI.patch). - Tests and docs: add differential audit corpora (isa-audit, fp-audit, integer-audit, x87-audit, x87-fp-audit, control-audit, descriptor-audit, fault-audit/32, rng-audit, ed25519test), offline Intel XED inventory tools, full-core parallelism in test/x64-test.mjs and vCPU-budgeted parallelism in test/x64-kernel-audit.mjs, and update .agents/x64.md, .agents/testing.md, and test/x64-audit.md. Verified on desktop (24-core x86-64 host): - x64 normal & atomics: 42/42 JIT unit tests (SIMD & nosimd), 2/2 object-import checks, and 196/196 physical-CPU guest/runner checks. - x64 UP/SMP kernel audit: 42/42 passed in parallel (41/42 serial, hitting the known intermittent kwtest-smp4 wakeup-placement check). - AArch64 normal & atomics regressions: 138 passed / 1 expected skip / 0 failed in JIT unit tests and 77/77 guest checks.
Co-authored-by: JeremySu0818 <xinghong.su0818@gmail.com>
The x86 front end no longer replaces A64 at build time: libkwemu exports the A64 ABI and the x86 one (kw_x64_run, kw_x64_set_isa, kw_x64_isa_supported, kw_x64_complete_entropy, kw_x64_load_segment) on the same struct kw_cpu, and include/kw_emu.h (ABI 5) describes both (struct kw_x64_regs; KW_EV_FPE, KW_EV_GPF and KW_EV_ENTROPY for x86). kw_cpu_init and kw_host_reset set up both. x86 blocks have their own sets in the block cache (blockSetFor: the top set bit flipped), so the blocks of the two ISAs at one pc never share a set and switching between an arm64 and an x86 task needs no flush. The compile-time is_x64 switches in src/emu become comptime hooks of the tier that looks a block up (Blocks.x86): the i386 key strip, the A64 stats hooks, and the shared x86 code-page set, which only x86 decodes mark (A64 keeps IC IVAU); a write-TLB fill reads it only once some x86 code has been marked. zig build test runs the A64 tests as before; zig build test-x64 runs the x86 ones (kwemu-x64-harness*, installed with the x86 guests by install-x64). The object bundles compiler-rt (the x86 front end's 128-bit and x87 arithmetic). Co-authored-by: JeremySu0818 <xinghong.su0818@gmail.com>
GPL-2.0-or-later, MIT for the JavaScript test driver, with the author's copyright line, as every other file has. Co-authored-by: JeremySu0818 <xinghong.su0818@gmail.com>
The kernel runs x86-64 ELF programs as their own tasks on kwemu's x86 front end (CONFIG_WASM_X86, on in kw_defconfig): exec picks the ISA from e_machine, and an x86 task gets x86-64's syscall table (through the same pt_regs wrappers, with translations where its ABI differs from arm64's: open flags, struct stat, clone's argument order, packed epoll events, uname, arch_prctl, MAP_32BIT, strict seccomp), signal frames, ptrace regsets and core notes, a vDSO, the vsyscall page, AT_PLATFORM, AT_HWCAP and /proc/cpuinfo in x86's format; kw.x86isa= masks its features. arm64 tasks are unchanged. The kernel patches are "wasm: run x86-64 user space beside arm64" after the arch patch and three generic ones (erofs without vmap on a flat vmalloc, eventpoll's packed events, seccomp's strict syscalls per task); the separate x86-only series (kernel/patches/linux-x64, KW_ARCH=x64) is gone, and so is the build switch. base-test.cpio has x86-64 builds of kwtest and abitest beside arm64's (kwtest-x86_64, abitest-x86_64; abitest_x64 finds itself under that name and checks the i386 cross exec only where there is an i386 build), and test/x64-kernel-audit.mjs runs them on the one kernel. i386 tasks are not there yet (no CONFIG_COMPAT). The distro images still register x86_64 with binfmt_misc (box64, qemu-x86_64), which comes before the kernel's ELF loader. Co-authored-by: JeremySu0818 <xinghong.su0818@gmail.com>
|
Thanks for the integration work! I'd be happy to continue with the single-kernel, per-task ISA architecture. I've also just completed an extensive ISA conformance audit and pushed the fixes to "x64-main". The full audit report and validation results are available here: https://github.com/JeremySu0818/unkernel/blob/x64-main/test/x64-audit.md The updated implementation includes x86 ABI changes (ABI 6), which will need to be accounted for during integration. Regarding the next steps, would you prefer me to open a PR against your integration branch, or work directly on this branch? I'd also be happy to investigate the i386 glibc crash and the x86 performance bottlenecks. |
|
Thanks for all your hard works. yes PR against branch sounds good. Did you have any chance to look at perf? |
Summary
A draft of what #92 could look like upstream: one kernel that runs both arm64 and x86-64 programs, picked per task at exec, instead of a separate x86-only build. The x86 CPU code is @JeremySu0818's fork (thank you!) — https://github.com/JeremySu0818/unkernel/tree/x64-main — merged as-is with its history; what changed is how it plugs in.
Shape
libkwemuexports the A64 ABI and an x86 one (kw_x64_run,kw_x64_set_isa,kw_x64_isa_supported,kw_x64_complete_entropy,kw_x64_load_segment) on the samestruct kw_cpu. There is one header,include/kw_emu.h, at ABI 5 (kw_emu_x64.his gone).blockSetFor: the top set bit flipped). Blocks of the two ISAs at one pc therefore never share a set, and switching between an arm64 and an x86 task needs no flush beyond the usualkw_set_pgd.is_x64switches insrc/emubecame comptime hooks of the tier that looks a block up.wasm: run x86-64 user space beside arm64,CONFIG_WASM_X86, comes after the arch patch. arm64's ABI headers and code paths are untouched.elf_check_archacceptsEM_X86_64,SET_PERSONALITYsetsTIF_X86,TASK_SIZEis per task (below 2^47 for x86), andpt_regscarries an ISA tag plus the x86 register file.user_mode_loop()runs the task's ISA and switches when anexecve()changes it.syscall_x86_64.tbl, generated) points at the same pt_regs wrappers as arm64. After the entry work, rdi, rsi, rdx, r10, r8 and r9 move to the slots the wrappers read. Only the calls whose ABI differs get x86 versions:/proc/cpuinfo, AT_HWCAP/AT_PLATFORM, andkw.x86isa=.TIF_X86tasks, as it does for ARM OABI.-Dkwemu-arch/KW_ARCHany more.zig build testis A64 as before, andzig build test-x64runs the fork's suite on the one library.base-test.cpiohaskwtest-x86_64andabitest-x86_64beside arm64's kwtest and abitest, andtest/x64-kernel-audit.mjspoints at the one kernel.Verified (2026-11-29, i7-10700K, Node 24)
zig build test: 77/77= qemu, and 138 passed / 1 skip in both JIT configurations, as before.zig build test-x64: 184 runner comparisons ok and 42/42 JIT units in both configurations. The 8 failures are all this host lacking SHA-NI: the host reference ofcryptotest, andedgetest's cpuid check.--cpus 2, JIT on and--no-jit: arm64kwtestandabitest0 failures, andkwtest-x86_640 failures.abitest-x86_64reports 0 failures out of 40 checks; it exits as PID 1, so exit code 253.chrootruns an amd64 Debian root's bash and Python (dynamic glibc) natively, after removing box64's binfmt entry (see TODO).python:3.13-slimandnode:24-slimimages all give the host CPU's output on this kernel.Speed against box64
Each column comes from the same kernel (this branch), the same session and the same workloads, as multiples of the arm64 build of the same programs. Setup: i7-10700K, UP, JIT on, median of runs 2–4, 2026-11-30.
python:3.13-slimandnode:24-slimroots.shandlscpuadded. It callslscputhroughshat every start; if both are x86, each start launches box64 again, in a loop.trues.TODO (what is left)
int 0x80from 64-bit code gets ENOSYS. On the fork's x86-only kernel, every dynamically linked Debian trixie i386 glibc program died in ld.so beforemain(same rip, same fault address); static musl i386 programs ran.BUG: Bad page map in process python3inexit_mmap. The PTE held0x5555b524c5e0, an x86 user address, and the next workload hung. It hasn't been reproduced yet. It looks like something in an x86 task writes through a stale mapping into a page that has since become a page table.openat2returns ENOSYS.modify_ldt,ioplandiopermreturn ENOSYS.sigaltstackminimum is arm64's 5120, not x86's 2048.semid64_dspadding isn't translated./proc/PID/fdinfoflags show arm64's O_* bits.PTRACE_GETREGS-style x86 requests are missing; the regsets are there.dpkg --add-architecture amd64without box64) is untested, and so is the page (browser).Question for @JeremySu0818
Would you be up for taking the series from here in this shape: one kernel with per-task ISA, x86 added beside arm64 with its ABI differences translated at the syscall boundary, and the CPU code unchanged? i386 would come next, as CONFIG_COMPAT on the same kernel. Your take on the dynamic i386 glibc crash, and on where the x86 tiers lose time against A64, would help most.
🤖 Generated with AI assistant