From 32a3a6865a636d520a90138f48f0023fe51d6d3a Mon Sep 17 00:00:00 2001 From: mio Date: Sun, 25 Sep 2022 17:41:09 +0200 Subject: [PATCH] Don't resize user alloc-ed memory --- qemu/exec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qemu/exec.c b/qemu/exec.c index 719895a3..2a664788 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -1087,8 +1087,12 @@ RAMBlock *qemu_ram_alloc_from_ptr(struct uc_struct *uc, ram_addr_t size, void *h RAMBlock *new_block; ram_addr_t max_size = size; - size = HOST_PAGE_ALIGN(uc, size); - max_size = HOST_PAGE_ALIGN(uc, max_size); + // Don't resize pre-alloced memory as they are given by users. + if (!host) { + size = HOST_PAGE_ALIGN(uc, size); + max_size = HOST_PAGE_ALIGN(uc, max_size); + } + new_block = g_malloc0(sizeof(*new_block)); if (new_block == NULL) return NULL;