From: "Nikunj A. Dadhania" <nikunj@amd.com>
To: "Kalra, Ashish" <ashish.kalra@amd.com>, Borislav Petkov <bp@alien8.de>
Cc: <tglx@kernel.org>, <mingo@redhat.com>,
<dave.hansen@linux.intel.com>, <x86@kernel.org>, <hpa@zytor.com>,
<thomas.lendacky@amd.com>, <Srikanth.Aithal@amd.com>,
<kvm@vger.kernel.org>, <linux-coco@lists.linux.dev>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] x86/sev: Skip DR7 write during kexec when it would trigger an unserviceable #VC
Date: Thu, 26 Nov 2026 14:57:51 +0530 [thread overview]
Message-ID: <e1b1d00b-b53a-4c6b-a746-72ed2058134a@amd.com> (raw)
In-Reply-To: <5acdbdc5-0c9e-4db8-a21c-fa011ba0bd57@amd.com>
On 11/26/2026 1:59 AM, Kalra, Ashish wrote:
> Hello Boris,
>
> On 11/24/2026 10:19 PM, Borislav Petkov wrote:
>> On Mon, Nov 23, 2026 at 06:22:09PM -0600, Kalra, Ashish wrote:
>>> On the "bogus VMGEXIT": before Nikunj's change, __sev_get_ghcb() returned
>>> the per-CPU GHCB, which snp_kexec_finish() had already converted back to
>>> private. The host mapped that GPA, read ciphertext (exit code 0) and
>>> returned GHCB_ERR_MISSING_INPUT, but couldn't write the result into the
>>> private page, so the guest saw its own stale contents, treated the call as
>>> successful and moved on. The DR7 write was simply dropped. It worked by
>>> accident.
>>
>> Oh lovely.
>>
>>> As for using do_vc_no_ghcb(): the GHCB MSR protocol requests are meant for
>>> specific guest-initiated operations (protocol negotiation, GHCB
>>> registration, page state changes, termination, etc.). The only one that
>>> corresponds to an intercepted instruction is CPUID, which is why
>>> do_vc_no_ghcb() handles only the CPUID exit code and terminates the guest
>>> for anything else. There's no MSR-protocol equivalent of a DR7 write, so the
>>> no-GHCB #VC handler can't handle it.
>>
>> Well, can you fashion something with VMEXIT_DR7_WRITE and a dummy GHCB MSR request
>> to the HV which is innocuous, just so that it can satisfy the flow?
>>
>
> We could issue a harmless MSR-protocol request and then skip the instruction,
> but the request wouldn't carry anything about the DR7 write. The hypervisor
> would end up in exactly the same state as if we just skipped it, so it would
> be an extra exit that doesn't actually communicate anything.
>
> So how about doing it in the #VC handler: once the GHCBs have been torn down,
> route the #VC to a GHCB-less path that decodes and skips DR7 accesses, completing
> them locally, and the kexec then proceeds normally.
Agreed on handling it in the #VC handler rather than in do_vc_no_ghcb().
If the DR7 skip lived there, it would have to decode the write and advance RIP
itself, and the startup code doesn't link the x86 instruction decoder. The
runtime handler already has vc_decode_insn() and vc_finish_insn().
> This is safe: without DebugSwap,
> KVM intercepts DR7 accesses and only tracks the value, it can't load it into the
> encrypted VMSA, and the kexec'ed kernel writes DR7 again in cpu_init() anyway. Any
> other #VC in that window, which can't be completed without the hypervisor, would
> terminate the guest with a specific reason code instead of dereferencing a NULL
> GHCB, so it gets caught explicitly rather than silently skipped.
Regards
Nikunj
next prev parent reply other threads:[~2026-11-26 9:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 23:03 Ashish Kalra
2026-11-17 7:10 ` Aithal, Srikanth
2026-11-23 23:43 ` Borislav Petkov
2026-11-24 0:22 ` Kalra, Ashish
2026-11-25 4:19 ` Borislav Petkov
2026-11-25 20:29 ` Kalra, Ashish
2026-11-26 9:27 ` Nikunj A. Dadhania [this message]
2026-11-24 8:55 ` Nikunj A. Dadhania
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=e1b1d00b-b53a-4c6b-a746-72ed2058134a@amd.com \
--to=nikunj@amd.com \
--cc=Srikanth.Aithal@amd.com \
--cc=ashish.kalra@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@kernel.org \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®