All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Use EfiACPIReclaimMemory for ESRT
@ 2022-12-06 23:27 ` Demi Marie Obenour
  0 siblings, 0 replies; 17+ messages in thread
From: Demi Marie Obenour @ 2022-10-11  3:42 UTC (permalink / raw)
  To: Xen developer discussion; +Cc: Demi Marie Obenour, Jan Beulich, Ard Biesheuval

A previous patch tried to get Linux to use the ESRT under Xen if it is
in memory of type EfiRuntimeServicesData.  However, this turns out to be
a bad idea.  Ard Biesheuvel pointed out that EfiRuntimeServices* memory
winds up fragmenting both the EFI page tables and the direct map, and
that EfiACPIReclaimMemory is a much better choice for this purpose.

Link: https://lists.xenproject.org/archives/html/xen-devel/2022-09/msg01365.html
Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
---
Changes since v1:

- Add link to Ard Biesheuvel’s post on xen-devel
- Expand comment to mention buggy firmware that place the ESRT in
  EfiBootServicesData.

 xen/common/efi/boot.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index db0340c8e2628314226c618dda11ede4c62fdf3b..b3de1011ee58a67a82a94da050eb1343f4e37faa 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -601,11 +601,14 @@ static size_t __init get_esrt_size(const EFI_MEMORY_DESCRIPTOR *desc)
     if ( physical_start > esrt || esrt - physical_start >= len )
         return 0;
     /*
-     * The specification requires EfiBootServicesData, but accept
-     * EfiRuntimeServicesData, which is a more logical choice.
+     * The specification requires EfiBootServicesData, but also accept
+     * EfiRuntimeServicesData (for compatibility with buggy firmware)
+     * and EfiACPIReclaimMemory (which will contain the tables after
+     * successful kexec).
      */
     if ( (desc->Type != EfiRuntimeServicesData) &&
-         (desc->Type != EfiBootServicesData) )
+         (desc->Type != EfiBootServicesData) &&
+         (desc->Type != EfiACPIReclaimMemory) )
         return 0;
     available_len = len - (esrt - physical_start);
     if ( available_len <= offsetof(EFI_SYSTEM_RESOURCE_TABLE, Entries) )
@@ -1144,18 +1147,19 @@ static void __init efi_relocate_esrt(EFI_SYSTEM_TABLE *SystemTable)
     for ( i = 0; i < info_size; i += mdesc_size )
     {
         /*
-         * ESRT needs to be moved to memory of type EfiRuntimeServicesData
+         * ESRT needs to be moved to memory of type EfiACPIReclaimMemory
          * so that the memory it is in will not be used for other purposes.
          */
         void *new_esrt = NULL;
-        size_t esrt_size = get_esrt_size(memory_map + i);
+        const EFI_MEMORY_DESCRIPTOR *desc = memory_map + i;
+        size_t esrt_size = get_esrt_size(desc);
 
         if ( !esrt_size )
             continue;
-        if ( ((EFI_MEMORY_DESCRIPTOR *)(memory_map + i))->Type ==
-             EfiRuntimeServicesData )
+        if ( desc->Type == EfiRuntimeServicesData ||
+             desc->Type == EfiACPIReclaimMemory )
             break; /* ESRT already safe from reuse */
-        status = efi_bs->AllocatePool(EfiRuntimeServicesData, esrt_size,
+        status = efi_bs->AllocatePool(EfiACPIReclaimMemory, esrt_size,
                                       &new_esrt);
         if ( status == EFI_SUCCESS && new_esrt )
         {
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] Use EfiACPIReclaimMemory for ESRT
  2022-12-06 23:27 ` [PATCH v2] " Demi Marie Obenour
  (?)
  (?)
@ 2022-10-11  9:59 ` Jan Beulich
  2022-10-11 16:52   ` Demi Marie Obenour
  -1 siblings, 1 reply; 17+ messages in thread
From: Jan Beulich @ 2022-10-11  9:59 UTC (permalink / raw)
  To: Demi Marie Obenour; +Cc: Ard Biesheuval, Xen developer discussion

On 11.10.2022 05:42, Demi Marie Obenour wrote:
> A previous patch tried to get Linux to use the ESRT under Xen if it is
> in memory of type EfiRuntimeServicesData.  However, this turns out to be
> a bad idea.  Ard Biesheuvel pointed out that EfiRuntimeServices* memory
> winds up fragmenting both the EFI page tables and the direct map,

Can this statement please be made describe Xen, not Linux? Aiui at least
the directmap aspect doesn't apply to Xen.

> and
> that EfiACPIReclaimMemory is a much better choice for this purpose.

I think the "better" wants explaining here, without requiring people to
follow ...

> Link: https://lists.xenproject.org/archives/html/xen-devel/2022-09/msg01365.html

... this link. Since the code change looks okay to me, I'd be okay to
replace the description with an adjusted one while committing. However,
if you expect the change to go into 4.17, you will want to resubmit
with Henry on Cc:, so he can consider giving the now necessary release-
ack.

Jan


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] Use EfiACPIReclaimMemory for ESRT
  2022-10-11  9:59 ` Jan Beulich
@ 2022-10-11 16:52   ` Demi Marie Obenour
  2022-10-12  6:19     ` Jan Beulich
  0 siblings, 1 reply; 17+ messages in thread
From: Demi Marie Obenour @ 2022-10-11 16:52 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Ard Biesheuval, Xen developer discussion

[-- Attachment #1: Type: text/plain, Size: 1584 bytes --]

On Tue, Oct 11, 2022 at 11:59:01AM +0200, Jan Beulich wrote:
> On 11.10.2022 05:42, Demi Marie Obenour wrote:
> > A previous patch tried to get Linux to use the ESRT under Xen if it is
> > in memory of type EfiRuntimeServicesData.  However, this turns out to be
> > a bad idea.  Ard Biesheuvel pointed out that EfiRuntimeServices* memory
> > winds up fragmenting both the EFI page tables and the direct map,
> 
> Can this statement please be made describe Xen, not Linux? Aiui at least
> the directmap aspect doesn't apply to Xen.

Should it apply to Xen?  My understanding is that Ard’s statements
regarding mismatched attributes refer to any kernel, not just Linux.
You would be in a better position to judge that, though.

> > and
> > that EfiACPIReclaimMemory is a much better choice for this purpose.
> 
> I think the "better" wants explaining here, without requiring people to
> follow ...

Something like, “EfiACPIReclaimMemory is the correct type for
configuration tables that are only used by the OS.”?

> > Link: https://lists.xenproject.org/archives/html/xen-devel/2022-09/msg01365.html
> 
> ... this link. Since the code change looks okay to me, I'd be okay to
> replace the description with an adjusted one while committing.

That is fine with me.

> However,
> if you expect the change to go into 4.17, you will want to resubmit
> with Henry on Cc:, so he can consider giving the now necessary release-
> ack.

Will do, with your updated commit message.
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] Use EfiACPIReclaimMemory for ESRT
  2022-10-11 16:52   ` Demi Marie Obenour
@ 2022-10-12  6:19     ` Jan Beulich
  0 siblings, 0 replies; 17+ messages in thread
From: Jan Beulich @ 2022-10-12  6:19 UTC (permalink / raw)
  To: Demi Marie Obenour; +Cc: Ard Biesheuval, Xen developer discussion

On 11.10.2022 18:52, Demi Marie Obenour wrote:
> On Tue, Oct 11, 2022 at 11:59:01AM +0200, Jan Beulich wrote:
>> On 11.10.2022 05:42, Demi Marie Obenour wrote:
>>> A previous patch tried to get Linux to use the ESRT under Xen if it is
>>> in memory of type EfiRuntimeServicesData.  However, this turns out to be
>>> a bad idea.  Ard Biesheuvel pointed out that EfiRuntimeServices* memory
>>> winds up fragmenting both the EFI page tables and the direct map,
>>
>> Can this statement please be made describe Xen, not Linux? Aiui at least
>> the directmap aspect doesn't apply to Xen.
> 
> Should it apply to Xen?  My understanding is that Ard’s statements
> regarding mismatched attributes refer to any kernel, not just Linux.
> You would be in a better position to judge that, though.

We run EFI runtime services functions on their own page tables (with
certain areas copied from the directmap). With EfiACPIReclaimMemory
converted to E820_ACPI we do not insert those ranges into the directmap
(i.e. no difference to EfiRuntimeServices*). At least this latter fact
means fragmentation effects - if they exist - are the same for both
types.

>>> and
>>> that EfiACPIReclaimMemory is a much better choice for this purpose.
>>
>> I think the "better" wants explaining here, without requiring people to
>> follow ...
> 
> Something like, “EfiACPIReclaimMemory is the correct type for
> configuration tables that are only used by the OS.”?

Preferably with "supposedly" inserted, unless you (or Ard) can point
out a place in the spec where this is actually written down.

Jan


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2] Use EfiACPIReclaimMemory for ESRT
@ 2022-12-06 23:27 ` Demi Marie Obenour
  0 siblings, 0 replies; 17+ messages in thread
From: Demi Marie Obenour @ 2022-12-06 23:27 UTC (permalink / raw)
  To: Xen developer discussion
  Cc: Demi Marie Obenour, Jan Beulich, Ard Biesheuval, Henry Wang,
	Marek Marczykowski-Górecki

A previous patch tried to get Linux to use the ESRT under Xen if it is
in memory of type EfiRuntimeServicesData.  However, this turns out to be
a bad idea.  Ard Biesheuvel pointed out that EfiRuntimeServices* memory
winds up fragmenting both the EFI page tables and the direct map, and
that EfiACPIReclaimMemory is a much better choice for this purpose.

Link: https://lists.xenproject.org/archives/html/xen-devel/2022-09/msg01365.html
Fixes: dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")
Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
---
Should this be included in 4.17?  It is a bug fix for a feature new to
4.17, so I suspect yes, but it is ultimately up to Henry Wang.

 xen/common/efi/boot.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index db0340c8e2628314226c618dda11ede4c62fdf3b..b3de1011ee58a67a82a94da050eb1343f4e37faa 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -601,11 +601,14 @@ static size_t __init get_esrt_size(const EFI_MEMORY_DESCRIPTOR *desc)
     if ( physical_start > esrt || esrt - physical_start >= len )
         return 0;
     /*
-     * The specification requires EfiBootServicesData, but accept
-     * EfiRuntimeServicesData, which is a more logical choice.
+     * The specification requires EfiBootServicesData, but also accept
+     * EfiRuntimeServicesData (for compatibility with buggy firmware)
+     * and EfiACPIReclaimMemory (which will contain the tables after
+     * successful kexec).
      */
     if ( (desc->Type != EfiRuntimeServicesData) &&
-         (desc->Type != EfiBootServicesData) )
+         (desc->Type != EfiBootServicesData) &&
+         (desc->Type != EfiACPIReclaimMemory) )
         return 0;
     available_len = len - (esrt - physical_start);
     if ( available_len <= offsetof(EFI_SYSTEM_RESOURCE_TABLE, Entries) )
@@ -1144,18 +1147,19 @@ static void __init efi_relocate_esrt(EFI_SYSTEM_TABLE *SystemTable)
     for ( i = 0; i < info_size; i += mdesc_size )
     {
         /*
-         * ESRT needs to be moved to memory of type EfiRuntimeServicesData
+         * ESRT needs to be moved to memory of type EfiACPIReclaimMemory
          * so that the memory it is in will not be used for other purposes.
          */
         void *new_esrt = NULL;
-        size_t esrt_size = get_esrt_size(memory_map + i);
+        const EFI_MEMORY_DESCRIPTOR *desc = memory_map + i;
+        size_t esrt_size = get_esrt_size(desc);
 
         if ( !esrt_size )
             continue;
-        if ( ((EFI_MEMORY_DESCRIPTOR *)(memory_map + i))->Type ==
-             EfiRuntimeServicesData )
+        if ( desc->Type == EfiRuntimeServicesData ||
+             desc->Type == EfiACPIReclaimMemory )
             break; /* ESRT already safe from reuse */
-        status = efi_bs->AllocatePool(EfiRuntimeServicesData, esrt_size,
+        status = efi_bs->AllocatePool(EfiACPIReclaimMemory, esrt_size,
                                       &new_esrt);
         if ( status == EFI_SUCCESS && new_esrt )
         {
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* RE: [PATCH v2] Use EfiACPIReclaimMemory for ESRT
  2022-12-06 23:27 ` [PATCH v2] " Demi Marie Obenour
                   ` (2 preceding siblings ...)
  (?)
@ 2022-12-07  2:44 ` Henry Wang
  2022-12-07  2:52   ` Demi Marie Obenour
  -1 siblings, 1 reply; 17+ messages in thread
From: Henry Wang @ 2022-12-07  2:44 UTC (permalink / raw)
  To: Demi Marie Obenour, Jan Beulich
  Cc: Ard Biesheuval, Xen developer discussion,
	Marek Marczykowski-Górecki, Julien Grall

Hi Demi,

(+Julien for his info since I am replying below about the 4.17 stuff)

> -----Original Message-----
> From: Demi Marie Obenour <demi@invisiblethingslab.com>
> Subject: [PATCH v2] Use EfiACPIReclaimMemory for ESRT
> 
> A previous patch tried to get Linux to use the ESRT under Xen if it is
> in memory of type EfiRuntimeServicesData.  However, this turns out to be
> a bad idea.  Ard Biesheuvel pointed out that EfiRuntimeServices* memory
> winds up fragmenting both the EFI page tables and the direct map, and
> that EfiACPIReclaimMemory is a much better choice for this purpose.
> 
> Link: https://lists.xenproject.org/archives/html/xen-devel/2022-
> 09/msg01365.html
> Fixes: dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")
> Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
> ---
> Should this be included in 4.17?  It is a bug fix for a feature new to
> 4.17, so I suspect yes, but it is ultimately up to Henry Wang.

I am planning to start the process of tagging the 4.17 so we can catch the
release date next Monday before the holiday season in Europe.

That said, if the EFI maintainer (Jan) is happy about including this in 4.17,
I don't object it if this patch can land in the stable-4.17 branch before the
end of Thursday (Dec. 8). Note that OSSTest probably needs ~1 day to do the
sync from the staging-4.17 branch.

Kind regards,
Henry


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] Use EfiACPIReclaimMemory for ESRT
  2022-12-07  2:44 ` Henry Wang
@ 2022-12-07  2:52   ` Demi Marie Obenour
  0 siblings, 0 replies; 17+ messages in thread
From: Demi Marie Obenour @ 2022-12-07  2:52 UTC (permalink / raw)
  To: Henry Wang, Jan Beulich
  Cc: Ard Biesheuval, Xen developer discussion,
	Marek Marczykowski-Górecki, Julien Grall

[-- Attachment #1: Type: text/plain, Size: 1616 bytes --]

On Wed, Dec 07, 2022 at 02:44:11AM +0000, Henry Wang wrote:
> Hi Demi,
> 
> (+Julien for his info since I am replying below about the 4.17 stuff)
> 
> > -----Original Message-----
> > From: Demi Marie Obenour <demi@invisiblethingslab.com>
> > Subject: [PATCH v2] Use EfiACPIReclaimMemory for ESRT
> > 
> > A previous patch tried to get Linux to use the ESRT under Xen if it is
> > in memory of type EfiRuntimeServicesData.  However, this turns out to be
> > a bad idea.  Ard Biesheuvel pointed out that EfiRuntimeServices* memory
> > winds up fragmenting both the EFI page tables and the direct map, and
> > that EfiACPIReclaimMemory is a much better choice for this purpose.
> > 
> > Link: https://lists.xenproject.org/archives/html/xen-devel/2022-
> > 09/msg01365.html
> > Fixes: dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")
> > Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
> > ---
> > Should this be included in 4.17?  It is a bug fix for a feature new to
> > 4.17, so I suspect yes, but it is ultimately up to Henry Wang.
> 
> I am planning to start the process of tagging the 4.17 so we can catch the
> release date next Monday before the holiday season in Europe.

> That said, if the EFI maintainer (Jan) is happy about including this in 4.17,
> I don't object it if this patch can land in the stable-4.17 branch before the
> end of Thursday (Dec. 8). Note that OSSTest probably needs ~1 day to do the
> sync from the staging-4.17 branch.

That’s fine, thanks!
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] Use EfiACPIReclaimMemory for ESRT
  2022-12-06 23:27 ` [PATCH v2] " Demi Marie Obenour
                   ` (3 preceding siblings ...)
  (?)
@ 2022-12-07 10:11 ` Jan Beulich
  2022-12-07 22:37   ` Demi Marie Obenour
  -1 siblings, 1 reply; 17+ messages in thread
From: Jan Beulich @ 2022-12-07 10:11 UTC (permalink / raw)
  To: Demi Marie Obenour
  Cc: Ard Biesheuval, Henry Wang, Marek Marczykowski-Górecki,
	Xen developer discussion

On 07.12.2022 00:27, Demi Marie Obenour wrote:
> A previous patch tried to get Linux to use the ESRT under Xen if it is
> in memory of type EfiRuntimeServicesData.  However, this turns out to be
> a bad idea.  Ard Biesheuvel pointed out that EfiRuntimeServices* memory
> winds up fragmenting both the EFI page tables and the direct map, and
> that EfiACPIReclaimMemory is a much better choice for this purpose.
> 
> Link: https://lists.xenproject.org/archives/html/xen-devel/2022-09/msg01365.html
> Fixes: dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")
> Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
> ---
> Should this be included in 4.17?  It is a bug fix for a feature new to
> 4.17, so I suspect yes, but it is ultimately up to Henry Wang.

First I was surprised this is numbered v2. But it indeed looks to be a
plain re-submission, merely with Henry Cc-ed. You didn't address my
comments; you didn't even incorporate the one adjustment where you
suggested alternative wording and where I did signal my agreement. All
this form of plain re-submission (without any kind of remark in that
direction) did is that I spent (wasted) time checking what the earlier
variant had, what was requested to be changed, and whether any of the
changes were actually carried out.

Jan


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2] Use EfiACPIReclaimMemory for ESRT
  2022-12-07 10:11 ` Jan Beulich
@ 2022-12-07 22:37   ` Demi Marie Obenour
  0 siblings, 0 replies; 17+ messages in thread
From: Demi Marie Obenour @ 2022-12-07 22:37 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Ard Biesheuval, Henry Wang, Marek Marczykowski-Górecki,
	Xen developer discussion

[-- Attachment #1: Type: text/plain, Size: 1536 bytes --]

On Wed, Dec 07, 2022 at 11:11:40AM +0100, Jan Beulich wrote:
> On 07.12.2022 00:27, Demi Marie Obenour wrote:
> > A previous patch tried to get Linux to use the ESRT under Xen if it is
> > in memory of type EfiRuntimeServicesData.  However, this turns out to be
> > a bad idea.  Ard Biesheuvel pointed out that EfiRuntimeServices* memory
> > winds up fragmenting both the EFI page tables and the direct map, and
> > that EfiACPIReclaimMemory is a much better choice for this purpose.
> > 
> > Link: https://lists.xenproject.org/archives/html/xen-devel/2022-09/msg01365.html
> > Fixes: dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")
> > Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
> > ---
> > Should this be included in 4.17?  It is a bug fix for a feature new to
> > 4.17, so I suspect yes, but it is ultimately up to Henry Wang.
> 
> First I was surprised this is numbered v2. But it indeed looks to be a
> plain re-submission, merely with Henry Cc-ed. You didn't address my
> comments; you didn't even incorporate the one adjustment where you
> suggested alternative wording and where I did signal my agreement. All
> this form of plain re-submission (without any kind of remark in that
> direction) did is that I spent (wasted) time checking what the earlier
> variant had, what was requested to be changed, and whether any of the
> changes were actually carried out.

Whoops, sorry about that.
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v3] Use EfiACPIReclaimMemory for ESRT
@ 2022-12-06 23:27 ` Demi Marie Obenour
  0 siblings, 0 replies; 17+ messages in thread
From: Demi Marie Obenour @ 2022-12-07 22:42 UTC (permalink / raw)
  To: Xen developer discussion
  Cc: Demi Marie Obenour, Jan Beulich, Ard Biesheuval, Henry Wang,
	Marek Marczykowski-Górecki

A previous patch tried to get Linux to use the ESRT under Xen if it is
in memory of type EfiRuntimeServicesData.  However, EfiRuntimeServices*
memory needs to be included in the EFI page tables, so it is best to
minimize the amount of memory of this type.  Since EFI runtime services
do not need access to the ESRT, EfiACPIReclaimMemory is a better choice.

Link: https://lists.xenproject.org/archives/html/xen-devel/2022-09/msg01365.html
Fixes: dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")
Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
---
Should this be included in 4.17?  It is a bug fix for a feature new to
4.17, so I suspect yes, but it is ultimately up to Henry Wang.  The code
is identical to v2, but I have improved the commit message.

 xen/common/efi/boot.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index db0340c8e2628314226c618dda11ede4c62fdf3b..b3de1011ee58a67a82a94da050eb1343f4e37faa 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -601,11 +601,14 @@ static size_t __init get_esrt_size(const EFI_MEMORY_DESCRIPTOR *desc)
     if ( physical_start > esrt || esrt - physical_start >= len )
         return 0;
     /*
-     * The specification requires EfiBootServicesData, but accept
-     * EfiRuntimeServicesData, which is a more logical choice.
+     * The specification requires EfiBootServicesData, but also accept
+     * EfiRuntimeServicesData (for compatibility with buggy firmware)
+     * and EfiACPIReclaimMemory (which will contain the tables after
+     * successful kexec).
      */
     if ( (desc->Type != EfiRuntimeServicesData) &&
-         (desc->Type != EfiBootServicesData) )
+         (desc->Type != EfiBootServicesData) &&
+         (desc->Type != EfiACPIReclaimMemory) )
         return 0;
     available_len = len - (esrt - physical_start);
     if ( available_len <= offsetof(EFI_SYSTEM_RESOURCE_TABLE, Entries) )
@@ -1144,18 +1147,19 @@ static void __init efi_relocate_esrt(EFI_SYSTEM_TABLE *SystemTable)
     for ( i = 0; i < info_size; i += mdesc_size )
     {
         /*
-         * ESRT needs to be moved to memory of type EfiRuntimeServicesData
+         * ESRT needs to be moved to memory of type EfiACPIReclaimMemory
          * so that the memory it is in will not be used for other purposes.
          */
         void *new_esrt = NULL;
-        size_t esrt_size = get_esrt_size(memory_map + i);
+        const EFI_MEMORY_DESCRIPTOR *desc = memory_map + i;
+        size_t esrt_size = get_esrt_size(desc);
 
         if ( !esrt_size )
             continue;
-        if ( ((EFI_MEMORY_DESCRIPTOR *)(memory_map + i))->Type ==
-             EfiRuntimeServicesData )
+        if ( desc->Type == EfiRuntimeServicesData ||
+             desc->Type == EfiACPIReclaimMemory )
             break; /* ESRT already safe from reuse */
-        status = efi_bs->AllocatePool(EfiRuntimeServicesData, esrt_size,
+        status = efi_bs->AllocatePool(EfiACPIReclaimMemory, esrt_size,
                                       &new_esrt);
         if ( status == EFI_SUCCESS && new_esrt )
         {
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
  2022-12-06 23:27 ` [PATCH v2] " Demi Marie Obenour
                   ` (4 preceding siblings ...)
  (?)
@ 2022-12-08  8:49 ` Jan Beulich
  2022-12-08  8:53   ` Henry Wang
  -1 siblings, 1 reply; 17+ messages in thread
From: Jan Beulich @ 2022-12-08  8:49 UTC (permalink / raw)
  To: Demi Marie Obenour, Henry Wang, Julien Grall
  Cc: Ard Biesheuval, Marek Marczykowski-Górecki,
	Xen developer discussion

On 07.12.2022 23:42, Demi Marie Obenour wrote:
> A previous patch tried to get Linux to use the ESRT under Xen if it is
> in memory of type EfiRuntimeServicesData.  However, EfiRuntimeServices*
> memory needs to be included in the EFI page tables, so it is best to
> minimize the amount of memory of this type.  Since EFI runtime services
> do not need access to the ESRT, EfiACPIReclaimMemory is a better choice.
> 
> Link: https://lists.xenproject.org/archives/html/xen-devel/2022-09/msg01365.html
> Fixes: dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")
> Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

> Should this be included in 4.17?  It is a bug fix for a feature new to
> 4.17, so I suspect yes, but it is ultimately up to Henry Wang.  The code
> is identical to v2, but I have improved the commit message.

It may be too late now, looking at the state of the tree. Henry, Julien?

Jan


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
  2022-12-08  8:49 ` [PATCH v3] " Jan Beulich
@ 2022-12-08  8:53   ` Henry Wang
  2022-12-08 18:05     ` Julien Grall
  0 siblings, 1 reply; 17+ messages in thread
From: Henry Wang @ 2022-12-08  8:53 UTC (permalink / raw)
  To: Jan Beulich, Demi Marie Obenour, Julien Grall
  Cc: Ard Biesheuval, Marek Marczykowski-Górecki,
	Xen developer discussion

Hi Jan,

> -----Original Message-----
> From: Jan Beulich <jbeulich@suse.com>
> Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
> 
> On 07.12.2022 23:42, Demi Marie Obenour wrote:
> > A previous patch tried to get Linux to use the ESRT under Xen if it is
> > in memory of type EfiRuntimeServicesData.  However, EfiRuntimeServices*
> > memory needs to be included in the EFI page tables, so it is best to
> > minimize the amount of memory of this type.  Since EFI runtime services
> > do not need access to the ESRT, EfiACPIReclaimMemory is a better choice.
> >
> > Link: https://lists.xenproject.org/archives/html/xen-devel/2022-
> 09/msg01365.html
> > Fixes: dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")
> > Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
> 
> Acked-by: Jan Beulich <jbeulich@suse.com>
> 
> > Should this be included in 4.17?  It is a bug fix for a feature new to
> > 4.17, so I suspect yes, but it is ultimately up to Henry Wang.  The code
> > is identical to v2, but I have improved the commit message.
> 
> It may be too late now, looking at the state of the tree. Henry, Julien?

Like I said in v2, I don't object the change if you would like to include this patch
to 4.17, so if you are sure this patch is safe and want to commit it, feel free to add:

Release-acked-by: Henry Wang <Henry.Wang@arm.com>

Since we also need to commit:
"[PATCH for-4.17] SUPPORT.md: Define support lifetime" so from my side
I am no problem. Julien might have different opinion though, if Julien object
the change I would like to respect his opinion and leave this patch uncommitted.

Kind regards,
Henry

> 
> Jan

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
  2022-12-08  8:53   ` Henry Wang
@ 2022-12-08 18:05     ` Julien Grall
  2022-12-09  7:37       ` Henry Wang
  0 siblings, 1 reply; 17+ messages in thread
From: Julien Grall @ 2022-12-08 18:05 UTC (permalink / raw)
  To: Henry Wang, Jan Beulich, Demi Marie Obenour
  Cc: Ard Biesheuval, Marek Marczykowski-Górecki,
	Xen developer discussion

Hi,

On 08/12/2022 08:53, Henry Wang wrote:
>> -----Original Message-----
>> From: Jan Beulich <jbeulich@suse.com>
>> Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
>>
>> On 07.12.2022 23:42, Demi Marie Obenour wrote:
>>> A previous patch tried to get Linux to use the ESRT under Xen if it is
>>> in memory of type EfiRuntimeServicesData.  However, EfiRuntimeServices*
>>> memory needs to be included in the EFI page tables, so it is best to
>>> minimize the amount of memory of this type.  Since EFI runtime services
>>> do not need access to the ESRT, EfiACPIReclaimMemory is a better choice.
>>>
>>> Link: https://lists.xenproject.org/archives/html/xen-devel/2022-
>> 09/msg01365.html
>>> Fixes: dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")
>>> Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
>>
>> Acked-by: Jan Beulich <jbeulich@suse.com>
>>
>>> Should this be included in 4.17?  It is a bug fix for a feature new to
>>> 4.17, so I suspect yes, but it is ultimately up to Henry Wang.  The code
>>> is identical to v2, but I have improved the commit message.
>>
>> It may be too late now, looking at the state of the tree. Henry, Julien?
> 
> Like I said in v2, I don't object the change if you would like to include this patch
> to 4.17, so if you are sure this patch is safe and want to commit it, feel free to add:
> 
> Release-acked-by: Henry Wang <Henry.Wang@arm.com>
> 
> Since we also need to commit:
> "[PATCH for-4.17] SUPPORT.md: Define support lifetime" so from my side
> I am no problem. Julien might have different opinion though, if Julien object
> the change I would like to respect his opinion and leave this patch uncommitted.

I have committed it after SUPPORT.md. So if for some reasons we are seen 
any issues with Osstest, then I can tag the tree without this patch 
(that said, I would rather prefer if we have staging-4.17 == stable-4.17).

My plan is to prepare the tarball tomorrow.

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
  2022-12-08 18:05     ` Julien Grall
@ 2022-12-09  7:37       ` Henry Wang
  2022-12-09 13:15         ` Demi Marie Obenour
  0 siblings, 1 reply; 17+ messages in thread
From: Henry Wang @ 2022-12-09  7:37 UTC (permalink / raw)
  To: Julien Grall, Jan Beulich, Demi Marie Obenour
  Cc: Ard Biesheuval, Marek Marczykowski-Górecki,
	Xen developer discussion

Hi Julien,

> -----Original Message-----
> From: Julien Grall <julien@xen.org>
> Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
> 
> Hi,
> 
> >>> Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
> >>
> >> Acked-by: Jan Beulich <jbeulich@suse.com>
> >>
> >>> Should this be included in 4.17?  It is a bug fix for a feature new to
> >>> 4.17, so I suspect yes, but it is ultimately up to Henry Wang.  The code
> >>> is identical to v2, but I have improved the commit message.
> >>
> >> It may be too late now, looking at the state of the tree. Henry, Julien?
> >
> > Like I said in v2, I don't object the change if you would like to include this
> patch
> > to 4.17, so if you are sure this patch is safe and want to commit it, feel free
> to add:
> >
> > Release-acked-by: Henry Wang <Henry.Wang@arm.com>
> >
> > Since we also need to commit:
> > "[PATCH for-4.17] SUPPORT.md: Define support lifetime" so from my side
> > I am no problem. Julien might have different opinion though, if Julien
> object
> > the change I would like to respect his opinion and leave this patch
> uncommitted.
> 
> I have committed it after SUPPORT.md. So if for some reasons we are seen
> any issues with Osstest, then I can tag the tree without this patch

This is a great solution :)

> (that said, I would rather prefer if we have staging-4.17 == stable-4.17).

Looks like now staging-4.17 == stable-4.17 now, with this patch pushed.
So we are ready to tag.

> 
> My plan is to prepare the tarball tomorrow.

Thanks very much.

Kind regards,
Henry

> 
> Cheers,
> 
> --
> Julien Grall

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
  2022-12-09  7:37       ` Henry Wang
@ 2022-12-09 13:15         ` Demi Marie Obenour
  2022-12-09 14:54           ` Henry Wang
  0 siblings, 1 reply; 17+ messages in thread
From: Demi Marie Obenour @ 2022-12-09 13:15 UTC (permalink / raw)
  To: Henry Wang, Julien Grall, Jan Beulich
  Cc: Ard Biesheuval, Marek Marczykowski-Górecki,
	Xen developer discussion

[-- Attachment #1: Type: text/plain, Size: 1972 bytes --]

On Fri, Dec 09, 2022 at 07:37:53AM +0000, Henry Wang wrote:
> Hi Julien,
> 
> > -----Original Message-----
> > From: Julien Grall <julien@xen.org>
> > Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
> > 
> > Hi,
> > 
> > >>> Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
> > >>
> > >> Acked-by: Jan Beulich <jbeulich@suse.com>
> > >>
> > >>> Should this be included in 4.17?  It is a bug fix for a feature new to
> > >>> 4.17, so I suspect yes, but it is ultimately up to Henry Wang.  The code
> > >>> is identical to v2, but I have improved the commit message.
> > >>
> > >> It may be too late now, looking at the state of the tree. Henry, Julien?
> > >
> > > Like I said in v2, I don't object the change if you would like to include this
> > patch
> > > to 4.17, so if you are sure this patch is safe and want to commit it, feel free
> > to add:
> > >
> > > Release-acked-by: Henry Wang <Henry.Wang@arm.com>
> > >
> > > Since we also need to commit:
> > > "[PATCH for-4.17] SUPPORT.md: Define support lifetime" so from my side
> > > I am no problem. Julien might have different opinion though, if Julien
> > object
> > > the change I would like to respect his opinion and leave this patch
> > uncommitted.
> > 
> > I have committed it after SUPPORT.md. So if for some reasons we are seen
> > any issues with Osstest, then I can tag the tree without this patch
> 
> This is a great solution :)
> 
> > (that said, I would rather prefer if we have staging-4.17 == stable-4.17).
> 
> Looks like now staging-4.17 == stable-4.17 now, with this patch pushed.
> So we are ready to tag.

And it turns out that I botched the initial patch, sorry.  (I forgot to
handle the multiboot2 case.)

I understand if it is too late for stable-4.17, but it ought to make
stable 4.17.1 as it was simply omitted from the initial patch series.
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
  2022-12-09 13:15         ` Demi Marie Obenour
@ 2022-12-09 14:54           ` Henry Wang
  2022-12-09 16:48             ` Demi Marie Obenour
  0 siblings, 1 reply; 17+ messages in thread
From: Henry Wang @ 2022-12-09 14:54 UTC (permalink / raw)
  To: Demi Marie Obenour, Julien Grall, Jan Beulich
  Cc: Ard Biesheuval, Marek Marczykowski-Górecki,
	Xen developer discussion

Hi,

> -----Original Message-----
> From: Demi Marie Obenour <demi@invisiblethingslab.com>
> Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
> 
> On Fri, Dec 09, 2022 at 07:37:53AM +0000, Henry Wang wrote:
> > Hi Julien,
> >
> > > -----Original Message-----
> > > From: Julien Grall <julien@xen.org>
> > > Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
> > >
> > > Hi,
> > >
> > > >>> Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
> > > >>
> > > >> Acked-by: Jan Beulich <jbeulich@suse.com>
> > > >>
> > > >>> Should this be included in 4.17?  It is a bug fix for a feature new to
> > > >>> 4.17, so I suspect yes, but it is ultimately up to Henry Wang.  The code
> > > >>> is identical to v2, but I have improved the commit message.
> > > >>
> > > >> It may be too late now, looking at the state of the tree. Henry, Julien?
> > > >
> > > > Like I said in v2, I don't object the change if you would like to include
> this
> > > patch
> > > > to 4.17, so if you are sure this patch is safe and want to commit it, feel
> free
> > > to add:
> > > >
> > > > Release-acked-by: Henry Wang <Henry.Wang@arm.com>
> > > >
> > > > Since we also need to commit:
> > > > "[PATCH for-4.17] SUPPORT.md: Define support lifetime" so from my
> side
> > > > I am no problem. Julien might have different opinion though, if Julien
> > > object
> > > > the change I would like to respect his opinion and leave this patch
> > > uncommitted.
> > >
> > > I have committed it after SUPPORT.md. So if for some reasons we are
> seen
> > > any issues with Osstest, then I can tag the tree without this patch
> >
> > This is a great solution :)
> >
> > > (that said, I would rather prefer if we have staging-4.17 == stable-4.17).
> >
> > Looks like now staging-4.17 == stable-4.17 now, with this patch pushed.
> > So we are ready to tag.
> 
> And it turns out that I botched the initial patch, sorry.  (I forgot to
> handle the multiboot2 case.)
> 
> I understand if it is too late for stable-4.17, but it ought to make
> stable 4.17.1 as it was simply omitted from the initial patch series.

I don't think this patch will make it today so I would suggest we still follow
what Julien planned yesterday. Also I think this is also consistent with the
release management guideline.

Kind regards,
Henry


> --
> Sincerely,
> Demi Marie Obenour (she/her/hers)
> Invisible Things Lab


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
  2022-12-09 14:54           ` Henry Wang
@ 2022-12-09 16:48             ` Demi Marie Obenour
  0 siblings, 0 replies; 17+ messages in thread
From: Demi Marie Obenour @ 2022-12-09 16:48 UTC (permalink / raw)
  To: Henry Wang, Julien Grall, Jan Beulich
  Cc: Ard Biesheuval, Marek Marczykowski-Górecki,
	Xen developer discussion

[-- Attachment #1: Type: text/plain, Size: 2693 bytes --]

On Fri, Dec 09, 2022 at 02:54:15PM +0000, Henry Wang wrote:
> Hi,
> 
> > -----Original Message-----
> > From: Demi Marie Obenour <demi@invisiblethingslab.com>
> > Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
> > 
> > On Fri, Dec 09, 2022 at 07:37:53AM +0000, Henry Wang wrote:
> > > Hi Julien,
> > >
> > > > -----Original Message-----
> > > > From: Julien Grall <julien@xen.org>
> > > > Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRT
> > > >
> > > > Hi,
> > > >
> > > > >>> Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
> > > > >>
> > > > >> Acked-by: Jan Beulich <jbeulich@suse.com>
> > > > >>
> > > > >>> Should this be included in 4.17?  It is a bug fix for a feature new to
> > > > >>> 4.17, so I suspect yes, but it is ultimately up to Henry Wang.  The code
> > > > >>> is identical to v2, but I have improved the commit message.
> > > > >>
> > > > >> It may be too late now, looking at the state of the tree. Henry, Julien?
> > > > >
> > > > > Like I said in v2, I don't object the change if you would like to include
> > this
> > > > patch
> > > > > to 4.17, so if you are sure this patch is safe and want to commit it, feel
> > free
> > > > to add:
> > > > >
> > > > > Release-acked-by: Henry Wang <Henry.Wang@arm.com>
> > > > >
> > > > > Since we also need to commit:
> > > > > "[PATCH for-4.17] SUPPORT.md: Define support lifetime" so from my
> > side
> > > > > I am no problem. Julien might have different opinion though, if Julien
> > > > object
> > > > > the change I would like to respect his opinion and leave this patch
> > > > uncommitted.
> > > >
> > > > I have committed it after SUPPORT.md. So if for some reasons we are
> > seen
> > > > any issues with Osstest, then I can tag the tree without this patch
> > >
> > > This is a great solution :)
> > >
> > > > (that said, I would rather prefer if we have staging-4.17 == stable-4.17).
> > >
> > > Looks like now staging-4.17 == stable-4.17 now, with this patch pushed.
> > > So we are ready to tag.
> > 
> > And it turns out that I botched the initial patch, sorry.  (I forgot to
> > handle the multiboot2 case.)
> > 
> > I understand if it is too late for stable-4.17, but it ought to make
> > stable 4.17.1 as it was simply omitted from the initial patch series.
> 
> I don't think this patch will make it today so I would suggest we still follow
> what Julien planned yesterday. Also I think this is also consistent with the
> release management guideline.

That’s okay.  Qubes can take this as an out of tree patch until it is
merged.
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-12-09 16:48 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-11  3:42 [PATCH v2] Use EfiACPIReclaimMemory for ESRT Demi Marie Obenour
2022-12-07 22:42 ` [PATCH v3] " Demi Marie Obenour
2022-12-06 23:27 ` [PATCH v2] " Demi Marie Obenour
2022-10-11  9:59 ` Jan Beulich
2022-10-11 16:52   ` Demi Marie Obenour
2022-10-12  6:19     ` Jan Beulich
2022-12-07  2:44 ` Henry Wang
2022-12-07  2:52   ` Demi Marie Obenour
2022-12-07 10:11 ` Jan Beulich
2022-12-07 22:37   ` Demi Marie Obenour
2022-12-08  8:49 ` [PATCH v3] " Jan Beulich
2022-12-08  8:53   ` Henry Wang
2022-12-08 18:05     ` Julien Grall
2022-12-09  7:37       ` Henry Wang
2022-12-09 13:15         ` Demi Marie Obenour
2022-12-09 14:54           ` Henry Wang
2022-12-09 16:48             ` Demi Marie Obenour

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.