From ea7d0e304775e81c07269e22b4412d328c3fb2fa Mon Sep 17 00:00:00 2001 From: Yang Zhong Date: Thu, 30 Mar 2017 18:20:50 +0800 Subject: qboot: modified the malloc for fseg and high momory. The fseg and high memory malloc all use the up align mode in do_alloc(),which will result in qboot hang issue.The high memory use the down align mode and fseg memory use the up align mode. With those changes,the qemu can boot up the image with qboot. Signed-off-by: Yang Zhong Message-Id: <1490869250-4357-1-git-send-email-yang.zhong@intel.com> Signed-off-by: Paolo Bonzini --- malloc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'malloc.c') diff --git a/malloc.c b/malloc.c index c8d865b..8738373 100644 --- a/malloc.c +++ b/malloc.c @@ -5,15 +5,17 @@ static uint8_t *fseg_base = &edata; static uint8_t *malloc_top = &stext; -void *malloc(int n) +void *malloc_align(int n, int align) { - malloc_top -= (n + 15) & -16; + malloc_top = (uint8_t *) ((uintptr_t)(malloc_top - n) & -align); return malloc_top; } -void *malloc_fseg(int n) +void *malloc_fseg_align(int n, int align) { - void *p = fseg_base; - fseg_base += (n + 15) & -16; + void *p; + fseg_base = (uint8_t *) (((uintptr_t)fseg_base + align - 1) & -align); + p = fseg_base; + fseg_base += n; return p; } -- cgit v1.1