summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2025-06-26 13:45:43 -0600
committerTom Rini <[email protected]>2025-06-26 13:45:43 -0600
commit778c552f86ab781abd8360592ff261707fdefaa7 (patch)
tree6d483f4fe8d922d6b194b8e19e813fc29cf48054 /arch
parent7d4eacb0e68a7eb471a8dc43a5585b46ec67a333 (diff)
parent788df0536237321efcd443c74316d37451bde31c (diff)
Merge patch series "sandbox: align LMB memory"
Heinrich Schuchardt <[email protected]> says: To implement the EFI_SYSTEM_TABLE_POINTER we need 4 MiB aligned memory. On the sandbox LMB uses addresses relative to the start of a page aligned RAM buffer allocated with mmap(). This leads to a mismatch of alignment between EFI which uses pointers and LMB which uses phys_addr_t. Ensure that the RAM buffer used for LMB is 4 MiB aligned. Provide a unit test for efi_alloc_aligned_pages() verifying this alignment. Do not overwrite RAM size in dram_init(). Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'arch')
-rw-r--r--arch/sandbox/cpu/state.c6
-rw-r--r--arch/sandbox/include/asm/state.h1
2 files changed, 5 insertions, 2 deletions
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index 49236db99c2..6a15c8b0a18 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -480,7 +480,9 @@ int state_init(void)
state = &main_state;
state->ram_size = CFG_SYS_SDRAM_SIZE;
- state->ram_buf = os_malloc(state->ram_size);
+ state->mmap_addr = os_malloc(state->ram_size + SB_SDRAM_ALIGN);
+ state->ram_buf = (uint8_t *)ALIGN((uintptr_t)state->mmap_addr,
+ SB_SDRAM_ALIGN);
if (!state->ram_buf) {
printf("Out of memory\n");
os_exit(1);
@@ -533,7 +535,7 @@ int state_uninit(void)
trace_set_enabled(0);
os_free(state->state_fdt);
- os_free(state->ram_buf);
+ os_free(state->mmap_addr);
memset(state, '\0', sizeof(*state));
return 0;
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index dc21a623106..9dea0980bfc 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -75,6 +75,7 @@ struct sandbox_state {
char **argv; /* Command line arguments */
const char *jumped_fname; /* Jumped from previous U-Boot */
const char *prog_fname; /* U-Boot executable filename */
+ uint8_t *mmap_addr; /* Memory allocated via mmap */
uint8_t *ram_buf; /* Emulated RAM buffer */
unsigned long ram_size; /* Size of RAM buffer */
const char *ram_buf_fname; /* Filename to use for RAM buffer */