Rename the arch interface to arch-neutral terms

The generic kernel imports cpu.zig as @import("arch") but still spoke
x86: readCr3/readCr2, pml4 and rip/rsp parameters, lapicHz/tscHz,
ioapicEntry*, IST stacks, APIC ids. Rename the public interface so the
same names work for x86_64, aarch64, and riscv64:

- readCr3 -> activePageTable; pml4 params -> root; vectorName ->
  exceptionName; postCode -> checkpoint; lapicHz/tscHz ->
  timerClockHz/clockHz; ioapicEntry* -> irqRoute*; ist_stack_size/
  setApIstStack -> fault_stack_size/setFaultStack; startSecondary
  takes a hw_id (APIC id here; MPIDR/hart id elsewhere)
- New trap-frame accessors (instructionPointer, stackPointer,
  fromUser, faultAddress, syscallNumber/syscallArg/setSyscallResult)
  so the generic syscall dispatcher and fault printer never name an
  x86 register; readCr2 folds into faultAddress (null unless #PF)
- Generic-kernel identifiers follow: Task.pml4 -> aspace, rsp -> sp,
  user_rip/user_rsp -> user_ip/user_sp, PerCpu.apic_id -> hw_id

PlatformConfig fields and the ACPI apic_id stay as-is: they describe
hardware actually discovered on this platform, and another arch would
define its own. The user-mode tests now assert fromUser instead of
the exact CS selector; the user-pf expectation follows the fault
printer's RIP -> IP label. All 28 QEMU tests pass.
This commit is contained in:
Daniel Samson
2026-07-09 05:52:05 +01:00
parent b9d9e1e523
commit 7384a730be
7 changed files with 218 additions and 157 deletions
+2 -2
View File
@@ -156,9 +156,9 @@ CASES = [
"expect": r"DANOS-TEST-RESULT: PASS",
"fail": r"DANOS-TEST-RESULT: FAIL"},
# Isolation: a ring-3 read of a kernel-only page must #PF with error code
# 0x5 (present|user) at the user RIP. ([\s\S] spans lines; `.` doesn't.)
# 0x5 (present|user) at the user IP. ([\s\S] spans lines; `.` doesn't.)
{"name": "user-pf",
"expect": r"page fault \(vector 14\)[\s\S]*error code : 0x5[\s\S]*RIP\s*: 0x00007000000000",
"expect": r"page fault \(vector 14\)[\s\S]*error code : 0x5[\s\S]*IP\s*: 0x00007000000000",
"fail": r"DANOS-TEST-RESULT: FAIL"},
# The real user binary: the bootloader ships sbin/init off the ESP, the
# kernel loads the ELF and runs it in ring 3, and it writes + exits cleanly.