From patchwork Fri Mar 28 23:08:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Philipson X-Patchwork-Id: 14032523 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 74EE11F4167; Fri, 28 Mar 2025 23:13:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743203603; cv=none; b=rbqwGMh/Hn6QIYdfYs5Ov7rUnujOlaKcWFeRp8O9VeaqAfoD5Pwi+D3vs+bYHCyNrlLBbnTCTriRkrAPq1+VqVdOpCjih7YK5FDdxqS7p29DJ4vXlOoxpctjPeju0XP7LNaAJXXpznYuPADaOfHSI/n9TttNjETrsj/68yoBGts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743203603; c=relaxed/simple; bh=EWgG8RiI4q7KuHBh7kJ0d19oPKTeOctxBG8I3hP+uyI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ud4dTS7+luC6GNuaTFu9KNS6Fhixzip5gDj4luDDHa9w2Uo2CoVlyojV0nsmkv9vCMoo8Ez2OAiRu+CJ/m0SmeqXHLFs8mefI08rjp+J9ZaK2EYkzKL1XDdhGgBAbsXt4VSbLPNXFSFWYX7QmWLk2Qec8ZbKUbjIepgSOBhbo4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=C/4nZokB; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="C/4nZokB" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 52SKWCIj026688; Fri, 28 Mar 2025 23:12:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2023-11-20; bh=cYdNy zemsXneNNzc437yr23QaPTvX9oNAYNn1dbuWKg=; b=C/4nZokBV9WTjVxzIXROZ 0YownO7Om24pmNcZ1KsHyO5OaENY39oZA4nIRPeEQmPpadaOQhP0JnapbY3Is/6l sw/6teriK/BVBaMQC4PdHTNES/gKwXpVf9T7VnU3blsIf8vqOfLoMiHqaLlbrxvm evb5927QJY9kox22NOcA+q4w3r1uCgnXgI+MXOPyO4XdtuaRXyurHUgMpLuVsFy0 54iD8Gbktw5q5SX1/ZO+zKSE2O1u/PoWLf83xiLCDIsZDGGbzcEE5Qx/UGIvUpLK WNQWn5zlM/MOhKVb+1WPx0M8f1Vuzo2vZpdcUY7w/mv2YyXbkXUuZ3Hh+d72mOI+ A== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 45hncryu3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Mar 2025 23:12:31 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 52SLfesN008237; Fri, 28 Mar 2025 23:12:30 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 45jj701jq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 28 Mar 2025 23:12:30 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 52SNCTDT024643; Fri, 28 Mar 2025 23:12:29 GMT Received: from bur-virt-x6-2-100.us.oracle.com (bur-virt-x6-2-100.us.oracle.com [10.153.92.40]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 45jj701jng-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 28 Mar 2025 23:12:29 +0000 From: Ross Philipson To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org, linux-crypto@vger.kernel.org, kexec@lists.infradead.org, linux-efi@vger.kernel.org, iommu@lists.linux.dev Cc: ross.philipson@oracle.com, dpsmith@apertussolutions.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, dave.hansen@linux.intel.com, ardb@kernel.org, mjg59@srcf.ucam.org, James.Bottomley@hansenpartnership.com, peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca, luto@amacapital.net, nivedita@alum.mit.edu, herbert@gondor.apana.org.au, davem@davemloft.net, corbet@lwn.net, ebiederm@xmission.com, dwmw2@infradead.org, baolu.lu@linux.intel.com, kanth.ghatraju@oracle.com, andrew.cooper3@citrix.com, trenchboot-devel@googlegroups.com Subject: [PATCH v13 06/19] x86: Add early SHA-256 support for Secure Launch early measurements Date: Fri, 28 Mar 2025 16:08:01 -0700 Message-Id: <20250328230814.2210230-7-ross.philipson@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20250328230814.2210230-1-ross.philipson@oracle.com> References: <20250328230814.2210230-1-ross.philipson@oracle.com> Precedence: bulk X-Mailing-List: linux-integrity@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-03-28_11,2025-03-27_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2503280156 X-Proofpoint-GUID: Og0fO9mNSsXq8cSAOSHZTiCS8dHRiGgF X-Proofpoint-ORIG-GUID: Og0fO9mNSsXq8cSAOSHZTiCS8dHRiGgF From: "Daniel P. Smith" The SHA-256 algorithm is necessary to measure configuration information into the TPM as early as possible before using the values. This implementation uses the established approach of #including the SHA-256 libraries directly in the code since the compressed kernel is not uncompressed at this point. Signed-off-by: Daniel P. Smith Signed-off-by: Ross Philipson --- arch/x86/boot/compressed/Makefile | 2 +- arch/x86/boot/compressed/sha256.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 arch/x86/boot/compressed/sha256.c diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 4626e2f95254..b5c167285f6b 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -109,7 +109,7 @@ vmlinux-objs-$(CONFIG_EFI) += $(obj)/efi.o vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_mixed.o vmlinux-libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a -vmlinux-objs-$(CONFIG_SECURE_LAUNCH) += $(obj)/sha1.o +vmlinux-objs-$(CONFIG_SECURE_LAUNCH) += $(obj)/sha1.o $(obj)/sha256.o $(obj)/vmlinux: $(vmlinux-objs-y) $(vmlinux-libs-y) FORCE $(call if_changed,ld) diff --git a/arch/x86/boot/compressed/sha256.c b/arch/x86/boot/compressed/sha256.c new file mode 100644 index 000000000000..7795926e7e1d --- /dev/null +++ b/arch/x86/boot/compressed/sha256.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2025 Apertus Solutions, LLC + */ + +#include "../../../../lib/crypto/sha256.c"