From nobody Sat Jul 11 14:55:25 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 C5A171494BC; Thu, 25 Apr 2024 15:08:01 +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=1714057683; cv=none; b=XhE+ZHStwEzR1ViA6H5FRmI6Y8H3PYD4nnDAZgvWGCulf6Zx23+1FAoj3h8sGDN8z2gb5A0P14MaCS+Snb9DmrF2aTdpUdxr4FERA0lLcalaIHzooMsLIh4OnnmfykuVseLo4V7KEYs5kxT7EfiK2DuZO8DMu9lQri2E0Xox6iE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714057683; c=relaxed/simple; bh=vbjxlZ9fr55zSok7faEH44pWS30Cwy8y7+xgJrOYiPY=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=fKbQ55sUosueSFL7q0Hcbml7ocQ+LSbzgpBj4YFVXrdIlDZcdeyl+qjXGiKFl2uUpFZmA1jIktJxyxSxDaRXro1KJ4+IEBKh2NjrqtESLZCPp/x2cCUdGuaq2YaXh4h0nDtHd2Bd8P0I+Yp/GwJ8xDek8wOz2QKIzBCtKAtd4u8= 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=XEMHB0Zg; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=3dOvG2JF; 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="XEMHB0Zg"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3dOvG2JF" Date: Thu, 25 Apr 2024 15:07:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1714057680; 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=dQrHP+BIUgux3fKnNfzwN/4PlzXExUzbIpKqr41Shz0=; b=XEMHB0ZgwojF/yMXpc6GGE3dkUmzG0GVwXTJMMAOiDraQn70RYM4fzuXF0AXVG/eKr7kgh +ASKxJP+YGtDqgKzSMUy71ULMGbSG54QbjiFv6WrNDfhLFVB3AvsQC20p3XgVN2rkJLDJT pfxXKCMU6KXht3iH+INhGkI3NxyUmPw5KMnV1t+gGbYrlhfA+4EeyhRG/sZw9RV7fbY3lJ QRabutsQw21A0pKHCs37hsJh43XJzaYumvfAtlrTtDXfsH/rpYoBwFhxWBJtaGQoL6VHtE 0a1UVKfKLsmC5/4TiS7Fry2pcPyGDe5RZCkPZqpKBYwyszBXYtZP9bh8luLKZw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1714057680; 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=dQrHP+BIUgux3fKnNfzwN/4PlzXExUzbIpKqr41Shz0=; b=3dOvG2JFLTqX4IzAe3PlsDnGItRror3ucmr/arhLXgjSsdSqS6u6qOIB8jMMWjWN/WF92d G08FUoPm8FfBKlDA== From: "tip-bot2 for Tom Lendacky" 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: Rename snp_init() in boot/compressed/sev.c Cc: Tom Lendacky , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: =?utf-8?q?=3Cafda29585c2724b9698003f24cefa77eb35f4ffb=2E17139?= =?utf-8?q?74291=2Egit=2Ethomas=2Elendacky=40amd=2Ecom=3E?= References: =?utf-8?q?=3Cafda29585c2724b9698003f24cefa77eb35f4ffb=2E171397?= =?utf-8?q?4291=2Egit=2Ethomas=2Elendacky=40amd=2Ecom=3E?= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171405767991.10875.1801205989577462423.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: 88ed43d32beb1ef3c06164c52b1c6ced47b5988b Gitweb: https://git.kernel.org/tip/88ed43d32beb1ef3c06164c52b1c6ced4= 7b5988b Author: Tom Lendacky AuthorDate: Wed, 24 Apr 2024 10:57:58 -05:00 Committer: Borislav Petkov (AMD) CommitterDate: Thu, 25 Apr 2024 16:14:25 +02:00 x86/sev: Rename snp_init() in boot/compressed/sev.c The snp_init() function in boot/compressed/sev.c is local to that file, is not called from outside of the file and is independent of the snp_init() function in kernel/sev.c. Change the name to better differentiate when each function is used. Move the renamed snp_init() and related functions up in the file to avoid having to add a forward declaration and make the function static. No functional change. Signed-off-by: Tom Lendacky Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/afda29585c2724b9698003f24cefa77eb35f4ffb.17= 13974291.git.thomas.lendacky@amd.com --- arch/x86/boot/compressed/sev.c | 162 ++++++++++++++++---------------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/arch/x86/boot/compressed/sev.c b/arch/x86/boot/compressed/sev.c index ec71846..5ad0ff4 100644 --- a/arch/x86/boot/compressed/sev.c +++ b/arch/x86/boot/compressed/sev.c @@ -413,6 +413,85 @@ void snp_check_features(void) } } =20 +/* Search for Confidential Computing blob in the EFI config table. */ +static struct cc_blob_sev_info *find_cc_blob_efi(struct boot_params *bp) +{ + unsigned long cfg_table_pa; + unsigned int cfg_table_len; + int ret; + + ret =3D efi_get_conf_table(bp, &cfg_table_pa, &cfg_table_len); + if (ret) + return NULL; + + return (struct cc_blob_sev_info *)efi_find_vendor_table(bp, cfg_table_pa, + cfg_table_len, + EFI_CC_BLOB_GUID); +} + +/* + * Initial set up of SNP relies on information provided by the + * Confidential Computing blob, which can be passed to the boot kernel + * by firmware/bootloader in the following ways: + * + * - via an entry in the EFI config table + * - via a setup_data structure, as defined by the Linux Boot Protocol + * + * Scan for the blob in that order. + */ +static struct cc_blob_sev_info *find_cc_blob(struct boot_params *bp) +{ + struct cc_blob_sev_info *cc_info; + + cc_info =3D find_cc_blob_efi(bp); + if (cc_info) + goto found_cc_info; + + cc_info =3D find_cc_blob_setup_data(bp); + if (!cc_info) + return NULL; + +found_cc_info: + if (cc_info->magic !=3D CC_BLOB_SEV_HDR_MAGIC) + sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SNP_UNSUPPORTED); + + return cc_info; +} + +/* + * Indicate SNP based on presence of SNP-specific CC blob. Subsequent chec= ks + * will verify the SNP CPUID/MSR bits. + */ +static bool early_snp_init(struct boot_params *bp) +{ + struct cc_blob_sev_info *cc_info; + + if (!bp) + return false; + + cc_info =3D find_cc_blob(bp); + if (!cc_info) + return false; + + /* + * If a SNP-specific Confidential Computing blob is present, then + * firmware/bootloader have indicated SNP support. Verifying this + * involves CPUID checks which will be more reliable if the SNP + * CPUID table is used. See comments over snp_setup_cpuid_table() for + * more details. + */ + setup_cpuid_table(cc_info); + + /* + * Pass run-time kernel a pointer to CC info via boot_params so EFI + * config table doesn't need to be searched again during early startup + * phase. + */ + bp->cc_blob_address =3D (u32)(unsigned long)cc_info; + + return true; +} + /* * sev_check_cpu_support - Check for SEV support in the CPU capabilities * @@ -463,7 +542,7 @@ void sev_enable(struct boot_params *bp) bp->cc_blob_address =3D 0; =20 /* - * Do an initial SEV capability check before snp_init() which + * Do an initial SEV capability check before early_snp_init() which * loads the CPUID page and the same checks afterwards are done * without the hypervisor and are trustworthy. * @@ -478,7 +557,7 @@ void sev_enable(struct boot_params *bp) * Setup/preliminary detection of SNP. This will be sanity-checked * against CPUID/MSR values later. */ - snp =3D snp_init(bp); + snp =3D early_snp_init(bp); =20 /* Now repeat the checks with the SNP CPUID table. */ =20 @@ -535,85 +614,6 @@ u64 sev_get_status(void) return m.q; } =20 -/* Search for Confidential Computing blob in the EFI config table. */ -static struct cc_blob_sev_info *find_cc_blob_efi(struct boot_params *bp) -{ - unsigned long cfg_table_pa; - unsigned int cfg_table_len; - int ret; - - ret =3D efi_get_conf_table(bp, &cfg_table_pa, &cfg_table_len); - if (ret) - return NULL; - - return (struct cc_blob_sev_info *)efi_find_vendor_table(bp, cfg_table_pa, - cfg_table_len, - EFI_CC_BLOB_GUID); -} - -/* - * Initial set up of SNP relies on information provided by the - * Confidential Computing blob, which can be passed to the boot kernel - * by firmware/bootloader in the following ways: - * - * - via an entry in the EFI config table - * - via a setup_data structure, as defined by the Linux Boot Protocol - * - * Scan for the blob in that order. - */ -static struct cc_blob_sev_info *find_cc_blob(struct boot_params *bp) -{ - struct cc_blob_sev_info *cc_info; - - cc_info =3D find_cc_blob_efi(bp); - if (cc_info) - goto found_cc_info; - - cc_info =3D find_cc_blob_setup_data(bp); - if (!cc_info) - return NULL; - -found_cc_info: - if (cc_info->magic !=3D CC_BLOB_SEV_HDR_MAGIC) - sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SNP_UNSUPPORTED); - - return cc_info; -} - -/* - * Indicate SNP based on presence of SNP-specific CC blob. Subsequent chec= ks - * will verify the SNP CPUID/MSR bits. - */ -bool snp_init(struct boot_params *bp) -{ - struct cc_blob_sev_info *cc_info; - - if (!bp) - return false; - - cc_info =3D find_cc_blob(bp); - if (!cc_info) - return false; - - /* - * If a SNP-specific Confidential Computing blob is present, then - * firmware/bootloader have indicated SNP support. Verifying this - * involves CPUID checks which will be more reliable if the SNP - * CPUID table is used. See comments over snp_setup_cpuid_table() for - * more details. - */ - setup_cpuid_table(cc_info); - - /* - * Pass run-time kernel a pointer to CC info via boot_params so EFI - * config table doesn't need to be searched again during early startup - * phase. - */ - bp->cc_blob_address =3D (u32)(unsigned long)cc_info; - - return true; -} - void sev_prep_identity_maps(unsigned long top_level_pgt) { /*