grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* kern/efi/mm.c - MAX_USABLE_ADDRESS
@ 2013-12-09 17:30 Leif Lindholm
  2013-12-09 19:08 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 9+ messages in thread
From: Leif Lindholm @ 2013-12-09 17:30 UTC (permalink / raw)
  To: grub-devel

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:
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index 6e9dace..5673d23 100644
--- a/grub-core/kern/efi/mm.c
+++ b/grub-core/kern/efi/mm.c
@@ -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
diff --git a/include/grub/arm/types.h b/include/grub/arm/types.h
index 4a806d0..612ea57 100644
--- a/include/grub/arm/types.h
+++ b/include/grub/arm/types.h
@@ -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
 
diff --git a/include/grub/arm64/types.h b/include/grub/arm64/types.h
index d132c5e..d52967d 100644
--- a/include/grub/arm64/types.h
+++ b/include/grub/arm64/types.h
@@ -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
 
diff --git a/include/grub/i386/types.h b/include/grub/i386/types.h
index c20063f..7fa7917 100644
--- a/include/grub/i386/types.h
+++ b/include/grub/i386/types.h
@@ -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
 
diff --git a/include/grub/ia64/types.h b/include/grub/ia64/types.h
index 91a546d..8f13cf6 100644
--- a/include/grub/ia64/types.h
+++ b/include/grub/ia64/types.h
@@ -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
 
diff --git a/include/grub/x86_64/types.h b/include/grub/x86_64/types.h
index d53138e..baa31bb 100644
--- a/include/grub/x86_64/types.h
+++ b/include/grub/x86_64/types.h
@@ -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


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

end of thread, other threads:[~2013-12-10 18:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-09 17:30 kern/efi/mm.c - MAX_USABLE_ADDRESS Leif Lindholm
2013-12-09 19:08 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-09 19:43   ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-09 21:26     ` Leif Lindholm
2013-12-09 21:17   ` Leif Lindholm
2013-12-10 14:59     ` Leif Lindholm
2013-12-10 16:00       ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-10 17:15         ` Leif Lindholm
2013-12-10 18:00           ` Vladimir 'φ-coder/phcoder' Serbinenko

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