KVM Lays the Groundwork for Intel APX Inside Virtual Machines on Linux 7.2
#Infrastructure

KVM Lays the Groundwork for Intel APX Inside Virtual Machines on Linux 7.2

Hardware Reporter
4 min read

The Linux 7.2 merge window is picking up KVM preparation patches for Advanced Performance Extensions, the x86 update that doubles general purpose registers from 16 to 32. Actual guest APX support is targeting 7.3, comfortably ahead of Diamond Rapids and Nova Lake silicon.

Kernel-based Virtual Machine maintainers have started merging the plumbing needed to expose Advanced Performance Extensions (APX) to guests, with the first batch landing in KVM's next branch ahead of the Linux 7.2 merge window. The actual ability to run an APX-aware guest is not in this cycle. What is here is the structural work to teach KVM about a register file that suddenly got twice as big.

Intel APX

What APX actually changes

For the better part of two decades, x86-64 has given software 16 general purpose registers: rax through r15. That number has been a real constraint. When a compiler runs out of registers, it spills values to the stack, and every spill is a load and store that the CPU has to track, cache, and eventually retire. APX takes the count from 16 to 32, adding r16 through r31. More registers means fewer spills, fewer redundant memory accesses, and shorter dependency chains through hot loops.

That is the headline feature, but APX is broader than just the register count. The extension also brings a new direct conditional jump form, three-operand instruction encodings that stop destroying one of their inputs, and optimized state save and restore paths. The three-operand encodings matter more than they sound. On classic x86, an add overwrites one of its source operands, so the compiler frequently emits an extra mov just to preserve a value it still needs. APX lets the destination be a separate register, which deletes a large class of those housekeeping moves.

Intel is shipping APX first on Nova Lake client parts and Xeon Diamond Rapids on the server side, with AMD support following on a later generation. That timeline is the whole reason this KVM work is happening now rather than after the hardware lands.

Why the register count is a virtualization problem

Going from 16 to 32 registers is not a transparent change for a hypervisor. KVM has to save and restore guest state on every VM exit and entry, and the guest register file is part of that state. Doubling the GPR count touches the structures KVM uses to shadow guest context, the code that copies registers in and out on emulation paths, and anything that enumerates registers by a fixed count.

The preparation patches merged so far are about making KVM's internal handling of the GPR set scale from 16 to 32 cleanly, without yet flipping on the guest-visible feature. A follow-up merge extended that groundwork further. Splitting it this way is sensible: the register-handling refactor is invasive and worth landing early so it can soak across a full release before APX enablement rides on top of it.

{{IMAGE:2}}

The schedule, and why it is comfortable

The realistic target for functional KVM APX guest support is Linux 7.3, not 7.2. That still leaves a healthy margin. Diamond Rapids and Nova Lake are not in users' hands yet, so a 7.3 landing means the kernel side is ready before anyone can actually boot an APX-capable host. For homelab operators who run their hypervisors on whatever the distro ships, the practical effect is that by the time you can buy a CPU with APX, a kernel that can pass it through to guests will already be in the stable tree and likely backported into enterprise distributions.

The behavior worth planning around: APX is a guest-visible CPU feature, which means it interacts with live migration and CPU model definitions. Once support lands, migrating a VM from an APX host to a non-APX host will require the usual feature-masking discipline in QEMU's CPU model, exactly as with AVX-512 or other instruction set extensions before it. If you run mixed-generation clusters, the safe default will be to define a baseline CPU model that omits APX unless every node in the migration pool exposes it.

What to watch next

Three things are worth tracking as this matures. First, whether QEMU's CPU model definitions gain an APX feature flag in lockstep with the KVM enablement, since guest exposure needs both halves. Second, how the optimized state save and restore interacts with KVM's existing FPU and extended-state handling, because that path is performance-sensitive on exit-heavy workloads. Third, real numbers: the register count increase should help spill-bound workloads inside VMs, but the only way to know how much is to benchmark recompiled guest binaries on actual silicon, and that data will not exist until the hardware ships.

For now this is unglamorous enabling work, the kind that has to land quietly a release or two early so the interesting part has somewhere stable to sit. The fact that it is showing up in 7.2 preparations rather than scrambling at the last minute is the encouraging signal here. You can follow the ongoing KVM changes through the kernel virtualization tree as the 7.2 window opens.

Comments

Loading comments...