xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][4.17] EFI: don't convert memory marked for runtime use to ordinary RAM
@ 2022-09-30  7:50 Jan Beulich
  2022-09-30 11:55 ` Bertrand Marquis
                   ` (4 more replies)
  0 siblings, 5 replies; 33+ messages in thread
From: Jan Beulich @ 2022-09-30  7:50 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, Wei Liu, Roger Pau Monné,
	Julien Grall, Stefano Stabellini, Volodymyr Babchuk,
	Bertrand Marquis, Henry Wang

efi_init_memory() in both relevant places is treating EFI_MEMORY_RUNTIME
higher priority than the type of the range. To avoid accessing memory at
runtime which was re-used for other purposes, make
efi_arch_process_memory_map() follow suit. While on x86 in theory the
same would apply to EfiACPIReclaimMemory, we don't actually "reclaim"
E820_ACPI memory there and hence that type's handling can be left alone.

Fixes: bf6501a62e80 ("x86-64: EFI boot code")
Fixes: facac0af87ef ("x86-64: EFI runtime code")
Fixes: 6d70ea10d49f ("Add ARM EFI boot support")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
Partly RFC for Arm, for two reasons:

On Arm I question the conversion of EfiACPIReclaimMemory, in two ways:
For one like on x86 such ranges would likely better be retained, as Dom0
may (will?) have a need to look at tables placed there. Plus converting
such ranges to RAM even if EFI_MEMORY_WB is not set looks suspicious to
me as well. I'd be inclined to make the latter adjustment right here
(while the other change probably would better be separate, if there
aren't actually reasons for the present behavior).

On Arm efi_init_memory() is compiled out, so adjusting Arm code here is
perhaps more for consistency (not leaving a trap for someone to later
fall into) than a strict requirement. I wonder though how Arm has
managed to get away without at least some parts of efi_init_memory() for
all the years that ACPI support has been present there. I guess this is
connected to most of runtime.c also being compiled out, but that
continuing to be the case is another aspect puzzling me.

--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -183,13 +183,15 @@ static EFI_STATUS __init efi_process_mem
 
     for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
     {
-        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 ( desc_ptr->Attribute & EFI_MEMORY_RUNTIME )
+            /* nothing */;
+        else 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) )
             {
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -185,7 +185,9 @@ static void __init efi_arch_process_memo
             /* fall through */
         case EfiLoaderCode:
         case EfiLoaderData:
-            if ( desc->Attribute & EFI_MEMORY_WB )
+            if ( desc->Attribute & EFI_MEMORY_RUNTIME )
+                type = E820_RESERVED;
+            else if ( desc->Attribute & EFI_MEMORY_WB )
                 type = E820_RAM;
             else
         case EfiUnusableMemory:


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

end of thread, other threads:[~2022-10-11  7:52 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-30  7:50 [PATCH][4.17] EFI: don't convert memory marked for runtime use to ordinary RAM Jan Beulich
2022-09-30 11:55 ` Bertrand Marquis
2022-09-30 12:47 ` Luca Fancellu
2022-09-30 12:51 ` Bertrand Marquis
2022-10-04 15:58   ` Jan Beulich
2022-10-05 10:44     ` Julien Grall
2022-10-05 11:55       ` Jan Beulich
2022-10-05 18:09         ` Julien Grall
2022-10-06  8:39           ` Jan Beulich
2022-10-06 14:11             ` Jan Beulich
2022-10-08 19:08               ` Julien Grall
2022-10-10  6:20                 ` Jan Beulich
2022-10-10 23:58                   ` Stefano Stabellini
2022-10-11  7:52                     ` Bertrand Marquis
2022-09-30 12:53 ` Andrew Cooper
2022-09-30 13:07   ` Jan Beulich
2022-09-30 13:35   ` Bertrand Marquis
2022-09-30 14:28 ` Roger Pau Monné
2022-10-04  8:06   ` Jan Beulich
2022-10-04  9:33     ` Roger Pau Monné
2022-10-04 10:23       ` Jan Beulich
2022-10-04 10:38         ` Roger Pau Monné
2022-10-04 10:44           ` Jan Beulich
2022-10-04 10:54             ` Roger Pau Monné
2022-10-04 12:18               ` Jan Beulich
2022-10-04 12:52                 ` Roger Pau Monné
2022-10-04 13:10                   ` Jan Beulich
2022-10-04 14:01                     ` Roger Pau Monné
2022-10-04 14:39                       ` Jan Beulich
2022-10-04 15:20                         ` Roger Pau Monné
2022-10-04 15:55                           ` Jan Beulich
2022-10-04 10:49         ` Andrew Cooper
2022-10-04 11:09           ` Jan Beulich

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).