Skip to contentSkip to conversation

kern/efi/mm.c - MAX_USABLE_ADDRESS

PATCH Leif Lindholm 2 participants 9 messages Dec 9, 2013 – Dec 10, 2013

lore
Share & tools
lore
#0 lore raw

Hi,

The EFI memory management code contains a hard-wired limit restricting physical (and virtual, all 1:1 mapped in UEFI) addresses to 32-bit. While this may be the right thing to do on x86, and hasn't caused me any issues on 32-bit ARM, I have received reports of at least two upcoming 64-bit ARM platforms with no RAM in the lower 4GB of physical address space.

A simple fix would be to just stack the ifdefs, but a better one might be to move the define to one of <cpu/efi/memory.h> (which is currently a dummy for all platforms, simply including <efi/memory.h>) or types.h.

So, for something compile tested only on arm64:

grub-core/kern/efi/mm.c +0 -6
index 6e9dace..5673d23 100644
@@ -32,12 +32,6 @@
 #define BYTES_TO_PAGES(bytes)  (((bytes) + 0xfff) >> 12)
 #define PAGES_TO_BYTES(pages)  ((pages) << 12)
 
-#if defined (__code_model_large__) || !defined (__x86_64__)
-#define MAX_USABLE_ADDRESS 0xffffffff
-#else
-#define MAX_USABLE_ADDRESS 0x7fffffff
-#endif
-
 /* The size of a memory map obtained from the firmware. This must be
    a multiplier of 4KB.  */
 #define MEMORY_MAP_SIZE        0x3000
include/grub/arm/types.h +2 -0
index 4a806d0..612ea57 100644
@@ -25,6 +25,8 @@
 /* The size of long.  */
 #define GRUB_TARGET_SIZEOF_LONG                4
 
+#define MAX_USABLE_ADDRESS             0xffffffff
+
 /* currently only support little-endian.  */
 #undef GRUB_TARGET_WORDS_BIGENDIAN
 
include/grub/arm64/types.h +2 -0
index d132c5e..d52967d 100644
@@ -25,6 +25,8 @@
 /* The size of long.  */
 #define GRUB_TARGET_SIZEOF_LONG                8
 
+#define MAX_USABLE_ADDRESS		0xffffffffffffULL
+
 /* currently only support little-endian.  */
 #undef GRUB_TARGET_WORDS_BIGENDIAN
 
include/grub/i386/types.h +6 -0
index c20063f..7fa7917 100644
@@ -25,6 +25,12 @@
 /* The size of long.  */
 #define GRUB_TARGET_SIZEOF_LONG                4
 
+#if defined (__code_model_large__)
+#define MAX_USABLE_ADDRESS             0xffffffff
+#else
+#define MAX_USABLE_ADDRESS             0x7fffffff
+#endif
+
 /* i386 is little-endian.  */
 #undef GRUB_TARGET_WORDS_BIGENDIAN
 
include/grub/ia64/types.h +2 -0
index 91a546d..8f13cf6 100644
@@ -25,6 +25,8 @@
 /* The size of long.  */
 #define GRUB_TARGET_SIZEOF_LONG                8
 
+#define MAX_USABLE_ADDRESS             0xffffffff
+
 /* ia64 is little-endian (usually).  */
 #undef GRUB_TARGET_WORDS_BIGENDIAN
 
include/grub/x86_64/types.h +6 -0
index d53138e..baa31bb 100644
@@ -25,6 +25,12 @@
 /* The size of long.  */
 #define GRUB_TARGET_SIZEOF_LONG                8
 
+#if defined (__code_model_large__)
+#define MAX_USABLE_ADDRESS             0xffffffff
+#else
+#define MAX_USABLE_ADDRESS             0x7fffffff
+#endif
+
 /* x86_64 is little-endian.  */
 #undef GRUB_TARGET_WORDS_BIGENDIAN
 

---

Would a cleaned-up patch of the same be acceptable?

/
Leif

#1 lore raw
Quoted 9 lines · Leif Lindholm

Hi,

The EFI memory management code contains a hard-wired limit restricting physical (and virtual, all 1:1 mapped in UEFI) addresses to 32-bit. While this may be the right thing to do on x86, and hasn't caused me any issues on 32-bit ARM, I have received reports of at least two upcoming 64-bit ARM platforms with no RAM in the lower 4GB of physical address space.

Quoted 4 lines

A simple fix would be to just stack the ifdefs, but a better one might be to move the define to one of <cpu/efi/memory.h> (which is currently a dummy for all platforms, simply including <efi/memory.h>) or types.h.

cpu/efi/memory.h is a possibility. cpu/types.h isn't because it's, at least partially, EFI limitation (due to EFI bugs), not CPU. Real restrictions is a mix of unrelated restriction but it seem to align well with CPU.
Increasing it beyond 0xffffffff will need chacking that efi/mm.c can handle it without overflow.
The limits are:
-0xffffffff on 32-bit platforms due to address space size (i386, arm) -0x7fffffff when x86_64 compiled without -mcmodel=large due to compiler assumptions
-0xffffffff on x86_64 because some EFI implementations don't map memory above 4G contrary to spec.
- On ia64 it's probably unlimited but I didn't test and there is always a danger of EFI bugs similar to x86_64 one, so better to be conservative about it
- arm64. You're the expert.

include/grub/i386/types.h line 33

Quoted 12 lines
include/grub/i386/types.h +6 -0
@@ -25,6 +25,12 @@
 /* The size of long.  */
 #define GRUB_TARGET_SIZEOF_LONG                4
 
+#if defined (__code_model_large__)
+#define MAX_USABLE_ADDRESS             0xffffffff
+#else
+#define MAX_USABLE_ADDRESS             0x7fffffff
+#endif
+

Should be MAX_USABLE_ADDRESS 0xffffffff

#2 lore raw
Quoted 14 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines · Leif Lindholm

Hi,

The EFI memory management code contains a hard-wired limit restricting physical (and virtual, all 1:1 mapped in UEFI) addresses to 32-bit. While this may be the right thing to do on x86, and hasn't caused me any issues on 32-bit ARM, I have received reports of at least two upcoming 64-bit ARM platforms with no RAM in the lower 4GB of physical address space.

Quoted 4 lines

A simple fix would be to just stack the ifdefs, but a better one might be to move the define to one of <cpu/efi/memory.h> (which is currently a dummy for all platforms, simply including <efi/memory.h>) or types.h.

Quoted 16 lines

cpu/efi/memory.h is a possibility. cpu/types.h isn't because it's, at least partially, EFI limitation (due to EFI bugs), not CPU. Real restrictions is a mix of unrelated restriction but it seem to align well with CPU.
Increasing it beyond 0xffffffff will need chacking that efi/mm.c can handle it without overflow.
The limits are:
-0xffffffff on 32-bit platforms due to address space size (i386, arm) -0x7fffffff when x86_64 compiled without -mcmodel=large due to compiler assumptions
-0xffffffff on x86_64 because some EFI implementations don't map memory above 4G contrary to spec.
- On ia64 it's probably unlimited but I didn't test and there is always a danger of EFI bugs similar to x86_64 one, so better to be conservative about it
- arm64. You're the expert.

If you want to increase it to 0xffffffffffffffff you'll need patch at bottom of this mail. All other uses of MAX_USABLE_ADDRESS seem to be fine. With this patch we would lose the last usable page but it's just 4K and this page is dangerous for overflows anyway so better to avoid. I'd suggest using something lower (perhaps 1M lower) to avoid potential bugs in EFI.

grub-core/kern/efi/mm.c +1 -0
index 6e9dace..2becb7b 100644
@@ -30,6 +30,7 @@
   ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
 
 #define BYTES_TO_PAGES(bytes)  (((bytes) + 0xfff) >> 12)
+#define BYTES_TO_PAGES_DOWN(bytes)     ((bytes) >> 12)
 #define PAGES_TO_BYTES(pages)  ((pages) << 12)
 
 #if defined (__code_model_large__) || !defined (__x86_64__)
@@ -343,9 +344,9 @@ filter_memory_map (grub_efi_memory_descriptor_t

*memory_map,
#if 1
if (BYTES_TO_PAGES (filtered_desc->physical_start)
+ filtered_desc->num_pages
- > BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL))
+ > BYTES_TO_PAGES_DOWN (MAX_USABLE_ADDRESS))

            filtered_desc->num_pages

- = (BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL)
+ = (BYTES_TO_PAGES_DOWN (MAX_USABLE_ADDRESS)
- BYTES_TO_PAGES (filtered_desc->physical_start));
#endif

#3 lore raw
Quoted 3 lines · Vladimir 'φ-coder/phcoder' Serbinenko

If you want to increase it to 0xffffffffffffffff you'll need patch at bottom of this mail. All other uses of MAX_USABLE_ADDRESS seem to be fine.

I can limit myself to 48 bits addressing due to current architectural restrictions, so not strictly speaking required, but...

Quoted 4 lines

With this patch we would lose the last usable page but it's just 4K and this page is dangerous for overflows anyway so better to avoid. I'd suggest using something lower (perhaps 1M lower) to avoid potential bugs in EFI.

...this certainly looks like a good idea regardless.

Quoted 24 lines
grub-core/kern/efi/mm.c +3 -2
index 6e9dace..2becb7b 100644
@@ -30,6 +30,7 @@
   ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
 
 #define BYTES_TO_PAGES(bytes)  (((bytes) + 0xfff) >> 12)
+#define BYTES_TO_PAGES_DOWN(bytes)     ((bytes) >> 12)
 #define PAGES_TO_BYTES(pages)  ((pages) << 12)
 
 #if defined (__code_model_large__) || !defined (__x86_64__)
@@ -343,9 +344,9 @@ filter_memory_map (grub_efi_memory_descriptor_t
 *memory_map,
 #if 1
          if (BYTES_TO_PAGES (filtered_desc->physical_start)
              + filtered_desc->num_pages
-             > BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL))
+             > BYTES_TO_PAGES_DOWN (MAX_USABLE_ADDRESS))
            filtered_desc->num_pages
-             = (BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL)
+             = (BYTES_TO_PAGES_DOWN (MAX_USABLE_ADDRESS)
                 - BYTES_TO_PAGES (filtered_desc->physical_start));
 #endif
#4 lore raw
In reply to Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 6 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 4 lines

A simple fix would be to just stack the ifdefs, but a better one might be to move the define to one of <cpu/efi/memory.h> (which is currently a dummy for all platforms, simply including <efi/memory.h>) or types.h.

cpu/efi/memory.h is a possibility. cpu/types.h isn't because it's, at least partially, EFI limitation (due to EFI bugs), not CPU.

Ah, ok - that makes sense then.

Quoted 7 lines

Real
restrictions is a mix of unrelated restriction but it seem to align well with CPU.
Increasing it beyond 0xffffffff will need chacking that efi/mm.c can handle it without overflow.
The limits are:
-0xffffffff on 32-bit platforms due to address space size (i386, arm)

Quoted 8 lines

-0x7fffffff when x86_64 compiled without -mcmodel=large due to compiler assumptions
-0xffffffff on x86_64 because some EFI implementations don't map memory above 4G contrary to spec.
- On ia64 it's probably unlimited but I didn't test and there is always a danger of EFI bugs similar to x86_64 one, so better to be conservative about it
- arm64. You're the expert.

Thank you - that makes it very clear.

/
Leif

#5 lore raw
Quoted 9 lines · Leif Lindholm
Quoted 6 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 4 lines

A simple fix would be to just stack the ifdefs, but a better one might be to move the define to one of <cpu/efi/memory.h> (which is currently a dummy for all platforms, simply including <efi/memory.h>) or types.h.

cpu/efi/memory.h is a possibility. cpu/types.h isn't because it's, at least partially, EFI limitation (due to EFI bugs), not CPU.

Ah, ok - that makes sense then.

How about the attached?

Compile tested for arm/arm64/i386/x86_64, runtime tested on arm64.

/
Leif

From 85e5e8576e944c2c7fb5d910f1b739e37f90d9ec Mon Sep 17 00:00:00 2001
From: Leif Lindholm <[email protected]>
Date: Tue, 10 Dec 2013 12:24:57 +0000
Subject: [PATCH] efi: mm: make MAX_USABLE_ADDRESS platform-specific

---
 ChangeLog                        |    5 +++++
 grub-core/kern/efi/mm.c          |   12 ++++--------
 include/grub/arm/efi/memory.h    |    5 +++++
 include/grub/arm64/efi/memory.h  |    5 +++++
 include/grub/i386/efi/memory.h   |    5 +++++
 include/grub/ia64/efi/memory.h   |    5 +++++
 include/grub/x86_64/efi/memory.h |    9 +++++++++
 7 files changed, 38 insertions(+), 8 deletions(-)
ChangeLog +5 -0
index aa4c05c..fef366a 100644
@@ -1,3 +1,8 @@
+2013-12-10  Leif Lindholm <[email protected]>
+
+	* make MAX_USABLE_ADDRESS platform-specific
+	* grub-core/kern/efi/mm.c: add Vladimir's new BYTES_TO_PAGES_DOWN macro.
+
 2013-12-09  Jon McCune <[email protected]>
 
 	* Add --no-rs-codes flag to optionally disable reed-solomon codes
grub-core/kern/efi/mm.c +4 -8
index 6e9dace..3ba69f8 100644
@@ -21,6 +21,7 @@
 #include <grub/mm.h>
 #include <grub/efi/api.h>
 #include <grub/efi/efi.h>
+#include <grub/cpu/efi/memory.h>
 
 #if defined (__i386__) || defined (__x86_64__)
 #include <grub/pci.h>
@@ -30,14 +31,9 @@
   ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
 
 #define BYTES_TO_PAGES(bytes)	(((bytes) + 0xfff) >> 12)
+#define BYTES_TO_PAGES_DOWN(bytes)	((bytes) >> 12)
 #define PAGES_TO_BYTES(pages)	((pages) << 12)
 
-#if defined (__code_model_large__) || !defined (__x86_64__)
-#define MAX_USABLE_ADDRESS 0xffffffff
-#else
-#define MAX_USABLE_ADDRESS 0x7fffffff
-#endif
-
 /* The size of a memory map obtained from the firmware. This must be
    a multiplier of 4KB.  */
 #define MEMORY_MAP_SIZE	0x3000
@@ -343,9 +339,9 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
 #if 1
 	  if (BYTES_TO_PAGES (filtered_desc->physical_start)
 	      + filtered_desc->num_pages
-	      > BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL))
+	      > BYTES_TO_PAGES_DOWN (MAX_USABLE_ADDRESS))
 	    filtered_desc->num_pages
-	      = (BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL)
+	      = (BYTES_TO_PAGES_DOWN (MAX_USABLE_ADDRESS)
 		 - BYTES_TO_PAGES (filtered_desc->physical_start));
 #endif
 
include/grub/arm/efi/memory.h +5 -0
index c9a61bb..1968b3b 100644
@@ -1 +1,6 @@
+#ifndef GRUB_MEMORY_CPU_HEADER
 #include <grub/efi/memory.h>
+
+#define MAX_USABLE_ADDRESS 0xffffffff
+
+#endif /* ! GRUB_MEMORY_CPU_HEADER */
include/grub/arm64/efi/memory.h +5 -0
index c9a61bb..8340083 100644
@@ -1 +1,6 @@
+#ifndef GRUB_MEMORY_CPU_HEADER
 #include <grub/efi/memory.h>
+
+#define MAX_USABLE_ADDRESS 0xffffffffffffULL
+
+#endif /* ! GRUB_MEMORY_CPU_HEADER */
include/grub/i386/efi/memory.h +5 -0
index c9a61bb..1968b3b 100644
@@ -1 +1,6 @@
+#ifndef GRUB_MEMORY_CPU_HEADER
 #include <grub/efi/memory.h>
+
+#define MAX_USABLE_ADDRESS 0xffffffff
+
+#endif /* ! GRUB_MEMORY_CPU_HEADER */
include/grub/ia64/efi/memory.h +5 -0
index c9a61bb..1968b3b 100644
@@ -1 +1,6 @@
+#ifndef GRUB_MEMORY_CPU_HEADER
 #include <grub/efi/memory.h>
+
+#define MAX_USABLE_ADDRESS 0xffffffff
+
+#endif /* ! GRUB_MEMORY_CPU_HEADER */
include/grub/x86_64/efi/memory.h +9 -0
index c9a61bb..ed1e640 100644
@@ -1 +1,10 @@
+#ifndef GRUB_MEMORY_CPU_HEADER
 #include <grub/efi/memory.h>
+
+#if defined (__code_model_large__)
+#define MAX_USABLE_ADDRESS 0xffffffff
+#else
+#define MAX_USABLE_ADDRESS 0x7fffffff
+#endif
+
+#endif /* ! GRUB_MEMORY_CPU_HEADER */
Signature · 1 line
1.7.10.4
#6 lore raw
Quoted 6 lines · Leif Lindholm
Quoted 5 lines · Leif Lindholm
Quoted 4 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 4 lines

A simple fix would be to just stack the ifdefs, but a better one might be to move the define to one of <cpu/efi/memory.h> (which is currently a dummy for all platforms, simply including <efi/memory.h>) or types.h.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

cpu/efi/memory.h is a possibility. cpu/types.h isn't because it's, at least partially, EFI limitation (due to EFI bugs), not CPU.

Ah, ok - that makes sense then.

How about the attached?

You need to prefix define with GRUB_EFI_ as soon as it's a global define and not limited to one file. Otherwise patch looks good. Can you send corrected version?

Quoted 12 lines

Compile tested for arm/arm64/i386/x86_64, runtime tested on arm64.

/
Leif

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#7 lore raw
Quoted 5 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 2 lines

How about the attached?

You need to prefix define with GRUB_EFI_ as soon as it's a global define and not limited to one file. Otherwise patch looks good. Can you send corrected version?

Attached.

Quoted 1 line
Quoted 1 line

Compile tested for arm/arm64/i386/x86_64, runtime tested on arm64.

Same again.

/
Leif

From 09d798628d88542b2af361d5898b179efa2194b3 Mon Sep 17 00:00:00 2001
From: Leif Lindholm <[email protected]>
Date: Tue, 10 Dec 2013 12:24:57 +0000
Subject: [PATCH] efi: mm: make MAX_USABLE_ADDRESS platform-specific

---
 ChangeLog                        |    5 +++++
 grub-core/kern/efi/mm.c          |   20 ++++++++------------
 include/grub/arm/efi/memory.h    |    5 +++++
 include/grub/arm64/efi/memory.h  |    5 +++++
 include/grub/i386/efi/memory.h   |    5 +++++
 include/grub/ia64/efi/memory.h   |    5 +++++
 include/grub/x86_64/efi/memory.h |    9 +++++++++
 7 files changed, 42 insertions(+), 12 deletions(-)
ChangeLog +5 -0
index b706eb5..62fdb03 100644
@@ -1,5 +1,10 @@
 2013-12-10  Leif Lindholm <[email protected]>
 
+	* make MAX_USABLE_ADDRESS platform-specific
+	* grub-core/kern/efi/mm.c: add Vladimir's new BYTES_TO_PAGES_DOWN macro.
+
+2013-12-10  Leif Lindholm <[email protected]>
+
 	* grub-core/lib/fdt.c: change memcpy => grub_memcpy
 
 2013-12-09  Jon McCune <[email protected]>
grub-core/kern/efi/mm.c +8 -12
index 6e9dace..be37afd 100644
@@ -21,6 +21,7 @@
 #include <grub/mm.h>
 #include <grub/efi/api.h>
 #include <grub/efi/efi.h>
+#include <grub/cpu/efi/memory.h>
 
 #if defined (__i386__) || defined (__x86_64__)
 #include <grub/pci.h>
@@ -30,14 +31,9 @@
   ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
 
 #define BYTES_TO_PAGES(bytes)	(((bytes) + 0xfff) >> 12)
+#define BYTES_TO_PAGES_DOWN(bytes)	((bytes) >> 12)
 #define PAGES_TO_BYTES(pages)	((pages) << 12)
 
-#if defined (__code_model_large__) || !defined (__x86_64__)
-#define MAX_USABLE_ADDRESS 0xffffffff
-#else
-#define MAX_USABLE_ADDRESS 0x7fffffff
-#endif
-
 /* The size of a memory map obtained from the firmware. This must be
    a multiplier of 4KB.  */
 #define MEMORY_MAP_SIZE	0x3000
@@ -64,7 +60,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
 
 #if 1
   /* Limit the memory access to less than 4GB for 32-bit platforms.  */
-  if (address > MAX_USABLE_ADDRESS)
+  if (address > GRUB_EFI_MAX_USABLE_ADDRESS)
     return 0;
 #endif
 
@@ -72,7 +68,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
   if (address == 0)
     {
       type = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
-      address = MAX_USABLE_ADDRESS;
+      address = GRUB_EFI_MAX_USABLE_ADDRESS;
     }
   else
     type = GRUB_EFI_ALLOCATE_ADDRESS;
@@ -92,7 +88,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
     {
       /* Uggh, the address 0 was allocated... This is too annoying,
 	 so reallocate another one.  */
-      address = MAX_USABLE_ADDRESS;
+      address = GRUB_EFI_MAX_USABLE_ADDRESS;
       status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address);
       grub_efi_free_pages (0, pages);
       if (status != GRUB_EFI_SUCCESS)
@@ -325,7 +321,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
     {
       if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
 #if 1
-	  && desc->physical_start <= MAX_USABLE_ADDRESS
+	  && desc->physical_start <= GRUB_EFI_MAX_USABLE_ADDRESS
 #endif
 	  && desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000
 	  && desc->num_pages != 0)
@@ -343,9 +339,9 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
 #if 1
 	  if (BYTES_TO_PAGES (filtered_desc->physical_start)
 	      + filtered_desc->num_pages
-	      > BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL))
+	      > BYTES_TO_PAGES_DOWN (GRUB_EFI_MAX_USABLE_ADDRESS))
 	    filtered_desc->num_pages
-	      = (BYTES_TO_PAGES (MAX_USABLE_ADDRESS+1LL)
+	      = (BYTES_TO_PAGES_DOWN (GRUB_EFI_MAX_USABLE_ADDRESS)
 		 - BYTES_TO_PAGES (filtered_desc->physical_start));
 #endif
 
include/grub/arm/efi/memory.h +5 -0
index c9a61bb..2c64918 100644
@@ -1 +1,6 @@
+#ifndef GRUB_MEMORY_CPU_HEADER
 #include <grub/efi/memory.h>
+
+#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
+
+#endif /* ! GRUB_MEMORY_CPU_HEADER */
include/grub/arm64/efi/memory.h +5 -0
index c9a61bb..c6cb324 100644
@@ -1 +1,6 @@
+#ifndef GRUB_MEMORY_CPU_HEADER
 #include <grub/efi/memory.h>
+
+#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffffffULL
+
+#endif /* ! GRUB_MEMORY_CPU_HEADER */
include/grub/i386/efi/memory.h +5 -0
index c9a61bb..2c64918 100644
@@ -1 +1,6 @@
+#ifndef GRUB_MEMORY_CPU_HEADER
 #include <grub/efi/memory.h>
+
+#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
+
+#endif /* ! GRUB_MEMORY_CPU_HEADER */
include/grub/ia64/efi/memory.h +5 -0
index c9a61bb..2c64918 100644
@@ -1 +1,6 @@
+#ifndef GRUB_MEMORY_CPU_HEADER
 #include <grub/efi/memory.h>
+
+#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
+
+#endif /* ! GRUB_MEMORY_CPU_HEADER */
include/grub/x86_64/efi/memory.h +9 -0
index c9a61bb..46e9145 100644
@@ -1 +1,10 @@
+#ifndef GRUB_MEMORY_CPU_HEADER
 #include <grub/efi/memory.h>
+
+#if defined (__code_model_large__)
+#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
+#else
+#define GRUB_EFI_MAX_USABLE_ADDRESS 0x7fffffff
+#endif
+
+#endif /* ! GRUB_MEMORY_CPU_HEADER */
Signature · 1 line
1.7.10.4
#8 lore raw

Go ahead.

Quoted 23 lines · Leif Lindholm
Quoted 5 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 2 lines

How about the attached?

You need to prefix define with GRUB_EFI_ as soon as it's a global define and not limited to one file. Otherwise patch looks good. Can you send corrected version?

Attached.

Quoted 1 line
Quoted 1 line

Compile tested for arm/arm64/i386/x86_64, runtime tested on arm64.

Same again.

/
Leif

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel