From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web12.43607.1606171095223830635 for ; Mon, 23 Nov 2020 14:38:15 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YFY+hXtZ; spf=pass (domain: redhat.com, ip: 63.128.21.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606171094; h=from:from: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=wFBUaVUK8Dpdx9CNj7RSE9ljLUYsgwvzmrXgQmdf7uE=; b=YFY+hXtZtbRULw1R54olH0zaFbnZFPnqAq6B8prDrdg/glRLFBCmr8bX31gFPcdBwp7xmV AJdHKowDXiu+mV/Hew2CE8EAJTEaAKoKck9U09hZT1Lp6CiHIbs7SfZWMIfQcI+BTLA0Pq zxrcjtZiwqw2bKrnjBWMPL2NIfzUxb8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-498-r2x3eyxFOveJ7M7LFFG1Nw-1; Mon, 23 Nov 2020 17:38:10 -0500 X-MC-Unique: r2x3eyxFOveJ7M7LFFG1Nw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 489DA1005E43; Mon, 23 Nov 2020 22:38:08 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-230.ams2.redhat.com [10.36.112.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C3AE5D705; Mon, 23 Nov 2020 22:38:05 +0000 (UTC) Subject: Re: [PATCH v2 5/6] OvmfPkg/AmdSev: assign and protect the Sev Secret area To: James Bottomley , devel@edk2.groups.io Cc: dovmurik@linux.vnet.ibm.com, Dov.Murik1@il.ibm.com, ashish.kalra@amd.com, brijesh.singh@amd.com, tobin@ibm.com, david.kaplan@amd.com, jon.grimm@amd.com, thomas.lendacky@amd.com, frankeh@us.ibm.com, "Dr . David Alan Gilbert" References: <20201120184521.19437-1-jejb@linux.ibm.com> <20201120184521.19437-6-jejb@linux.ibm.com> From: "Laszlo Ersek" Message-ID: Date: Mon, 23 Nov 2020 23:38:04 +0100 MIME-Version: 1.0 In-Reply-To: <20201120184521.19437-6-jejb@linux.ibm.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 11/20/20 19:45, James Bottomley wrote: > Create a one page secret area in the MEMFD and protect the area with a > boot time HOB. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3077 > Signed-off-by: James Bottomley > --- > OvmfPkg/AmdSev/AmdSevX64.dsc | 1 + > OvmfPkg/AmdSev/AmdSevX64.fdf | 4 +++ > OvmfPkg/AmdSev/SecretPei/SecretPei.inf | 39 ++++++++++++++++++++++++++ > OvmfPkg/AmdSev/SecretPei/SecretPei.c | 25 +++++++++++++++++ > 4 files changed, 69 insertions(+) > create mode 100644 OvmfPkg/AmdSev/SecretPei/SecretPei.inf > create mode 100644 OvmfPkg/AmdSev/SecretPei/SecretPei.c > > diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc > index c0b4e1b274fc..a3f75a626e5e 100644 > --- a/OvmfPkg/AmdSev/AmdSevX64.dsc > +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc > @@ -624,6 +624,7 @@ [Components] > > } > UefiCpuPkg/CpuMpPei/CpuMpPei.inf > + OvmfPkg/AmdSev/SecretPei/SecretPei.inf > > !if $(TPM_ENABLE) == TRUE > OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf > diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf > index 97f031950abd..c628e6d8f6e7 100644 > --- a/OvmfPkg/AmdSev/AmdSevX64.fdf > +++ b/OvmfPkg/AmdSev/AmdSevX64.fdf > @@ -59,6 +59,9 @@ [FD.MEMFD] > 0x00B000|0x001000 > gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase|gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaSize > > +0x00C000|0x001000 > +gUefiOvmfPkgTokenSpaceGuid.PcdSevLaunchSecretBase|gUefiOvmfPkgTokenSpaceGuid.PcdSevLaunchSecretSize > + > 0x010000|0x010000 > gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize > > @@ -138,6 +141,7 @@ [FV.PEIFV] > INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf > INF UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf > INF UefiCpuPkg/CpuMpPei/CpuMpPei.inf > +INF OvmfPkg/AmdSev/SecretPei/SecretPei.inf > > !if $(TPM_ENABLE) == TRUE > INF OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf > diff --git a/OvmfPkg/AmdSev/SecretPei/SecretPei.inf b/OvmfPkg/AmdSev/SecretPei/SecretPei.inf > new file mode 100644 > index 000000000000..1b40ac036aba > --- /dev/null > +++ b/OvmfPkg/AmdSev/SecretPei/SecretPei.inf > @@ -0,0 +1,39 @@ > +## @file > +# PEI support for SEV Secrets > +# > +# Copyright (C) 2020 James Bottomley, IBM Corporation. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION = 0x00010005 > + BASE_NAME = SecretPei > + FILE_GUID = 45260dde-0c3c-4b41-a226-ef3803fac7d4 > + MODULE_TYPE = PEIM > + VERSION_STRING = 1.0 > + ENTRY_POINT = InitializeSecretPei > + > +# > +# The following information is for reference only and not required by the build tools. > +# (1) I'm very sorry, my previous point on this was unclear. The above comment refers to the VALID_ARCHITECTURES (non-)macro. Therefore, if we keep VALID_ARCHITECTURES, then it should be restricted to X64, and the comment should stay. If we remove VALID_ARCHITECTURES, then the comment becomes dangling -- and it should disappear too. With this updated: Reviewed-by: Laszlo Ersek Thanks Laszlo > + > +[Sources] > + SecretPei.c > + > +[Packages] > + OvmfPkg/OvmfPkg.dec > + MdePkg/MdePkg.dec > + > +[LibraryClasses] > + HobLib > + PeimEntryPoint > + PcdLib > + > +[FixedPcd] > + gUefiOvmfPkgTokenSpaceGuid.PcdSevLaunchSecretBase > + gUefiOvmfPkgTokenSpaceGuid.PcdSevLaunchSecretSize > + > +[Depex] > + TRUE > diff --git a/OvmfPkg/AmdSev/SecretPei/SecretPei.c b/OvmfPkg/AmdSev/SecretPei/SecretPei.c > new file mode 100644 > index 000000000000..ad491515dd5d > --- /dev/null > +++ b/OvmfPkg/AmdSev/SecretPei/SecretPei.c > @@ -0,0 +1,25 @@ > +/** @file > + SEV Secret boot time HOB placement > + > + Copyright (C) 2020 James Bottomley, IBM Corporation. > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > +#include > +#include > +#include > + > +EFI_STATUS > +EFIAPI > +InitializeSecretPei ( > + IN EFI_PEI_FILE_HANDLE FileHandle, > + IN CONST EFI_PEI_SERVICES **PeiServices > + ) > +{ > + BuildMemoryAllocationHob ( > + PcdGet32 (PcdSevLaunchSecretBase), > + PcdGet32 (PcdSevLaunchSecretSize), > + EfiBootServicesData > + ); > + > + return EFI_SUCCESS; > +} >