CVE-2025-21839: KVM: x86: Load DR6 with guest value only before entering .vcpu_run() loop

Published Mar 7, 2025
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

KVM: x86: Load DR6 with guest value only before entering .vcpurun() loop

Move the conditional loading of hardware DR6 with the guest's DR6 value out of the core .vcpurun() loop to fix a bug where KVM can load hardware with a stale vcpu->arch.dr6.

When the guest accesses a DR and host userspace isn't debugging the guest, KVM disables DR interception and loads the guest's values into hardware on VM-Enter and saves them on VM-Exit. This allows the guest to access DRs at will, e.g. so that a sequence of DR accesses to configure a breakpoint only generates one VM-Exit.

For DR0-DR3, the logic/behavior is identical between VMX and SVM, and also identical between KVMDEBUGREGBPENABLED (userspace debugging the guest) and KVMDEBUGREGWONTEXIT (guest using DRs), and so KVM handles loading DR0-DR3 in common code, outside of the core kvmx86ops.vcpurun() loop.

But for DR6, the guest's value doesn't need to be loaded into hardware for KVMDEBUGREGBPENABLED, and SVM provides a dedicated VMCB field whereas VMX requires software to manually load the guest value, and so loading the guest's value into DR6 is handled by {svm,vmx}vcpurun(), i.e. is done inside the core run loop.

Unfortunately, saving the guest values on VM-Exit is initiated by common x86, again outside of the core run loop. If the guest modifies DR6 (in hardware, when DR interception is disabled), and then the next VM-Exit is a fastpath VM-Exit, KVM will reload hardware DR6 with vcpu->arch.dr6 and clobber the guest's actual value.

The bug shows up primarily with nested VMX because KVM handles the VMX preemption timer in the fastpath, and the window between hardware DR6 being modified (in guest context) and DR6 being read by guest software is orders of magnitude larger in a nested setup. E.g. in non-nested, the VMX preemption timer would need to fire precisely between #DB injection and the #DB handler's read of DR6, whereas with a KVM-on-KVM setup, the window where hardware DR6 is "dirty" extends all the way from L1 writing DR6 to VMRESUME (in L1).

L1's view: ========== <L1 disables DR interception> CPU 0/KVM-7289 [023] d.... 2925.640961: kvmentry: vcpu 0 A: L1 Writes DR6 CPU 0/KVM-7289 [023] d.... 2925.640963: <hack>: Set DRs, DR6 = 0xffff0ff1

B: CPU 0/KVM-7289 [023] d.... 2925.640967: kvmexit: vcpu 0 reason EXTERNALINTERRUPT intrinfo 0x800000ec

D: L1 reads DR6, arch.dr6 = 0 CPU 0/KVM-7289 [023] d.... 2925.640969: <hack>: Sync DRs, DR6 = 0xffff0ff0

CPU 0/KVM-7289 [023] d.... 2925.640976: kvmentry: vcpu 0 L2 reads DR6, L1 disables DR interception CPU 0/KVM-7289 [023] d.... 2925.640980: kvmexit: vcpu 0 reason DRACCESS info1 0x0000000000000216 CPU 0/KVM-7289 [023] d.... 2925.640983: kvmentry: vcpu 0

CPU 0/KVM-7289 [023] d.... 2925.640983: <hack>: Set DRs, DR6 = 0xffff0ff0

L2 detects failure CPU 0/KVM-7289 [023] d.... 2925.640987: kvmexit: vcpu 0 reason HLT L1 reads DR6 (confirms failure) CPU 0/KVM-7289 [023] d.... 2925.640990: <hack>: Sync DRs, DR6 = 0xffff0ff0

L0's view: ========== L2 reads DR6, arch.dr6 = 0 CPU 23/KVM-5046 [001] d.... 3410.005610: kvmexit: vcpu 23 reason DRACCESS info1 0x0000000000000216 CPU 23/KVM-5046 [001] ..... 3410.005610: kvmnestedvmexit: vcpu 23 reason DRACCESS info1 0x0000000000000216

L2 => L1 nested VM-Exit CPU 23/KVM-5046 [001] ..... 3410.005610: kvmnestedvmexitinject: reason: DRACCESS extinf1: 0x0000000000000216

CPU 23/KVM-5046 [001] d.... 3410.005610: kvmentry: vcpu 23 CPU 23/KVM-5046 [001] d.... 3410.005611: kvmexit: vcpu 23 reason VMREAD CPU 23/KVM-5046 [001] d.... 3410.005611: kvmentry: vcpu 23 CPU 23/KVM-5046 [001] d.... 3410. ---truncated---

Other sources

In the Linux kernel, the following vulnerability has been resolved:

KVM: x86: Load DR6 with guest value only before entering .vcpurun() loop

Move the conditional loading of hardware DR6 with the guest's DR6 value out of the core .vcpurun() loop to fix a bug where KVM can load hardware with a stale vcpu-arch.dr6.

When the guest accesses a DR and host userspace isn't debugging the guest, KVM disables DR interception and loads the guest's values into hardware on VM-Enter and saves them on VM-Exit. This allows the guest to access DRs at will, e.g. so that a sequence of DR accesses to configure a breakpoint only generates one VM-Exit.

For DR0-DR3, the logic/behavior is identical between VMX and SVM, and also identical between KVMDEBUGREGBPENABLED (userspace debugging the guest) and KVMDEBUGREGWONTEXIT (guest using DRs), and so KVM handles loading DR0-DR3 in common code, outside of the core kvmx86ops.vcpurun() loop.

But for DR6, the guest's value doesn't need to be loaded into hardware for KVMDEBUGREGBPENABLED, and SVM provides a dedicated VMCB field whereas VMX requires software to manually load the guest value, and so loading the guest's value into DR6 is handled by {svm,vmx}vcpurun(), i.e. is done inside the core run loop.

Unfortunately, saving the guest values on VM-Exit is initiated by common x86, again outside of the core run loop. If the guest modifies DR6 (in hardware, when DR interception is disabled), and then the next VM-Exit is a fastpath VM-Exit, KVM will reload hardware DR6 with vcpu-arch.dr6 and clobber the guest's actual value.

The bug shows up primarily with nested VMX because KVM handles the VMX preemption timer in the fastpath, and the window between hardware DR6 being modified (in guest context) and DR6 being read by guest software is orders of magnitude larger in a nested setup. E.g. in non-nested, the VMX preemption timer would need to fire precisely between #DB injection and the #DB handler's read of DR6, whereas with a KVM-on-KVM setup, the window where hardware DR6 is "dirty" extends all the way from L1 writing DR6 to VMRESUME (in L1).

L1's view: ========== L1 disables DR interception CPU 0/KVM-7289 [023] d.... 2925.640961: kvmentry: vcpu 0 A: L1 Writes DR6 CPU 0/KVM-7289 [023] d.... 2925.640963: hack: Set DRs, DR6 = 0xffff0ff1

B: CPU 0/KVM-7289 [023] d.... 2925.640967: kvmexit: vcpu 0 reason EXTERNALINTERRUPT intrinfo 0x800000ec

D: L1 reads DR6, arch.dr6 = 0 CPU 0/KVM-7289 [023] d.... 2925.640969: hack: Sync DRs, DR6 = 0xffff0ff0

CPU 0/KVM-7289 [023] d.... 2925.640976: kvmentry: vcpu 0 L2 reads DR6, L1 disables DR interception CPU 0/KVM-7289 [023] d.... 2925.640980: kvmexit: vcpu 0 reason DRACCESS info1 0x0000000000000216 CPU 0/KVM-7289 [023] d.... 2925.640983: kvmentry: vcpu 0

CPU 0/KVM-7289 [023] d.... 2925.640983: hack: Set DRs, DR6 = 0xffff0ff0

L2 detects failure CPU 0/KVM-7289 [023] d.... 2925.640987: kvmexit: vcpu 0 reason HLT L1 reads DR6 (confirms failure) CPU 0/KVM-7289 [023] d.... 2925.640990: hack: Sync DRs, DR6 = 0xffff0ff0

L0's view: ========== L2 reads DR6, arch.dr6 = 0 CPU 23/KVM-5046 [001] d.... 3410.005610: kvmexit: vcpu 23 reason DRACCESS info1 0x0000000000000216 CPU 23/KVM-5046 [001] ..... 3410.005610: kvmnestedvmexit: vcpu 23 reason DRACCESS info1 0x0000000000000216

L2 = L1 nested VM-Exit CPU 23/KVM-5046 [001] ..... 3410.005610: kvmnestedvmexitinject: reason: DRACCESS extinf1: 0x0000000000000216

CPU 23/KVM-5046 [001] d.... 3410.005610: kvmentry: vcpu 23 CPU 23/KVM-5046 [001] d.... 3410.005611: kvmexit: vcpu 23 reason VMREAD CPU 23/KVM-5046 [001] d.... 3410.005611: kvmentry: vcpu 23 CPU 23/KVM-5046 [001] d.... 3410. ---truncated---

IBM

Affected Software

17 affected componentsFixes available
Linux Linux kernel
Linux Linux kernel>=5.7.1<5.15.182
Linux Linux kernel>=5.16<6.1.138
Linux Linux kernel>=6.2<6.6.90
Linux Linux kernel>=6.7<6.12.16
Linux Linux kernel>=6.13<6.13.4
Linux Linux kernel=5.7
Linux Linux kernel=5.7-rc6
Linux Linux kernel=5.7-rc7
Linux Linux kernel=6.14-rc1
Linux Linux kernel=6.14-rc2
Microsoft azl3 kernel 6.6.85.1-4
Microsoft azl3 kernel 6.6.92.2-1
IBM Verify Identity Access<=11.0 - 11.0.2
IBM Security Verify Access<=10.0 - 10.0.9.1
IBM Verify Identity Access Container<=11.0 - 11.0.2
IBM Security Verify Access Container<=10.0 - 10.0.9.1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade Linux kernel (KVM/x86: DR6 handling) to a version that resolves this vulnerability.

    Patch KVM: x86: Load DR6 with guest value only before entering .vcpu_run() loop

Event History

Mar 7, 2025
CVE Published
via MITRE·09:09 AM
Data Sourced
via MITRE·09:09 AM
Description
Data Sourced
via NVD·09:15 AM
RemedyDescriptionSeverityAffected Software
Data Sourced
via Red Hat·10:01 AM
DescriptionSeverityAffected Software
Jul 11, 2025
Data Sourced
via Microsoft·07:00 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·07:00 AM
Affected Software
Updated
via Microsoft·07:00 AM
DescriptionSeverity
Jul 8, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2025-21839?

CVE-2025-21839 has a medium severity level due to its potential to cause issues with KVM guest virtualization.

2

How do I fix CVE-2025-21839?

To fix CVE-2025-21839, update to the latest patched version of the Linux kernel as released by the maintainers.

3

What systems are affected by CVE-2025-21839?

CVE-2025-21839 affects systems that utilize the Linux kernel with KVM for virtualization.

4

What is the nature of the vulnerability in CVE-2025-21839?

CVE-2025-21839 is related to the incorrect loading of the DR6 register value in KVM before entering the .vcpu_run() loop.

5

Is there a workaround for CVE-2025-21839?

There is no specific workaround for CVE-2025-21839; updating the kernel is the recommended approach.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203