From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by mx.groups.io with SMTP id smtpd.web09.61049.1629321677078319078 for ; Wed, 18 Aug 2021 14:21:17 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lAJ3aiiO; spf=pass (domain: linux.ibm.com, ip: 148.163.156.1, mailfrom: tobin@linux.ibm.com) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 17IL3RRM020554; Wed, 18 Aug 2021 17:21:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=f265STP5mnDcArfwzI6u5ScZjJH8wnsTw4myuQxMWkg=; b=lAJ3aiiOgb6CM6biszPxcmvpN8oiPRGmoe/cvGlnJUWe3j3lkt4kuV9W+PoSETJJoX7B /BBZqu31c2pUkFZczzbrn0epl0q787pt0iMuUrXmPJzcr20RhD8Q9uQ1SFZFW75AvaXo Mmfm6o5myTV7p7LTRzfzl+V/3Qmtc88sjxA9Ss2o+esBF98w+3kAWjhuHCFNjdDhGKgr WslAtk+adf/F44AGgVnrcPaFOeQstIgSoq6N88IKlFyqndvLL9vQeLvrHBO9L4netwRL AtzMY8BYQE0GzA+gLXulg9SbFiBMDlti7sggGaBh1ol/m/CiCz8WkaC5v4wHqUTb29/I PA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3agcf6uap3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Aug 2021 17:21:12 -0400 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 17IL7g8p034788; Wed, 18 Aug 2021 17:21:12 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 3agcf6uank-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Aug 2021 17:21:12 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 17ILIJpv012814; Wed, 18 Aug 2021 21:21:10 GMT Received: from b03cxnp07027.gho.boulder.ibm.com (b03cxnp07027.gho.boulder.ibm.com [9.17.130.14]) by ppma01wdc.us.ibm.com with ESMTP id 3ae5fdn7y3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Aug 2021 21:21:10 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 17ILL9E214745898 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Aug 2021 21:21:09 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 551FDBE056; Wed, 18 Aug 2021 21:21:09 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A64DBE05A; Wed, 18 Aug 2021 21:21:08 +0000 (GMT) Received: from amdrome1.watson.ibm.com (unknown [9.2.130.16]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 18 Aug 2021 21:21:08 +0000 (GMT) From: "Tobin Feldman-Fitzthum" To: tobin@ibm.com, dovmurik@linux.vnet.ibm.com, jejb@linux.ibm.com, frankeh@us.ibm.com, pbonzini@redhat.com, ashish.kalra@amd.com, thomas.lendacky@amd.com, brijesh.singh@amd.com, dgilbert@redhat.com, srutherford@google.com, devel@edk2.groups.io, ard.biesheuvel@arm.com, jiewen.yao@intel.com Subject: [RFC PATCH 3/9] OvmfPkg/AmdSev: Setup Migration Handler Mailbox Date: Wed, 18 Aug 2021 17:20:42 -0400 Message-Id: <20210818212048.162626-4-tobin@linux.ibm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210818212048.162626-1-tobin@linux.ibm.com> References: <20210818212048.162626-1-tobin@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 1L_Ka9OvYWbGF-FVTHuuLICuftnA8kwf X-Proofpoint-GUID: Tg4NceNYBPaY2oBMXM20Jx8AjosgYNma X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-08-18_07:2021-08-17,2021-08-18 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 adultscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108180130 Content-Transfer-Encoding: 8bit The migration handler communicates with the hypervisor using a special mailbox, a page of shared memory where pending commands can be written. Another shared page is used to pass the incoming or outgoing guest memory pages. These pages are set aside in MEMFD, which this patch expands, and reserved as runtime memory in ConfidentialMigrationPei, which this patch introduces. Signed-off-by: Tobin Feldman-Fitzthum --- OvmfPkg/OvmfPkg.dec | 5 +++ OvmfPkg/AmdSev/AmdSevX64.dsc | 1 + OvmfPkg/AmdSev/AmdSevX64.fdf | 12 ++++--- .../ConfidentialMigrationPei.inf | 35 +++++++++++++++++++ .../ConfidentialMigrationPei.c | 25 +++++++++++++ 5 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationPei.inf create mode 100644 OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationPei.c diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index cfc645619d..1252582c99 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -331,6 +331,11 @@ gUefiOvmfPkgTokenSpaceGuid.PcdQemuHashTableBase|0x0|UINT32|0x47 gUefiOvmfPkgTokenSpaceGuid.PcdQemuHashTableSize|0x0|UINT32|0x48 + ## Area used by the confidential migration handler to communicate with + # the hypervisor. + gUefiOvmfPkgTokenSpaceGuid.PcdConfidentialMigrationMailboxBase|0x0|UINT32|0x4b + gUefiOvmfPkgTokenSpaceGuid.PcdConfidentialMigrationMailboxSize|0x0|UINT32|0x4c + [PcdsDynamic, PcdsDynamicEx] gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10 diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc index 982ecaf70e..cd6189f330 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc @@ -623,6 +623,7 @@ UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf UefiCpuPkg/CpuMpPei/CpuMpPei.inf OvmfPkg/AmdSev/SecretPei/SecretPei.inf + OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationPei.inf !if $(TPM_ENABLE) == TRUE OvmfPkg/Tcg/TpmMmioSevDecryptPei/TpmMmioSevDecryptPei.inf diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf index 9bf17b8d51..a8e296e641 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.fdf +++ b/OvmfPkg/AmdSev/AmdSevX64.fdf @@ -36,10 +36,10 @@ FV = SECFV [FD.MEMFD] BaseAddress = $(MEMFD_BASE_ADDRESS) -Size = 0xD00000 +Size = 0xE00000 ErasePolarity = 1 BlockSize = 0x10000 -NumBlocks = 0xD0 +NumBlocks = 0xE0 0x000000|0x006000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize @@ -71,11 +71,14 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBackupBase|gUefiOvmfPkgTokenSpaceGuid.P 0x010000|0x010000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize -0x020000|0x0E0000 +0x020000|0x003000 +gUefiOvmfPkgTokenSpaceGuid.PcdConfidentialMigrationMailboxBase|gUefiOvmfPkgTokenSpaceGuid.PcdConfidentialMigrationMailboxSize + +0x120000|0x0E0000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize FV = PEIFV -0x100000|0xC00000 +0x200000|0xC00000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize FV = DXEFV @@ -148,6 +151,7 @@ INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf INF UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf INF UefiCpuPkg/CpuMpPei/CpuMpPei.inf INF OvmfPkg/AmdSev/SecretPei/SecretPei.inf +INF OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationPei.inf !if $(TPM_ENABLE) == TRUE INF OvmfPkg/Tcg/TpmMmioSevDecryptPei/TpmMmioSevDecryptPei.inf diff --git a/OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationPei.inf b/OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationPei.inf new file mode 100644 index 0000000000..918cf22abd --- /dev/null +++ b/OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationPei.inf @@ -0,0 +1,35 @@ +## @file +# PEI support for confidential migration. +# +# Copyright (C) 2021 IBM Corporation. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = ConfidentialMigration + FILE_GUID = a747792e-71a1-4c24-84a9-a76a0a279878 + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + ENTRY_POINT = InitializeConfidentialMigrationPei + +[Sources] + ConfidentialMigrationPei.c + +[Packages] + OvmfPkg/OvmfPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + HobLib + PeimEntryPoint + PcdLib + +[FixedPcd] + gUefiOvmfPkgTokenSpaceGuid.PcdConfidentialMigrationMailboxBase + gUefiOvmfPkgTokenSpaceGuid.PcdConfidentialMigrationMailboxSize + +[Depex] + TRUE diff --git a/OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationPei.c b/OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationPei.c new file mode 100644 index 0000000000..ce304bc07b --- /dev/null +++ b/OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationPei.c @@ -0,0 +1,25 @@ +/** @file + Reserve memory for confidential migration handler. + + Copyright (C) 2020 IBM Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include +#include +#include + +EFI_STATUS +EFIAPI +InitializeConfidentialMigrationPei ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + BuildMemoryAllocationHob ( + PcdGet32 (PcdConfidentialMigrationMailboxBase), + PcdGet32 (PcdConfidentialMigrationMailboxSize), + EfiRuntimeServicesData + ); + + return EFI_SUCCESS; +} -- 2.20.1