public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Lendacky, Thomas" <thomas.lendacky@amd.com>
To: Mikolaj Lisik <lisik@google.com>, devel@edk2.groups.io
Cc: pedro.falcato@gmail.com, erdemaktas@google.com,
	jejb@linux.ibm.com, jiewen.yao@intel.com, min.m.xu@intel.com,
	michael.roth@amd.com
Subject: Re: [PATCH v2] OvmfPkg: Create additional PML1 entries for large SEV-SNP VMs
Date: Fri, 27 Jan 2023 09:29:14 -0600	[thread overview]
Message-ID: <3e8ea9e2-502b-4cd3-3b02-74a42d62f7ec@amd.com> (raw)
In-Reply-To: <b3f494e97062bccbf591fce90f624ae77b8f2d40.1674764281.git.lisik@google.com>

On 1/26/23 14:26, Mikolaj Lisik wrote:
> Edk2 was failing, rather than creating more PML4 entries, when they
> weren't present in the initial memory acceptance flow. Because of that
> VMs with more than 512G memory were crashing. This code fixes that.
> 
> This change affects only SEV-SNP VMs.
> 
> The code was tested by successfully booting a 512G SEV-SNP VM.
> 
> Signed-off-by: Mikolaj Lisik <lisik@google.com>

Acked-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>   .../X64/PeiDxeVirtualMemory.c                 | 26 ++++++++++++-------
>   1 file changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
> index b9c0a5b25a..75c2c36bb4 100644
> --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
> +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
> @@ -548,6 +548,7 @@ InternalMemEncryptSevCreateIdentityMap1G (
>     PAGE_MAP_AND_DIRECTORY_POINTER  *PageMapLevel4Entry;
>     PAGE_TABLE_1G_ENTRY             *PageDirectory1GEntry;
>     UINT64                          PgTableMask;
> +  UINT64                          *NewPageTable;
>     UINT64                          AddressEncMask;
>     BOOLEAN                         IsWpEnabled;
>     RETURN_STATUS                   Status;
> @@ -602,15 +603,22 @@ InternalMemEncryptSevCreateIdentityMap1G (
>       PageMapLevel4Entry  = (VOID *)(Cr3BaseAddress & ~PgTableMask);
>       PageMapLevel4Entry += PML4_OFFSET (PhysicalAddress);
>       if (!PageMapLevel4Entry->Bits.Present) {
> -      DEBUG ((
> -        DEBUG_ERROR,
> -        "%a:%a: bad PML4 for Physical=0x%Lx\n",
> -        gEfiCallerBaseName,
> -        __FUNCTION__,
> -        PhysicalAddress
> -        ));
> -      Status = RETURN_NO_MAPPING;
> -      goto Done;
> +      NewPageTable = AllocatePageTableMemory (1);
> +      if (NewPageTable == NULL) {
> +        DEBUG ((
> +          DEBUG_ERROR,
> +          "%a:%a: failed to allocate a new PML4 entry\n",
> +          gEfiCallerBaseName,
> +          __FUNCTION__
> +          ));
> +        Status = RETURN_NO_MAPPING;
> +        goto Done;
> +      }
> +      SetMem (NewPageTable, EFI_PAGE_SIZE, 0);
> +      PageMapLevel4Entry->Uint64          = (UINT64)(UINTN)NewPageTable | AddressEncMask;
> +      PageMapLevel4Entry->Bits.MustBeZero = 0;
> +      PageMapLevel4Entry->Bits.ReadWrite  = 1;
> +      PageMapLevel4Entry->Bits.Present    = 1;
>       }
>   
>       PageDirectory1GEntry = (VOID *)(

  parent reply	other threads:[~2023-01-27 15:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 20:26 [PATCH v2] OvmfPkg: Create additional PML1 entries for large SEV-SNP VMs Mikolaj Lisik
2023-01-27  8:27 ` [edk2-devel] " Gerd Hoffmann
2023-01-27 15:29 ` Lendacky, Thomas [this message]
2023-06-02 21:20 ` Lendacky, Thomas
2023-06-02 22:49   ` [edk2-devel] " Ard Biesheuvel
2023-06-02 23:03     ` Ard Biesheuvel
2023-06-02 23:56     ` Lendacky, Thomas

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=3e8ea9e2-502b-4cd3-3b02-74a42d62f7ec@amd.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