Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1191761lqd; Thu, 25 Apr 2024 08:20:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWFwUdg4p9z7obl9qKfgsmbHc5xk4gYwwgoivtLax2UoNIimt0IolnevSohoefoaU3bRAuMyxcCF99/LXVE7ZnSCJsXeMXeuW3mIjS/YA== X-Google-Smtp-Source: AGHT+IF/7Dn6nNgoWqZwk6Adip1RdYAGXrMvoEmB/H21LcMFT/gWC29HUVTgXDqMv6hZ+obmhr6i X-Received: by 2002:a05:6a20:3251:b0:1a7:84e8:8037 with SMTP id hm17-20020a056a20325100b001a784e88037mr5723588pzc.41.1714058446769; Thu, 25 Apr 2024 08:20:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714058446; cv=pass; d=google.com; s=arc-20160816; b=bOkBuFPZ+g/c+ALB+XiBXggaUlMCdxRE+Ik9mf4agL3ALLV3XHkG1zmp5voaDU1+RH nUGAfKBzGpxqHfDW6GXCX/HlrdIPThfSjKVghudZC0x7ZYOX8CqivbHOEn1FeF5DdH4Q 4MRkU0BU1YuOhM+Q+Lx18UXX7OC4e7JJTDCjlvHi4DKbvMKd6q/T8Pb325n6WEkhZ9Xg kKogvSS4Dm+W+wq0ADAccMu6Rk+MkdkomFZjufq/wn0OcHJdOuWw3aXEW7IimoVtKydH OeJb/mICFmYm5f0TV5SsPhJ+F0wL31XPHQYiKFWd9YvjAMy8eUOFBhupnA05bF+Q+W6b 1k7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=dQrHP+BIUgux3fKnNfzwN/4PlzXExUzbIpKqr41Shz0=; fh=Xi+WReo1vRbc0tmLnxHzjtVwrJe3+PSRi3c87fXUVWA=; b=J1HSXn0+fn6wBHwrO3+zDdWJ93tuU93gkUGpzGH47DevxcasDO5gFMzClp10L0NhAW 4JD/L35OtYjmfN5m+53TvSnIhFELG7tAn/UV7OcYH26J2NpD5ycDayJB9nQmGn0B30w5 s5HMOfPt0TCw8S5HTTe1Sx7Hezm4aEoTziGzMrIBdaVUm9enl62xZ5W5r8V/J7vWa+lX m0PaaHrnAluZ5X3LgXtimlIOiQ6uVezZGPZ5/nb7qV7tExg78y8a2CYFxEoKjc3c/CQm QPWgKOy7AM6M58/hVW63tw2GTWLZc00QqbYKEga9o6wEL14G+CkS21z4zggxIkltkX0J woNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XEMHB0Zg; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-158772-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158772-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z15-20020a634c0f000000b005d44c945aebsi13439199pga.82.2024.04.25.08.20.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 08:20:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158772-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XEMHB0Zg; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-158772-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158772-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4889628AE18 for ; Thu, 25 Apr 2024 15:08:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA21614B07B; Thu, 25 Apr 2024 15:08:04 +0000 (UTC) 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" 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 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: 7bit The following commit has been merged into the x86/sev branch of tip: Commit-ID: 88ed43d32beb1ef3c06164c52b1c6ced47b5988b Gitweb: https://git.kernel.org/tip/88ed43d32beb1ef3c06164c52b1c6ced47b5988b 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.1713974291.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) } } +/* 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 = 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 = find_cc_blob_efi(bp); + if (cc_info) + goto found_cc_info; + + cc_info = find_cc_blob_setup_data(bp); + if (!cc_info) + return NULL; + +found_cc_info: + if (cc_info->magic != 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 checks + * 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 = 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 = (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 = 0; /* - * 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 = snp_init(bp); + snp = early_snp_init(bp); /* Now repeat the checks with the SNP CPUID table. */ @@ -535,85 +614,6 @@ u64 sev_get_status(void) return m.q; } -/* 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 = 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 = find_cc_blob_efi(bp); - if (cc_info) - goto found_cc_info; - - cc_info = find_cc_blob_setup_data(bp); - if (!cc_info) - return NULL; - -found_cc_info: - if (cc_info->magic != 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 checks - * 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 = 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 = (u32)(unsigned long)cc_info; - - return true; -} - void sev_prep_identity_maps(unsigned long top_level_pgt) { /*