Use EfiACPIReclaimMemory for ESRT
PATCH v2 1/1 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.
---
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(-)
xen/common/efi/boot.c +12 -8
@@ -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 ) {
Signature · 3 lines
Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab
Quoted 4 lines · Demi Marie Obenour
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.
Quoted 2 lines
and
that EfiACPIReclaimMemory is a much better choice for this purpose.
I think the "better" wants explaining here, without requiring people to follow ...
... 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
Quoted 8 lines · Jan Beulich
Quoted 4 lines · Demi Marie Obenour
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.
Quoted 5 lines
Quoted 2 lines
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.”?
Quoted 4 lines
... 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.
Quoted 4 lines
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.
Signature · 3 lines
Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab
Quoted 7 lines · Demi Marie Obenour
Quoted 6 lines · Jan Beulich
Quoted 4 lines · Demi Marie Obenour
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,
Quoted 6 lines
Quoted 2 lines
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.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
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
Hi Demi,
(+Julien for his info since I am replying below about the 4.17 stuff)
Quoted 10 lines
-----Original Message-----
From: Demi Marie Obenour <[email protected]>
Subject: [PATCH v2] Use EfiACPIReclaimMemory for ESRTA 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.
Quoted 7 lines
09/msg01365.html
Fixes dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")Signed-off-by Demi Marie Obenour <[email protected]>---
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
Quoted 22 lines · Henry Wang
Hi Demi,
(+Julien for his info since I am replying below about the 4.17 stuff)
Quoted 10 lines
-----Original Message-----
From: Demi Marie Obenour <[email protected]>
Subject: [PATCH v2] Use EfiACPIReclaimMemory for ESRTA 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.
Quoted 7 lines
09/msg01365.html
Fixes dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")Signed-off-by Demi Marie Obenour <[email protected]>---
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.
Quoted 7 lines
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!
Signature · 3 lines
Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab
Quoted 6 lines · Demi Marie Obenour
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.
Quoted 6 lines
Fixes dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")Signed-off-by Demi Marie Obenour <[email protected]>---
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
Quoted 14 lines · Jan Beulich
Quoted 6 lines · Demi Marie Obenour
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.
Quoted 6 lines
Fixes dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")Signed-off-by Demi Marie Obenour <[email protected]>---
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.
Quoted 8 lines
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.
Signature · 3 lines
Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab
Quoted 9 lines · Demi Marie Obenour
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.
Fixes dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")Signed-off-by Demi Marie Obenour <[email protected]>
Quoted 3 lines
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
Hi Jan,
Quoted 16 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRTQuoted 7 lines · Demi Marie Obenour
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.
09/msg01365.html
Quoted 2 lines
Fixes dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")Signed-off-by Demi Marie Obenour <[email protected]>
Quoted 7 lines
Acked-by Jan Beulich <[email protected]>Quoted 3 lines
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:
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
Quoted 2 lines
Jan
Hi,
Quoted 27 lines · Henry Wang
Quoted 16 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRTQuoted 7 lines · Demi Marie Obenour
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.
09/msg01365.html
Quoted 2 lines
Fixes dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")Signed-off-by Demi Marie Obenour <[email protected]>Quoted 7 lines
Acked-by Jan Beulich <[email protected]>Quoted 3 lines
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:
Quoted 6 lines
Release-acked-by Henry Wang <[email protected]>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,
Signature · 1 line
Julien Grall
Hi Julien,
Quoted 26 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRTHi,
Quoted 11 lines
Quoted 9 lines
Quoted 1 line
Signed-off-by Demi Marie Obenour <[email protected]>Acked-by Jan Beulich <[email protected]>Quoted 3 lines
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
Quoted 1 line
to 4.17, so if you are sure this patch is safe and want to commit it, feel free
to add:
Quoted 6 lines
Release-acked-by Henry Wang <[email protected]>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
Quoted 6 lines
object
Quoted 1 line
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 :)
Quoted 1 line
(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.
Quoted 2 lines
My plan is to prepare the tarball tomorrow.
Thanks very much.
Kind regards,
Henry
Quoted 5 lines
Cheers,
--
Julien Grall
Quoted 35 lines · Henry Wang
Hi Julien,
Quoted 26 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRTHi,
Quoted 11 lines
Quoted 9 lines
Quoted 1 line
Signed-off-by Demi Marie Obenour <[email protected]>Acked-by Jan Beulich <[email protected]>Quoted 3 lines
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
Quoted 1 line
to 4.17, so if you are sure this patch is safe and want to commit it, feel free
to add:
Quoted 6 lines
Release-acked-by Henry Wang <[email protected]>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 JulienQuoted 6 lines
object
Quoted 1 line
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
Quoted 6 lines
This is a great solution :)
Quoted 1 line
(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.
Signature · 3 lines
Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab
Hi,
Quoted 48 lines
-----Original Message-----
From: Demi Marie Obenour <[email protected]>
Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRTQuoted 19 lines · Henry Wang
Hi Julien,
Quoted 17 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRTHi,
Quoted 11 lines
Quoted 9 lines
Quoted 1 line
Signed-off-by Demi Marie Obenour <[email protected]>Acked-by Jan Beulich <[email protected]>Quoted 3 lines
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
Quoted 2 lines
Quoted 2 lines
patch
Quoted 1 line
to 4.17, so if you are sure this patch is safe and want to commit it, feel
free
Quoted 6 lines
Quoted 6 lines
to add:
Quoted 5 lines
Release-acked-by Henry Wang <[email protected]>Since we also need to commit:
"[PATCH for-4.17] SUPPORT.md: Define support lifetime" so from myside
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
I am no problem. Julien might have different opinion though, if Julien
object
Quoted 1 line
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
Quoted 6 lines
Quoted 1 line
any issues with Osstest, then I can tag the tree without this patch
This is a great solution :)
Quoted 1 line
(that said, I would rather prefer if we have staging-4.17 == stable-4.17).
Quoted 8 lines
Quoted 2 lines
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
Quoted 4 lines
--
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab
Quoted 56 lines · Henry Wang
Hi,
Quoted 54 lines
-----Original Message-----
From: Demi Marie Obenour <[email protected]>
Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRTQuoted 19 lines · Henry Wang
Hi Julien,
Quoted 17 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Subject: Re: [PATCH v3] Use EfiACPIReclaimMemory for ESRTHi,
Quoted 11 lines
Quoted 9 lines
Quoted 1 line
Signed-off-by Demi Marie Obenour <[email protected]>Acked-by Jan Beulich <[email protected]>Quoted 3 lines
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
Quoted 2 lines
Quoted 2 lines
patch
Quoted 1 line
to 4.17, so if you are sure this patch is safe and want to commit it, feel
free
Quoted 6 lines
Quoted 6 lines
to add:
Quoted 5 lines
Release-acked-by Henry Wang <[email protected]>Since we also need to commit:
"[PATCH for-4.17] SUPPORT.md: Define support lifetime" so from myside
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
I am no problem. Julien might have different opinion though, if Julien
object
Quoted 1 line
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
Quoted 8 lines
Quoted 1 line
any issues with Osstest, then I can tag the tree without this patch
This is a great solution :)
Quoted 1 line
(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.)
Quoted 6 lines
Quoted 2 lines
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.
Signature · 3 lines
Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab