From nobody Fri Dec 19 00:02:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+79523+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+79523+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1629321681; cv=none; d=zohomail.com; s=zohoarc; b=NPk5a15jx1Gw73NgD+uPCUkCz2N0VG7h6alM5jVS37KxdsjwvPtr+YegLC48GqfBuf+TyhZydJeqy/38nQ13jlsAy+/4kBuhwk8eYDjjC6afGe7lCR5KgS9MLU0IB+KCG8ReBfZNf50AOPahw+LDlfMugzROy9NpDmlK85ZtDWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629321681; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=P4mgvGScpnNdWOk8OqTOq6x/hiKyucdKzsWriVBB4Jk=; b=SvViMSAuW75FywMaQwSlZsvGoBSIJlqU6Mg0gxAOk4dRtb48RiNehXqxQQHEjXnd0kvQgjj3tezl/RVOOZYylJ3qVcXnjqzwH0/3zWo6H5nqHfV4Lfv/Dv5IlxBa120KtlAYo9iOb/h4oEIZyg+K1/e3yEO1egq+4UDMrvzBVaw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+79523+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1629321681927138.6291067273729; Wed, 18 Aug 2021 14:21:21 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 1v2eYY1788612xsUUNbbPm4a; Wed, 18 Aug 2021 14:21:21 -0700 X-Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by mx.groups.io with SMTP id smtpd.web10.61419.1629321681105517692 for ; Wed, 18 Aug 2021 14:21:21 -0700 X-Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 17IL2xhG028046; Wed, 18 Aug 2021 17:21:16 -0400 X-Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3agcsrjft6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Aug 2021 17:21:16 -0400 X-Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 17IL37xx028450; Wed, 18 Aug 2021 17:21:15 -0400 X-Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 3agcsrjfsn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Aug 2021 17:21:15 -0400 X-Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 17ILIJhO002793; Wed, 18 Aug 2021 21:21:14 GMT X-Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma03dal.us.ibm.com with ESMTP id 3ae5ffhucb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Aug 2021 21:21:14 +0000 X-Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 17ILLDYE31719906 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Aug 2021 21:21:13 GMT X-Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1270EBE04F; Wed, 18 Aug 2021 21:21:13 +0000 (GMT) X-Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F1BC5BE056; Wed, 18 Aug 2021 21:21:11 +0000 (GMT) X-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:11 +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: [edk2-devel] [RFC PATCH 6/9] OvmfPkg/AmdSev: Don't overwrite mailbox or pagetables Date: Wed, 18 Aug 2021 17:20:45 -0400 Message-Id: <20210818212048.162626-7-tobin@linux.ibm.com> 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: MwylJ3fTvh254AuoNNN2iXOqVtr6ZG5J X-Proofpoint-GUID: Bf8eIlRO0wpBjbJhFCu3tAQdLdJWq2XW Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tobin@linux.ibm.com X-Gm-Message-State: ofry5gYzr7htuS7nfvuYn3EYx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1629321681; bh=Sx/2IXDSIPFXsYRwBymnn/+CrRgif3Bu6Xac3GMTYwc=; h=Date:From:Reply-To:Subject:To; b=NJIxiS1ihV9ezY/rLy5j6OBMU8PPfssHHUmK4SOtPzNjNYL89bWBxoFYmzgt0fIZ8So gv/HEegl//Ian7ObBnT2bV2YP1Urz6sRdBpij6BQEOo2GhlgDX547aSPnaGuncbairw7i ZQ38bh7//L7mITrOKPlYUDORcpFhiaRdQcE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1629321682265100013 Content-Type: text/plain; charset="utf-8" While restoring pages, the MH should avoid overwriting its pagetables or the mailbox it uses to communicate with the HV. Signed-off-by: Tobin Feldman-Fitzthum --- .../ConfidentialMigrationDxe.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationDxe.= c b/OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationDxe.c index 34d449fe10..ee1466eb00 100644 --- a/OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationDxe.c +++ b/OvmfPkg/AmdSev/ConfidentialMigration/ConfidentialMigrationDxe.c @@ -109,6 +109,9 @@ EFIAPI MigrationHandlerMain () { UINT64 MailboxStart; + UINT64 MailboxEnd; + UINT64 PagetableStart; + UINT64 PagetableEnd; MH_COMMAND_PARAMETERS *Params; VOID *PageVa; =20 @@ -118,6 +121,11 @@ MigrationHandlerMain () Params =3D (VOID *)(MailboxStart + UNENC_VIRT_ADDR_BASE); PageVa =3D (VOID *)(MailboxStart + UNENC_VIRT_ADDR_BASE + 0x1000); =20 + MailboxEnd =3D MailboxStart + 2 * EFI_PAGE_SIZE; + + PagetableStart =3D mMigrationHandlerPageTables; + PagetableEnd =3D PagetableStart + 11 * EFI_PAGE_SIZE; + DisableInterrupts (); Params->Go =3D 0; =20 @@ -138,7 +146,14 @@ MigrationHandlerMain () break; =20 case MH_FUNC_RESTORE_PAGE: - CopyMem ((VOID *)Params->Gpa, PageVa, 4096); + // + // Don't import a page that covers the mailbox or pagetables. + // + if (!((Params->Gpa >=3D MailboxStart && Params->Gpa < MailboxEnd) || + (Params->Gpa >=3D PagetableStart && Params->Gpa < PagetableEnd))= ) { + + CopyMem ((VOID *)Params->Gpa, PageVa, 4096); + } Params->Ret =3D MH_SUCCESS; break; =20 --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#79523): https://edk2.groups.io/g/devel/message/79523 Mute This Topic: https://groups.io/mt/84982986/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-