Skip to main content

Crate kh_runtime

Crate kh_runtime 

Source
Expand description

Native ARM64 execution context, guest memory layout, and trap hooks.

Dependency rule: this crate must not depend on kh-loader or kh-cli.

Layout:

  • bottle — guest root FS / tools install
  • mem — page geometry, mapping, address-space registry
  • syscall — BSD / helper dispatch
  • cpu — registers, trap backend, entry, host-thread slots
  • thread — guest threads + TLS
  • process — process-wide run state, stack, dyld table
  • host — host OS primitives + fat Mach-O open

unsafe is denied by workspace lints and only allowed in tightly scoped modules (cpu/*, host/*, mem/*, thread/*, syscall handlers, and bottle::read_c_string).

Re-exports§

pub use cpu::entry;
pub use cpu::host_slot;
pub use cpu::regs;
pub use cpu::trap;
pub use host::fat_thin;
pub use process::dyld_table;
pub use process::stack;
pub use thread::tls;
pub use thread::tls_fd;
pub use thread::tls_verify;
pub use bottle::BottleError;
pub use bottle::BottleStatus;
pub use bottle::CreateOptions;
pub use bottle::CreateResult;
pub use bottle::DARWIN_7ZZ_URL;
pub use bottle::DARWIN_CURL_URL;
pub use bottle::DEFAULT_7ZZ_PATH;
pub use bottle::ENV_7ZZ;
pub use bottle::ENV_CURL;
pub use bottle::GUEST_7ZZ_REL;
pub use bottle::GUEST_CURL_REL;
pub use bottle::GUEST_LIBCURL_REL;
pub use bottle::GUEST_LIBCURL_TARGET;
pub use bottle::GUEST_LIBCXX_REL;
pub use bottle::GUEST_LIBCXX_TARGET;
pub use bottle::GUEST_PATH_DIRS;
pub use bottle::InstallPackage;
pub use bottle::InstallReport;
pub use bottle::PathError;
pub use bottle::ToolError;
pub use bottle::active_root;
pub use bottle::bottle_root;
pub use bottle::create as create_bottle;
pub use bottle::create_with as create_bottle_with;
pub use bottle::destroy as destroy_bottle;
pub use bottle::discover_7zz;
pub use bottle::discover_curl;
pub use bottle::ensure as ensure_bottle;
pub use bottle::guest_path_to_host;
pub use bottle::install_package;
pub use bottle::package_host_path;
pub use bottle::resolve_guest_program;
pub use bottle::set_bottle_root;
pub use bottle::status as bottle_status;
pub use bottle::translate_path;
pub use bottle::translate_path_with_root;
pub use dyld_table::RTLD_DEFAULT;
pub use dyld_table::RTLD_NEXT;
pub use dyld_table::RTLD_SELF;
pub use dyld_table::clear as dyld_table_clear;
pub use dyld_table::dlopen_lookup;
pub use dyld_table::dlsym_lookup;
pub use dyld_table::register_image as dyld_register_image;
pub use process::ProcessState;
pub use process::reset_run;
pub use entry::EntryError;
pub use entry::call_guest;
pub use entry::call_guest_args;
pub use entry::jump_to_guest;
pub use entry::jump_to_guest_args;
pub use host::MappedFile;
pub use mem::AddressSpace;
pub use mem::DARWIN_ARM64_PAGE_SIZE;
pub use mem::GuestMemory;
pub use mem::GuestPageSize;
pub use mem::HostPageSize;
pub use mem::MapError;
pub use mem::MapRequest;
pub use mem::MappedRegion;
pub use mem::PageError;
pub use mem::PageLayout;
pub use mem::VM_PROT_EXECUTE;
pub use mem::VM_PROT_READ;
pub use mem::VM_PROT_WRITE;
pub use mem::map_stack;
pub use mem::mprotect_darwin;
pub use mem::mprotect_rw;
pub use mem::register_borrowed;
pub use mem::registry_clear;
pub use mem::registry_install;
pub use mem::registry_take;
pub use regs::ThreadRegs;
pub use stack::StackError;
pub use stack::bootstrap_stack;
pub use syscall::BsdSyscall;
pub use syscall::SyscallArgs;
pub use syscall::SyscallResult;
pub use syscall::known_syscalls;
pub use syscall::lookup as lookup_syscall;
pub use syscall::name_of;
pub use tls::GUEST_TLS_MAGIC;
pub use tls::enter_host_tls;
pub use tls::install_main_guest_tls;
pub use tls::leave_host_tls;
pub use tls::prepare_host_meta;
pub use trap::PSTATE_C;
pub use trap::TrapConfig;
pub use trap::TrapError;
pub use trap::TrapEvent;
pub use trap::TrapOutcome;
pub use trap::clear_expect_code;
pub use trap::clear_trace_on_exit;
pub use trap::finish_with_exit_code;
pub use trap::hypercall_entry_addr;
pub use trap::install_trap_handlers;
pub use trap::patch_svc_to_brk;
pub use trap::set_expect_code;
pub use trap::set_trace_on_exit;
pub use trap::take_trace_events;

Modules§

bottle
Bottle: path translation and single-bottle lifecycle management.
cpu
AArch64 guest execution: registers, trap backend, entry, host-thread slots.
host
Host OS primitives and fat Mach-O helpers.
mem
Guest and host page geometry for Darwin arm64 images on Linux.
process
Process-wide guest state: run flags, stack bootstrap, dyld image table.
syscall
Table-driven Darwin BSD syscall dispatch (arm64, number in x16).
thread
Guest threads and TLS (TPIDR_EL0, FD TLS path, cert verify).