From: Simon Glass <[email protected]>

At present the sandbox RAM buffer is not aligned to any particular
address boundary. This makes the internal pointers somewhat random with
respect to the associated RAM buffer addresses.

Align the buffer to the page size of the machine to help with this.

Signed-off-by: Simon Glass <[email protected]>
Signed-off-by: Alexander Graf <[email protected]>
---
 arch/sandbox/cpu/os.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index e3fe017b5f..3067503d51 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -143,15 +143,16 @@ void os_tty_raw(int fd, bool allow_sigs)
 void *os_malloc(size_t length)
 {
        struct os_mem_hdr *hdr;
+       int page_size = getpagesize();
 
-       hdr = mmap(NULL, length + sizeof(*hdr),
+       hdr = mmap(NULL, length + page_size,
                   PROT_READ | PROT_WRITE | PROT_EXEC,
                   MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
        if (hdr == MAP_FAILED)
                return NULL;
        hdr->length = length;
 
-       return hdr + 1;
+       return (void *)hdr + page_size;
 }
 
 void os_free(void *ptr)
-- 
2.12.3

_______________________________________________
U-Boot mailing list
[email protected]
https://lists.denx.de/listinfo/u-boot

Reply via email to