mirror of
https://github.com/hanzoai/visor.git
synced 2026-09-24 17:04:14 +00:00
Initialize FPU and XCR0 in assembly before entering Go code, switch %rip to the lower half before calling kernel syscall and exception trampolines. In recent Go toolchains, the compiler-generated ABI0 wrappers that bridge assembly and internal ABI Go code zero X15. The wrapper performs a RIP-relative load of runtime.x86HasAVX to see if AVX is available on the host, and executes VXORPS. This introduces two requirements in ring0: 1. When booting a vCPU, XCR0 only enables x87 state by default. Executing VXORPS in startGo.abi0 triggers a #UD fault if AVX is not enabled in XCR0. Moving fninit and xsetbv into assembly before calling startGo ensures AVX state is enabled before the wrapper runs. 2. The syscall and exception entrypoints execute in the upper half of the virtual address space where data pages are not mapped. The RIP-relative load of runtime.x86HasAVX faults unless we transition %rip to the lower half via jumpToUser before calling into Go trampolines. PiperOrigin-RevId: 974188468