Repository navigation
issues: user programs use AVX under XSAVE is done, and the records stop saying otherwise - #959
Conversation
Review of #959 at
|
…op saying otherwise The track landed in #859 (XCR0 and CR4.OSXSAVE from control_regs' declaration; each CPU saves by XSAVES, XSAVEC or XSAVEOPT, the owner's ruling there) and #871 (the save at the switch). Its exit, item by item: - Threads with different vector contents each find their own after a switch: vector_state on the T14 (XSAVES, Width(Avx512)) and the AMD bench (XSAVEC, Width(Avx)) exited 0 at #871's merged head cdd090b (ToyOS#871 comment 6127208453). Since then fpu.rs, switch.rs, entry.rs and vector_state are unchanged; xsave.rs and control_regs.rs changed in #873 and #915 without changing either bench's XCR0 or form. Under TCG, vector_state_survives_a_switch passed again at 4b8684f: "5 threads each held Width(Avx) through 3 rounds". - The EPYC KVM proving machines: merge-queue run 38725606232, job 116394005489 (guest / suite under KVM on an AMD EPYC 9V45, at 45b66f8, whose diff to 4b8684f is empty over fpu.rs, switch.rs, entry.rs, xsave.rs, control_regs.rs, sched/, build/arch.rs and the test): "vector_state: 5 threads each held Width(Avx512) through 3 rounds", PASS. It is one EPYC form: the 9V45 is outside erratum 1386's families, and its save form is not in the job log; a family-19h EPYC guest saves with XSAVEC since #915 and has no reading here. - Mutations: the save mask short of YMM (XSAVEOPT eax=3) under TCG went red again at 4b8684f, "ymm0 changed while it was switched out" in four threads, applied and restored in the same run. Short of Hi16_ZMM (eax=0x67) on the T14 went red at zmm16 in #859 (365bd21), when the save still sat in the entry bracket; the mask is the same operand of the same instruction at the switch now, not re-run there. - The T14's ChaCha20-Poly1305 figure: #932's parity boots, with the ISA each build recorded (avx, avx2, avx512f/vl on the T14). The citing records drop the slug, and ap-control-registers-inherit-init no longer says OSXSAVE is asserted clear (it is in CR4_REQUIRED) or counts the CR4 bits its gate names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a3a5fe1 to
e42dd7e
Compare
|
Review round 1, now at head
No re-run: the amend changes one markdown line, and the 🤖 Generated with Claude Code |
issues/user-programs-use-avx-under-xsave.mdis done and this deletes it. The track landed in #859 and #871, but the issue was never closed. It still saidCR4.OSXSAVEstays clear and AVX is#UD. This PR changes records only, no code.What landed (on main before this PR)
kernel/src/arch/x86_64/control_regs.rsdeclaresCR4.OSXSAVE(inCR4_REQUIRED) andXCR0as a single declaration. Each CPU computesXCR0from its own CPUID (kernel::xsave::xcr0: x87, SSE and AVX required, all of AVX-512 or none), the BSP publishes it, and every CPU asserts it.kernel/src/arch/x86_64/fpu.rssaves at the switch and restores there. The area is sized from CPUID leaf 0xD and sits above the kernel stack's top. A new thread starts byload_initial.+xsave,+xsaveopt,+avx,+avx2(build/arch.rs).The issue's exit, item by item
vector_statejudge exit 0,Width(Avx512), XSAVES (#871 comment)cdd090baa, #871's merged headvector_statejudge exit 0,Width(Avx), XSAVEC (same comment)cdd090baavector_state_survives_a_switchexit 0, "5 threads each held Width(Avx) through 3 rounds" (log L147)4b8684f6f(this PR's base), run for this PRvector_state_survives_a_switchPASS, "5 threads each held Width(Avx512) through 3 rounds", under KVM on an AMD EPYC 9V45 (merge-queue run 38725606232, job 116394005489, L452 CPU, L699–L700 result). This is one EPYC form only: the 9V45 is outside erratum 1386's families, and the job log does not record its save form. A family-19h EPYC guest (7763, 9V74) has saved with XSAVEC since #915 and has no reading here.45b66f8d6(#945's queue commit);git diff 45b66f8d6 4b8684f6fis empty overfpu.rs,switch.rs,entry.rs,xsave.rs,control_regs.rs,sched/,build/arch.rsand the testeax=3(patch), applied, run and restored in one command: exit 1, "ymm0 changed while it was switched out" in four threads (log L15)4b8684f6f+ patch, run for this PReax=0x67: EXIT=1, seven threads red atzmm16(#859 body, Checks)365bd213b(#859)avx,avx2,…,avx512f,avx512vl(issues/toyos-crypto-is-in-the-tree-on-par-with-ring-and-secure.md)Why the earlier metal readings still hold. Between
cdd090baaand4b8684f6f,git diffshows no change tofpu.rs,switch.rs,entry.rs,vector_state.rsorarch/vector.rs.xsave.rsandcontrol_regs.rschanged in #873 (CR4.PGE) and #915 (the erratum moved in-tree and widened to more Zen models). Neither change alters either bench'sXCR0or save form. #915's body says so for the AMD bench (model 60h, already XSAVEC), and the T14 is Intel, where the erratum does not apply.sched/changed only in keyboard-controller polling and a task's release list.One mutation reading is older and was not re-run. The Hi16_ZMM mutation went red on the T14 when the save was still in the entry bracket, before #871 moved it to the switch. The mask is the same operand of the same instruction, now in
fpu::save. #871's stack-slot mutant also went red on the T14 at the current save site ("zmm21 changed"). I judge the Hi16_ZMM control still valid; that is an inference, not a new measurement. If the orchestrator wants it re-measured, it is a single T14 boot ofvector_statewitheax = 0x67in theForm::Xsavesarm offpu::save.Changed records
issues/user-programs-use-avx-under-xsave.md. It carries no durable rule that is not already infpu.rs's andcontrol_regs.rs's headers.issues/toyos-uses-what-modern-hardware-offers-for-speed.md: removed it from the exit list.issues/toyos-crypto-is-in-the-tree-on-par-with-ring-and-secure.md: removed the "remaining exit" sentence.issues/user-programs-have-no-protection-keys.md: the ordering dependency is replaced by the remaining fact: PKRU is XSAVE state thatkernel::xsave::xcr0does not yet enable.issues/ap-control-registers-inherit-init.md: it saidOSXSAVEis in neitherCR4_REQUIREDnorCR4_OPTIONALand is asserted clear. It is now required and asserted set, and the divergence is still unrepresentable. Its count of theCR4bits the gate names is dropped.git grep user-programs-use-avxat the head finds nothing.User-space feature detection (report, nothing changed)
With
OSXSAVEset, these paths are open on ToyOS. They have been since #859 (f7b497231), not since this PR:library/std_detect/src/detect/os/x86.rs, not OS-specific): readsXCR0throughxgetbv.xcr0 & 6 == 6admits AVX, AVX2, FMA, F16C, VAES and VPCLMULQDQ.xcr0 & 0xe0 == 0xe0admits the AVX-512 family on the T14. AMX stays unreported, becauseXCR0bits 17 and 18 are clear.crypto/cpu_intel.c, not OS-specific):(xcr0 & 6) == 6keeps AVX and everything gated on it, and(xcr0 & 0xe6) == 0xe6keeps AVX-512. The paths taken: ChaCha20ChaCha20_ctr32_avx2, the AVX2 and BMI2 integrated ChaCha20-Poly1305, AES-GCM'sclmulavxmovbeand, where VAES and VPCLMULQDQ exist (the T14),VAesClMulAvx2.arch/x86_64/avx2.rsgates ChaCha on CPUID andxgetbv(0), andvaes.rsonis_x86_feature_detected!. Both are open on both benches. The ring comparator: toyos-crypto beside ring in a guest, on metal rows (crypto stage 2) #932 recorded those ISAs.Checks
cargo test --test toyos-build -- vector_state_survives_a_switch(x86-64 under TCG on an AArch64 host)4b8684f6f4b8684f6f+ patchcargo run -- --ci hosta3a5fe1e6tree (the amend toe42dd7ef7changes one markdown line and the commit message)The PR changes only markdown under
issues/, so no image build and no metal run is needed.Risks
The EPYC KVM reading covers only the 9V45. Family-19h EPYC guests (XSAVEC since toyos-cpuvuln leaves the tree; what the kernel read of it stands on Intel's and AMD's documents #915) have no
vector_statereading. The nightly'skvm / suitelane is new with ci: the merge queue builds both images, the guest suite runs nightly, documentation alone builds nothing #954 (2026-10-20); its first runs give the next EPYC reading, on whatever EPYC form the runner draws.The Hi16_ZMM metal control is from before the save moved to the switch (above).
The ChaCha "figure" item is read as satisfied by The ring comparator: toyos-crypto beside ring in a guest, on metal rows (crypto stage 2) #932's measured figure with AVX-512 state enabled. The issue set no threshold for it.
🤖 Generated with Claude Code