[U-Boot] [PATCH v5 06/10] sandbox: Align RAM buffer to the machine page size
Alexander Graf
agraf at suse.de
Fri Jun 22 12:44:14 UTC 2018
From: Simon Glass <sjg at chromium.org>
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 <sjg at chromium.org>
Signed-off-by: Alexander Graf <agraf at suse.de>
---
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
More information about the U-Boot
mailing list