Skip to content

Commit

Permalink
softmmu/physmem: Remove HOST_PAGE_ALIGN
Browse files Browse the repository at this point in the history
Align allocation sizes to the maximum of host and target page sizes.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Acked-by: Helge Deller <deller@gmx.de>
Message-Id: <20240102015808.132373-15-richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Feb 29, 2024
1 parent 80c3aee commit 9260bd4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions system/physmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,8 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp)

assert(block);

newsize = HOST_PAGE_ALIGN(newsize);
newsize = TARGET_PAGE_ALIGN(newsize);
newsize = REAL_HOST_PAGE_ALIGN(newsize);

if (block->used_length == newsize) {
/*
Expand Down Expand Up @@ -1916,7 +1917,9 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
return NULL;
}

size = HOST_PAGE_ALIGN(size);
size = TARGET_PAGE_ALIGN(size);
size = REAL_HOST_PAGE_ALIGN(size);

file_size = get_file_size(fd);
if (file_size > offset && file_size < (offset + size)) {
error_setg(errp, "backing store size 0x%" PRIx64
Expand Down Expand Up @@ -2014,13 +2017,17 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
{
RAMBlock *new_block;
Error *local_err = NULL;
int align;

assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC |
RAM_NORESERVE)) == 0);
assert(!host ^ (ram_flags & RAM_PREALLOC));

size = HOST_PAGE_ALIGN(size);
max_size = HOST_PAGE_ALIGN(max_size);
align = qemu_real_host_page_size();
align = MAX(align, TARGET_PAGE_SIZE);
size = ROUND_UP(size, align);
max_size = ROUND_UP(max_size, align);

new_block = g_malloc0(sizeof(*new_block));
new_block->mr = mr;
new_block->resized = resized;
Expand Down

0 comments on commit 9260bd4

Please sign in to comment.