From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.158.5]) by mx.groups.io with SMTP id smtpd.web11.10990.1677748551681281388 for ; Thu, 02 Mar 2023 01:15:51 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@ibm.com header.s=pp1 header.b=tKqGYii9; spf=pass (domain: linux.ibm.com, ip: 148.163.158.5, mailfrom: dovmurik@linux.ibm.com) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3228v4eP030268; Thu, 2 Mar 2023 09:15:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=uxtap5q5ecGy1DrebVBOfEizDCFBJhmyg4mRsWUtSrU=; b=tKqGYii9QKo0rglwMV3XrH8VxlqwuiN+3MMgPduP91B2w+6OxkPWmc+XzuTI8cplDn36 c+M2R6UfyD4KP2QTCwEwqZYcZFX89OZ0H9USWLuuPjJ9LN15Os4znKfrvU9Qo+bj/hXF Gux064UiAqjjoh+XVtMccMeJGAnibkEzEQ/IEd6jpUDXCrYnHCOYC8iOry189Y5LKT38 f6oHXYyMU+z1D6NeooPDFnE6GvY8fDsVcZRzz1yrjDf1W1MZRtgHgUYIrTcXsCPSn87M 2dLmDMN2HUzi0GCKzTo3geFVdgN9EF8+vRRIp0tRFQB/d4LxeLcnevSmc8zYsAXgCPCh HA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3p2rr78h6p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 09:15:49 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3228wxeX008508; Thu, 2 Mar 2023 09:15:49 GMT Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3p2rr78h6a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 09:15:48 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3226KaN4024608; Thu, 2 Mar 2023 09:15:48 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([9.208.129.113]) by ppma05wdc.us.ibm.com (PPS) with ESMTPS id 3nybe9v0uq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 09:15:48 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3229FkX58848074 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Mar 2023 09:15:46 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A61AE5805A; Thu, 2 Mar 2023 09:15:46 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 647A058054; Thu, 2 Mar 2023 09:15:45 +0000 (GMT) Received: from amdmilan1.watson.ibm.com (unknown [9.2.130.16]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 2 Mar 2023 09:15:45 +0000 (GMT) From: "Dov Murik" To: devel@edk2.groups.io Cc: Dov Murik , Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann , Erdem Aktas , James Bottomley , Min Xu , Tom Lendacky , Michael Roth , Ashish Kalra , Mario Smarduch , Tobin Feldman-Fitzthum Subject: [PATCH v3 2/2] OvmfPkg/ResetVector: Define SNP metadata for kernel hashes Date: Thu, 2 Mar 2023 09:15:32 +0000 Message-Id: <20230302091532.1985238-3-dovmurik@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230302091532.1985238-1-dovmurik@linux.ibm.com> References: <20230302091532.1985238-1-dovmurik@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: M1j0EnAy8cigFd0Y-sR-V4FN5xkB5EfT X-Proofpoint-GUID: Jb9t9Tsfl5zJvMSN4Spc_UsvnMXp3xix X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-02_04,2023-03-02_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 mlxscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=834 phishscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303020078 Content-Transfer-Encoding: quoted-printable In order to allow the VMM (such as QEMU) to add a page with hashes of kernel/initrd/cmdline for measured direct boot on SNP, add it explicitly to the SNP metadata list report to the VMM. In such case, VMM should fill the page with the hashes content, or explicitly update it as a zero page (if kernel hashes are not used). Note that for SNP, the launch secret part of the page (lower 3KB) are not relevant and will remain zero. The last 1KB is used for the hashes. This should have no effect on OvmfPkgX64 targets (which don't define PcdSevLaunchSecretBase). Signed-off-by: Dov Murik --- OvmfPkg/ResetVector/ResetVector.nasmb | 11 ++++++++++- OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/ResetVector/ResetVector.nasmb b/OvmfPkg/ResetVector/Re= setVector.nasmb index 94fbb0a87b37..5832aaa8abf7 100644 --- a/OvmfPkg/ResetVector/ResetVector.nasmb +++ b/OvmfPkg/ResetVector/ResetVector.nasmb @@ -64,6 +64,15 @@ %define SEV_SNP_SECRETS_SIZE (FixedPcdGet32 (PcdOvmfSnpSecretsSiz= e))=0D %define CPUID_BASE (FixedPcdGet32 (PcdOvmfCpuidBase))=0D %define CPUID_SIZE (FixedPcdGet32 (PcdOvmfCpuidSize))=0D +%if (FixedPcdGet32 (PcdSevLaunchSecretBase) > 0)=0D + ; There's a reserved page for SEV secrets and hashes; the VMM will fill = and=0D + ; validate the page, or mark it as a zero page.=0D + %define SEV_SNP_KERNEL_HASHES_BASE (FixedPcdGet32 (PcdSevLaunchSecret= Base))=0D + %define SEV_SNP_KERNEL_HASHES_SIZE (FixedPcdGet32 (PcdSevLaunchSecret= Size) + FixedPcdGet32 (PcdQemuHashTableSize))=0D +%else=0D + %define SEV_SNP_KERNEL_HASHES_BASE 0=0D + %define SEV_SNP_KERNEL_HASHES_SIZE 0=0D +%endif=0D %define SNP_SEC_MEM_BASE_DESC_1 (FixedPcdGet32 (PcdOvmfSecPageTables= Base))=0D %define SNP_SEC_MEM_SIZE_DESC_1 (FixedPcdGet32 (PcdOvmfSecGhcbBase) = - SNP_SEC_MEM_BASE_DESC_1)=0D ;=0D @@ -75,7 +84,7 @@ ;=0D %define SNP_SEC_MEM_BASE_DESC_2 (GHCB_BASE + 0x1000)=0D %define SNP_SEC_MEM_SIZE_DESC_2 (SEV_SNP_SECRETS_BASE - SNP_SEC_MEM_= BASE_DESC_2)=0D -%define SNP_SEC_MEM_BASE_DESC_3 (CPUID_BASE + CPUID_SIZE)=0D +%define SNP_SEC_MEM_BASE_DESC_3 (CPUID_BASE + CPUID_SIZE + SEV_SNP_K= ERNEL_HASHES_SIZE)=0D %define SNP_SEC_MEM_SIZE_DESC_3 (FixedPcdGet32 (PcdOvmfPeiMemFvBase)= - SNP_SEC_MEM_BASE_DESC_3)=0D =0D %ifdef ARCH_X64=0D diff --git a/OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm b/OvmfPkg/ResetVec= tor/X64/OvmfSevMetadata.asm index d03fc6d45175..8aa77d870123 100644 --- a/OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm +++ b/OvmfPkg/ResetVector/X64/OvmfSevMetadata.asm @@ -26,6 +26,8 @@ BITS 64 ;=0D %define OVMF_SECTION_TYPE_CPUID 0x3=0D =0D +; Kernel hashes section for measured direct boot=0D +%define OVMF_SECTION_TYPE_KERNEL_HASHES 0x10=0D =0D ALIGN 16=0D =0D @@ -65,6 +67,15 @@ CpuidSec: DD CPUID_SIZE=0D DD OVMF_SECTION_TYPE_CPUID=0D =0D +%if (SEV_SNP_KERNEL_HASHES_BASE > 0)=0D +; Kernel hashes for measured direct boot, or zero page if=0D +; there are no kernel hashes / SEV secrets=0D +SevSnpKernelHashes:=0D + DD SEV_SNP_KERNEL_HASHES_BASE=0D + DD SEV_SNP_KERNEL_HASHES_SIZE=0D + DD OVMF_SECTION_TYPE_KERNEL_HASHES=0D +%endif=0D +=0D ; Region need to be pre-validated by the hypervisor=0D PreValidate3:=0D DD SNP_SEC_MEM_BASE_DESC_3=0D --=20 2.25.1