public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: Nikunj A Dadhania <nikunj@amd.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org, bp@alien8.de
Cc: tglx@kernel.org, mingo@redhat.com, dave.hansen@linux.intel.com,
	hpa@zytor.com, xin@zytor.com, seanjc@google.com,
	pbonzini@redhat.com, x86@kernel.org, sohil.mehta@intel.com,
	jon.grimm@amd.com
Subject: Re: [PATCH v2 2/2] x86/fred: Fix early boot failures on SEV-ES/SNP guests
Date: Thu, 26 Feb 2026 08:14:59 -0600	[thread overview]
Message-ID: <c92d46a3-48a9-48ba-bc65-4eb0df290dcd@amd.com> (raw)
In-Reply-To: <20260226092349.803491-3-nikunj@amd.com>

On 2/26/26 03:23, Nikunj A Dadhania wrote:
> FRED-enabled SEV-ES and SNP guests fail to boot due to the following issues
> in the early boot sequence:
> 
> * FRED does not have a #VC exception handler in the dispatch logic
> 
> * Early FRED #VC exceptions attempt to use uninitialized per-CPU GHCBs
>   instead of boot_ghcb
> 
> Add X86_TRAP_VC case to fred_hwexc() with a new exc_vmm_communication()
> function that provides the unified entry point FRED requires, dispatching
> to existing user/kernel handlers based on privilege level. The function is
> already declared via DECLARE_IDTENTRY_VC().
> 
> Fix early GHCB access by falling back to boot_ghcb in
> __sev_{get,put}_ghcb() when per-CPU GHCBs are not yet initialized.
> 
> Fixes: 14619d912b65 ("x86/fred: FRED entry/exit and dispatch code")
> Cc: stable@vger.kernel.org # 6.9+
> Signed-off-by: Nikunj A Dadhania <nikunj@amd.com>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

Looking at the code, I think there are a couple of call sights that can
be simplified now. Can you verify that? Then as a follow-on patch,
replace the checks in arch/x86/coco/sev/core.c to just call
__sev_{get,put}_ghcb() now (svsm_perform_call_protocol() and
__set_pages_state())?

Thanks,
Tom

> ---
>  arch/x86/coco/sev/noinstr.c |  6 ++++++
>  arch/x86/entry/entry_fred.c | 14 ++++++++++++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/arch/x86/coco/sev/noinstr.c b/arch/x86/coco/sev/noinstr.c
> index 9d94aca4a698..5afd663a1c21 100644
> --- a/arch/x86/coco/sev/noinstr.c
> +++ b/arch/x86/coco/sev/noinstr.c
> @@ -121,6 +121,9 @@ noinstr struct ghcb *__sev_get_ghcb(struct ghcb_state *state)
>  
>  	WARN_ON(!irqs_disabled());
>  
> +	if (!sev_cfg.ghcbs_initialized)
> +		return boot_ghcb;
> +
>  	data = this_cpu_read(runtime_data);
>  	ghcb = &data->ghcb_page;
>  
> @@ -164,6 +167,9 @@ noinstr void __sev_put_ghcb(struct ghcb_state *state)
>  
>  	WARN_ON(!irqs_disabled());
>  
> +	if (!sev_cfg.ghcbs_initialized)
> +		return;
> +
>  	data = this_cpu_read(runtime_data);
>  	ghcb = &data->ghcb_page;
>  
> diff --git a/arch/x86/entry/entry_fred.c b/arch/x86/entry/entry_fred.c
> index 88c757ac8ccd..fbe2d10dd737 100644
> --- a/arch/x86/entry/entry_fred.c
> +++ b/arch/x86/entry/entry_fred.c
> @@ -177,6 +177,16 @@ static noinstr void fred_extint(struct pt_regs *regs)
>  	}
>  }
>  
> +#ifdef CONFIG_AMD_MEM_ENCRYPT
> +noinstr void exc_vmm_communication(struct pt_regs *regs, unsigned long error_code)
> +{
> +	if (user_mode(regs))
> +		return user_exc_vmm_communication(regs, error_code);
> +	else
> +		return kernel_exc_vmm_communication(regs, error_code);
> +}
> +#endif
> +
>  static noinstr void fred_hwexc(struct pt_regs *regs, unsigned long error_code)
>  {
>  	/* Optimize for #PF. That's the only exception which matters performance wise */
> @@ -207,6 +217,10 @@ static noinstr void fred_hwexc(struct pt_regs *regs, unsigned long error_code)
>  #ifdef CONFIG_X86_CET
>  	case X86_TRAP_CP: return exc_control_protection(regs, error_code);
>  #endif
> +#ifdef CONFIG_AMD_MEM_ENCRYPT
> +	case X86_TRAP_VC: return exc_vmm_communication(regs, error_code);
> +#endif
> +
>  	default: return fred_bad_type(regs, error_code);
>  	}
>  


  reply	other threads:[~2026-02-26 14:15 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-26  9:23 [PATCH v2 0/2] x86/fred: Fix SEV-ES/SNP guest boot failures Nikunj A Dadhania
2026-02-26  9:23 ` [PATCH v2 1/2] x86/cpu: Disable CR pinning during CPU bringup Nikunj A Dadhania
2026-03-09 13:46   ` Borislav Petkov
2026-03-09 15:38     ` Dave Hansen
2026-03-09 16:15       ` Borislav Petkov
2026-03-09 18:03         ` Dave Hansen
2026-03-09 18:40           ` Tom Lendacky
2026-03-09 19:27             ` Dave Hansen
2026-03-11 10:41               ` Nikunj A. Dadhania
2026-03-11 14:07                 ` Dave Hansen
2026-03-11 15:42                   ` Nikunj A. Dadhania
2026-03-11 17:28                     ` Dave Hansen
2026-03-12  7:21                       ` Nikunj A. Dadhania
2026-03-12  7:26                         ` Nikunj A. Dadhania
2026-03-12 14:08                       ` Nikunj A. Dadhania
2026-03-12 14:20                         ` Dave Hansen
2026-03-12 14:53                           ` Nikunj A. Dadhania
2026-03-12 15:02                             ` Dave Hansen
2026-03-12 19:06                               ` David Laight
2026-03-16 20:27                           ` Chang S. Bae
2026-03-16 21:43                             ` Dave Hansen
2026-03-17  4:12                               ` Nikunj A. Dadhania
2026-03-17 14:26                                 ` Borislav Petkov
2026-03-17 15:31                                 ` Dave Hansen
2026-03-17 16:54                                   ` Borislav Petkov
2026-03-18  8:19                                     ` Nikunj A. Dadhania
2026-03-17 17:04                               ` Chang S. Bae
2026-03-17 17:51                                 ` Chang S. Bae
2026-03-12 18:09                         ` Sohil Mehta
2026-03-13  8:35                           ` Nikunj A. Dadhania
2026-03-13 18:05                             ` Sohil Mehta
2026-03-13 19:10                               ` Borislav Petkov
2026-03-17 17:06                             ` Chang S. Bae
2026-02-26  9:23 ` [PATCH v2 2/2] x86/fred: Fix early boot failures on SEV-ES/SNP guests Nikunj A Dadhania
2026-02-26 14:14   ` Tom Lendacky [this message]
2026-02-27  4:14     ` 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=c92d46a3-48a9-48ba-bc65-4eb0df290dcd@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jon.grimm@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nikunj@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=sohil.mehta@intel.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    --cc=xin@zytor.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