AArch64-only iSH: asbestos guest gadgets, kernel consolidation - #1
Draft
CodeJoule wants to merge 8 commits into
Draft
AArch64-only iSH: asbestos guest gadgets, kernel consolidation#1CodeJoule wants to merge 8 commits into
CodeJoule wants to merge 8 commits into
Conversation
Introduce a compile-time guest_arch meson option (i386 or aarch64) so iSH can emulate AArch64 Linux userspace alongside the existing i386 backend. The AArch64 engine uses a C interpreter for guest instructions, AArch64 Linux syscall dispatch, ELF64 loading, signal frames, and an aarch64 VDSO. The default i386 asbestos gadget path is unchanged. Includes an aarch64 hello-world test and README build instructions. Co-authored-by: CodeJoule <CodeJoule@users.noreply.github.com>
Replace the standalone C interpreter loop with the real asbestos engine: gen-aarch64 compiles guest basic blocks into gadget streams, fiber_enter dispatches guest AArch64 gadgets, and asbestos.c handles block caching and invalidation using guest pc instead of eip. - Add emu/aarch64-exec.c for per-instruction semantics used by gadgets - Add asbestos/gen-aarch64.c and gadgets-guest-aarch64/entry.c - Remove aarch64-interp.c, aarch64-engine.c, and no-op asbestos stubs - Default guest_arch to aarch64; keep i386 behind -Dguest_arch=i386 Co-authored-by: CodeJoule <CodeJoule@users.noreply.github.com>
- Rewrite gen-aarch64.c to emit per-instruction-type guest gadgets - Add gadgets-guest-aarch64: C gadgets (all hosts), asm hot gadgets + fiber_enter (aarch64 host) - Add offsets-aarch64.c, helpers-aarch64.c, logical immediate decode - Merge AArch64 syscall dispatch into kernel/calls.c; remove calls-aarch64.c - Default ISH_GUEST_ARCH=aarch64 in Xcode and xcode-meson.sh - Add exit42 assembler test for mov/svc gadget coverage Co-authored-by: CodeJoule <CodeJoule@users.noreply.github.com>
- Fix gadgets-guest-aarch64 assembly to assemble on Apple Darwin: runtime read_xn/write_xn macros, variable shifts, insn_gadget branches - Split C vs asm gadget sources by host arch in meson (no duplicate symbols) - Add PT_INTERP dynamic linker loading in exec-aarch64.c - Expand AArch64 syscall table and wire accept4 to sys_accept - Add memory/math/misc insn gadgets and gen-aarch64 emissions - Document Alpine aarch64 rootfs setup; default guest_arch to aarch64 Co-authored-by: CodeJoule <CodeJoule@users.noreply.github.com>
Co-authored-by: CodeJoule <CodeJoule@users.noreply.github.com>
- fiber_interrupt: read interrupt code from w23 (gadget result), not w20 (_cpu) - CBZ/CBNZ: use uxtw for W-form and correct take-branch condition - Preserve segfault_was_write across helper_a64_run_insn_word - Rebuild aarch64 syscall table from Linux asm-generic NRs (unlinkat/ppoll/nanosleep/prctl/socket/accept4/eventfd2/etc.) - Align AArch64 signal frames to 16-byte SP ABI - Point vdso __kernel_sigreturn at rt_sigreturn (NR 139) Co-authored-by: CodeJoule <CodeJoule@users.noreply.github.com>
Co-authored-by: CodeJoule <CodeJoule@users.noreply.github.com>
Co-authored-by: CodeJoule <CodeJoule@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables building iSH on Apple Silicon with an AArch64 Linux guest (default
guest_arch=aarch64).Critical fixes (post-review)
fiber_interrupt: was reading interrupt code fromw20(_cpu) instead ofw23(gadget result) — broke Mac/asm interrupt pathuxth(16-bit) instead ofuxtw; take-branch condition correctedasm-generic/unistd.hNRs (previous table had many wrong slots: unlinkat/ppoll/nanosleep/prctl/socket/accept4/eventfd2/…)segfault_was_write: no longer cleared by helper on faultssp+4trick)Guest execution (asbestos)
entry.Sgret tail-call fiber modelcontrol.Sasm gadgets for branches, SVC, mov_wide, etc.memory.S/math.S/misc.Sinsn gadgets →helper_a64_run_insn_wordKernel
exec-aarch64.c: ELF64 + PT_INTERPApp / docs
ISH_GUEST_ARCH = aarch64inapp/iSH.xcconfigMac usage
./build/ish -f alpine-aarch64 /bin/shRemaining gaps
aarch64-exec.c(needed for full musl)ROOTFS_URLstill i386 — must fakefsify Alpine aarch64 manually/bin/shCI test yet