arm64/efi: fix grub_efi_get_ram_base()

Message ID 20190221101508.17399-1-leif.lindholm@linaro.org
State Accepted
Commit 566b16a0dc23d72357d2d75b781d3c7895b8a234
Headers show
Series
  • arm64/efi: fix grub_efi_get_ram_base()
Related show

Commit Message

Leif Lindholm Feb. 21, 2019, 10:15 a.m.
grub_efi_get_ram_base() looks for the lowest available RAM address by
traversing the memory map, comparing lowest address found so far.
Due to a brain glitch, that "so far" was initialized to GRUB_UINT_MAX -
completely preventing boot on systems without RAM below 4GB.

Change the initial value to GRUB_EFI_MAX_USABLE_ADDRESS, as originally
intended.

Reported-by: Steve McIntyre <93sam@debian.org>
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

---
 grub-core/kern/efi/mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.11.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Comments

Steve McIntyre Feb. 21, 2019, 11:10 a.m. | #1
On Thu, Feb 21, 2019 at 10:15:08AM +0000, Leif Lindholm wrote:
>grub_efi_get_ram_base() looks for the lowest available RAM address by

>traversing the memory map, comparing lowest address found so far.

>Due to a brain glitch, that "so far" was initialized to GRUB_UINT_MAX -

>completely preventing boot on systems without RAM below 4GB.

>

>Change the initial value to GRUB_EFI_MAX_USABLE_ADDRESS, as originally

>intended.

>

>Reported-by: Steve McIntyre <93sam@debian.org>

>Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>


Tested-by: Steve McIntyre <93sam@debian.org>


>---

> grub-core/kern/efi/mm.c | 2 +-

> 1 file changed, 1 insertion(+), 1 deletion(-)

>

>diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c

>index 42ad7c570..cfe9764b7 100644

>--- a/grub-core/kern/efi/mm.c

>+++ b/grub-core/kern/efi/mm.c

>@@ -653,7 +653,7 @@ grub_efi_get_ram_base(grub_addr_t *base_addr)

>   if (ret < 1)

>     return GRUB_ERR_BUG;

> 

>-  for (desc = memory_map, *base_addr = GRUB_UINT_MAX;

>+  for (desc = memory_map, *base_addr = GRUB_EFI_MAX_USABLE_ADDRESS;

>        (grub_addr_t) desc < ((grub_addr_t) memory_map + memory_map_size);

>        desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))

>     if (desc->attribute & GRUB_EFI_MEMORY_WB)

>-- 

>2.11.0

>

>

-- 
Steve McIntyre, Cambridge, UK.                                steve@einval.com
"I've only once written 'SQL is my bitch' in a comment. But that code 
 is in use on a military site..." -- Simon Booth


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
Daniel Kiper Feb. 21, 2019, 2:45 p.m. | #2
On Thu, Feb 21, 2019 at 11:10:35AM +0000, Steve McIntyre wrote:
> On Thu, Feb 21, 2019 at 10:15:08AM +0000, Leif Lindholm wrote:

> >grub_efi_get_ram_base() looks for the lowest available RAM address by

> >traversing the memory map, comparing lowest address found so far.

> >Due to a brain glitch, that "so far" was initialized to GRUB_UINT_MAX -

> >completely preventing boot on systems without RAM below 4GB.

> >

> >Change the initial value to GRUB_EFI_MAX_USABLE_ADDRESS, as originally

> >intended.

> >

> >Reported-by: Steve McIntyre <93sam@debian.org>

> >Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

>

> Tested-by: Steve McIntyre <93sam@debian.org>


Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>


Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Patch

diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index 42ad7c570..cfe9764b7 100644
--- a/grub-core/kern/efi/mm.c
+++ b/grub-core/kern/efi/mm.c
@@ -653,7 +653,7 @@  grub_efi_get_ram_base(grub_addr_t *base_addr)
   if (ret < 1)
     return GRUB_ERR_BUG;
 
-  for (desc = memory_map, *base_addr = GRUB_UINT_MAX;
+  for (desc = memory_map, *base_addr = GRUB_EFI_MAX_USABLE_ADDRESS;
        (grub_addr_t) desc < ((grub_addr_t) memory_map + memory_map_size);
        desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
     if (desc->attribute & GRUB_EFI_MEMORY_WB)