Re: [PATCH v2 12/14] meson: Disallow 64-bit on 32-bit TCG emulation

2025-02-03 Thread Alex Bennée
Richard Henderson  writes:

> For system mode, we can rarely support the amount of RAM that
> the guest requires. Emulation is restricted to round-robin
> mode, which solves many of the atomicity issues, but not those
> associated with virtio.  In any case, round-robin does nothing
> to help the speed of emulation.
>
> For user mode, most emulation does not succeed at all.  Most
> of the time we cannot even load 64-bit non-PIE binaries due
> to lack of a 64-bit address space.  Threads are run in
> parallel, not round-robin, which means that atomicity
> is not handled.

I think in itself is not enough, on aarch64.ci.org:

  ./../configure --disable-docs --disable-tools 
--cross-prefix=arm-linux-gnueabihf-

Should only build 32 bit binaries. Which it does:

  13:52:57 [alex@aarch64:~/l/q/b/arm32.crossbuild] 
review/deprecate-64-on-32-v2|… + ls qemu-*
  qemu-arm qemu-keymapqemu-mipsel   qemu-sh4 
qemu-system-i386qemu-system-ppc  qemu-system-sparc qemu-xtensa
  qemu-armeb   qemu-m68k  qemu-options.def  qemu-sh4eb   
qemu-system-m68kqemu-system-riscv32  qemu-system-tricore   qemu-xtensaeb
  qemu-hexagon qemu-microblazeqemu-or1k qemu-sparc   
qemu-system-mipsqemu-system-rx   qemu-system-xtensa
  qemu-i386qemu-microblazeel  qemu-ppc  qemu-system-arm  
qemu-system-mipsel  qemu-system-sh4  qemu-system-xtensaeb
  qemu-img-cmds.h  qemu-mips  qemu-riscv32  qemu-system-avr  
qemu-system-or1kqemu-system-sh4ebqemu-version.h

However make check-tcg fails because:

  13:53:09 [alex@aarch64:~/l/q/b/arm32.crossbuild] 
review/deprecate-64-on-32-v2|… + cat config-host.mak 
  # Automatically generated by configure - do not modify

  all:
  SRC_PATH=/home/alex/lsrc/qemu.git
  TARGET_DIRS=aarch64-linux-user aarch64_be-linux-user alpha-linux-user 
arm-linux-user armeb-linux-user hexagon-linux-user hppa-linux-user 
i386-linux-user loongarch64-linux-user m68k-linux-user microblaze-linux-user 
microblazeel-linux-user mips-linux-user mips64-linux-user mips64el-linux-user 
mipsel-linux-user mipsn32-linux-user mipsn32el-linux-user or1k-linux-user 
ppc-linux-user ppc64-linux-user ppc64le-linux-user riscv32-linux-user 
riscv64-linux-user s390x-linux-user sh4-linux-user sh4eb-linux-user 
sparc-linux-user sparc32plus-linux-user sparc64-linux-user x86_64-linux-user 
xtensa-linux-user xtensaeb-linux-user aarch64-softmmu alpha-softmmu arm-softmmu 
avr-softmmu hppa-softmmu i386-softmmu loongarch64-softmmu m68k-softmmu 
microblaze-softmmu microblazeel-softmmu mips-softmmu mips64-softmmu 
mips64el-softmmu mipsel-softmmu or1k-softmmu ppc-softmmu ppc64-softmmu 
riscv32-softmmu riscv64-softmmu rx-softmmu s390x-softmmu sh4-softmmu 
sh4eb-softmmu sparc-softmmu sparc64-softmmu tricore-softmmu x86_64-softmmu 
xtensa-softmmu xtensaeb-softmmu
  GDB=/usr/bin/gdb-multiarch
  RUNC=docker
  SUBDIRS= pc-bios/optionrom pc-bios/s390-ccw
  PYTHON=/home/alex/lsrc/qemu.git/builds/arm32.crossbuild/pyvenv/bin/python3 -B
  
MKVENV_ENSUREGROUP=/home/alex/lsrc/qemu.git/builds/arm32.crossbuild/pyvenv/bin/python3
 -B /home/alex/lsrc/qemu.git/python/scripts/mkvenv.py ensuregroup  --online
  GENISOIMAGE=/usr/bin/genisoimage
  MESON=/home/alex/lsrc/qemu.git/builds/arm32.crossbuild/pyvenv/bin/meson
  NINJA=/usr/bin/ninja
  EXESUF=
  CONFIG_DEFAULT_TARGETS=y
  TCG_TESTS_TARGETS= aarch64-linux-user arm-linux-user i386-linux-user 
mips64el-linux-user mipsel-linux-user riscv64-linux-user s390x-linux-user 
aarch64-softmmu arm-softmmu i386-softmmu riscv64-softmmu s390x-softmmu

So possible TCG_TESTS_TARGET needs to be merged with the meson code?
Also do we still use TARGET_DIRS?

>
> Signed-off-by: Richard Henderson 
> ---
>  meson.build | 14 +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 5ca3cc3f34..866b8ce477 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -3176,6 +3176,9 @@ if host_os == 'windows'
>endif
>  endif
>  
> +# Detect host pointer size for the target configuration loop.
> +host_long_bits = cc.sizeof('void *') * 8
> +
>  
>  # Target configuration #
>  
> @@ -3268,11 +3271,18 @@ foreach target : target_dirs
>  }
>endif
>  
> +  config_target += keyval.load('configs/targets' / target + '.mak')
> +
>target_kconfig = []
>foreach sym: accelerators
>  if sym == 'CONFIG_TCG'
> +  # Disallow 64-bit on 32-bit TCG emulation.
> +  if host_long_bits < config_target['TARGET_LONG_BITS'].to_int()
> +continue
> +  endif
>config_target += { 'CONFIG_TCG_TARGET': 'y' }
>  elif target not in accelerator_targets.get(sym, [])
> +  # Other accelerators are handled by accelerator_targets.
>continue
>  endif
>  config_target += { sym: 'y' }
> @@ -3286,9 +3296,6 @@ foreach target : target_dirs
>  error('No accelerator available for target @0@'.format(target))
>endi

Re: [PATCH v2 12/14] meson: Disallow 64-bit on 32-bit TCG emulation

2025-02-03 Thread Thomas Huth

On 03/02/2025 04.18, Richard Henderson wrote:

For system mode, we can rarely support the amount of RAM that
the guest requires. Emulation is restricted to round-robin
mode, which solves many of the atomicity issues, but not those
associated with virtio.  In any case, round-robin does nothing
to help the speed of emulation.

For user mode, most emulation does not succeed at all.  Most
of the time we cannot even load 64-bit non-PIE binaries due
to lack of a 64-bit address space.  Threads are run in
parallel, not round-robin, which means that atomicity
is not handled.

Signed-off-by: Richard Henderson 
---
  meson.build | 14 +++---
  1 file changed, 11 insertions(+), 3 deletions(-)


Reviewed-by: Thomas Huth 




[PATCH v2 12/14] meson: Disallow 64-bit on 32-bit TCG emulation

2025-02-02 Thread Richard Henderson
For system mode, we can rarely support the amount of RAM that
the guest requires. Emulation is restricted to round-robin
mode, which solves many of the atomicity issues, but not those
associated with virtio.  In any case, round-robin does nothing
to help the speed of emulation.

For user mode, most emulation does not succeed at all.  Most
of the time we cannot even load 64-bit non-PIE binaries due
to lack of a 64-bit address space.  Threads are run in
parallel, not round-robin, which means that atomicity
is not handled.

Signed-off-by: Richard Henderson 
---
 meson.build | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/meson.build b/meson.build
index 5ca3cc3f34..866b8ce477 100644
--- a/meson.build
+++ b/meson.build
@@ -3176,6 +3176,9 @@ if host_os == 'windows'
   endif
 endif
 
+# Detect host pointer size for the target configuration loop.
+host_long_bits = cc.sizeof('void *') * 8
+
 
 # Target configuration #
 
@@ -3268,11 +3271,18 @@ foreach target : target_dirs
 }
   endif
 
+  config_target += keyval.load('configs/targets' / target + '.mak')
+
   target_kconfig = []
   foreach sym: accelerators
 if sym == 'CONFIG_TCG'
+  # Disallow 64-bit on 32-bit TCG emulation.
+  if host_long_bits < config_target['TARGET_LONG_BITS'].to_int()
+continue
+  endif
   config_target += { 'CONFIG_TCG_TARGET': 'y' }
 elif target not in accelerator_targets.get(sym, [])
+  # Other accelerators are handled by accelerator_targets.
   continue
 endif
 config_target += { sym: 'y' }
@@ -3286,9 +3296,6 @@ foreach target : target_dirs
 error('No accelerator available for target @0@'.format(target))
   endif
 
-  config_target += keyval.load('configs/targets' / target + '.mak')
-  config_target += { 'TARGET_' + config_target['TARGET_ARCH'].to_upper(): 'y' }
-
   if 'TARGET_NEED_FDT' in config_target and not fdt.found()
 if default_targets
   warning('Disabling ' + target + ' due to missing libfdt')
@@ -3301,6 +3308,7 @@ foreach target : target_dirs
   actual_target_dirs += target
 
   # Add default keys
+  config_target += { 'TARGET_' + config_target['TARGET_ARCH'].to_upper(): 'y' }
   if 'TARGET_BASE_ARCH' not in config_target
 config_target += {'TARGET_BASE_ARCH': config_target['TARGET_ARCH']}
   endif
-- 
2.43.0