From: sashiko-bot@kernel.org
To: "Hao Zhang" <hao_zhang_kdev@163.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 1/2] KVM: nSVM: Restore L1's debug registers on nested VM-Exit
Date: Thu, 27 Aug 2026 05:52:38 +0000 [thread overview]
Message-ID: <20260827055239.5A6C31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <ao_Ms5alWwKa30U8@192.168.1.215>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Restoring L1's architectural DR6 and DR7 from the hardware `vmcb01->save` state on nested VM-Exit corrupts L1's debug state and leaks host debugging information.
--
commit cba4fc9e5c8bde0943c94c7835fb0e3712e3df8e
Author: Hao Zhang <zhanghao1@kylinos.cn>
KVM: nSVM: Restore L1's debug registers on nested VM-Exit
This commit restores L1's DR6 and DR7 when emulating a nested VM-Exit from L2
to L1. It copies the debug states from vmcb01 to prevent L1 from observing
stale L2 state or losing its DR7 state.
> diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
> index 73f37b050d0a0..e7975ac7bfca2 100644
> --- a/arch/x86/kvm/svm/nested.c
> +++ b/arch/x86/kvm/svm/nested.c
> @@ -1427,7 +1427,8 @@ void nested_svm_vmexit(struct vcpu_svm *svm)
> kvm_rsp_write(vcpu, vmcb01->save.rsp);
> kvm_rip_write(vcpu, vmcb01->save.rip);
>
> - svm->vcpu.arch.dr7 = DR7_FIXED_1;
> + svm->vcpu.arch.dr6 = vmcb01->save.dr6;
> + svm->vcpu.arch.dr7 = vmcb01->save.dr7;
[Severity: High]
Does copying the hardware state from vmcb01->save back into the software
structures here in nested_svm_vmexit() corrupt L1's architectural debug state?
If KVM intercepts debug registers (which is the default) or if the host is
actively debugging the guest, vmcb01->save contains host-controlled values
like DR6_ACTIVE_LOW or vcpu->arch.guest_debug_dr7.
Overwriting L1's software-tracked DR6 destroys pending L1 debug exceptions,
while pulling the host-polluted DR7 permanently leaks host-level breakpoints
to the unprivileged L1 guest.
> kvm_update_dr7(&svm->vcpu);
>
> nested_svm_transition_tlb_flush(vcpu);
--
Sashiko AI review · https://sashiko.dev/#/patchset/ao_Ms5alWwKa30U8@192.168.1.215?part=1
next prev parent reply other threads:[~2026-08-27 5:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 5:35 [PATCH 1/2] KVM: nSVM: Restore L1's debug registers on nested VM-Exit Hao Zhang
2026-08-27 5:38 ` [PATCH 2/2] selftests: kvm: Add regression test for nSVM debug register state Hao Zhang
2026-08-27 5:52 ` sashiko-bot [this message]
2026-08-27 13:43 ` [PATCH 1/2] KVM: nSVM: Restore L1's debug registers on nested VM-Exit Sean Christopherson
2026-08-28 1:11 ` Hao Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260827055239.5A6C31F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hao_zhang_kdev@163.com \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.