xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [Xen-devel] [PATCH v2] xen/arm: during efi boot, improve the check for usable memory
@ 2020-01-14 23:31 Stefano Stabellini
  2020-01-15 10:24 ` Julien Grall
  0 siblings, 1 reply; 2+ messages in thread
From: Stefano Stabellini @ 2020-01-14 23:31 UTC (permalink / raw)
  To: xen-devel; +Cc: sstabellini, Julien Grall, Stefano Stabellini

When booting via EFI, the EFI memory map has information about memory
regions and their type. Improve the check for the type and attribute of
each memory region to figure out whether it is usable memory or not.
This patch brings the check on par with Linux v5.5-rc6 and makes more
memory reusable as normal memory by Xen (except that Linux also reuses
EFI_PERSISTENT_MEMORY, which we do not).

Specifically, this patch also reuses memory marked as
EfiLoaderCode/Data, and it uses both Attribute and Type for the check
(Attribute needs to be EFI_MEMORY_WB).

Reported-by: Roman Shaposhnik <roman@zededa.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
CC: Julien Grall <julien@xen.org>

---
Changes in v2:
- improve commit message
- do not allocate memory marked as EFI_PERSISTENT_MEMORY
- do not change map_bs' behavior
---
 xen/arch/arm/efi/efi-boot.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
index d7bf934077..6527cb0bdf 100644
--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -149,10 +149,13 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
 
     for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
     {
-        if ( desc_ptr->Type == EfiConventionalMemory ||
-             (!map_bs &&
-              (desc_ptr->Type == EfiBootServicesCode ||
-               desc_ptr->Type == EfiBootServicesData)) )
+        if ( desc_ptr->Attribute & EFI_MEMORY_WB &&
+             (desc_ptr->Type == EfiConventionalMemory ||
+              desc_ptr->Type == EfiLoaderCode ||
+              desc_ptr->Type == EfiLoaderData ||
+              (!map_bs &&
+               (desc_ptr->Type == EfiBootServicesCode ||
+                desc_ptr->Type == EfiBootServicesData))) )
         {
             if ( !meminfo_add_bank(&bootinfo.mem, desc_ptr) )
             {
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH v2] xen/arm: during efi boot, improve the check for usable memory
  2020-01-14 23:31 [Xen-devel] [PATCH v2] xen/arm: during efi boot, improve the check for usable memory Stefano Stabellini
@ 2020-01-15 10:24 ` Julien Grall
  0 siblings, 0 replies; 2+ messages in thread
From: Julien Grall @ 2020-01-15 10:24 UTC (permalink / raw)
  To: Stefano Stabellini, xen-devel; +Cc: Stefano Stabellini

Hi Stefano,

On 14/01/2020 23:31, Stefano Stabellini wrote:
> When booting via EFI, the EFI memory map has information about memory
> regions and their type. Improve the check for the type and attribute of
> each memory region to figure out whether it is usable memory or not.
> This patch brings the check on par with Linux v5.5-rc6 and makes more
> memory reusable as normal memory by Xen (except that Linux also reuses
> EFI_PERSISTENT_MEMORY, which we do not).
> 
> Specifically, this patch also reuses memory marked as
> EfiLoaderCode/Data, and it uses both Attribute and Type for the check
> (Attribute needs to be EFI_MEMORY_WB).
> 
> Reported-by: Roman Shaposhnik <roman@zededa.com>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
> CC: Julien Grall <julien@xen.org>

Acked-by: Julien Grall <julien@xen.org>

Cheers,

> 
> ---
> Changes in v2:
> - improve commit message
> - do not allocate memory marked as EFI_PERSISTENT_MEMORY
> - do not change map_bs' behavior
> ---
>   xen/arch/arm/efi/efi-boot.h | 11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
> index d7bf934077..6527cb0bdf 100644
> --- a/xen/arch/arm/efi/efi-boot.h
> +++ b/xen/arch/arm/efi/efi-boot.h
> @@ -149,10 +149,13 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
>   
>       for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
>       {
> -        if ( desc_ptr->Type == EfiConventionalMemory ||
> -             (!map_bs &&
> -              (desc_ptr->Type == EfiBootServicesCode ||
> -               desc_ptr->Type == EfiBootServicesData)) )
> +        if ( desc_ptr->Attribute & EFI_MEMORY_WB &&
> +             (desc_ptr->Type == EfiConventionalMemory ||
> +              desc_ptr->Type == EfiLoaderCode ||
> +              desc_ptr->Type == EfiLoaderData ||
> +              (!map_bs &&
> +               (desc_ptr->Type == EfiBootServicesCode ||
> +                desc_ptr->Type == EfiBootServicesData))) )
>           {
>               if ( !meminfo_add_bank(&bootinfo.mem, desc_ptr) )
>               {
> 

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2020-01-15 10:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 23:31 [Xen-devel] [PATCH v2] xen/arm: during efi boot, improve the check for usable memory Stefano Stabellini
2020-01-15 10:24 ` Julien Grall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).