On Fri, Nov 06, 2026 at 15:53:00 +0100, Denis V. Lunev wrote:
> From: Denis V. Lunev <[email protected]>
>
> Kernel commit 76ea438b4afc ("KVM: X86: Expose bus lock debug exception
> to guest") made KVM offer bus-lock-detect on every host that enumerates
> it, AMD Zen 5 included. Kernel commit 54950bfe2b69 ("KVM: SVM: Don't
> advertise Bus Lock Detect to guest if SVM support is missing"), marked
> for stable, stopped offering it on AMD.
I might be missing something, but the commit summary claims to remove it
only when SVM support is missing. I don't understand how as it seems to
be disabling it unconditionally, but still I'm not sure we can just
unconditionally drop it from CPU definition.
> A host-model guest started on
> Zen 5 under an older kernel has bus-lock-detect in its live definition.
> On a destination with the newer kernel QEMU filters the feature out and
> the incoming migration fails:
>
> guest CPU doesn't match specification: missing features: bus-lock-detect
>
> Restoring a save image or reverting a snapshot fails the same way, so
> the guest cannot be moved to the new kernel without a restart.
>
> Dropping the bit in libvirt costs the guest nothing. Bus lock detection
> is enabled through DEBUGCTL, which SVM loads for the guest only with
> LBR virtualization active, and 54950bfe2b69 says the guest could not
> use the feature despite the CPUID bit. QEMU does not migrate DEBUGCTL,
> so the guest resumes with bus lock detection off. A Linux guest since
> kernel commit 408eb7417a92 ("x86/bus_lock: Add support for AMD") sets
> DEBUGCTL.BLD again only when it brings a CPU online; with LBR
> virtualization enabled, the default, kernels since 5ecdb48dd918 ("KVM:
> SVM: Treat DEBUGCTL[5:2] as reserved") answer that write with #GP,
> which Linux reports as an "unchecked MSR access error" warning and
> carries on, and older kernels ignore the bit. QEMU drops the bit either
> way; libvirt only decides whether the guest survives.
>
> Kernel commit 62ad461079e7 ("KVM: SVM: Add support for virtualizating
> Bus Lock Detect") lets KVM offer the feature on AMD again with LBR
> virtualization. A guest started there and moved to a host without it
> loses the bus lock #DB, which Linux uses only to warn about or throttle
> tasks that cause bus locks.
Unfortunately Linux is not the only possible guest OS. And I'm afraid
both Linux and QEMU behavior may change in the future so we should not
rely on it.
>
> Add bus-lock-detect next to spec-ctrl in the table of droppable
> features, for CPU models whose vendor is AMD: when the hypervisor
> dropped it, virCPUUpdateLive() disables it in the live definition and
> removes it from the features QEMU reports as filtered. Intel keeps
> failing: VMX has virtualized bus lock detection since 76ea438b4afc, so
> a missing bit there is a real loss.
So in contrast to the spec-ctrl situation, this looks like we have no
reliable way to decide whether it is safe to ignore this feature if it
is missing.
Jirka