2 KiB
2 KiB
AArch64 Guest-Side C Runtime
Goal: Convert the AArch64 guest payload from hand-written assembly to a real freestanding C program that links against uos_hv_abi.h, proving the guest-side inline helpers compile and work, and laying the foundation for richer guests (tiny RTOS, eventually Linux usermode-style payloads).
Why: The current payload is ~100 lines of asm. To write a guest that does IPC, scheduling, or device I/O, we need C. The uos_hv_abi.h already ships guest-side inline helpers (uos_hv_putc/puts/gettime/shutdown/ack_vtimer); this phase wires them into a buildable C guest with a minimal vector table + crt0.
Files:
- Create:
kernel/src/arch/aarch64/guest_payload/crt0.S— minimal EL1 vector table + entry that callsguest_main() - Create:
kernel/src/arch/aarch64/guest_payload/guest_main.c— the C guest (puts/gettime/vtimer/shutdown via the ABI) - Modify:
kernel/src/arch/aarch64/guest_payload/linker.ld— set entry toguest_crt0, place.rodatafor the string - Modify:
kernel/src/arch/aarch64/guest_payload/Makefile— compile crt0.S + guest_main.c, link - Delete:
kernel/src/arch/aarch64/guest_payload/guest_payload.S(superseded)
C guest behavior (parity with the asm payload):
uos_hv_puts("guest C runtime online\n")- print the value from
uos_hv_gettime()formatted via a tinyitoa(proves GETTIME returns the physical counter) - arm CNTV for ~10 ms, unmask IRQs,
wfiloop guest_irq_handler()(C): disable CNTV,uos_hv_ack_vtimer(), EOI INTID 27, thenuos_hv_shutdown()
crt0.S:
- 2 KiB vector table (16 slots); slot 0x200 =
guest_main, slot 0x280 =guest_irq_handler guest_crt0: set SP to top of guest RAM (0x60000000), zero BSS,bl guest_main, thenwfeloop if it returns.
Verification:
make ARCH=aarch64 PLATFORM=qemu-aarch64-virtclean (rebuilds payload + kernel)-smp 4boot shows "guest C runtime online", a non-zero tick count, "[hv] guest shutdown", interleaved A/B- ARMv7 build clean