Re: [PATCH 3/5] scripts/meson-buildoptions: Sort coroutine_backend choices lexicographically

2025-06-11 Thread Kohei Tokunaga
I should've made sure to run the tool, sorry. Thanks for spotting and fixing this issue. Reviewed-by: Kohei Tokunaga

Re: [PATCH 0/5] Enable QEMU TCI to run 64bit guests on browsers

2025-06-02 Thread Kohei Tokunaga
Hi all, Kinldy ping on this patch series. I would appreciate any feedback or comments. Patchew URL: https://patchew.org/QEMU/cover.1747922170.git.ktokunaga.m...@gmail.com/ Kohei

[PATCH 0/5] Enable QEMU TCI to run 64bit guests on browsers

2025-05-22 Thread Kohei Tokunaga
x27;-append', 'earlyprintk=ttyS0 console=ttyS0 root=/dev/vda loglevel=7', ]; The sample repository[1] provides a complete setup, including an HTML file that implements a terminal UI. [1] https://github.com/ktock/qemu-wasm-sample # Additional references - A talk at FOSDEM 202

[PATCH 3/5] tlb: specify address field size based on TCG_VADDR_BITS

2025-05-22 Thread Kohei Tokunaga
ATOMIC_REG_SIZE value for the wasm build to ensure assertions pass. Signed-off-by: Kohei Tokunaga --- accel/tcg/cputlb.c| 8 include/exec/tlb-common.h | 18 +- include/qemu/atomic.h | 4 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a

[PATCH 2/5] include: define vaddr based on TCG_VADDR_BITS

2025-05-22 Thread Kohei Tokunaga
This commit defines vaddr based on TCG_VADDR_BITS. For non-wasm hosts, TCG_VADDR_BITS maches the pointer size, so this change preserves the original behaviour. Signed-off-by: Kohei Tokunaga --- include/exec/helper-head.h.inc | 9 + include/exec/vaddr.h | 28

[PATCH 5/5] tci: use tcg_target_ulong when retrieving the pool data

2025-05-22 Thread Kohei Tokunaga
o this change ensures TCI retrieves the data using the correct type consistent with how it was stored using the pool feature. Signed-off-by: Kohei Tokunaga --- tcg/tci.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tcg/tci.c b/tcg/tci.c index 700e672616..cee65bce

[PATCH 1/5] meson.build: add TCG_VADDR_BITS for defining the vaddr size

2025-05-22 Thread Kohei Tokunaga
64bit guests. Signed-off-by: Kohei Tokunaga --- meson.build | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index ad2053f968..185ec96149 100644 --- a/meson.build +++ b/meson.build @@ -3229,6 +3229,9 @@ endif # Detect host pointer size for the t

[PATCH 4/5] tci: define TCG_TARGET_REG_BITS based on TCG_VADDR_BITS

2025-05-22 Thread Kohei Tokunaga
This commit defines TCG_TARGET_REG_BITS based on the value of TCG_VADDR_BITS. For non-wasm hosts, TCG_VADDR_BITS matches the pointer size, so this change preserves the original behaviour. For the wasm host, this change enables support for 64bit guests. Signed-off-by: Kohei Tokunaga --- tcg/tci

Re: [PATCH 23/33] include/exec: Allow using 64bit guest addresses on emscripten

2025-05-21 Thread Kohei Tokunaga
Hi Paolo, > On 5/20/25 14:51, Kohei Tokunaga wrote: > > target_kconfig = [] > > foreach sym: accelerators > > -# Disallow 64-bit on 32-bit emulation and virtualization > > -if host_long_bits < config_target['TARGET_LONG_BITS'].to_int() &

[PATCH 32/33] meson: Propagate optimization flag for linking on Emscripten

2025-05-20 Thread Kohei Tokunaga
WebAssembly. [1] https://emscripten.org/docs/optimizing/Optimizing-Code.html#how-emscripten-optimizes Signed-off-by: Kohei Tokunaga --- meson.build | 4 1 file changed, 4 insertions(+) diff --git a/meson.build b/meson.build index f6ed867819..91e182092d 100644 --- a/meson.build +++ b

[PATCH 26/33] tcg/wasm32: Add initialization of fundamental registers

2025-05-20 Thread Kohei Tokunaga
. Signed-off-by: Kohei Tokunaga --- tcg/wasm32.h| 10 ++ tcg/wasm32/tcg-target.c.inc | 17 + 2 files changed, 27 insertions(+) diff --git a/tcg/wasm32.h b/tcg/wasm32.h index 1944249891..ab23e26eca 100644 --- a/tcg/wasm32.h +++ b/tcg/wasm32.h @@ -22,6 +22,16

[PATCH 24/33] tcg/wasm32: Set TCG_TARGET_REG_BITS to 64

2025-05-20 Thread Kohei Tokunaga
This commit enables to Wasm backend to run as a 64bit backend with removing TCG_TARGET_REG_BITS = 32 macros. Signed-off-by: Kohei Tokunaga --- tcg/wasm32.c | 5 ++- tcg/wasm32/tcg-target-reg-bits.h | 8 +--- tcg/wasm32/tcg-target.c.inc | 69

[PATCH 29/33] tcg/wasm32: Allow Asyncify unwinding from TB

2025-05-20 Thread Kohei Tokunaga
n.org/docs/api_reference/fiber.h.html [2] https://kripken.github.io/blog/wasm/2019/07/16/asyncify.html#new-asyncify Signed-off-by: Kohei Tokunaga --- tcg/wasm32.c| 3 ++ tcg/wasm32.h| 11 tcg/wasm32/tcg-target.c.inc | 56 ++

[PATCH 10/33] tcg/wasm32: Add load and store instructions

2025-05-20 Thread Kohei Tokunaga
This commit implements load and store operations using Wasm memory instructions. Since Wasm's load/store instructions don't support negative offset, address calculations are performed separately before the memory access. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c

[PATCH 14/33] tcg/wasm32: Add rem/div instructions

2025-05-20 Thread Kohei Tokunaga
This commit implements rem and div operations using Wasm's rem/div instructions. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 120 1 file changed, 120 insertions(+) diff --git a/tcg/wasm32/tcg-target.c.inc b/tcg/wasm32/tcg-target.

[PATCH 27/33] tcg/wasm32: Write wasm binary to TB

2025-05-20 Thread Kohei Tokunaga
ps://github.com/WebAssembly/threads/blob/b2567bff61ee6fbe731934f0ed17a5d48dc9ab01/proposals/threads/Overview.md Signed-off-by: Kohei Tokunaga --- tcg/wasm32.h| 26 +++ tcg/wasm32/tcg-target.c.inc | 390 2 files changed, 416 insertions(+) diff --git a/tcg/wasm32.h b/tcg/wasm32.h i

[PATCH 08/33] tcg/wasm32: Add setcond/negsetcond/movcond instructions

2025-05-20 Thread Kohei Tokunaga
This commit implements setcond and movcond operations using Wasm's if/else instructions. Support for TCG_COND_TSTEQ and TCG_COND_TSTNE is not yet implemented, so TCG_TARGET_HAS_tst is set to 0. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target-has.h | 2 +- tcg/wasm32/tcg-target.

[PATCH 05/33] tcg/wasm32: Add and/or/xor instructions

2025-05-20 Thread Kohei Tokunaga
two code buffers must be merged into the final code buffer before tcg_gen_code returns. [1] https://webassembly.github.io/spec/core/binary/index.html Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 137 +++- 1 file changed, 136 insertions(+), 1

[PATCH 21/33] tcg/wasm32: Add call instruction

2025-05-20 Thread Kohei Tokunaga
tly via pointer parameters and returned via a prepended pointer argument, as described in [1]. [1] https://github.com/WebAssembly/tool-conventions/blob/060cf4073e46931160c2e9ecd43177ee1fe93866/BasicCABI.md#function-arguments-and-return-values Signed-off-by: Kohei Tokunaga --- tcg/wasm32.h

[PATCH 13/33] tcg/wasm32: Add bswap instructions

2025-05-20 Thread Kohei Tokunaga
This commit implements the bswap operation using Wasm instructions. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 136 1 file changed, 136 insertions(+) diff --git a/tcg/wasm32/tcg-target.c.inc b/tcg/wasm32/tcg-target.c.inc index

[PATCH 30/33] tcg/wasm32: Enable instantiation of TBs executed many times

2025-05-20 Thread Kohei Tokunaga
x27;s removeFunction function. Once the removal of the instance is detected via FinalizationRegistry API[1], instances_global is decremented, which allows instantiation of new modules again. [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry

[PATCH 16/33] tcg/wasm32: Add neg/not/ctpop instructions

2025-05-20 Thread Kohei Tokunaga
This commit implements neg, not and ctpop operations using Wasm instructions. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 39 +++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/tcg/wasm32/tcg-target.c.inc b/tcg/wasm32/tcg

[PATCH 04/33] tcg/wasm32: Set TCG_TARGET_INSN_UNIT_SIZE to 1

2025-05-20 Thread Kohei Tokunaga
WebAssembly instructions vary in size, including single-byte instructions. This commit sets TCG_TARGET_INSN_UNIT_SIZE to 1 and updates the TCI fork to use "tcg_insn_unit_tci" (a uint32_t) for 4-byte operations. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.

[PATCH 03/33] meson: Enable to build wasm backend

2025-05-20 Thread Kohei Tokunaga
Now that there is a backend for WebAssembly build (/tcg/wasm32/), the requirement of --enable-tcg-interpreter in meson.build can be removed. Signed-off-by: Kohei Tokunaga --- meson.build | 4 1 file changed, 4 deletions(-) diff --git a/meson.build b/meson.build index ad2053f968

[PATCH 28/33] tcg/wasm32: Implement instantiation of Wasm binary

2025-05-20 Thread Kohei Tokunaga
Interacting-with-code.html#calling-javascript-functions-as-function-pointers-from-c [2] https://bugzilla.mozilla.org/show_bug.cgi?id=1965217 [3] https://github.com/ktock/qemu-wasm/pull/25 Signed-off-by: Kohei Tokunaga --- tcg/wasm32.c | 24 1 file changed, 24 insertions(+) d

[PATCH 23/33] include/exec: Allow using 64bit guest addresses on emscripten

2025-05-20 Thread Kohei Tokunaga
) when compiling with Emscripten. While this serves as a temporary workaround, a long-term solution could involve adopting Wasm's 64-bit memory model once it gains broader support, as it is currently not widely adopted (e.g. unsupported by Safari and libffi). Signed-off-by: Kohei Tokunaga ---

[PATCH 06/33] tcg/wasm32: Add add/sub/mul instructions

2025-05-20 Thread Kohei Tokunaga
Add, sub and mul operations are implemented using the corresponding instructions in Wasm. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 18 ++ 1 file changed, 18 insertions(+) diff --git a/tcg/wasm32/tcg-target.c.inc b/tcg/wasm32/tcg-target.c.inc index

[PATCH 33/33] .gitlab-ci.d: build wasm backend in CI

2025-05-20 Thread Kohei Tokunaga
Check if wasm backend can be built in CI. Signed-off-by: Kohei Tokunaga --- .gitlab-ci.d/buildtest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index 248aaed137..fc42de231a 100644 --- a/.gitlab-ci.d/buildtest.yml

[PATCH 20/33] tcg/wasm32: Add exit_tb/goto_tb/goto_ptr instructions

2025-05-20 Thread Kohei Tokunaga
s the current TB itself, there is no need to return control to the caller. Instead, execution can jump directly to the top of the loop within the TB. The exit_tb operation sets the pointer in wasmContext to 0, indicating that there is no destination TB. Signed-off-by: Kohei Tokunaga --- MAINTA

[PATCH 19/33] tcg/wasm32: Add br/brcond instructions

2025-05-20 Thread Kohei Tokunaga
ded as LEB128) is emitted instead. These placeholders are tracked in BlockPlaceholder and resolved later. Signed-off-by: Kohei Tokunaga --- tcg/aarch64/tcg-target.c.inc | 11 ++ tcg/arm/tcg-target.c.inc | 11 ++ tcg/i386/tcg-target.c.inc| 11 ++ tcg/loongarch64/tcg-target.c

[PATCH 22/33] tcg/wasm32: Add qemu_ld/qemu_st instructions

2025-05-20 Thread Kohei Tokunaga
This commit adds qemu_ld and qemu_st by calling the helper functions corresponding to MemOp. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 108 1 file changed, 108 insertions(+) diff --git a/tcg/wasm32/tcg-target.c.inc b/tcg/wasm32/tcg

[PATCH 17/33] tcg/wasm32: Add rot/clz/ctz instructions

2025-05-20 Thread Kohei Tokunaga
This commit implements rot, clz and ctz operations using Wasm instructions. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 155 1 file changed, 155 insertions(+) diff --git a/tcg/wasm32/tcg-target.c.inc b/tcg/wasm32/tcg-target.c.inc index

[PATCH 07/33] tcg/wasm32: Add shl/shr/sar instructions

2025-05-20 Thread Kohei Tokunaga
, this commit introduces an encoder function implemented following [1]. [1] https://en.wikipedia.org/wiki/LEB128 Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 107 1 file changed, 107 insertions(+) diff --git a/tcg/wasm32/tcg-target.c.inc b/tcg

[PATCH 25/33] tcg/wasm32: Set mulu2/muls2 as unimplemented

2025-05-20 Thread Kohei Tokunaga
These operations have no direct equivalents in Wasm, so they are left unimplemented and delegated to helper functions. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 38 ++--- 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/tcg

[PATCH 31/33] tcg/wasm32: Enable TLB lookup

2025-05-20 Thread Kohei Tokunaga
followed by a if branch: if the lookup succeeds, the memory is accessed directly; otherwise, a fallback helper function is invoked. Support for MO_BSWAP is not yet implemented, so has_memory_bswap is set to false. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 223

[PATCH 11/33] tcg/wasm32: Add mov/movi instructions

2025-05-20 Thread Kohei Tokunaga
This commit implements mov/movi instructions. The tcg_out_mov[i] functions are used by several other functions and are intended to emit TCI code. So they have been renamed to tcg_tci_out_mov[i]. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 85

[PATCH 18/33] tcg/wasm32: Add addc/subb instructions

2025-05-20 Thread Kohei Tokunaga
This commit implements addc and subb operations using Wasm instructions. A carry flag is introduced as the 16th variable in the module following other 15 variables that represent TCG variables. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 151

[PATCH 09/33] tcg/wasm32: Add deposit/sextract/extract instrcutions

2025-05-20 Thread Kohei Tokunaga
This implements deposit, sextract and extract operations. The tcg_out_[s]extract functions are used by several other functions (e.g. tcg_out_ext*) and are intended to emit TCI code. So they have been renamed to tcg_tci_out_[s]extract. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg

[PATCH 01/33] tcg: Fork TCI for wasm32 backend

2025-05-20 Thread Kohei Tokunaga
Wasm backend is implemented based on the TCI backend and utilizes a forked TCI to execute TBs. Signed-off-by: Kohei Tokunaga --- MAINTAINERS |6 + include/accel/tcg/getpc.h|2 +- include/tcg/helper-info.h|4 +- include/tcg/tcg.h

[PATCH 12/33] tcg/wasm32: Add ext instructions

2025-05-20 Thread Kohei Tokunaga
This commit implements the ext operations using Wasm's extend instructions. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 79 - 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/tcg/wasm32/tcg-target.c.inc b/tcg/wasm3

[PATCH 15/33] tcg/wasm32: Add andc/orc/eqv/nand/nor instructions

2025-05-20 Thread Kohei Tokunaga
This commit implements andc, orc, eqv, nand and nor operations using Wasm instructions. Signed-off-by: Kohei Tokunaga --- tcg/wasm32/tcg-target.c.inc | 55 + 1 file changed, 55 insertions(+) diff --git a/tcg/wasm32/tcg-target.c.inc b/tcg/wasm32/tcg

[PATCH 02/33] tcg/wasm32: Do not use TCI disassembler in Wasm backend

2025-05-20 Thread Kohei Tokunaga
Wasm backend should implement its own disassember for Wasm instructions. Signed-off-by: Kohei Tokunaga --- tcg/wasm32.c | 243 +-- 1 file changed, 1 insertion(+), 242 deletions(-) diff --git a/tcg/wasm32.c b/tcg/wasm32.c index 6de9b26b76

[PATCH 00/33] tcg: Add WebAssembly backend

2025-05-20 Thread Kohei Tokunaga
at implements a terminal UI. [1] https://github.com/ktock/qemu-wasm-sample # Additional references - A talk at FOSDEM 2025: https://fosdem.org/2025/schedule/event/fosdem-2025-6290-running-qemu-inside-browser/ - Demo page on GitHub Pages: https://ktock.github.io/qemu-wasm-demo/ Kohei Tokunaga

[PATCH v3 10/20] include/glib-compat.h: Poison g_list_sort and g_slist_sort

2025-04-27 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga Reviewed-by: Thomas Huth --- include/glib-compat.h | 7 +++ 1 file changed, 7 insertions(+) V3: - Fixed the multiline comment to ensure it starts with "/*&

[PATCH v3 13/20] block: Fix type confict of the copy_file_range stub

2025-04-27 Thread Kohei Tokunaga
uring compilation. To fix this error, this commit updates the stub implementation in file-posix.c to exactly match the declaration in Emscripten's headers. The manpage also aligns with this signature. Signed-off-by: Kohei Tokunaga Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Stefa

[PATCH v3 09/20] target/s390x: Fix type conflict of GLib function pointers

2025-04-27 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga Reviewed-by: Thomas Huth --- target/s390x/cpu_models.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x

[PATCH v3 19/20] tests: Add Dockerfile containing dependencies for Emscripten build

2025-04-27 Thread Kohei Tokunaga
The added Dockerfile is based on the emsdk image, which includes the Emscripten toolchain. It also cross-compiles the necessary dependencies (glib, libffi, pixman, and zlib) for the Emscripten target environment. Signed-off-by: Kohei Tokunaga --- MAINTAINERS

[PATCH v3 17/20] util: Add coroutine backend for emscripten

2025-04-27 Thread Kohei Tokunaga
Emscripten does not support couroutine methods currently used by QEMU but provides a coroutine implementation called "fiber". This commit introduces a coroutine backend using fiber. Note that fiber does not support submitting coroutines to other threads. Signed-off-by: Kohei Tokunaga

[PATCH v3 20/20] gitlab: Enable CI for wasm build

2025-04-27 Thread Kohei Tokunaga
Add GitLab CI job that builds QEMU using emscripten. The build runs in the container defined in tests/docker/dockerfiles/emsdk-wasm32-cross.docker. Signed-off-by: Kohei Tokunaga --- .gitlab-ci.d/buildtest-template.yml | 27 +++ .gitlab-ci.d/buildtest.yml | 9

[PATCH v3 18/20] meson: Add wasm build in build scripts

2025-04-27 Thread Kohei Tokunaga
has_int128_type is set to false on emscripten as of now to avoid errors by libffi. Tests are disabled on emscripten because they rely on host features that aren't supported by emscripten (e.g. fork and unix socket). Signed-off-by: Kohei Tokunaga --- MAINTAINERS | 1 + co

[PATCH v3 03/20] system/vl.c: Fix type conflict of GLib function pointers

2025-04-27 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga Reviewed-by: Philippe Mathieu-Daudé --- system/vl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) V3: - This commit is included in this series sololy to

[PATCH v3 01/20] hw/core/loader.c: Fix type conflict of GLib function pointers

2025-04-27 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga Reviewed-by: Philippe Mathieu-Daudé --- hw/core/loader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) V3: - This commit is included in this series sololy

[PATCH v3 14/20] include/qemu/osdep.h: Add Emscripten-specific OS dependencies

2025-04-27 Thread Kohei Tokunaga
On emscripten, some implementations in os-posix.c can't be used such as daemonizing and changing user. This commit introduces os-wasm.c and os-wasm.h which are forked from os-posix.c and os-posix.h and patched for targetting Emscripten. Signed-off-by: Kohei Tokunaga --- MAINTA

[PATCH v3 16/20] util: exclude mmap-alloc.c from compilation target on Emscripten

2025-04-27 Thread Kohei Tokunaga
/lib/libc/emscripten_mmap.c#L61 Signed-off-by: Kohei Tokunaga --- backends/meson.build | 6 -- system/memory.c | 2 +- system/physmem.c | 9 + util/meson.build | 4 +++- util/oslib-posix.c | 28 5 files changed, 41 insertions(+), 8

[PATCH v3 15/20] Disable options unsupported on Emscripten

2025-04-27 Thread Kohei Tokunaga
Daemonizing and run-with aren't supported on Emscripten so disable these flags. Signed-off-by: Kohei Tokunaga Reviewed-by: Philippe Mathieu-Daudé --- qemu-options.hx | 4 ++-- system/vl.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qemu-options.hx b

[PATCH v3 04/20] target/arm/helper.c: Fix type conflict of GLib function pointers

2025-04-27 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga --- target/arm/helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) V3: - Fixed the argument type of cpreg_key_compare to use gpointer instead of void

[PATCH v3 12/20] block: Add including of ioctl header for Emscripten build

2025-04-27 Thread Kohei Tokunaga
Including is still required on Emscripten, just like on other platforms, to make the ioctl function available. Signed-off-by: Kohei Tokunaga Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/file-posix.c | 4 1 file changed, 4 insertions(+) diff --git a/block

[PATCH v3 11/20] util/cacheflush.c: Update cache flushing mechanism for Emscripten

2025-04-27 Thread Kohei Tokunaga
ror: error in backend: llvm.clear_cache is not supported on wasm To resolve this, this commit removes the call to __builtin___clear_cache for Emscripten build. Signed-off-by: Kohei Tokunaga Reviewed-by: Philippe Mathieu-Daudé --- include/qemu/cacheflush.h | 7 +++ util/cacheflush.c

[PATCH v3 05/20] target/i386/cpu.c: Fix type conflict of GLib function pointers

2025-04-27 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga --- target/i386/cpu.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 1f970aa4da..fedc47ea84

[PATCH v3 02/20] qom/object.c: Fix type conflict of GLib function pointers

2025-04-27 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga Reviewed-by: Philippe Mathieu-Daudé --- qom/object.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) V3: - This commit is included in this series sololy to

[PATCH v3 08/20] target/ppc: Fix type conflict of GLib function pointers

2025-04-27 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga --- target/ppc/cpu_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index fde7d71fc6

[PATCH v3 07/20] hw/net/can: Fix type conflict of GLib function pointers

2025-04-27 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga Reviewed-by: Philippe Mathieu-Daudé Acked-by: Francisco Iglesias --- hw/net/can/xlnx-versal-canfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) V3

[PATCH v3 06/20] contrib/plugins: Fix type conflict of GLib function pointers

2025-04-27 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga Reviewed-by: Philippe Mathieu-Daudé --- contrib/plugins/cache.c | 12 ++-- contrib/plugins/cflow.c | 10 +- contrib/plugins/hotblocks.c | 4

[PATCH v3 00/20] Enable QEMU TCI to run 32bit guests on browsers

2025-04-27 Thread Kohei Tokunaga
l.img', '-append', 'console=ttyAMA0 root=/dev/vda loglevel=7', ]; The sample repository[1] provides a complete setup, including an HTML file that implements a terminal UI. [1] https://github.com/ktock/qemu-wasm-sample/tree/tcidev # Additional references - Original

Re: [PATCH v2 10/20] include/glib-compat.h: Poison g_list_sort and g_slist_sort

2025-04-26 Thread Kohei Tokunaga
Hi Thomas, > Cosmetic nit: Multiline comments in QEMU should start with "/*" on their own > line. Thank you for the feedback. I'll fix this in the next version of the series.

Re: [PATCH v2 04/20] target/arm/helper.c: Fix type conflict of GLib function pointers

2025-04-26 Thread Kohei Tokunaga
Hi Philippe, > Why not use a gpointer for @d like in other patches? Thank you for the feedback. I'll fix this to use a gpointer in the next version of the series.

Re: [PATCH v2 11/20] util/cacheflush.c: Update cache flushing mechanism for Emscripten

2025-04-22 Thread Kohei Tokunaga
Hi Philippe, >On 22/4/25 07:27, Kohei Tokunaga wrote: >> Although __builtin___clear_cache is used to flush the instruction cache for >> a specified memory region[1], this operation doesn't apply to wasm, as its >> memory isn't executable. Moreover, Emscripten does

[PATCH v2 12/20] block: Add including of ioctl header for Emscripten build

2025-04-21 Thread Kohei Tokunaga
Including is still required on Emscripten, just like on other platforms, to make the ioctl function available. Signed-off-by: Kohei Tokunaga --- block/file-posix.c | 4 1 file changed, 4 insertions(+) V2: - Split this from the previous 12th patch into a separate commit and revised the

[PATCH v2 16/20] util: exclude mmap-alloc.c from compilation target on Emscripten

2025-04-21 Thread Kohei Tokunaga
/lib/libc/emscripten_mmap.c#L61 Signed-off-by: Kohei Tokunaga --- backends/meson.build | 6 -- system/memory.c | 2 +- system/physmem.c | 9 + util/meson.build | 4 +++- util/oslib-posix.c | 28 5 files changed, 41 insertions(+), 8

[PATCH v2 14/20] include/qemu/osdep.h: Add Emscripten-specific OS dependencies

2025-04-21 Thread Kohei Tokunaga
On emscripten, some implementations in os-posix.c can't be used such as daemonizing and changing user. This commit introduces os-wasm.c and os-wasm.h which are forked from os-posix.c and os-posix.h and patched for targetting Emscripten. Signed-off-by: Kohei Tokunaga --- MAINTA

[PATCH v2 17/20] util: Add coroutine backend for emscripten

2025-04-21 Thread Kohei Tokunaga
Emscripten does not support couroutine methods currently used by QEMU but provides a coroutine implementation called "fiber". This commit introduces a coroutine backend using fiber. Note that fiber does not support submitting coroutines to other threads. Signed-off-by: Kohe

[PATCH v2 19/20] tests: Add Dockerfile containing dependencies for Emscripten build

2025-04-21 Thread Kohei Tokunaga
The added Dockerfile is based on the emsdk image, which includes the Emscripten toolchain. It also cross-compiles the necessary dependencies (glib, libffi, pixman, and zlib) for the Emscripten target environment. Signed-off-by: Kohei Tokunaga --- MAINTAINERS

[PATCH v2 18/20] meson: Add wasm build in build scripts

2025-04-21 Thread Kohei Tokunaga
has_int128_type is set to false on emscripten as of now to avoid errors by libffi. Tests are disabled on emscripten because they rely on host features that aren't supported by emscripten (e.g. fork and unix socket). Signed-off-by: Kohei Tokunaga --- MAINTAINERS | 1 + co

[PATCH v2 15/20] Disable options unsupported on Emscripten

2025-04-21 Thread Kohei Tokunaga
Daemonizing and run-with aren't supported on Emscripten so disable these flags. Signed-off-by: Kohei Tokunaga --- qemu-options.hx | 4 ++-- system/vl.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) V2: - Unified two consecutive #ifndef macros into a single condition in

[PATCH v2 20/20] gitlab: Enable CI for wasm build

2025-04-21 Thread Kohei Tokunaga
Add GitLab CI job that builds QEMU using emscripten. The build runs in the container defined in tests/docker/dockerfiles/emsdk-wasm32-cross.docker. Signed-off-by: Kohei Tokunaga --- .gitlab-ci.d/buildtest-template.yml | 27 +++ .gitlab-ci.d/buildtest.yml | 9

[PATCH v2 06/20] contrib/plugins: Fix type conflict of GLib function pointers

2025-04-21 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga --- contrib/plugins/cache.c | 12 ++-- contrib/plugins/cflow.c | 10 +- contrib/plugins/hotblocks.c | 4 ++-- contrib/plugins/hotpages.c | 4

[PATCH v2 07/20] hw/net/can: Fix type conflict of GLib function pointers

2025-04-21 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga --- hw/net/can/xlnx-versal-canfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) V2: - Updated the commit message to explicitly explain that function pointer

[PATCH v2 01/20] hw/core/loader.c: Fix type conflict of GLib function pointers

2025-04-21 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga --- hw/core/loader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) V2: - Updated the commit message to explicitly explain that function pointer casts are

[PATCH v2 13/20] block: Fix type confict of the copy_file_range stub

2025-04-21 Thread Kohei Tokunaga
uring compilation. To fix this error, this commit updates the stub implementation in file-posix.c to exactly match the declaration in Emscripten's headers. The manpage also aligns with this signature. Signed-off-by: Kohei Tokunaga --- block/file-posix.c | 4 ++-- 1 file changed, 2 insert

[PATCH v2 10/20] include/glib-compat.h: Poison g_list_sort and g_slist_sort

2025-04-21 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga --- include/glib-compat.h | 6 ++ 1 file changed, 6 insertions(+) V2: - Fixed typo in the comment: s/insted/instead/ - Updated the commit message to explicitly

[PATCH v2 03/20] system/vl.c: Fix type conflict of GLib function pointers

2025-04-21 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga --- system/vl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) V2: - Updated the commit message to explicitly explain that function pointer casts are

[PATCH v2 09/20] target/s390x: Fix type conflict of GLib function pointers

2025-04-21 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga --- target/s390x/cpu_models.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) V2: - Updated the commit message to explicitly explain that function pointer

[PATCH v2 05/20] target/i386/cpu.c: Fix type conflict of GLib function pointers

2025-04-21 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga --- target/i386/cpu.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) V2: - Updated the commit message to explicitly explain that function pointer

[PATCH v2 04/20] target/arm/helper.c: Fix type conflict of GLib function pointers

2025-04-21 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga --- target/arm/helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) V2: - Updated the commit message to explicitly explain that function pointer casts

[PATCH v2 08/20] target/ppc: Fix type conflict of GLib function pointers

2025-04-21 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga --- target/ppc/cpu_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) V2: - Updated the commit message to explicitly explain that function pointer casts

[PATCH v2 11/20] util/cacheflush.c: Update cache flushing mechanism for Emscripten

2025-04-21 Thread Kohei Tokunaga
error: error in backend: llvm.clear_cache is not supported on wasm To resolve this, this commit removes the call to __builtin___clear_cache for Emscripten build. [1] https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005f_005f_005fclear_005fcache Signed-

[PATCH v2 00/20] Enable QEMU TCI to run 32bit guests on browsers

2025-04-21 Thread Kohei Tokunaga
v # Additional references - Original patch series "Enable QEMU to run on browsers": https://patchew.org/QEMU/cover.1744032780.git.ktokunaga.m...@gmail.com/ - A talk at FOSDEM 2025: https://fosdem.org/2025/schedule/event/fosdem-2025-6290-running-qemu-inside-browser/ Kohei Tokunaga (2

[PATCH v2 02/20] qom/object.c: Fix type conflict of GLib function pointers

2025-04-21 Thread Kohei Tokunaga
g_slist_sort_with_data should be used instead, as they do not rely on function pointer casting. Signed-off-by: Kohei Tokunaga --- qom/object.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) V2: - Updated the commit message to explicitly explain that function pointer casts are

Re: [PATCH 15/19] util/mmap-alloc: Add qemu_ram_mmap implementation for emscripten

2025-04-20 Thread Kohei Tokunaga
Hi Philippe, While working on mmap-alloc.c, I found that Emscripten does not support partial unmapping of memory regions [1]. This limitation prevents correct implementation of qemu_ram_mmap and qemu_ram_munmap, which rely on partial unmap behavior. [1] https://github.com/emscripten-core/emscript

Re: [PATCH 01/19] hw/core/loader.c: Fix type conflict of GLib function pointers

2025-04-18 Thread Kohei Tokunaga
Hi Daniel and Philippe, >>> On emscripten, function pointer casts can cause function call failure. >>> This commit fixes the function definition to match to the type of the >>> function call using g_list_sort_with_data. >>> >>> Signed-off-by: Kohei

Re: [PATCH 01/19] hw/core/loader.c: Fix type conflict of GLib function pointers

2025-04-18 Thread Kohei Tokunaga
Hi Daniel, Paolo and Thomas, > > > I suggested this solution to Kohei because it's easy to check that we're > > > converting all users and not introducing new ones in the future (see > > > poisoning in patch 10). > > > > It is easy to check this /one/ example, but this pattern of bad casts > > is

Re: [PATCH 13/19] include/qemu/osdep.h: Add Emscripten-specific OS dependencies

2025-04-17 Thread Kohei Tokunaga
Hi Philippe, > You shouldn't have to modify this file, likely a rebase typo. Thank you for pointing this out. I'll fix this in the next version of the series.

Re: [PATCH 12/19] block: Update block to compile with Emscripten

2025-04-17 Thread Kohei Tokunaga
Hi Philippe, > If meson fails to link, it won't define HAVE_COPY_FILE_RANGE, Yes, meson correctly detects the link failure when checking for copy_file_range, as shown in meson-log.txt: > wasm-ld: error: /tmp/emscripten_temp_oqvz296m/testfile_0.o: undefined symbol: copy_file_range and reflects t

Re: [PATCH 12/19] block: Update block to compile with Emscripten

2025-04-17 Thread Kohei Tokunaga
Hi Philippe, > I'd include in this patch this hunk from patch 17: > > -- >8 -- > diff --git a/stubs/meson.build b/stubs/meson.build > index 63392f5e78..4fd4d362f9 100644 > --- a/stubs/meson.build > +++ b/stubs/meson.build > @@ -89,3 +89,7 @@ if have_system or have_user > stub_ss.add(files('hot

Re: [PATCH 19/19] MAINTAINERS: Update MAINTAINERS file for wasm-related files

2025-04-17 Thread Kohei Tokunaga
Hi Philippe, > Just "WebAssembly target"? (I'd add the future > tcg/wasm/ files in another MAINTAINERS section). > > Maybe better to squash with patch 17? Or start adding > the section when you add a new file, then update for > each new file added? Sure, I'll update the patch to follow this appro

Re: [PATCH 18/19] gitlab: Enable CI for wasm build

2025-04-17 Thread Kohei Tokunaga
Hi Philippe, > Probably nitpicking, I'd add the Dockerfile first, then the GitLab job > in another patch. Thank you for the suggestion. I'll split the patch in the next version.

Re: [PATCH 17/19] meson: Add wasm build in build scripts

2025-04-17 Thread Kohei Tokunaga
Hi Philippe, > Does wasm depend on TCI at this point (no TCG backend)? If so, should > we check TCI is enabled? (I wonder if configuring with the > --disable-tcg-interpreter option succeed). Yes, it depends on TCI at this point. Configuring with the --disable-tcg-interpreter succeeds but leads to

Re: [PATCH 15/19] util/mmap-alloc: Add qemu_ram_mmap implementation for emscripten

2025-04-17 Thread Kohei Tokunaga
Hi Philippe, > Can we keep this code generic? I.e. with something in the lines > of (only build-tested): Thank you for the suggestion. I'll try this approach.

Re: [PATCH 14/19] Disable options unsupported on Emscripten

2025-04-17 Thread Kohei Tokunaga
Hi Philippe, > > #ifndef _WIN32 > > +#ifndef EMSCRIPTEN > > #if !defined(_WIN32) && !defined(EMSCRIPTEN) > > ? Thank you for the sueggestion. I'll apply this in the next version of the series.

Re: [PATCH 12/19] block: Update block to compile with Emscripten

2025-04-17 Thread Kohei Tokunaga
Hi Philippe and Richard, thank you for the feedback. > Actually what about checking the symbol presence in meson? > Something like (untested): > > -- >8 -- > diff --git a/meson.build b/meson.build > index b18c46d16a2..33185fdf315 100644 > --- a/meson.build > +++ b/meson.build > @@ -2654,3 +2654,2

  1   2   >