Repository navigation
Keep guest vectors in XMM registers between translated instructions - #6
Merged
Merged
Conversation
losfair
marked this pull request as ready for review
October 25, 2026 08:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NEON, FP, and crypto lowerings previously loaded and stored guest vectors through the state page between instructions. Cache up to eight frequently used guest vectors in XMM0..7, retaining them across self-loop back-edges and spilling/refilling around helpers and other block boundaries. The AES benchmark loop goes from 20 vector-state memory accesses per iteration to zero.
Recovery metadata records the mapping and whether saved XMM registers or the state page is authoritative, including partial fills/spills, helper returns, and exit trampolines. Location markers are preserved when an instruction marker shares their host address. Scalar, lane, and full-width accesses use cache-aware accessors; scratch results still commit in one host instruction.
The native x86 backend captures live or saved user XMM state, including IRQ-disabled epoch recovery and XSAVE init state. Other ports opt in with
KEMU_ARCH_VECTOR_CACHEand their ownkemu_arch_read_xmm()hook. Ports without that hook retain the memory-only representation.kemu.jitoff=64/NO_VCACHE=1disable caching. Allocation is block-local; cross-block allocation and dynamic eviction remain future work.Interrupted SVC stubs now distinguish pending syscalls from completed ones. Recovery restarts a pending guest SVC, preventing epoch recovery from skipping a syscall such as
rt_sigreturn; after the host syscall, the restored page state remains authoritative. Kernel and userspace tests share this recovery routine.Validation:
rt_sigreturn.kemu.stress=1) and cache-disabled coverage pass, with no kernel warnings.Performance measured at
6949dacon the i7-13700H host, using the same revision and static AArch64tests/bench/crypto.{c,S}binary inkemu-user: nine interleaved cache-off/cache-on pairs, 2,000,000 iterations, warmed translations, pinned to CPU 0. Values are median ns per benchmarked crypto instruction, including loop and operand-handling overhead.Reproduce each pair with
NO_VCACHE=1 taskset -c 0 tools/kemu-user/target/release/kemu-user --jit build/crypto-bench 2000000 1, then the same command withoutNO_VCACHE=1; the benchmark source includes its build command.These are translator microbenchmarks, not native-performance ratios. Separate baseline-main/patched KVM runs passed all checksum checks, but end-to-end OpenSSL timings were too variable to support a speedup claim: even native AES-GCM ranged from 84 to 5,942 MB/s in the final three runs. Shared-host timing noise remains a limitation; this PR does not claim to close the remaining gap to native crypto implementations.