From nobody Mon Feb 9 04:28:55 2026 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45DE014A617 for ; Mon, 6 Jan 2025 15:58:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736179084; cv=none; b=Dt0OSbx2z5wkeu/ju2ETG02xoNyVt+69fJnbM2Vc95db7aCnwGCEoqfgkNGEDnvrF6qnguV+lbdqn9Yk6oYkDDZQIj7dfTtrHcm8Rl29ojqOr49mYWnEORAhADCqKXM1Z3rsq7Z86Hycb5nvu8bPHszbKQFUxDpcdkX0VoUQLLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736179084; c=relaxed/simple; bh=ob8/Hb3qw8JSiMBpuSVaczmfpPm2NXv14jVipuvSutY=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=ESzE+QrdcpP8pfGMS7jFFwe7FtMiSxj/Swf5K7Vu0L0hFwQFPuRvj79Tt35KVRhkFj2Z/RmaCp8+D2CBfMRvR0vUlBxQXpPERosRRNnov9wxyV39hKiaeaE79OmDGaU+rhUxRjJywNYwKORJ5HuN1hYV4Jjo7OvL8JG9z5EESjI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SDjLZdWB; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SDjLZdWB" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-38a540ea7c1so2908213f8f.1 for ; Mon, 06 Jan 2025 07:58:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736179080; x=1736783880; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=RbZFOTqp9pY6oEVCgNSZKghXYSnH8iL49oyi0VY3luI=; b=SDjLZdWBWBBoMREGqUWwcvXbBExvBdaF7RsB16Bg7iX4ogqvi7JoQq8pfbl/4y9mkf AlCVS/JLwhodR4h/IfgYzSTvtrTp36u5VY9pfyG+vEppxl68hZbCFtJuRe+wJt3+vGoZ dYo9ZCTgSujCLhRjREM22vETFHVsG19yhgnc5KSe4CZ3sZxo9GHYzT1ZgRP/n0sNAyOh kkQIOLUC7lMwwFf789gu5Gi1/Bj7JwHrSlNWVScWmAlj7dVK4A77LIM0EVhE36HYHalL 3/N8m9hQRHR6cQXLLp5PY6s4CbMfwD+ujntOxd0QwnF6NCIB/w2QWikbC5W1rEpa+dck GREg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736179080; x=1736783880; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=RbZFOTqp9pY6oEVCgNSZKghXYSnH8iL49oyi0VY3luI=; b=WxPdHCjW38SbtF6TJ+RbO1O85r92SvXR1vv/eXlcpSoWZAML/WALg4xavFl2yZiWDm NCNzr0rLSwLONOsno7e1wU3vi3S1P9pD9MQ+0BItSwfE6qXbT7psm1JmqG15cg9xMT/k ZcU28187qe+ufTcFW5DaNaDHoweYHUOB06DUBeDsOX4i/kq1JwKYmtnlCFeExfQMb6E9 wWugurQyNgzHOUy4gtbrhH81nOE97acJgVVHsR2oCsV+8FaHFsK4Zy4UqtAbXLhyMuHC iD6wYPzDU6REZeXwAVpV8T56zws6no4pS3rSkf7rtfwzi/MZnAEVDPth28P+UWH065yk UrdA== X-Gm-Message-State: AOJu0YyKugwyeNTZHYNdmVx1GLzwoD4sCq/mFfbxbKxMGP5gjb2IGpjF fWeM6o19qDbf7fotN/PAmA1c0dP+NO/Q+9xCJ3gRuC8ASD1AGmUBZM4cAdsB3iL84yhEJEQ3dFH LWSSMp8UA3BTEFadPvVJOZKPkO3xJ9Av0PQUhLDOFna4vK1zm24kWD5/YsIpys9Z4qdoLoIBxtY yCkXnZOfBj1E/ybSQe6bZyt7vhds9rNg== X-Google-Smtp-Source: AGHT+IH1cpFoY44/DgScMs/kQnHHIzEap0wFzKHoHkwMBwKhkoSj6iEblISTsp27dMu50+BgmOulU82H X-Received: from wrhx14.prod.google.com ([2002:adf:cc0e:0:b0:386:3e01:4d73]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:18a8:b0:388:c790:1dff with SMTP id ffacd0b85a97d-38a223f9c65mr45225219f8f.47.1736179080782; Mon, 06 Jan 2025 07:58:00 -0800 (PST) Date: Mon, 6 Jan 2025 16:57:46 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=2044; i=ardb@kernel.org; h=from:subject; bh=ksPqT9qLIeEL8wH+XTv22JnqhnkYWzYvE3KmkXI6O8c=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIb36b1V5xNONtgfV3pxc4MSoyxbnK3ua0UV/t53NjOPHN d5khwR3lLIwiHEwyIopsgjM/vtu5+mJUrXOs2Rh5rAygQxh4OIUgIk8+M7I0BJYLsBjmrRvZXR1 bH/xvlCLBU/WhRg4dGyvVj79JpxfguF/9cyvjIHfJZwbFi461Dlhj1aa4zoxHdc1N+561ynf7Tv PBAA= X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20250106155745.281221-2-ardb+git@google.com> Subject: [PATCH] x86/sev: Don't hang but terminate on failure to remap SVSM CA From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Ard Biesheuvel , Tom Lendacky Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel Commit 09d35045cd0f ("x86/sev: Avoid WARN()s and panic()s in early boot code") replaced a panic() that could potentially hit before the kernel is even mapped with a deadloop, to ensure that execution does not proceed when the condition in question hits. As Tom suggests, it is better to terminate and return to the hypervisor in this case, using a newly invented failure code to describe the failure condition. Suggested-by: Tom Lendacky Link: https://lore.kernel.org/all/9ce88603-20ca-e644-2d8a-aeeaf79cde69@amd.= com Signed-off-by: Ard Biesheuvel Reviewed-by: Tom Lendacky --- arch/x86/coco/sev/core.c | 4 ++-- arch/x86/include/asm/sev-common.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c index 499b41953e3c..86898547056e 100644 --- a/arch/x86/coco/sev/core.c +++ b/arch/x86/coco/sev/core.c @@ -2356,8 +2356,8 @@ static __head void svsm_setup(struct cc_blob_sev_info= *cc_info) call.rax =3D SVSM_CORE_CALL(SVSM_CORE_REMAP_CA); call.rcx =3D pa; ret =3D svsm_perform_call_protocol(&call); - while (ret) - cpu_relax(); /* too early to panic */ + if (ret) + sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_SVSM_CA_REMAP_FAIL); =20 RIP_REL_REF(boot_svsm_caa) =3D (struct svsm_ca *)pa; RIP_REL_REF(boot_svsm_caa_pa) =3D pa; diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-c= ommon.h index 50f5666938c0..577b64dda8b4 100644 --- a/arch/x86/include/asm/sev-common.h +++ b/arch/x86/include/asm/sev-common.h @@ -206,6 +206,7 @@ struct snp_psc_desc { #define GHCB_TERM_NO_SVSM 7 /* SVSM is not advertised in the secrets page= */ #define GHCB_TERM_SVSM_VMPL0 8 /* SVSM is present but has set VMPL to 0 */ #define GHCB_TERM_SVSM_CAA 9 /* SVSM is present but CAA is not page align= ed */ +#define GHCB_TERM_SVSM_CA_REMAP_FAIL 10 /* SVSM is present but CA could no= t be remapped */ =20 #define GHCB_RESP_CODE(v) ((v) & GHCB_MSR_INFO_MASK) =20 --=20 2.47.1.613.gc27f4b7a9f-goog