diff options
author | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2016-09-29 20:09:37 +0100 |
---|---|---|
committer | Juan Quintela <quintela@trasno.org> | 2016-10-13 17:23:53 +0200 |
commit | 863e9621c51a7544f1a2ae78387749145adaf450 (patch) | |
tree | 9afdd1b75ec05b47c7f9c25e89ddb887a15e5a6f /exec.c | |
parent | 2ebeaec012b4e5695612774c44f14c61ab46c72c (diff) |
RAMBlocks: Store page size
Store the page size in each RAMBlock, we need it later.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'exec.c')
-rw-r--r-- | exec.c | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -1199,7 +1199,6 @@ static void *file_ram_alloc(RAMBlock *block, char *c; void *area = MAP_FAILED; int fd = -1; - int64_t page_size; if (kvm_enabled() && !kvm_has_sync_mmu()) { error_setg(errp, @@ -1254,17 +1253,17 @@ static void *file_ram_alloc(RAMBlock *block, */ } - page_size = qemu_fd_getpagesize(fd); - block->mr->align = MAX(page_size, QEMU_VMALLOC_ALIGN); + block->page_size = qemu_fd_getpagesize(fd); + block->mr->align = MAX(block->page_size, QEMU_VMALLOC_ALIGN); - if (memory < page_size) { + if (memory < block->page_size) { error_setg(errp, "memory size 0x" RAM_ADDR_FMT " must be equal to " - "or larger than page size 0x%" PRIx64, - memory, page_size); + "or larger than page size 0x%zx", + memory, block->page_size); goto error; } - memory = ROUND_UP(memory, page_size); + memory = ROUND_UP(memory, block->page_size); /* * ftruncate is not supported by hugetlbfs in older @@ -1419,6 +1418,11 @@ void qemu_ram_unset_idstr(RAMBlock *block) } } +size_t qemu_ram_pagesize(RAMBlock *rb) +{ + return rb->page_size; +} + static int memory_try_enable_merging(void *addr, size_t len) { if (!machine_mem_merge(current_machine)) { @@ -1658,6 +1662,7 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size, new_block->max_length = max_size; assert(max_size >= size); new_block->fd = -1; + new_block->page_size = getpagesize(); new_block->host = host; if (host) { new_block->flags |= RAM_PREALLOC; |