* [PATCH v2] OvmfPkg: Create additional PML1 entries for large SEV-SNP VMs
@ 2023-01-26 20:26 Mikolaj Lisik
2023-01-27 8:27 ` [edk2-devel] " Gerd Hoffmann
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Mikolaj Lisik @ 2023-01-26 20:26 UTC (permalink / raw)
To: devel
Cc: pedro.falcato, erdemaktas, jejb, jiewen.yao, min.m.xu,
thomas.lendacky, michael.roth, Mikolaj Lisik
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>
---
.../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 *)(
--
2.39.1.456.gfc5497dd1b-goog
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [edk2-devel] [PATCH v2] OvmfPkg: Create additional PML1 entries for large SEV-SNP VMs
2023-01-26 20:26 [PATCH v2] OvmfPkg: Create additional PML1 entries for large SEV-SNP VMs Mikolaj Lisik
@ 2023-01-27 8:27 ` Gerd Hoffmann
2023-01-27 15:29 ` Lendacky, Thomas
2023-06-02 21:20 ` Lendacky, Thomas
2 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2023-01-27 8:27 UTC (permalink / raw)
To: devel, lisik
Cc: pedro.falcato, erdemaktas, jejb, jiewen.yao, min.m.xu,
thomas.lendacky, michael.roth
On Thu, Jan 26, 2023 at 08:26:40PM +0000, Mikolaj Lisik via groups.io 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.
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] OvmfPkg: Create additional PML1 entries for large SEV-SNP VMs
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
2023-06-02 21:20 ` Lendacky, Thomas
2 siblings, 0 replies; 7+ messages in thread
From: Lendacky, Thomas @ 2023-01-27 15:29 UTC (permalink / raw)
To: Mikolaj Lisik, devel
Cc: pedro.falcato, erdemaktas, jejb, jiewen.yao, min.m.xu,
michael.roth
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 *)(
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] OvmfPkg: Create additional PML1 entries for large SEV-SNP VMs
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
@ 2023-06-02 21:20 ` Lendacky, Thomas
2023-06-02 22:49 ` [edk2-devel] " Ard Biesheuvel
2 siblings, 1 reply; 7+ messages in thread
From: Lendacky, Thomas @ 2023-06-02 21:20 UTC (permalink / raw)
To: Mikolaj Lisik, devel, Gerd Hoffmann
Cc: pedro.falcato, erdemaktas, jejb, jiewen.yao, min.m.xu,
michael.roth
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>
I don't see where this was merged. Both Gerd and I acked it back in
January, was there a problem with it?
Thanks,
Tom
> ---
> .../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 *)(
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [edk2-devel] [PATCH v2] OvmfPkg: Create additional PML1 entries for large SEV-SNP VMs
2023-06-02 21:20 ` Lendacky, Thomas
@ 2023-06-02 22:49 ` Ard Biesheuvel
2023-06-02 23:03 ` Ard Biesheuvel
2023-06-02 23:56 ` Lendacky, Thomas
0 siblings, 2 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2023-06-02 22:49 UTC (permalink / raw)
To: devel, thomas.lendacky
Cc: Mikolaj Lisik, Gerd Hoffmann, pedro.falcato, erdemaktas, jejb,
jiewen.yao, min.m.xu, michael.roth
On Fri, 2 Jun 2023 at 23:20, Lendacky, Thomas via groups.io
<thomas.lendacky=amd.com@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 <lisik@google.com>
>
> 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 *)(
>
>
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [edk2-devel] [PATCH v2] OvmfPkg: Create additional PML1 entries for large SEV-SNP VMs
2023-06-02 22:49 ` [edk2-devel] " Ard Biesheuvel
@ 2023-06-02 23:03 ` Ard Biesheuvel
2023-06-02 23:56 ` Lendacky, Thomas
1 sibling, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2023-06-02 23:03 UTC (permalink / raw)
To: devel, thomas.lendacky, Michael Kinney, Michael Kubacki,
Sean Brogan
Cc: Mikolaj Lisik, Gerd Hoffmann, pedro.falcato, erdemaktas, jejb,
jiewen.yao, min.m.xu, michael.roth
On Sat, 3 Jun 2023 at 00:49, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Fri, 2 Jun 2023 at 23:20, Lendacky, Thomas via groups.io
> <thomas.lendacky=amd.com@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 <lisik@google.com>
> >
> > 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.
>
PR here
https://github.com/tianocore/edk2/pull/4473
CI is spuriously failing again.
(cc Mike + Mike + Sean)
Could someone please push the merge button on this? Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [edk2-devel] [PATCH v2] OvmfPkg: Create additional PML1 entries for large SEV-SNP VMs
2023-06-02 22:49 ` [edk2-devel] " Ard Biesheuvel
2023-06-02 23:03 ` Ard Biesheuvel
@ 2023-06-02 23:56 ` Lendacky, Thomas
1 sibling, 0 replies; 7+ messages in thread
From: Lendacky, Thomas @ 2023-06-02 23:56 UTC (permalink / raw)
To: Ard Biesheuvel, devel
Cc: Mikolaj Lisik, Gerd Hoffmann, pedro.falcato, erdemaktas, jejb,
jiewen.yao, min.m.xu, michael.roth
On 6/2/23 17:49, Ard Biesheuvel wrote:
> On Fri, 2 Jun 2023 at 23:20, Lendacky, Thomas via groups.io
> <thomas.lendacky=amd.com@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 <lisik@google.com>
>>
>> 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.
Ah, I hadn't noticed that you weren't cc'd...
>
> I've queued this up now.
Thanks, Ard!
Tom
>
>
>
>>
>>> ---
>>> .../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 *)(
>>
>>
>>
>>
>>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-06-02 23:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox