Skip to contentSkip to conversation

Allow booting a 32-bit system with a top memory address beyond 4 GiB

PATCH Superseded Bin Meng 2 participants 23 messages Jan 31, 2021 – Feb 4, 2021

Subsystems (10)
lore
Share & tools
lore

Bin Meng

author
#0 lore raw

v2 cover Allow booting a 32-bit system with a top memory address beyond 4 GiB

When testing QEMU RISC-V 'virt' machine with a 2 GiB memory configuration, it was discovered gd->ram_top is assigned to value zero in setup_dest_addr().

While 2 GiB QEMU RISC-V 'virt' happens to work with U-Boot today, increasing more memory doesn't make a bootable system. There are various places in U-Boot that prevents such from working.

While this is seen and tested on RISC-V, it's not RISC-V centric, but a generic issue that may affect all architectures.

Changes in v2:
- new patch: arm: rockchip: Explicitly cast gd->ram_top in dram_init_banksize()
- new patch: riscv: ax25-ae350: Cast addr with uintptr_t
- new patch: net: ftmac100: Cast priv->iobase with uintptr_t

Bin Meng (10):
riscv: Adjust board_get_usable_ram_top() for 32-bit
arm: rockchip: Explicitly cast gd->ram_top in dram_init_banksize() global_data.h: Change ram_top type to phys_addr_t
serial: sifive: Cast dev_read_addr() with uintptr_t
riscv: ax25-ae350: Cast addr with uintptr_t
net: ftmac100: Cast priv->iobase with uintptr_t
fdtdec: Cast prior_stage_fdt_address with uintptr_t
riscv: Change phys_addr_t and phys_size_t to 64-bit
bdinfo: Rename function names to be clearer
bdinfo: Change to use bdinfo_print_num_ll() where the number could be

    64-bit
 arch/arm/lib/bdinfo.c                   | 16 ++++----
 arch/arm/mach-rockchip/sdram.c          |  2 +-
 arch/m68k/lib/bdinfo.c                  |  2 +-
 arch/powerpc/lib/bdinfo.c               |  4 +-
 arch/riscv/cpu/fu540/dram.c             |  7 ++--
 arch/riscv/cpu/generic/dram.c           |  7 ++--
 arch/riscv/include/asm/types.h          |  4 +-
 board/AndesTech/ax25-ae350/ax25-ae350.c |  2 +-
 cmd/bdinfo.c                            | 52 ++++++++++++-------------
 drivers/net/ftmac100.c                  | 10 ++---
 drivers/serial/serial_sifive.c          |  2 +-
 include/asm-generic/global_data.h       |  2 +-
 include/init.h                          |  3 +-
 lib/fdtdec.c                            |  2 +-
 14 files changed, 57 insertions(+), 58 deletions(-)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v2 1/10 riscv: Adjust board_get_usable_ram_top() for 32-bit

From: Bin Meng <[email protected]>

When testing QEMU RISC-V 'virt' machine with a 2 GiB memory configuration, it was discovered gd->ram_top is assigned to value zero in setup_dest_addr().

While gd->ram_top should not be declared as type unsigned long, which will be updated in a future patch, the current logic in board_get_usable_ram_top() can be updated to cover both 64-bit and 32-bit RISC-V.

---

(no changes since v1)

 arch/riscv/cpu/fu540/dram.c   | 7 +++----
 arch/riscv/cpu/generic/dram.c | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)
arch/riscv/cpu/fu540/dram.c +3 -4
index 1dc77efeca..259da65a54 100644
@@ -22,7 +22,6 @@ int dram_init_banksize(void)
 
 ulong board_get_usable_ram_top(ulong total_size)
 {
-#ifdef CONFIG_64BIT
 	/*
 	 * Ensure that we run from first 4GB so that all
 	 * addresses used by U-Boot are 32bit addresses.
@@ -31,8 +30,8 @@ ulong board_get_usable_ram_top(ulong total_size)
 	 * devices work fine because DMA mapping APIs will
 	 * provide 32bit DMA addresses only.
 	 */
-	if (gd->ram_top > SZ_4G)
-		return SZ_4G;
-#endif
+	if (gd->ram_top >= SZ_4G)
+		return SZ_4G - 1;
+
 	return gd->ram_top;
 }
arch/riscv/cpu/generic/dram.c +3 -4
index 1dc77efeca..259da65a54 100644
@@ -22,7 +22,6 @@ int dram_init_banksize(void)
 
 ulong board_get_usable_ram_top(ulong total_size)
 {
-#ifdef CONFIG_64BIT
 	/*
 	 * Ensure that we run from first 4GB so that all
 	 * addresses used by U-Boot are 32bit addresses.
@@ -31,8 +30,8 @@ ulong board_get_usable_ram_top(ulong total_size)
 	 * devices work fine because DMA mapping APIs will
 	 * provide 32bit DMA addresses only.
 	 */
-	if (gd->ram_top > SZ_4G)
-		return SZ_4G;
-#endif
+	if (gd->ram_top >= SZ_4G)
+		return SZ_4G - 1;
+
 	return gd->ram_top;
 }
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 1/10 riscv: Adjust board_get_usable_ram_top() for 32-bit

From: Bin Meng <[email protected]>

When testing QEMU RISC-V 'virt' machine with a 2 GiB memory configuration, it was discovered gd->ram_top is assigned to value zero in setup_dest_addr().

While gd->ram_top should not be declared as type unsigned long, which will be updated in a future patch, the current logic in board_get_usable_ram_top() can be updated to cover both 64-bit and 32-bit RISC-V.

---

(no changes since v1)

 arch/riscv/cpu/fu540/dram.c   | 7 +++----
 arch/riscv/cpu/generic/dram.c | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)

Applied to u-boot-dm, thanks!

author
#3 lore raw

PATCH v2 2/10 arm: rockchip: Explicitly cast gd->ram_top in dram_init_banksize()

In reply to Bin Meng

From: Bin Meng <[email protected]>

The min() macro used in dram_init_banksize() requires two elements to compare have the same type. Let's explicitly cast gd->ram_top.

---

Changes in v2:
- new patch: arm: rockchip: Explicitly cast gd->ram_top in dram_init_banksize()

 arch/arm/mach-rockchip/sdram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-rockchip/sdram.c +1 -1
index 4c637b7767..c3d5fed7db 100644
@@ -37,7 +37,7 @@ struct tos_parameter_t {
 int dram_init_banksize(void)
 {
 	size_t top = min((unsigned long)(gd->ram_size + CONFIG_SYS_SDRAM_BASE),
-			 gd->ram_top);
+			 (unsigned long)(gd->ram_top));
 
 #ifdef CONFIG_ARM64
 	/* Reserve 0x200000 for ATF bl31 */
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 2/10 arm: rockchip: Explicitly cast gd->ram_top in dram_init_banksize()

From: Bin Meng <[email protected]>

The min() macro used in dram_init_banksize() requires two elements to compare have the same type. Let's explicitly cast gd->ram_top.

---

Changes in v2:
- new patch: arm: rockchip: Explicitly cast gd->ram_top in dram_init_banksize()

 arch/arm/mach-rockchip/sdram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm, thanks!

author
#5 lore raw

PATCH v2 3/10 global_data.h: Change ram_top type to phys_addr_t

In reply to Bin Meng

From: Bin Meng <[email protected]>

It's possible to have ram_top above 4 GiB in a 32-bit system, hence we need to declare ram_top as phys_addr_t.

---

(no changes since v1)

 include/asm-generic/global_data.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/global_data.h +1 -1
index b6f707e97e..998beb0176 100644
@@ -147,7 +147,7 @@ struct global_data {
 	/**
 	 * @ram_top: top address of RAM used by U-Boot
 	 */
-	unsigned long ram_top;
+	phys_addr_t ram_top;
 	/**
 	 * @relocaddr: start address of U-Boot in RAM
 	 *
Signature · 1 line
2.25.1
author
#7 lore raw

PATCH v2 4/10 serial: sifive: Cast dev_read_addr() with uintptr_t

In reply to Bin Meng

From: Bin Meng <[email protected]>

dev_read_addr() returns fdt_addr_t which is now a 64-bit address. In a 32-bit build, this causes the following warning seen when building serial_sifive.c:

warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

Cast the return value with uintptr_t.

---

(no changes since v1)

 drivers/serial/serial_sifive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/serial/serial_sifive.c +1 -1
index d26fe7e770..97bf20c967 100644
@@ -178,7 +178,7 @@ static int sifive_serial_of_to_plat(struct udevice *dev)
 {
 	struct sifive_uart_plat *plat = dev_get_plat(dev);
 
-	plat->regs = (struct uart_sifive *)dev_read_addr(dev);
+	plat->regs = (struct uart_sifive *)(uintptr_t)dev_read_addr(dev);
 	if (IS_ERR(plat->regs))
 		return PTR_ERR(plat->regs);
 
Signature · 1 line
2.25.1
#8 lore raw

PATCH v2 4/10 serial: sifive: Cast dev_read_addr() with uintptr_t

From: Bin Meng <[email protected]>

dev_read_addr() returns fdt_addr_t which is now a 64-bit address. In a 32-bit build, this causes the following warning seen when building serial_sifive.c:

warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]

Cast the return value with uintptr_t.

---

(no changes since v1)

 drivers/serial/serial_sifive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm, thanks!

author
#9 lore raw

PATCH v2 5/10 riscv: ax25-ae350: Cast addr with uintptr_t

In reply to Bin Meng

From: Bin Meng <[email protected]>

addr was delcared as fdt_addr_t which is now a 64-bit address. In a 32-bit build, this causes the following warning seen when building ax25-ae350.c:

warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

Cast addr with uintptr_t.

---

Changes in v2:
- new patch: riscv: ax25-ae350: Cast addr with uintptr_t

 board/AndesTech/ax25-ae350/ax25-ae350.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/AndesTech/ax25-ae350/ax25-ae350.c +1 -1
index 59a43e4dcc..3125233488 100644
@@ -77,7 +77,7 @@ int smc_init(void)
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
-	regs = (struct ftsmc020_bank *)addr;
+	regs = (struct ftsmc020_bank *)(uintptr_t)addr;
 	regs->cr &= ~FTSMC020_BANK_WPROT;
 
 	return 0;
Signature · 1 line
2.25.1
#10 lore raw

PATCH v2 5/10 riscv: ax25-ae350: Cast addr with uintptr_t

From: Bin Meng <[email protected]>

addr was delcared as fdt_addr_t which is now a 64-bit address. In a 32-bit build, this causes the following warning seen when building ax25-ae350.c:

warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]

Cast addr with uintptr_t.

---

Changes in v2:
- new patch: riscv: ax25-ae350: Cast addr with uintptr_t

 board/AndesTech/ax25-ae350/ax25-ae350.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm, thanks!

author
#11 lore raw

PATCH v2 6/10 net: ftmac100: Cast priv->iobase with uintptr_t

In reply to Bin Meng

From: Bin Meng <[email protected]>

priv->iobase was declared as phys_addr_t which is now a 64-bit address. In a 32-bit build, this causes the following warning seen when building ftmac100.c:

warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

Cast priv->iobase with uintptr_t.

---

Changes in v2:
- new patch: net: ftmac100: Cast priv->iobase with uintptr_t

 drivers/net/ftmac100.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ftmac100.c +5 -5
index 0d672374fd..fc578b0375 100644
@@ -35,7 +35,7 @@ struct ftmac100_data {
  */
 static void ftmac100_reset(struct ftmac100_data *priv)
 {
-	struct ftmac100 *ftmac100 = (struct ftmac100 *)priv->iobase;
+	struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase;
 
 	debug ("%s()\n", __func__);
 
@@ -56,7 +56,7 @@ static void ftmac100_reset(struct ftmac100_data *priv)
 static void ftmac100_set_mac(struct ftmac100_data *priv ,
 	const unsigned char *mac)
 {
-	struct ftmac100 *ftmac100 = (struct ftmac100 *)priv->iobase;
+	struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase;
 	unsigned int maddr = mac[0] << 8 | mac[1];
 	unsigned int laddr = mac[2] << 24 | mac[3] << 16 | mac[4] << 8 | mac[5];
 
@@ -71,7 +71,7 @@ static void ftmac100_set_mac(struct ftmac100_data *priv ,
  */
 static void _ftmac100_halt(struct ftmac100_data *priv)
 {
-	struct ftmac100 *ftmac100 = (struct ftmac100 *)priv->iobase;
+	struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase;
 	debug ("%s()\n", __func__);
 	writel (0, &ftmac100->maccr);
 }
@@ -81,7 +81,7 @@ static void _ftmac100_halt(struct ftmac100_data *priv)
  */
 static int _ftmac100_init(struct ftmac100_data *priv, unsigned char enetaddr[6])
 {
-	struct ftmac100 *ftmac100 = (struct ftmac100 *)priv->iobase;
+	struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase;
 	struct ftmac100_txdes *txdes = priv->txdes;
 	struct ftmac100_rxdes *rxdes = priv->rxdes;
 	unsigned int maccr;
@@ -186,7 +186,7 @@ static int __ftmac100_recv(struct ftmac100_data *priv)
  */
 static int _ftmac100_send(struct ftmac100_data *priv, void *packet, int length)
 {
-	struct ftmac100 *ftmac100 = (struct ftmac100 *)priv->iobase;
+	struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase;
 	struct ftmac100_txdes *curr_des = priv->txdes;
 	ulong start;
 
Signature · 1 line
2.25.1
#12 lore raw

PATCH v2 6/10 net: ftmac100: Cast priv->iobase with uintptr_t

From: Bin Meng <[email protected]>

priv->iobase was declared as phys_addr_t which is now a 64-bit address. In a 32-bit build, this causes the following warning seen when building ftmac100.c:

warning: cast to pointer from integer of different size
[-Wint-to-pointer-cast]

Cast priv->iobase with uintptr_t.

---

Changes in v2:
- new patch: net: ftmac100: Cast priv->iobase with uintptr_t

 drivers/net/ftmac100.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Applied to u-boot-dm, thanks!

author
#13 lore raw

PATCH v2 7/10 fdtdec: Cast prior_stage_fdt_address with uintptr_t

In reply to Bin Meng

From: Bin Meng <[email protected]>

At present prior_stage_fdt_address is declared as phys_addr_t. On a 32-bit platform where phys_addr_t can be 64-bit, assigning its value to gd->fdt_blob which is a pointer, can cause warnings.

Cast it to uintptr_t before the assignment.

---

(no changes since v1)

 lib/fdtdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/fdtdec.c +1 -1
index a2d2fb4e1f..e048f7777d 100644
@@ -1572,7 +1572,7 @@ int fdtdec_setup(void)
 		return -1;
 	}
 # elif defined(CONFIG_OF_PRIOR_STAGE)
-	gd->fdt_blob = (void *)prior_stage_fdt_address;
+	gd->fdt_blob = (void *)(uintptr_t)prior_stage_fdt_address;
 # endif
 # ifndef CONFIG_SPL_BUILD
 	/* Allow the early environment to override the fdt address */
Signature · 1 line
2.25.1
#14 lore raw

PATCH v2 7/10 fdtdec: Cast prior_stage_fdt_address with uintptr_t

From: Bin Meng <[email protected]>

At present prior_stage_fdt_address is declared as phys_addr_t. On a 32-bit platform where phys_addr_t can be 64-bit, assigning its value to gd->fdt_blob which is a pointer, can cause warnings.

Cast it to uintptr_t before the assignment.

---

(no changes since v1)

 lib/fdtdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm, thanks!

author
#15 lore raw

PATCH v2 8/10 riscv: Change phys_addr_t and phys_size_t to 64-bit

In reply to Bin Meng

From: Bin Meng <[email protected]>

phys_addr_t and phys_size_t are currently defined as unsigned long, but RV32 supports 34-bit physical address, hence both phys_addr_t and phys_size_t should be defined to 64-bit using unsigned long long.

---

(no changes since v1)

 arch/riscv/include/asm/types.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/include/asm/types.h +2 -2
index b800b2d221..49f7a5d6b3 100644
@@ -35,8 +35,8 @@ typedef u64 dma_addr_t;
 typedef u32 dma_addr_t;
 #endif
 
-typedef unsigned long phys_addr_t;
-typedef unsigned long phys_size_t;
+typedef unsigned long long phys_addr_t;
+typedef unsigned long long phys_size_t;
 
 #endif /* __KERNEL__ */
 
Signature · 1 line
2.25.1
#16 lore raw

PATCH v2 8/10 riscv: Change phys_addr_t and phys_size_t to 64-bit

From: Bin Meng <[email protected]>

phys_addr_t and phys_size_t are currently defined as unsigned long, but RV32 supports 34-bit physical address, hence both phys_addr_t and phys_size_t should be defined to 64-bit using unsigned long long.

---

(no changes since v1)

 arch/riscv/include/asm/types.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!

author
#17 lore raw

PATCH v2 9/10 bdinfo: Rename function names to be clearer

In reply to Bin Meng

From: Bin Meng <[email protected]>

At present we have bdinfo_print_num() to print unsigned long numbers. We also have print_phys_addr() which accept numbers that might be 64-bit on a 32-bit platform.

Rename these 2 functions to be clearer:

bdinfo_print_num() => bdinfo_print_num_l()
print_phys_addr() => bdinfo_print_num_ll()

While we are here, make bdinfo_print_num_ll() public so that it can be used outside cmd/bdinfo.c in the future.

---

(no changes since v1)

 arch/arm/lib/bdinfo.c     | 16 ++++++------
 arch/m68k/lib/bdinfo.c    |  2 +-
 arch/powerpc/lib/bdinfo.c |  4 +--
 cmd/bdinfo.c              | 52 +++++++++++++++++++--------------------
 include/init.h            |  3 ++-
 5 files changed, 39 insertions(+), 38 deletions(-)
arch/arm/lib/bdinfo.c +8 -8
index 25bc6e80f4..4a98cb7ef5 100644
@@ -15,23 +15,23 @@ void arch_print_bdinfo(void)
 {
 	struct bd_info *bd = gd->bd;
 
-	bdinfo_print_num("arch_number", bd->bi_arch_number);
+	bdinfo_print_num_l("arch_number", bd->bi_arch_number);
 #ifdef CONFIG_SYS_MEM_RESERVE_SECURE
 	if (gd->arch.secure_ram & MEM_RESERVE_SECURE_SECURED) {
-		bdinfo_print_num("Secure ram",
-				 gd->arch.secure_ram &
-				 MEM_RESERVE_SECURE_ADDR_MASK);
+		bdinfo_print_num_l("Secure ram",
+				   gd->arch.secure_ram &
+				   MEM_RESERVE_SECURE_ADDR_MASK);
 	}
 #endif
 #ifdef CONFIG_RESV_RAM
 	if (gd->arch.resv_ram)
-		bdinfo_print_num("Reserved ram", gd->arch.resv_ram);
+		bdinfo_print_num_l("Reserved ram", gd->arch.resv_ram);
 #endif
 #if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
-	bdinfo_print_num("TLB addr", gd->arch.tlb_addr);
+	bdinfo_print_num_l("TLB addr", gd->arch.tlb_addr);
 #endif
-	bdinfo_print_num("irq_sp", gd->irq_sp);	/* irq stack pointer */
-	bdinfo_print_num("sp start ", gd->start_addr_sp);
+	bdinfo_print_num_l("irq_sp", gd->irq_sp);	/* irq stack pointer */
+	bdinfo_print_num_l("sp start ", gd->start_addr_sp);
 	/*
 	 * TODO: Currently only support for davinci SOC's is added.
 	 * Remove this check once all the board implement this.
arch/m68k/lib/bdinfo.c +1 -1
index 404e5f19ed..92ea175202 100644
@@ -38,7 +38,7 @@ void arch_print_bdinfo(void)
 
 	bdinfo_print_mhz("busfreq", bd->bi_busfreq);
 #if defined(CONFIG_SYS_MBAR)
-	bdinfo_print_num("mbar", bd->bi_mbar_base);
+	bdinfo_print_num_l("mbar", bd->bi_mbar_base);
 #endif
 	bdinfo_print_mhz("cpufreq", bd->bi_intfreq);
 	if (IS_ENABLED(CONFIG_PCI))
arch/powerpc/lib/bdinfo.c +2 -2
index 36c9c99ee6..b14e75b68a 100644
@@ -47,9 +47,9 @@ void arch_print_bdinfo(void)
 
 	bdinfo_print_mhz("busfreq", bd->bi_busfreq);
 #if defined(CONFIG_MPC8xx) || defined(CONFIG_E500)
-	bdinfo_print_num("immr_base", bd->bi_immr_base);
+	bdinfo_print_num_l("immr_base", bd->bi_immr_base);
 #endif
-	bdinfo_print_num("bootflags", bd->bi_bootflags);
+	bdinfo_print_num_l("bootflags", bd->bi_bootflags);
 	bdinfo_print_mhz("intfreq", bd->bi_intfreq);
 #ifdef CONFIG_ENABLE_36BIT_PHYS
 	if (IS_ENABLED(CONFIG_PHYS_64BIT))
cmd/bdinfo.c +26 -26

103 lines not on this page · raw message

include/init.h +2 -1
index 980be27993..88f84599e9 100644
@@ -326,7 +326,8 @@ void relocate_code(ulong start_addr_sp, struct global_data *new_gd,
 #endif
 
 /* Print a numeric value (for use in arch_print_bdinfo()) */
-void bdinfo_print_num(const char *name, ulong value);
+void bdinfo_print_num_l(const char *name, ulong value);
+void bdinfo_print_num_ll(const char *name, unsigned long long value);
 
 /* Print a clock speed in MHz */
 void bdinfo_print_mhz(const char *name, unsigned long hz);
Signature · 1 line
2.25.1
#18 lore raw

PATCH v2 9/10 bdinfo: Rename function names to be clearer

From: Bin Meng <[email protected]>

At present we have bdinfo_print_num() to print unsigned long numbers. We also have print_phys_addr() which accept numbers that might be 64-bit on a 32-bit platform.

Rename these 2 functions to be clearer:

bdinfo_print_num() => bdinfo_print_num_l()
print_phys_addr() => bdinfo_print_num_ll()

While we are here, make bdinfo_print_num_ll() public so that it can be used outside cmd/bdinfo.c in the future.

---

(no changes since v1)

 arch/arm/lib/bdinfo.c     | 16 ++++++------
 arch/m68k/lib/bdinfo.c    |  2 +-
 arch/powerpc/lib/bdinfo.c |  4 +--
 cmd/bdinfo.c              | 52 +++++++++++++++++++--------------------
 include/init.h            |  3 ++-
 5 files changed, 39 insertions(+), 38 deletions(-)

Applied to u-boot-dm, thanks!

author
#19 lore raw

PATCH v2 10/10 bdinfo: Change to use bdinfo_print_num_ll() where the number could be 64-bit

In reply to Bin Meng

From: Bin Meng <[email protected]>

There are some calls to bdinfo_print_num_l() with parameters that could be a 64-bit value on a 32-bit system. Change those calls to use bdinfo_print_num_ll() instead.

---

(no changes since v1)

 arch/arm/lib/bdinfo.c | 8 ++++----
 cmd/bdinfo.c          | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/lib/bdinfo.c +4 -4
index 4a98cb7ef5..c905783bdc 100644
@@ -18,14 +18,14 @@ void arch_print_bdinfo(void)
 	bdinfo_print_num_l("arch_number", bd->bi_arch_number);
 #ifdef CONFIG_SYS_MEM_RESERVE_SECURE
 	if (gd->arch.secure_ram & MEM_RESERVE_SECURE_SECURED) {
-		bdinfo_print_num_l("Secure ram",
-				   gd->arch.secure_ram &
-				   MEM_RESERVE_SECURE_ADDR_MASK);
+		bdinfo_print_num_ll("Secure ram",
+				    gd->arch.secure_ram &
+				    MEM_RESERVE_SECURE_ADDR_MASK);
 	}
 #endif
 #ifdef CONFIG_RESV_RAM
 	if (gd->arch.resv_ram)
-		bdinfo_print_num_l("Reserved ram", gd->arch.resv_ram);
+		bdinfo_print_num_ll("Reserved ram", gd->arch.resv_ram);
 #endif
 #if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
 	bdinfo_print_num_l("TLB addr", gd->arch.tlb_addr);
cmd/bdinfo.c +2 -2
index 996546faf3..dfd50ae849 100644
@@ -55,8 +55,8 @@ static void print_bi_dram(const struct bd_info *bd)
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
 		if (bd->bi_dram[i].size) {
 			bdinfo_print_num_l("DRAM bank",	i);
-			bdinfo_print_num_l("-> start",	bd->bi_dram[i].start);
-			bdinfo_print_num_l("-> size",	bd->bi_dram[i].size);
+			bdinfo_print_num_ll("-> start",	bd->bi_dram[i].start);
+			bdinfo_print_num_ll("-> size",	bd->bi_dram[i].size);
 		}
 	}
 }
Signature · 1 line
2.25.1
#20 lore raw

PATCH v2 10/10 bdinfo: Change to use bdinfo_print_num_ll() where the number could be 64-bit

Quoted 7 lines · Bin Meng

From: Bin Meng <[email protected]>

There are some calls to bdinfo_print_num_l() with parameters that could be a 64-bit value on a 32-bit system. Change those calls to use bdinfo_print_num_ll() instead.

Quoted 9 lines

---

(no changes since v1)

 arch/arm/lib/bdinfo.c | 8 ++++----
 cmd/bdinfo.c          | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
#21 lore raw

PATCH v2 10/10 bdinfo: Change to use bdinfo_print_num_ll() where the number could be 64-bit

Quoted 7 lines · Bin Meng

From: Bin Meng <[email protected]>

There are some calls to bdinfo_print_num_l() with parameters that could be a 64-bit value on a 32-bit system. Change those calls to use bdinfo_print_num_ll() instead.

Quoted 9 lines

---

(no changes since v1)

 arch/arm/lib/bdinfo.c | 8 ++++----
 cmd/bdinfo.c          | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

Applied to u-boot-dm, thanks!

author
#22 lore raw

v2 cover Allow booting a 32-bit system with a top memory address beyond 4 GiB

In reply to Bin Meng

Hi Simon,

Quoted 9 lines · Bin Meng

When testing QEMU RISC-V 'virt' machine with a 2 GiB memory configuration, it was discovered gd->ram_top is assigned to value zero in setup_dest_addr().

While 2 GiB QEMU RISC-V 'virt' happens to work with U-Boot today, increasing more memory doesn't make a bootable system. There are various places in U-Boot that prevents such from working.

Quoted 8 lines

While this is seen and tested on RISC-V, it's not RISC-V centric, but a generic issue that may affect all architectures.

Changes in v2:
- new patch: arm: rockchip: Explicitly cast gd->ram_top in dram_init_banksize()
- new patch: riscv: ax25-ae350: Cast addr with uintptr_t
- new patch: net: ftmac100: Cast priv->iobase with uintptr_t

GitLab pass:
https://gitlab.denx.de/u-boot/custodians/u-boot-x86/-/pipelines/6148

Azure pass with the patch [1]:
https://dev.azure.com/bmeng/GitHub/_build/results?buildId=312&view=results

[1] http://patchwork.ozlabs.org/project/uboot/patch/20210131083835.9916-1-bmeng.cn at gmail.com/

Regards,
Bin