Linux Confidential Computing Development
 help / color / mirror / Atom feed
From: "Nikunj A. Dadhania" <nikunj@amd.com>
To: Borislav Petkov <bp@alien8.de>, Ashish Kalra <Ashish.Kalra@amd.com>
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: Tue, 24 Nov 2026 14:25:03 +0530	[thread overview]
Message-ID: <ffcba80a-9a75-4fcd-983e-decfc5f846f4@amd.com> (raw)
In-Reply-To: <20261123234341.GCawTPrczGd6iM_Uby@fat_crate.local>

Hi Boris,

On 11/24/2026 5:13 AM, Borislav Petkov wrote:
> On Mon, Nov 16, 2026 at 11:03:35PM +0000, Ashish Kalra wrote:
>> From: Ashish Kalra <ashish.kalra@amd.com>
>>
>> machine_kexec() calls hw_breakpoint_disable(), which writes DR7. On
>> SEV-ES/SNP guests that do not have DebugSwap enabled, DR7 accesses are
>> intercepted and delivered to the guest as a #VC exception, which must be
>> serviced through the GHCB.
>>
>> By the time machine_kexec() runs, snp_kexec_finish() (called from
>> native_machine_shutdown()) has already converted the per-CPU GHCBs and
>> the boot GHCB back to private and set boot_ghcb to NULL, tearing down the
>> GHCB infrastructure. The DR7 write therefore raises a #VC that
>> dereferences a NULL GHCB pointer, causing a page fault and the kexec to
>> fail.
>>
>> The NULL boot_ghcb pointer is a result of commit 3645eb7e3915 ("x86/fred:
>> Fix early boot failures on SEV-ES/SNP guests"): that change makes
>> __sev_get_ghcb() return the now-NULL boot_ghcb in this window, turning
>> the previously-benign teardown-window #VC (a bogus VMGEXIT the host
>> rejected but survived) into a NULL dereference.
> 
> So, before that patch from Nikunj, __sev_get_ghcb() would return the per-CPU
> GHCBs which are not initialized. That was fine for the kexec case - I don't
> understand the bogus VMGEXIT thing - but apparently it worked there.

Before 3645eb7e3915, the DR7 write during kexec was silently dropped by the
hypervisor because the GHCB had already been converted back to private. The
guest did not notice and carried on, so kexec only worked because nothing
depended on that write.

Regards,
Nikunj


      parent reply	other threads:[~2026-11-24  8:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 23:03 [PATCH v2] x86/sev: Skip DR7 write during kexec when it would trigger an unserviceable #VC 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-24  8:55   ` Nikunj A. Dadhania [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=ffcba80a-9a75-4fcd-983e-decfc5f846f4@amd.com \
    --to=nikunj@amd.com \
    --cc=Ashish.Kalra@amd.com \
    --cc=Srikanth.Aithal@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