From nobody Mon May 25 01:16:06 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 112F231AA9B; Tue, 19 May 2026 21:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779225931; cv=none; b=PG769Aa2w0/JqtuYdU2273cXlODBrekdfYUtLsBr3IB8wnDkDMinucC7uFm21WrHvwICWk2/x6jeUaB47rmjuXUjpt/tj8vUEJGNsfN+TTHEs83EKgA0P1yzhz4Pe7i7evseQ1Favvol9YnTumdcY4WMb5wNUMbrW9J7JBAvnt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779225931; c=relaxed/simple; bh=aGeFjlvgpUN5hwRfl2hUv78d4MiDvS8GLrP+PfFjVAw=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=tGmVTnKa9d6xQaxuG7iPVrgrfnH23GVduKTKkUoi5ZqCl4VPFgPBgebwG66SxUa2F2Rxrh0tMLNIG0Je0pg2ojLC1zGQCpuH7JBhyFyl2ERPhdaW2YHN2k0LXtV3c7wEXfcEJlNlyJjer5cidNCaKa0JwTBv2HACFK/8/cz8uw8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=34tsxp+T; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=8VQGJta/; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="34tsxp+T"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="8VQGJta/" Date: Tue, 19 May 2026 21:25:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779225927; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PKHf1e17u9euVjlOp2OhrQyj57u35zq2jlPZwgG95S0=; b=34tsxp+T86m2RB4zLnaZR6M1akTR9strrS+fzRH7KSEzLWfjv94cR1XQtiH1gu/m94ijWs +mHcNVjDnVNjhy3P3AFHO85f+6/3J22Dlc+C+FGCty0K2vLh+lxZ9Yp5fMjQensUTqGREd 0RBcYtGKxZ4/Cz3oSyeCF/ivt7FfPxuIaE2qJXYcXTHRqj20groB2AFwD0ubK0Ky9brKUP wzCB87bR/AFmq7CktfuH5g3jw5Ymif55Rcj5nMgJGH4EZuJsXwDE9qUs3xCJKk2ehAGYxb pRGP+cDuYkA3jOWY7+6WZSbXqR+ihQn5IZ5emN85h6cQAiDYlyzfn6EZxLnx/w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779225927; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PKHf1e17u9euVjlOp2OhrQyj57u35zq2jlPZwgG95S0=; b=8VQGJta/+QJMxOFQaEOpItP7B3/bveQob62iLqJ3PhdgEz82ck2bn4/Nl6TCuc51/qf62E fVbxFSy2E3nIQ2Dw== From: "tip-bot2 for Nikunj A Dadhania" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/sev] x86/sev: Remove redundant ghcbs_initialized checks around __sev_{get,put}_ghcb() Cc: Tom Lendacky , Nikunj A Dadhania , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260518102230.3394603-1-nikunj@amd.com> References: <20260518102230.3394603-1-nikunj@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177922592537.711.16700749751242647359.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/sev branch of tip: Commit-ID: 9d8460a1c7a6b0f2dc6302e5d0f31d4e8c2a7913 Gitweb: https://git.kernel.org/tip/9d8460a1c7a6b0f2dc6302e5d0f31d4e8= c2a7913 Author: Nikunj A Dadhania AuthorDate: Mon, 18 May 2026 10:22:30=20 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 19 May 2026 13:31:29 -07:00 x86/sev: Remove redundant ghcbs_initialized checks around __sev_{get,put}_g= hcb() After 3645eb7e3915 ("x86/fred: Fix early boot failures on SEV-ES/SNP guests"), __sev_{get,put}_ghcb() handle the early-boot GHCB fallback internally, maki= ng the ghcbs_initialized guards in __set_pages_state() and svsm_perform_call_protocol() redundant. Remove them. Also initialize state->ghcb to NULL in the early-boot path of __sev_get_ghcb() so that the ghcb_state is well-defined for all callers, even though __sev_put_ghcb() currently returns early before reading it. No functional change intended. Suggested-by: Tom Lendacky Signed-off-by: Nikunj A Dadhania Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Tom Lendacky Link: https://patch.msgid.link/20260518102230.3394603-1-nikunj@amd.com --- arch/x86/coco/sev/core.c | 8 ++------ arch/x86/coco/sev/noinstr.c | 4 +++- arch/x86/coco/sev/svsm.c | 10 ++-------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c index 7ed3da9..ecd77d3 100644 --- a/arch/x86/coco/sev/core.c +++ b/arch/x86/coco/sev/core.c @@ -367,17 +367,13 @@ static unsigned long __set_pages_state(struct snp_psc= _desc *data, unsigned long=20 =20 local_irq_save(flags); =20 - if (sev_cfg.ghcbs_initialized) - ghcb =3D __sev_get_ghcb(&state); - else - ghcb =3D boot_ghcb; + ghcb =3D __sev_get_ghcb(&state); =20 /* Invoke the hypervisor to perform the page state changes */ if (!ghcb || vmgexit_psc(ghcb, data)) sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_PSC); =20 - if (sev_cfg.ghcbs_initialized) - __sev_put_ghcb(&state); + __sev_put_ghcb(&state); =20 local_irq_restore(flags); =20 diff --git a/arch/x86/coco/sev/noinstr.c b/arch/x86/coco/sev/noinstr.c index 5afd663..e1e03f1 100644 --- a/arch/x86/coco/sev/noinstr.c +++ b/arch/x86/coco/sev/noinstr.c @@ -121,8 +121,10 @@ noinstr struct ghcb *__sev_get_ghcb(struct ghcb_state = *state) =20 WARN_ON(!irqs_disabled()); =20 - if (!sev_cfg.ghcbs_initialized) + if (!sev_cfg.ghcbs_initialized) { + state->ghcb =3D NULL; return boot_ghcb; + } =20 data =3D this_cpu_read(runtime_data); ghcb =3D &data->ghcb_page; diff --git a/arch/x86/coco/sev/svsm.c b/arch/x86/coco/sev/svsm.c index 2acf4a7..916d62c 100644 --- a/arch/x86/coco/sev/svsm.c +++ b/arch/x86/coco/sev/svsm.c @@ -74,20 +74,14 @@ int svsm_perform_call_protocol(struct svsm_call *call) =20 flags =3D native_local_irq_save(); =20 - if (sev_cfg.ghcbs_initialized) - ghcb =3D __sev_get_ghcb(&state); - else if (boot_ghcb) - ghcb =3D boot_ghcb; - else - ghcb =3D NULL; + ghcb =3D __sev_get_ghcb(&state); =20 do { ret =3D ghcb ? svsm_perform_ghcb_protocol(ghcb, call) : __pi_svsm_perform_msr_protocol(call); } while (ret =3D=3D -EAGAIN); =20 - if (sev_cfg.ghcbs_initialized) - __sev_put_ghcb(&state); + __sev_put_ghcb(&state); =20 native_local_irq_restore(flags); =20