mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
util: exclude mmap-alloc.c from compilation target on Emscripten
Emscripten does not support partial unmapping of mmapped memory
regions[1]. This limitation prevents correct implementation of qemu_ram_mmap
and qemu_ram_munmap, which rely on partial unmap behavior.
As a workaround, this commit excludes mmap-alloc.c from the Emscripten
build. Instead, for Emscripten build, this modifies qemu_anon_ram_alloc to
use qemu_memalign in place of qemu_ram_mmap, and disable memory backends
that rely on mmap, such as memory-backend-file and memory-backend-shm.
[1] d4a74336f2/system/lib/libc/emscripten_mmap.c (L61)
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
Link: https://lore.kernel.org/r/76834f933ee4f14eeb5289d21c59d306886e58e9.1745820062.git.ktokunaga.mail@gmail.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
1a89644240
commit
8e72b0eb18
5 changed files with 41 additions and 8 deletions
|
@ -1243,7 +1243,7 @@ long qemu_maxrampagesize(void)
|
|||
return pagesize;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_POSIX
|
||||
#if defined(CONFIG_POSIX) && !defined(EMSCRIPTEN)
|
||||
static int64_t get_file_size(int fd)
|
||||
{
|
||||
int64_t size;
|
||||
|
@ -1978,7 +1978,7 @@ out_free:
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_POSIX
|
||||
#if defined(CONFIG_POSIX) && !defined(EMSCRIPTEN)
|
||||
RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, ram_addr_t max_size,
|
||||
qemu_ram_resize_cb resized, MemoryRegion *mr,
|
||||
uint32_t ram_flags, int fd, off_t offset,
|
||||
|
@ -2158,7 +2158,8 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
|
|||
assert(!host ^ (ram_flags & RAM_PREALLOC));
|
||||
assert(max_size >= size);
|
||||
|
||||
#ifdef CONFIG_POSIX /* ignore RAM_SHARED for Windows */
|
||||
/* ignore RAM_SHARED for Windows and emscripten*/
|
||||
#if defined(CONFIG_POSIX) && !defined(EMSCRIPTEN)
|
||||
if (!host) {
|
||||
if (!share_flags && current_machine->aux_ram_share) {
|
||||
ram_flags |= RAM_SHARED;
|
||||
|
@ -2255,7 +2256,7 @@ static void reclaim_ramblock(RAMBlock *block)
|
|||
;
|
||||
} else if (xen_enabled()) {
|
||||
xen_invalidate_map_cache_entry(block->host);
|
||||
#ifndef _WIN32
|
||||
#if !defined(_WIN32) && !defined(EMSCRIPTEN)
|
||||
} else if (block->fd >= 0) {
|
||||
qemu_ram_munmap(block->fd, block->host, block->max_length);
|
||||
close(block->fd);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue