From: "Tobin Feldman-Fitzthum" <tobin@linux.ibm.com>
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 6/9] OvmfPkg/AmdSev: Don't overwrite mailbox or pagetables
Date: Wed, 18 Aug 2021 17:20:45 -0400 [thread overview]
Message-ID: <20210818212048.162626-7-tobin@linux.ibm.com> (raw)
In-Reply-To: <20210818212048.162626-1-tobin@linux.ibm.com>
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 <tobin@linux.ibm.com>
---
.../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;
@@ -118,6 +121,11 @@ MigrationHandlerMain ()
Params = (VOID *)(MailboxStart + UNENC_VIRT_ADDR_BASE);
PageVa = (VOID *)(MailboxStart + UNENC_VIRT_ADDR_BASE + 0x1000);
+ MailboxEnd = MailboxStart + 2 * EFI_PAGE_SIZE;
+
+ PagetableStart = mMigrationHandlerPageTables;
+ PagetableEnd = PagetableStart + 11 * EFI_PAGE_SIZE;
+
DisableInterrupts ();
Params->Go = 0;
@@ -138,7 +146,14 @@ MigrationHandlerMain ()
break;
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 >= MailboxStart && Params->Gpa < MailboxEnd) ||
+ (Params->Gpa >= PagetableStart && Params->Gpa < PagetableEnd))) {
+
+ CopyMem ((VOID *)Params->Gpa, PageVa, 4096);
+ }
Params->Ret = MH_SUCCESS;
break;
--
2.20.1
next prev parent reply other threads:[~2021-08-18 21:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-18 21:20 [RFC PATCH 0/9] Firmware Support for Fast Live Migration for AMD SEV Tobin Feldman-Fitzthum
2021-08-18 21:20 ` [RFC PATCH 1/9] OvmfPkg/AmdSev: Base for Confidential Migration Handler Tobin Feldman-Fitzthum
2021-08-18 21:20 ` [RFC PATCH 2/9] OvmfPkg/PlatfomPei: Set Confidential Migration PCD Tobin Feldman-Fitzthum
2021-08-18 21:20 ` [RFC PATCH 3/9] OvmfPkg/AmdSev: Setup Migration Handler Mailbox Tobin Feldman-Fitzthum
2021-08-18 21:20 ` [RFC PATCH 4/9] OvmfPkg/AmdSev: MH support for mailbox protocol Tobin Feldman-Fitzthum
2021-08-18 21:20 ` [RFC PATCH 5/9] OvmfPkg/AmdSev: Build page table for migration handler Tobin Feldman-Fitzthum
2021-08-18 21:20 ` Tobin Feldman-Fitzthum [this message]
2021-08-18 21:20 ` [RFC PATCH 7/9] OvmfPkg/AmdSev: Don't overwrite MH stack Tobin Feldman-Fitzthum
2021-08-18 21:20 ` [RFC PATCH 8/9] OvmfPkg/AmdSev: Add Migration Handler entry point Tobin Feldman-Fitzthum
2021-08-18 21:20 ` [RFC PATCH 9/9] OvmfPkg/ResetVector: Expose Migration Handler Entry Addresses Tobin Feldman-Fitzthum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210818212048.162626-7-tobin@linux.ibm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox