From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.512.1685746169451528897 for ; Fri, 02 Jun 2023 15:49:29 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wrf7m1TB; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D18F76133B for ; Fri, 2 Jun 2023 22:49:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42970C433EF for ; Fri, 2 Jun 2023 22:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685746168; bh=H5Mj1u9VNmqA3RoMfpfCNw9umtkY2h+tDHAgMy+SWTA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Wrf7m1TBbDhG/m7d0oigBOsxGcJOKY7G/w1HeLbZ9RgWcxITkFraNSSwSDFd/FVDg N/GXIwcN2R5cY++MwNetVoD2JoYKzkxS5FrlFCQxtY2R/Bgk5ajcTqoAo2CrK8cEE8 CjHGQ8h5/lKrT8mBU6NByYFI837rPV4JSekki/HoGhPHa21WojPSc2ohAuh4Z9/XZh HTWkPhxnmFF69ttawoK4etrrkcr9ZY4kPsWO3nVXe+A/cSTP4ceAPW2eVXhUAGHq1b /DgCcREqQRU/TAIuIfExphGMLmeHqtNfEPtwIgibX3yGKuEoFw4ktAcK8KrOBaBYzU YBfIUH5O3qbgw== Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2b1badb8f9bso1061351fa.1 for ; Fri, 02 Jun 2023 15:49:28 -0700 (PDT) X-Gm-Message-State: AC+VfDwu5xGrjE0xMBAQFRFAxGXE3K5gf1rDOl9QupHFh5nJb+PuwY9+ BhtNzLZhpGnQiY4o4/mZsSQBtEMH7qdb4Io2P2A= X-Google-Smtp-Source: ACHHUZ7BzRrql7uuM7ZkH4F7O8HafYXXffMffXh6AlXytQrkiOUb0tl5z9Y/CW+COY46tQtrlGgUc9+jJITVf+LQJHM= X-Received: by 2002:a2e:7a0e:0:b0:2a7:748c:1eef with SMTP id v14-20020a2e7a0e000000b002a7748c1eefmr762235ljc.38.1685746166217; Fri, 02 Jun 2023 15:49:26 -0700 (PDT) MIME-Version: 1.0 References: <9d9d8bb2-ac6f-0339-738e-44c6d50f286b@amd.com> In-Reply-To: <9d9d8bb2-ac6f-0339-738e-44c6d50f286b@amd.com> From: "Ard Biesheuvel" Date: Sat, 3 Jun 2023 00:49:14 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH v2] OvmfPkg: Create additional PML1 entries for large SEV-SNP VMs To: devel@edk2.groups.io, thomas.lendacky@amd.com Cc: Mikolaj Lisik , Gerd Hoffmann , pedro.falcato@gmail.com, erdemaktas@google.com, jejb@linux.ibm.com, jiewen.yao@intel.com, min.m.xu@intel.com, michael.roth@amd.com Content-Type: text/plain; charset="UTF-8" On Fri, 2 Jun 2023 at 23:20, Lendacky, Thomas via groups.io wrote: > > 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 > > I don't see where this was merged. Both Gerd and I acked it back in > January, was there a problem with it? > I wasn't cc'ed. I've queued this up now. > > > --- > > .../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 *)( > > > > >