Skip to contentSkip to conversation

efi_loader: Handle memory overflows

PATCH New Andreas Färber 3 participants 3 messages Apr 13, 2016 – Apr 21, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 efi_loader: Handle memory overflows

jetson-tk1 has 2 GB of RAM at 0x80000000, causing gd->ram_top to be zero. Handle this by either avoiding ram_top or by using the same type as ram_top to reverse the overflow effect.

---
 lib/efi_loader/efi_memory.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/efi_loader/efi_memory.c +4 -4
index 138736f..82003d7 100644
@@ -225,7 +225,7 @@ efi_status_t efi_allocate_pages(int type, int memory_type,
 	switch (type) {
 	case 0:
 		/* Any page */
-		addr = efi_find_free_memory(len, gd->ram_top);
+		addr = efi_find_free_memory(len, gd->start_addr_sp);
 		if (!addr) {
 			r = EFI_NOT_FOUND;
 			break;
@@ -325,9 +325,9 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
 
 int efi_memory_init(void)
 {
-	uint64_t runtime_start, runtime_end, runtime_pages;
-	uint64_t uboot_start, uboot_pages;
-	uint64_t uboot_stack_size = 16 * 1024 * 1024;
+	unsigned long runtime_start, runtime_end, runtime_pages;
+	unsigned long uboot_start, uboot_pages;
+	unsigned long uboot_stack_size = 16 * 1024 * 1024;
 	int i;
 
 	/* Add RAM */
Signature · 1 line
2.6.6
#1 lore raw

PATCH v2 1/1 efi_loader: Handle memory overflows

Quoted 6 lines · Andreas F?rber

jetson-tk1 has 2 GB of RAM at 0x80000000, causing gd->ram_top to be zero. Handle this by either avoiding ram_top or by using the same type as ram_top to reverse the overflow effect.

Alex

Quoted 30 lines
---
  lib/efi_loader/efi_memory.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
lib/efi_loader/efi_memory.c +4 -4
index 138736f..82003d7 100644
@@ -225,7 +225,7 @@ efi_status_t efi_allocate_pages(int type, int memory_type,
  	switch (type) {
  	case 0:
  		/* Any page */
-		addr = efi_find_free_memory(len, gd->ram_top);
+		addr = efi_find_free_memory(len, gd->start_addr_sp);
  		if (!addr) {
  			r = EFI_NOT_FOUND;
  			break;
@@ -325,9 +325,9 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
 
  int efi_memory_init(void)
  {
-	uint64_t runtime_start, runtime_end, runtime_pages;
-	uint64_t uboot_start, uboot_pages;
-	uint64_t uboot_stack_size = 16 * 1024 * 1024;
+	unsigned long runtime_start, runtime_end, runtime_pages;
+	unsigned long uboot_start, uboot_pages;
+	unsigned long uboot_stack_size = 16 * 1024 * 1024;
  	int i;
 
  	/* Add RAM */
#2 lore raw

PATCH v2 1/1 efi_loader: Handle memory overflows

In reply to Andreas Färber
Quoted 7 lines · Andreas F?rber

jetson-tk1 has 2 GB of RAM at 0x80000000, causing gd->ram_top to be zero. Handle this by either avoiding ram_top or by using the same type as ram_top to reverse the overflow effect.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160421/3d9160fd/attachment.sig>