]> git.ipfire.org Git - thirdparty/qemu.git/log
thirdparty/qemu.git
14 months agotarget/arm: Move cpu_get_tb_cpu_state to hflags.c
Richard Henderson [Tue, 29 Apr 2025 18:35:26 +0000 (11:35 -0700)] 
target/arm: Move cpu_get_tb_cpu_state to hflags.c

This is a tcg-specific function, so move it to a tcg file.
Also move mve_no_pred, a static function only used within
cpu_get_tb_cpu_state.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Hoist cpu_get_tb_cpu_state decl to accl/tcg/cpu-ops.h
Richard Henderson [Sun, 27 Apr 2025 22:15:14 +0000 (15:15 -0700)] 
accel/tcg: Hoist cpu_get_tb_cpu_state decl to accl/tcg/cpu-ops.h

For some targets, simply remove the local definition.
For other targets, move the inline definition out of line.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/i386: Split out x86_cpu_exec_reset
Richard Henderson [Sun, 27 Apr 2025 18:44:23 +0000 (11:44 -0700)] 
target/i386: Split out x86_cpu_exec_reset

Note that target/i386/cpu.h defines CPU_INTERRUPT_INIT
as CPU_INTERRUPT_RESET.  Therefore we can handle the
new TCGCPUOps.cpu_exec_reset hook.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Introduce TCGCPUOps.cpu_exec_reset
Richard Henderson [Sun, 27 Apr 2025 18:31:30 +0000 (11:31 -0700)] 
accel/tcg: Introduce TCGCPUOps.cpu_exec_reset

Initialize all instances with cpu_reset(), so that there
is no functional change.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Unconditionally use CPU_DUMP_CCOP in log_cpu_exec
Richard Henderson [Sun, 27 Apr 2025 18:02:25 +0000 (11:02 -0700)] 
accel/tcg: Unconditionally use CPU_DUMP_CCOP in log_cpu_exec

This flag is only tested by target/i386, so including this
makes no functional change.  This is similar to other places
like cpu-target.c which use CPU_DUMP_CCOP unconditionally.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Generalize fake_user_interrupt test
Richard Henderson [Sat, 26 Apr 2025 20:20:24 +0000 (20:20 +0000)] 
accel/tcg: Generalize fake_user_interrupt test

Test for the hook being present instead of ifdef TARGET_I386.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoinclude: Remove 'exec/exec-all.h'
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:12 +0000 (22:24 +0200)] 
include: Remove 'exec/exec-all.h'

"exec/exec-all.h" is now fully empty, let's remove it.

Mechanical change running:

  $ sed -i '/exec\/exec-all.h/d' $(git grep -wl exec/exec-all.h)

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-14-philmd@linaro.org>

14 months agoaccel/tcg: Extract probe API out of 'exec/exec-all.h'
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:11 +0000 (22:24 +0200)] 
accel/tcg: Extract probe API out of 'exec/exec-all.h'

Declare probe methods in "accel/tcg/probe.h" to emphasize
they are specific to TCG accelerator.

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-13-philmd@linaro.org>

14 months agophysmem: Restrict TCG IOTLB code to TCG accel
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:10 +0000 (22:24 +0200)] 
physmem: Restrict TCG IOTLB code to TCG accel

Restrict iotlb_to_section(), address_space_translate_for_iotlb()
and memory_region_section_get_iotlb() to TCG. Declare them in
the new "accel/tcg/iommu.h" header. Declare iotlb_to_section()
using the MemoryRegionSection typedef.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-12-philmd@linaro.org>

14 months agophysmem: Move TCG IOTLB methods around
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:09 +0000 (22:24 +0200)] 
physmem: Move TCG IOTLB methods around

The next commit will restrict TCG specific code in physmem.c
using some #ifdef'ry. In order to keep it simple, move
iotlb_to_section() and memory_region_section_get_iotlb()
around close together.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-11-philmd@linaro.org>

14 months agoaccel/tcg: Include 'accel/tcg/getpc.h' in 'exec/helper-proto'
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:08 +0000 (22:24 +0200)] 
accel/tcg: Include 'accel/tcg/getpc.h' in 'exec/helper-proto'

Most files including "exec/helper-proto.h" call GETPC().
Include it there (in the common part) instead of the
unspecific "exec/exec-all.h" header.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-10-philmd@linaro.org>

14 months agotarget/riscv: Include missing 'accel/tcg/getpc.h' in csr.c
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:06 +0000 (22:24 +0200)] 
target/riscv: Include missing 'accel/tcg/getpc.h' in csr.c

"accel/tcg/getpc.h" is pulled in indirectly. Include it
explicitly to avoid when refactoring unrelated headers:

  target/riscv/csr.c:2117:25: error: call to undeclared function 'GETPC' [-Wimplicit-function-declaration]
   2117 |     if ((val & RVC) && (GETPC() & ~3) != 0) {
        |                         ^

Note the TODO comment around GETPC() added upon introduction in
commit f18637cd611 ("RISC-V: Add misa runtime write support"):

 2099 static RISCVException write_misa(CPURISCVState *env, int csrno,
 2100                                  target_ulong val)
 2101 {
  ...
 2113     /*
 2114      * Suppress 'C' if next instruction is not aligned
 2115      * TODO: this should check next_pc
 2116      */
 2117     if ((val & RVC) && (GETPC() & ~3) != 0) {
 2118         val &= ~RVC;
 2119     }

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-8-philmd@linaro.org>

14 months agoaccel/tcg: Remove #error for non-tcg in getpc.h
Richard Henderson [Sat, 26 Apr 2025 19:35:00 +0000 (19:35 +0000)] 
accel/tcg: Remove #error for non-tcg in getpc.h

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Compile tb-maint.c twice
Richard Henderson [Thu, 24 Apr 2025 20:24:05 +0000 (22:24 +0200)] 
accel/tcg: Compile tb-maint.c twice

Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoinclude/exec: Move tb_invalidate_phys_range to translation-block.h
Richard Henderson [Thu, 24 Apr 2025 20:24:04 +0000 (22:24 +0200)] 
include/exec: Move tb_invalidate_phys_range to translation-block.h

Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoinclude/exec: Include missing headers in exec-all.h
Philippe Mathieu-Daudé [Thu, 24 Apr 2025 20:24:03 +0000 (22:24 +0200)] 
include/exec: Include missing headers in exec-all.h

"exec/exec-all.h" declares prototypes such:

  void *probe_access(CPUArchState *env, vaddr addr, int size,
                                        ^^^^^
                     MMUAccessType access_type, int mmu_idx,
                     uintptr_t retaddr);
  MemoryRegionSection *iotlb_to_section(CPUState *cpu,
                                        hwaddr index,
                                        ^^^^^^
                                        MemTxAttrs attrs);
                                        ^^^^^^^^^^

vaddr is defined in "exec/vaddr.h", hwaddr in "exec/hwaddr.h"
and MemTxAttrs in "exec/memattrs.h". All these headers are
indirectly pulled in via "exec/translation-block.h". Since
we will remove "exec/translation-block.h" in the next commit,
include the missing ones, otherwise we'd get errors such:

  include/exec/exec-all.h:51:1: error: unknown type name 'hwaddr'
     51 | hwaddr memory_region_section_get_iotlb(CPUState *cpu,
        | ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250424202412.91612-5-philmd@linaro.org>

14 months agoaccel/tcg: Use vaddr in user/page-protection.h
Richard Henderson [Thu, 24 Apr 2025 20:24:01 +0000 (22:24 +0200)] 
accel/tcg: Use vaddr in user/page-protection.h

Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Use vaddr for walk_memory_regions callback
Richard Henderson [Thu, 24 Apr 2025 20:24:00 +0000 (22:24 +0200)] 
accel/tcg: Use vaddr for walk_memory_regions callback

Use vaddr instead of target_ulong.  At the same time,
use int instead of unsigned long for flags, to match
page_set_flags().

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Reduce scope of tb_phys_invalidate, tb_set_jmp_target
Richard Henderson [Sat, 5 Apr 2025 16:45:48 +0000 (09:45 -0700)] 
accel/tcg: Reduce scope of tb_phys_invalidate, tb_set_jmp_target

Move the declarations of these functions out of exec/exec-all.h
to accel/tcg/internal-common.h.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Merge internal-target.h into internal-common.h
Richard Henderson [Sat, 5 Apr 2025 16:36:27 +0000 (09:36 -0700)] 
accel/tcg: Merge internal-target.h into internal-common.h

There's nothing left in internal-target.h that is
target specific.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Simplify L1_MAP_ADDR_SPACE_BITS
Richard Henderson [Wed, 2 Apr 2025 19:30:39 +0000 (12:30 -0700)] 
accel/tcg: Simplify L1_MAP_ADDR_SPACE_BITS

Stop taking TARGET_PHYS_ADDR_SPACE_BITS into account.
Simply allow the entire ram_addr_t space.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Simplify CPU_TLB_DYN_MAX_BITS
Richard Henderson [Wed, 2 Apr 2025 15:40:31 +0000 (08:40 -0700)] 
accel/tcg: Simplify CPU_TLB_DYN_MAX_BITS

Stop taking TARGET_VIRT_ADDR_SPACE_BITS into account.

Since we currently bound CPU_TLB_DYN_MAX_BITS to 22,
the new bound with a 4k page size is 20, which isn't
so different.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Convert TARGET_HAS_PRECISE_SMC to TCGCPUOps.precise_smc
Richard Henderson [Sat, 5 Apr 2025 15:43:44 +0000 (08:43 -0700)] 
accel/tcg: Convert TARGET_HAS_PRECISE_SMC to TCGCPUOps.precise_smc

Instead of having a compile-time TARGET_HAS_PRECISE_SMC definition,
have each target set the 'precise_smc' field in the TCGCPUOps
structure.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Add CPUState arg to tb_invalidate_phys_range_fast
Richard Henderson [Wed, 23 Apr 2025 20:10:45 +0000 (13:10 -0700)] 
accel/tcg: Add CPUState arg to tb_invalidate_phys_range_fast

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Add CPUState arg to tb_invalidate_phys_range
Richard Henderson [Wed, 23 Apr 2025 20:06:12 +0000 (13:06 -0700)] 
accel/tcg: Add CPUState arg to tb_invalidate_phys_range

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Merge tb_invalidate_phys_range{__locked}
Richard Henderson [Wed, 23 Apr 2025 19:37:28 +0000 (12:37 -0700)] 
accel/tcg: Merge tb_invalidate_phys_range{__locked}

Merge tb_invalidate_phys_page_fast__locked into its
only caller, tb_invalidate_phys_range_fast.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Add CPUState arg to tb_invalidate_phys_page_range__locked
Richard Henderson [Wed, 23 Apr 2025 19:23:30 +0000 (12:23 -0700)] 
accel/tcg: Add CPUState arg to tb_invalidate_phys_page_range__locked

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Add CPUState argument to tb_invalidate_phys_page_unwind
Richard Henderson [Fri, 4 Apr 2025 01:06:21 +0000 (18:06 -0700)] 
accel/tcg: Add CPUState argument to tb_invalidate_phys_page_unwind

Replace existing usage of current_cpu.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoaccel/tcg: Add CPUState argument to page_unprotect
Richard Henderson [Thu, 3 Apr 2025 23:59:29 +0000 (16:59 -0700)] 
accel/tcg: Add CPUState argument to page_unprotect

In the next patch, page_unprotect will need to pass
the CPUState to tb_invalidate_phys_page_unwind.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agodocs/devel/build-environment: enhance MSYS2 instructions
Pierrick Bouvier [Wed, 30 Apr 2025 18:10:47 +0000 (11:10 -0700)] 
docs/devel/build-environment: enhance MSYS2 instructions

Add missing prerequisite packages, and use more explicit makepkg
command.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20250430181047.2043492-1-pierrick.bouvier@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
14 months agohw/rtc/mc146818rtc: Drop pre-v3 migration stream support
Philippe Mathieu-Daudé [Wed, 15 Jan 2025 21:00:48 +0000 (22:00 +0100)] 
hw/rtc/mc146818rtc: Drop pre-v3 migration stream support

mc146818rtc's migration stream is at version 3 since commit
56038ef6234 ("RTC: Update the RTC clock only when reading it")
from 12 years ago, released in QEMU v1.3.0!
No versioned machines are that old, we can safely remove
support for older streams and the qdev_set_legacy_instance_id()
call.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Message-ID: <20250115210048.25396-1-philmd@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
14 months agomeson.build: Put the D-Bus summary into the UI section
Thomas Huth [Tue, 25 Mar 2025 05:51:25 +0000 (06:51 +0100)] 
meson.build: Put the D-Bus summary into the UI section

We've got a dedicated section for UI options nowadays, so the
D-Bus display should get reported here, too.

Message-ID: <20250325055125.253669-1-thuth@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
14 months agotests/functional/test_ppc64_pseries: Skip test_ppc64_linux_smt_boot if necessary
Thomas Huth [Thu, 24 Apr 2025 08:54:26 +0000 (10:54 +0200)] 
tests/functional/test_ppc64_pseries: Skip test_ppc64_linux_smt_boot if necessary

The test_ppc64_linux_smt_boot function lacks the set_machine('pseries'),
so this test is currently failing in case the 'pseries' machine has not
been compiled into the binary. Add the check now to fix it.

Message-ID: <20250424085426.663377-1-thuth@redhat.com>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
14 months agoDrop support for Python 3.8
Thomas Huth [Fri, 25 Apr 2025 12:07:10 +0000 (14:07 +0200)] 
Drop support for Python 3.8

Python 3.8 went "end of life" in October 2024 and Fedora 42 dropped
this version already, so the "python" CI job is currently failing.
Thus it's time to drop support for this Python version in QEMU, too.

While we're at it, also look for "python3.13" in the configure script.

Message-ID: <20250425120710.879518-1-thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
14 months agomeson/configure: add 'valgrind' option & --{en, dis}able-valgrind flag
Daniel P. Berrangé [Fri, 25 Apr 2025 12:17:12 +0000 (13:17 +0100)] 
meson/configure: add 'valgrind' option & --{en, dis}able-valgrind flag

Currently valgrind debugging support for coroutine stacks is enabled
unconditionally when valgrind/valgrind.h is found. There is no way
to disable valgrind support if valgrind.h is present in the build env.

This is bad for distros, as an dependency far down the chain may cause
valgrind.h to become installed, inadvertently enabling QEMU's valgrind
debugging support. It also means if a distro wants valgrind support
there is no way to mandate this.

The solution is to add a 'valgrind' build feature to meson and thus
configure script.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20250425121713.1913424-1-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
14 months agoMerge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging
Stefan Hajnoczi [Wed, 30 Apr 2025 17:34:43 +0000 (13:34 -0400)] 
Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging

Pull request

Kevin's fix for the divide-by-zero in my recent discard commit, triggered when
a host block device does not support discard.

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmgSRfsACgkQnKSrs4Gr
# c8hGBwf8CBoDZzCJAE1sw2GSKnnd3J2qGf4Kg6CcMYOSZ8TLssDKQj6HG2gfWaJZ
# it9g9zq7TsodWCyV/qXrzOy5aa7WX8Tsf10O/87baFqGOp82KMPX8jQK1csRnTTF
# QyDocZhIvO+QJXnmnFjtvY7qfaxkzaT/8U+mWgaQM2zG83BNGg3uNyRPyz+RAfYl
# tVM3xNf2ETbN3D8SIOcpr80/tiWP8dZ8xTLyTfBYPbIP59QX2+Iu8BtLFt9npwT6
# kABnFkqnE/pA6FJz0ZIVenduOBs7IUSQFNvmxAjYIwxowQKsk4WFfjJEKHIHzwwO
# a64i43DcH8XgjCcueJ11DnmoB5RfAg==
# =yODA
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 30 Apr 2025 11:47:07 EDT
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [ultimate]
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>" [ultimate]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* tag 'block-pull-request' of https://gitlab.com/stefanha/qemu:
  file-posix: Fix crash on discard_granularity == 0

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14 months agoMerge tag 'pull-tcg-20250429' of https://gitlab.com/rth7680/qemu into staging
Stefan Hajnoczi [Wed, 30 Apr 2025 17:34:35 +0000 (13:34 -0400)] 
Merge tag 'pull-tcg-20250429' of https://gitlab.com/rth7680/qemu into staging

Convert TCG backend code generators to TCGOutOp structures,
decomposing the monolithic tcg_out_op functions.

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmgRDgcdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+0SQf9Ef8IE5QWjXEws706
# q+1deeDV2xa1sKAHG5fnskk1bXM31Cy4koNdDQbHTtDWedNEzWKyR7FxjlRm+zSW
# 6CposaEEsCGxdKUbvraflGbWuf2NUZpJoreNGo9BYZkfNWE9yJ0HlypjpxclziRA
# G0Ro4XMevi+yVA3cd8lEmft9cW+woFrVWu5I4tucMwY/8gzWRiHV4Z5YCeCEjD3C
# 3YYukhRTaA+7Lyd1G3rcqh8uSsAGGv2NLO26upK1mnVtZOoS/CgKWfBq5enVEuDd
# X6T544ipz8Z3eXFgzTzK4nl7TpmO+XEUbja3op7psrLHU84puX1/47HLk4TkHlE+
# 6/95eA==
# =vzOx
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 29 Apr 2025 13:36:07 EDT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* tag 'pull-tcg-20250429' of https://gitlab.com/rth7680/qemu: (161 commits)
  tcg/sparc64: Implement CTPOP
  tcg/sparc64: Unexport use_vis3_instructions
  tcg: Remove tcg_out_op
  tcg: Convert qemu_st{2} to TCGOutOpLdSt{2}
  tcg: Convert qemu_ld{2} to TCGOutOpLoad{2}
  tcg: Merge INDEX_op_{ld,st}_{i32,i64,i128}
  tcg: Remove INDEX_op_qemu_st8_*
  tcg: Stash MemOp size in TCGOP_FLAGS
  tcg: Merge INDEX_op_st*_{i32,i64}
  tcg: Convert st to TCGOutOpStore
  tcg: Merge INDEX_op_ld*_{i32,i64}
  tcg: Convert ld to TCGOutOpLoad
  tcg: Formalize tcg_out_goto_ptr
  tcg: Formalize tcg_out_br
  tcg: Formalize tcg_out_mb
  tcg: Remove add2/sub2 opcodes
  tcg/tci: Implement add/sub carry opcodes
  tcg/sparc64: Implement add/sub carry opcodes
  tcg/sparc64: Hoist tcg_cond_to_bcond lookup out of tcg_out_movcc
  tcg/s390x: Use ADD LOGICAL WITH SIGNED IMMEDIATE
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14 months agofile-posix: Fix crash on discard_granularity == 0
Kevin Wolf [Tue, 29 Apr 2025 15:56:54 +0000 (17:56 +0200)] 
file-posix: Fix crash on discard_granularity == 0

Block devices that don't support discard have a discard_granularity of
0. Currently, this results in a division by zero when we try to make
sure that it's a multiple of request_alignment. Only try to update
bs->bl.pdiscard_alignment when we got a non-zero discard_granularity
from sysfs.

Fixes: f605796aae4 ('file-posix: probe discard alignment on Linux block devices')
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-ID: <20250429155654.102735-1-kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14 months agotarget/s390x: Return UVC cmd code, RC and RRC value when DIAG 308 Subcode 10 fails...
Gautam Gala [Wed, 23 Apr 2025 08:09:15 +0000 (10:09 +0200)] 
target/s390x: Return UVC cmd code, RC and RRC value when DIAG 308 Subcode 10 fails to enter secure mode

Extend DIAG308 subcode 10 to return the UVC RC, RRC and command code
in bit positions 32-47, 16-31, and 0-15 of register R1 + 1 if the
function does not complete successfully (in addition to the
previously returned diag response code in bit position 47-63).

Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Gautam Gala <ggala@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Message-ID: <20250423080915.1048123-4-ggala@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
14 months agotarget/s390x: Introduce function when exiting PV
Gautam Gala [Wed, 23 Apr 2025 08:09:14 +0000 (10:09 +0200)] 
target/s390x: Introduce function when exiting PV

Replace an existing macro (s390_pv_cmd_exit) that looks like
a function with an actual function. The function will be used
when exiting PV instead of the macro.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Gautam Gala <ggala@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20250423080915.1048123-3-ggala@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
14 months agotarget/s390x: Introduce constant when checking if PV header couldn't be decrypted
Gautam Gala [Wed, 23 Apr 2025 08:09:13 +0000 (10:09 +0200)] 
target/s390x: Introduce constant when checking if PV header couldn't be decrypted

Introduce a named constant when checking the Set Secure Configuration parameters
UV call return code for the case where no valid host key was found and therefore
the PV header couldn't be decrypted (0x108).

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Gautam Gala <ggala@linux.ibm.com>
Message-ID: <20250423080915.1048123-2-ggala@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
14 months agoblock: move commit_run loop to separate function
Vincent Vanlaer [Sat, 26 Oct 2024 16:30:06 +0000 (18:30 +0200)] 
block: move commit_run loop to separate function

Signed-off-by: Vincent Vanlaer <libvirt-e6954efa@volkihar.be>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Message-Id: <20241026163010.2865002-3-libvirt-e6954efa@volkihar.be>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
14 months agoblock: get type of block allocation in commit_run
Vincent Vanlaer [Sat, 26 Oct 2024 16:30:05 +0000 (18:30 +0200)] 
block: get type of block allocation in commit_run

bdrv_co_common_block_status_above not only returns whether the block is
allocated, but also if it contains zeroes.

Signed-off-by: Vincent Vanlaer <libvirt-e6954efa@volkihar.be>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Message-Id: <20241026163010.2865002-2-libvirt-e6954efa@volkihar.be>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
14 months agotcg/sparc64: Implement CTPOP
Richard Henderson [Fri, 25 Apr 2025 19:57:11 +0000 (12:57 -0700)] 
tcg/sparc64: Implement CTPOP

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/sparc64: Unexport use_vis3_instructions
Richard Henderson [Fri, 25 Apr 2025 18:59:58 +0000 (11:59 -0700)] 
tcg/sparc64: Unexport use_vis3_instructions

This variable is no longer used outside tcg-target.c.inc.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Remove tcg_out_op
Richard Henderson [Sun, 16 Feb 2025 22:22:48 +0000 (14:22 -0800)] 
tcg: Remove tcg_out_op

All integer opcodes are now converted to TCGOutOp.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Convert qemu_st{2} to TCGOutOpLdSt{2}
Richard Henderson [Sun, 16 Feb 2025 22:02:00 +0000 (14:02 -0800)] 
tcg: Convert qemu_st{2} to TCGOutOpLdSt{2}

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Convert qemu_ld{2} to TCGOutOpLoad{2}
Richard Henderson [Tue, 11 Feb 2025 21:41:42 +0000 (13:41 -0800)] 
tcg: Convert qemu_ld{2} to TCGOutOpLoad{2}

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Merge INDEX_op_{ld,st}_{i32,i64,i128}
Richard Henderson [Sun, 9 Feb 2025 20:55:15 +0000 (12:55 -0800)] 
tcg: Merge INDEX_op_{ld,st}_{i32,i64,i128}

Merge into INDEX_op_{ld,st,ld2,st2}, where "2" indicates that two
inputs or outputs are required. This simplifies the processing of
i64/i128 depending on host word size.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Remove INDEX_op_qemu_st8_*
Richard Henderson [Mon, 27 Jan 2025 01:34:19 +0000 (17:34 -0800)] 
tcg: Remove INDEX_op_qemu_st8_*

The i386 backend can now check TCGOP_FLAGS to select
the correct set of constraints.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Stash MemOp size in TCGOP_FLAGS
Richard Henderson [Thu, 23 Jan 2025 17:46:57 +0000 (09:46 -0800)] 
tcg: Stash MemOp size in TCGOP_FLAGS

This will enable removing INDEX_op_qemu_st8_*_i32,
by exposing the operand size to constraint selection.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Merge INDEX_op_st*_{i32,i64}
Richard Henderson [Wed, 22 Jan 2025 21:28:55 +0000 (13:28 -0800)] 
tcg: Merge INDEX_op_st*_{i32,i64}

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Convert st to TCGOutOpStore
Richard Henderson [Wed, 22 Jan 2025 20:49:41 +0000 (12:49 -0800)] 
tcg: Convert st to TCGOutOpStore

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Merge INDEX_op_ld*_{i32,i64}
Richard Henderson [Wed, 22 Jan 2025 05:47:16 +0000 (21:47 -0800)] 
tcg: Merge INDEX_op_ld*_{i32,i64}

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Convert ld to TCGOutOpLoad
Richard Henderson [Wed, 22 Jan 2025 04:44:42 +0000 (20:44 -0800)] 
tcg: Convert ld to TCGOutOpLoad

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Formalize tcg_out_goto_ptr
Richard Henderson [Tue, 21 Jan 2025 05:57:32 +0000 (21:57 -0800)] 
tcg: Formalize tcg_out_goto_ptr

Split these functions out from tcg_out_op.
Define outop_goto_ptr generically.
Call tcg_out_goto_ptr from tcg_reg_alloc_op.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Formalize tcg_out_br
Richard Henderson [Tue, 21 Jan 2025 05:17:07 +0000 (21:17 -0800)] 
tcg: Formalize tcg_out_br

Split these functions out from tcg_out_op.
Call it directly from tcg_gen_code.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Formalize tcg_out_mb
Richard Henderson [Tue, 21 Jan 2025 04:47:42 +0000 (20:47 -0800)] 
tcg: Formalize tcg_out_mb

Most tcg backends already have a function for this;
the rest can split one out from tcg_out_op.
Call it directly from tcg_gen_code.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Remove add2/sub2 opcodes
Richard Henderson [Tue, 21 Jan 2025 04:15:31 +0000 (20:15 -0800)] 
tcg: Remove add2/sub2 opcodes

All uses have been replaced by add/sub carry opcodes.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/tci: Implement add/sub carry opcodes
Richard Henderson [Tue, 21 Jan 2025 03:46:04 +0000 (19:46 -0800)] 
tcg/tci: Implement add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/sparc64: Implement add/sub carry opcodes
Richard Henderson [Tue, 21 Jan 2025 02:48:06 +0000 (18:48 -0800)] 
tcg/sparc64: Implement add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/sparc64: Hoist tcg_cond_to_bcond lookup out of tcg_out_movcc
Richard Henderson [Tue, 21 Jan 2025 00:34:47 +0000 (16:34 -0800)] 
tcg/sparc64: Hoist tcg_cond_to_bcond lookup out of tcg_out_movcc

Pass the sparc COND_* value not the tcg TCG_COND_* value.
This makes the usage within add2/sub2 clearer.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/s390x: Use ADD LOGICAL WITH SIGNED IMMEDIATE
Richard Henderson [Sun, 19 Jan 2025 18:01:18 +0000 (10:01 -0800)] 
tcg/s390x: Use ADD LOGICAL WITH SIGNED IMMEDIATE

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/s390x: Implement add/sub carry opcodes
Richard Henderson [Sun, 19 Jan 2025 17:31:26 +0000 (09:31 -0800)] 
tcg/s390x: Implement add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/s390x: Add TCG_CT_CONST_N32
Richard Henderson [Sat, 18 Jan 2025 22:01:12 +0000 (14:01 -0800)] 
tcg/s390x: Add TCG_CT_CONST_N32

We were using S32 | U32 for add2/sub2.  But the ALGFI and SLGFI
insns that implement this both have uint32_t immediates.
This makes the composite range balanced and
enables use of -0xffffffff ... -0x80000001.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/s390x: Honor carry_live in tcg_out_movi
Richard Henderson [Sat, 18 Jan 2025 21:26:43 +0000 (13:26 -0800)] 
tcg/s390x: Honor carry_live in tcg_out_movi

Do not clobber flags if they're live.  Required in order
to perform register allocation on add/sub carry opcodes.
LA and AGHI are the same size, so use LA unconditionally.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/ppc: Implement add/sub carry opcodes
Richard Henderson [Sat, 18 Jan 2025 00:38:13 +0000 (00:38 +0000)] 
tcg/ppc: Implement add/sub carry opcodes

Tested-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/arm: Implement add/sub carry opcodes
Richard Henderson [Wed, 15 Jan 2025 23:35:53 +0000 (23:35 +0000)] 
tcg/arm: Implement add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/aarch64: Implement add/sub carry opcodes
Richard Henderson [Wed, 15 Jan 2025 10:41:58 +0000 (02:41 -0800)] 
tcg/aarch64: Implement add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/tricore: Use tcg_gen_addcio_i32 for gen_addc_CC
Richard Henderson [Sat, 18 Jan 2025 10:08:55 +0000 (02:08 -0800)] 
target/tricore: Use tcg_gen_addcio_i32 for gen_addc_CC

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/sparc: Use tcg_gen_addcio_tl for gen_op_addcc_int
Richard Henderson [Sat, 18 Jan 2025 10:05:19 +0000 (02:05 -0800)] 
target/sparc: Use tcg_gen_addcio_tl for gen_op_addcc_int

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/sh4: Use tcg_gen_addcio_i32 for addc
Richard Henderson [Sat, 18 Jan 2025 10:03:03 +0000 (02:03 -0800)] 
target/sh4: Use tcg_gen_addcio_i32 for addc

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/s390x: Use tcg_gen_addcio_i64 for op_addc64
Richard Henderson [Sat, 18 Jan 2025 09:59:12 +0000 (01:59 -0800)] 
target/s390x: Use tcg_gen_addcio_i64 for op_addc64

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/ppc: Use tcg_gen_addcio_tl for ADD and SUBF
Richard Henderson [Sat, 18 Jan 2025 09:55:11 +0000 (01:55 -0800)] 
target/ppc: Use tcg_gen_addcio_tl for ADD and SUBF

Tested-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/openrisc: Use tcg_gen_addcio_* for ADDC
Richard Henderson [Sat, 18 Jan 2025 09:50:50 +0000 (01:50 -0800)] 
target/openrisc: Use tcg_gen_addcio_* for ADDC

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/microblaze: Use tcg_gen_addcio_i32
Richard Henderson [Sat, 18 Jan 2025 09:47:53 +0000 (01:47 -0800)] 
target/microblaze: Use tcg_gen_addcio_i32

Use this in gen_addc and gen_rsubc, both of which need
add with carry-in and carry-out.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/hppa: Use tcg_gen_addcio_i64
Richard Henderson [Sat, 18 Jan 2025 09:35:49 +0000 (01:35 -0800)] 
target/hppa: Use tcg_gen_addcio_i64

Use this in do_add, do_sub, and do_ds, all of which need
add with carry-in and carry-out.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/arm: Use tcg_gen_addcio_* for ADCS
Richard Henderson [Sat, 18 Jan 2025 09:27:41 +0000 (01:27 -0800)] 
target/arm: Use tcg_gen_addcio_* for ADCS

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Add tcg_gen_addcio_{i32,i64,tl}
Richard Henderson [Sat, 18 Jan 2025 09:19:51 +0000 (01:19 -0800)] 
tcg: Add tcg_gen_addcio_{i32,i64,tl}

Create a function for performing an add with carry-in
and producing carry out.  The carry-out result is boolean.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/i386: Special case addci r, 0, 0
Richard Henderson [Sat, 18 Jan 2025 06:39:14 +0000 (22:39 -0800)] 
tcg/i386: Special case addci r, 0, 0

Using addci with two zeros as input in order to capture the value
of the carry-in bit is common.  Special case this with sbb+neg so
that we do not have to load 0 into a register first.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/i386: Implement add/sub carry opcodes
Richard Henderson [Sat, 18 Jan 2025 06:24:56 +0000 (22:24 -0800)] 
tcg/i386: Implement add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/i386: Honor carry_live in tcg_out_movi
Richard Henderson [Sat, 18 Jan 2025 06:05:48 +0000 (22:05 -0800)] 
tcg/i386: Honor carry_live in tcg_out_movi

Do not clobber flags if they're live.  Required in order
to perform register allocation on add/sub carry opcodes.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Use sub carry opcodes to expand sub2
Richard Henderson [Wed, 15 Jan 2025 02:58:05 +0000 (18:58 -0800)] 
tcg: Use sub carry opcodes to expand sub2

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Use add carry opcodes to expand add2
Richard Henderson [Tue, 14 Jan 2025 07:29:42 +0000 (23:29 -0800)] 
tcg: Use add carry opcodes to expand add2

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/optimize: With two const operands, prefer 0 in arg1
Richard Henderson [Wed, 15 Jan 2025 07:08:24 +0000 (23:08 -0800)] 
tcg/optimize: With two const operands, prefer 0 in arg1

For most binary operands, two const operands fold.
However, the add/sub carry opcodes have a third input.
Prefer "reg, zero, const" since many risc hosts have a
zero register that can fit a "reg, reg, const" insn format.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/optimize: Handle add/sub with carry opcodes
Richard Henderson [Wed, 15 Jan 2025 02:28:15 +0000 (18:28 -0800)] 
tcg/optimize: Handle add/sub with carry opcodes

Propagate known carry when possible, and simplify the opcodes
to not require carry-in when known.  The result will be cleaned
up further by the subsequent liveness analysis pass.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Add TCGOutOp structures for add/sub carry opcodes
Richard Henderson [Wed, 15 Jan 2025 07:27:53 +0000 (23:27 -0800)] 
tcg: Add TCGOutOp structures for add/sub carry opcodes

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Add add/sub with carry opcodes and infrastructure
Richard Henderson [Tue, 14 Jan 2025 21:58:39 +0000 (13:58 -0800)] 
tcg: Add add/sub with carry opcodes and infrastructure

Liveness needs to track carry-live state in order to
determine if the (hidden) output of the opcode is used.
Code generation needs to track carry-live state in order
to avoid clobbering cpu flags when loading constants.

So far, output routines and backends are unchanged.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Sink def, nb_iargs, nb_oargs loads in liveness_pass_1
Richard Henderson [Tue, 14 Jan 2025 21:12:35 +0000 (13:12 -0800)] 
tcg: Sink def, nb_iargs, nb_oargs loads in liveness_pass_1

Sink the sets of the def, nb_iargs, nb_oargs variables to
the default and do_not_remove labels.  They're not really
needed beforehand, and it avoids preceding code from having
to keep them up-to-date.  Note that def had *not* been kept
up-to-date; thankfully only def->flags had been used and
those bits were constant between opcode changes.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Move i into each for loop in liveness_pass_1
Richard Henderson [Tue, 14 Jan 2025 21:04:15 +0000 (13:04 -0800)] 
tcg: Move i into each for loop in liveness_pass_1

Use per-loop variables instead of one 'i' for the function.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/riscv: Drop support for add2/sub2
Richard Henderson [Tue, 14 Jan 2025 05:24:25 +0000 (21:24 -0800)] 
tcg/riscv: Drop support for add2/sub2

We now produce exactly the same code via generic expansion.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/mips: Drop support for add2/sub2
Richard Henderson [Tue, 14 Jan 2025 05:16:40 +0000 (21:16 -0800)] 
tcg/mips: Drop support for add2/sub2

We now produce exactly the same code via generic expansion.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Do not default add2/sub2_i32 for 32-bit hosts
Richard Henderson [Tue, 14 Jan 2025 05:13:54 +0000 (21:13 -0800)] 
tcg: Do not default add2/sub2_i32 for 32-bit hosts

Require TCG_TARGET_HAS_{add2,sub2}_i32 be defined,
one way or another.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Expand fallback sub2 with 32-bit operations
Richard Henderson [Tue, 14 Jan 2025 04:21:09 +0000 (20:21 -0800)] 
tcg: Expand fallback sub2 with 32-bit operations

No need to expand to i64 to perform the subtract.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Expand fallback add2 with 32-bit operations
Richard Henderson [Tue, 14 Jan 2025 04:14:09 +0000 (20:14 -0800)] 
tcg: Expand fallback add2 with 32-bit operations

No need to expand to i64 to perform the add.
This is smaller on a loongarch64 host, e.g.

bstrpick_d  r28, r27, 31, 0
bstrpick_d  r29, r24, 31, 0
add_d       r28, r28, r29
addi_w      r29, r28, 0
srai_d      r28, r28, 32
  ---
add_w       r28, r27, r24
sltu        r29, r28, r24

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Merge INDEX_op_extract2_{i32,i64}
Richard Henderson [Mon, 13 Jan 2025 05:40:43 +0000 (21:40 -0800)] 
tcg: Merge INDEX_op_extract2_{i32,i64}

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Convert extract2 to TCGOutOpExtract2
Richard Henderson [Mon, 13 Jan 2025 05:30:10 +0000 (21:30 -0800)] 
tcg: Convert extract2 to TCGOutOpExtract2

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Merge INDEX_op_deposit_{i32,i64}
Richard Henderson [Mon, 13 Jan 2025 04:48:57 +0000 (20:48 -0800)] 
tcg: Merge INDEX_op_deposit_{i32,i64}

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg/aarch64: Improve deposit
Richard Henderson [Mon, 13 Jan 2025 04:42:13 +0000 (20:42 -0800)] 
tcg/aarch64: Improve deposit

Use ANDI for deposit 0 into a register.
Use UBFIZ, aka UBFM, for deposit register into 0.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotcg: Convert deposit to TCGOutOpDeposit
Richard Henderson [Mon, 13 Jan 2025 04:29:41 +0000 (20:29 -0800)] 
tcg: Convert deposit to TCGOutOpDeposit

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>