Re: [PATCH v2] x86/sev: Skip DR7 write during kexec when it would trigger an unserviceable #VC

From: Borislav Petkov

Date: Tue Nov 24 2026 - 23:19:52 EST


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?

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette