Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Hao Zhang <hao_zhang_kdev@163.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Hao Zhang <hao_zhang_kdev@163.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org
Subject: Re: [PATCH 1/2] KVM: nSVM: Restore L1's debug registers on nested VM-Exit
Date: Fri, 28 Aug 2026 09:11:30 +0800	[thread overview]
Message-ID: <apDgQmZiieX9mCft@192.168.1.215> (raw)
In-Reply-To: <apA-9UEveHuHhKkV@google.com>

On Thu, Aug 27, 2026, Sean Christopherson wrote:
> On Thu, Aug 27, 2026, Hao Zhang wrote:
> > From: Hao Zhang <zhanghao1@kylinos.cn>
> > 
> > Restore L1's DR6 and DR7 when emulating a nested VM-Exit from L2 to L1.
> > KVM loads L2's debug register state from vmcb12 on nested VMRUN, but
> > currently restores DR7 to its reset value and leaves DR6 untouched when
> > switching back to vmcb01.  As a result, L1 can observe stale L2 DR6 state
> > and lose its DR7 state after an L2 VM-Exit.
> 
> Well, yeah, because the APM says so.  The APM very clearly says:
> 
>   Disables all breakpoints in the host DR7 register.
> 
> In typical APM fashion, it says nothing about DR6, so it's reasonable to assume
> it's preserved as-is across #VMEXIT, i.e. is L1's responsibility to ignore since
> there's no #DB.
>
Thanks. I checked the APM which requires #VMEXIT disables all breakpoints in
the host DR7 register, which means KVM's DR7_FIXED_1 restore on nested VM-Exit 
is intentional architectural behavior for L1-as-host, not a lost-state bug.

I'll drop this patch as-is.

Thanks,
Hao
> > Restore both registers from vmcb01, matching the rest of the L1 processor
> > state restored on nested VM-Exit.
> 
> What happens to other state is irrelevant, what matters is what the architecture
> says happens.


      reply	other threads:[~2026-08-28  1:11 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 ` [PATCH 1/2] KVM: nSVM: Restore L1's debug registers on nested VM-Exit sashiko-bot
2026-08-27 13:43 ` Sean Christopherson
2026-08-28  1:11   ` Hao Zhang [this message]

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=apDgQmZiieX9mCft@192.168.1.215 \
    --to=hao_zhang_kdev@163.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox