universalisos/docs/T8-1.2g_WIRE_PERSONALITY_LOADER.md

83 lines
2.8 KiB
Markdown

# T8-1.2g — Wire Personality Loader into Boot Path
**Task:** Wire the personality loader (T8-1.2c) into the actual boot path so it loads and boots the personality ELF instead of just pointing the vCPU at the entry point.
**Current State:**
- Personality loader exists (`personality_loader.{h,cpp}`) with ELF parsing, segment loading, and lifecycle management
- `UOS_PERSONALITY_BOOT` path in `kernel_aarch64.cpp` bypasses the loader and points vCPU directly at entry
- `personality_boot()` currently just sets state to RUNNING without creating a real task
**Goal:**
Make the personality loader actually load the ELF and boot it as a proper UOS task.
---
## Path A: Direct Integration (Recommended)
Wire the personality loader into `mp1_guest_setup()` so it:
1. Creates a personality via `personality_create()`
2. Loads the ELF via `personality_load_elf()`
3. Configures it via `personality_configure()`
4. Boots it via `personality_boot()` (which creates the actual task)
### Changes Required:
#### 1. `kernel_aarch64.cpp` — `mp1_guest_setup()`
- Include `personality_loader.h`
- When `UOS_PERSONALITY_BOOT` is defined:
- Call `personality_manager_init()`
- Create personality: `personality_create("gate_hmalloc", PERSONALITY_TYPE_MUSL)`
- Load ELF from `QEMU_GUEST_BASE` (where QEMU placed it)
- Configure with default settings
- Boot it (creates the vCPU/task)
#### 2. `personality_loader.cpp` — `personality_boot()`
- Actually create a UOS task/vCPU instead of just setting state
- Call `aarch64_vcpu_init()` with the personality's entry point
- Call `aarch64_vcpu_run()` to start it
#### 3. `personality_loader.h`
- Add function to get the vCPU for a personality (so the boot path can run it)
---
## Implementation Steps:
1. **Add personality loader to boot path** (`kernel_aarch64.cpp`)
2. **Implement actual task creation in `personality_boot()`**
3. **Test build** (compile for aarch64)
4. **Test boot** (QEMU with `run-personality`)
---
## Verification:
- Build succeeds for aarch64
- QEMU boots with personality
- Personality loader messages appear in UART output
- Gate test (hardened_malloc) runs successfully
---
## Files to Modify:
- `kernel/src/arch/aarch64/kernel_aarch64.cpp` — wire loader into boot path
- `kernel/src/arch/aarch64/personality_loader.cpp` — implement actual task creation
- `kernel/src/arch/aarch64/personality_loader.h` — add vCPU accessor
---
## Dependencies:
- T8-1.2c (personality loader) — DONE
- T8-1.2f (gate test ELF) — DONE
- aarch64 kernel build — needs to be fixed (task_context_t issue)
---
## Notes:
- The aarch64 kernel build is currently broken at HEAD (task_context_t typedef issue)
- This is a pre-existing issue from another session's refactor
- The personality loader files compile independently
- May need to fix the build issue first or work around it