qemu.git
4 months agohw/usb/hcd-xhci-nec: Remove unused XHCINecState::flags field
Philippe Mathieu-Daudé [Wed, 27 Nov 2024 09:51:34 +0000 (10:51 +0100)]
hw/usb/hcd-xhci-nec: Remove unused XHCINecState::flags field

Commit b9599519a01 ("hw/usb/hcd-xhci: Remove XHCI_FLAG_SS_FIRST
flag") remove the last use of XHCINecState::flags but neglected
to remove it; do that now.

Reported-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20241127122812.89487-1-philmd@linaro.org>

4 months agohw/usb/msd: Add status to usb_msd_packet_complete() function
Nicholas Piggin [Sun, 10 Nov 2024 03:39:59 +0000 (13:39 +1000)]
hw/usb/msd: Add status to usb_msd_packet_complete() function

This is a convenience change that accepts a status when completing a
packet.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20241110034000.379463-2-npiggin@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4 months agohw/net/can: clean-up unnecessary includes
Alex Bennée [Mon, 9 Dec 2024 10:06:35 +0000 (10:06 +0000)]
hw/net/can: clean-up unnecessary includes

The event_notifier, thread and socket includes look like copy and
paste of standard headers. None of the canbus devices use chardev
although some relied on chardev to bring in bitops and byte swapping
headers. In this case include them directly.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Acked-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-ID: <20241209100635.93243-1-alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4 months agohw/nvram/fw_cfg: Remove fw_cfg_add_extra_pci_roots()
Philippe Mathieu-Daudé [Fri, 6 Dec 2024 17:10:20 +0000 (18:10 +0100)]
hw/nvram/fw_cfg: Remove fw_cfg_add_extra_pci_roots()

Now that all uses of fw_cfg_add_extra_pci_roots() have been
converted to the newer pci_bus_add_fw_cfg_extra_pci_roots(),
we can remove that bogus method. hw/nvram/fw_cfg must
stay generic. Device specific entries have to be implemented
using TYPE_FW_CFG_DATA_GENERATOR_INTERFACE.

This mostly reverts commit 0abd38885ac0fcdb08653922f339849cad387961
("fw_cfg: Refactor extra pci roots addition").

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20241206181352.6836-7-philmd@linaro.org>

4 months agohw: Use pci_bus_add_fw_cfg_extra_pci_roots()
Philippe Mathieu-Daudé [Fri, 6 Dec 2024 16:14:19 +0000 (17:14 +0100)]
hw: Use pci_bus_add_fw_cfg_extra_pci_roots()

We want to remove fw_cfg_add_extra_pci_roots() which introduced
PCI bus knowledge within the generic hw/nvram/fw_cfg.c file.
Replace the calls by the pci_bus_add_fw_cfg_extra_pci_roots()
which is a 1:1 equivalent, but using correct API.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20241206181352.6836-6-philmd@linaro.org>

4 months agohw/pci: Add pci_bus_add_fw_cfg_extra_pci_roots() helper
Philippe Mathieu-Daudé [Fri, 6 Dec 2024 16:50:47 +0000 (17:50 +0100)]
hw/pci: Add pci_bus_add_fw_cfg_extra_pci_roots() helper

pci_bus_add_fw_cfg_extra_pci_roots() calls the fw_cfg
API with PCI bus specific arguments.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20241206181352.6836-5-philmd@linaro.org>

4 months agohw/pci: Have PCI_BUS implement TYPE_FW_CFG_DATA_GENERATOR_INTERFACE
Philippe Mathieu-Daudé [Fri, 6 Dec 2024 16:41:40 +0000 (17:41 +0100)]
hw/pci: Have PCI_BUS implement TYPE_FW_CFG_DATA_GENERATOR_INTERFACE

The FW_CFG_DATA_GENERATOR interface allows any object to
produce a blob of data consumable by the fw_cfg device.
Implement that for PCI bus objects.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20241213133352.10915-5-philmd@linaro.org>

4 months agohw/nvram/fw_cfg: Skip FW_CFG_DATA_GENERATOR when no data to generate
Philippe Mathieu-Daudé [Fri, 13 Dec 2024 13:22:02 +0000 (14:22 +0100)]
hw/nvram/fw_cfg: Skip FW_CFG_DATA_GENERATOR when no data to generate

Allow the FW_CFG_DATA_GENERATOR interface get_data() handler to
return NULL when there is nothing to generate. In that case
fw_cfg_add_file_from_generator() will not add any item and
return %true.

Reported-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20241213133352.10915-4-philmd@linaro.org>

4 months agohw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_generator()
Philippe Mathieu-Daudé [Fri, 6 Dec 2024 16:04:09 +0000 (17:04 +0100)]
hw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_generator()

Currently fw_cfg_add_file_from_generator() is restricted
to command line created objects which reside in the
'/objects' QOM container. In order to extend to other
types of containers, pass the QOM parent by argument.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20241206181352.6836-3-philmd@linaro.org>

4 months agohw/nvram/fw_cfg: Rename fw_cfg_add_[file]_from_generator()
Philippe Mathieu-Daudé [Fri, 6 Dec 2024 17:48:21 +0000 (18:48 +0100)]
hw/nvram/fw_cfg: Rename fw_cfg_add_[file]_from_generator()

fw_cfg_add_from_generator() is adding a 'file' entry,
so rename as fw_cfg_add_file_from_generator() for
clarity. Besides, we might introduce generators for
other entry types.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20241206181352.6836-2-philmd@linaro.org>

4 months agohw/riscv/virt: Remove pointless GPEX_HOST() cast
Philippe Mathieu-Daudé [Mon, 25 Nov 2024 13:07:25 +0000 (14:07 +0100)]
hw/riscv/virt: Remove pointless GPEX_HOST() cast

No need to QOM-cast twice, since the intermediate value
is not used.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20241125140535.4526-7-philmd@linaro.org>

4 months agohw/virtio/virtio-nsm: Support string data for extendPCR
Dorjoy Chowdhury [Sat, 9 Nov 2024 12:32:08 +0000 (18:32 +0600)]
hw/virtio/virtio-nsm: Support string data for extendPCR

NSM device in AWS Nitro Enclaves supports extending with both
bytestring and string data.

Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>
Reviewed-by: Alexander Graf <graf@amazon.com>
Message-ID: <20241109123208.24281-1-dorjoychy111@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4 months agohw/core/eif: Use stateful qcrypto apis
Dorjoy Chowdhury [Sat, 9 Nov 2024 12:30:39 +0000 (18:30 +0600)]
hw/core/eif: Use stateful qcrypto apis

We were storing the pointers to buffers in a GList due to lack of
stateful crypto apis and instead doing the final hash computation at
the end after we had all the necessary buffers. Now that we have the
stateful qcrypto apis available, we can instead update the hashes
inline in the read_eif_* functions which makes the code much simpler.

Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>
Reviewed-by: Alexander Graf <graf@amazon.com>
Message-ID: <20241109123039.24180-1-dorjoychy111@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4 months agodocs/nitro-enclave: Fix terminal commands formatting
Dorjoy Chowdhury [Sat, 9 Nov 2024 12:28:44 +0000 (18:28 +0600)]
docs/nitro-enclave: Fix terminal commands formatting

Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>
Reviewed-by: Alexander Graf <graf@amazon.com>
Message-ID: <20241109122844.24057-1-dorjoychy111@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4 months agoMerge tag 'pull-tcg-20241212' of https://gitlab.com/rth7680/qemu into staging
Stefan Hajnoczi [Thu, 12 Dec 2024 23:45:39 +0000 (18:45 -0500)]
Merge tag 'pull-tcg-20241212' of https://gitlab.com/rth7680/qemu into staging

tcg: Reset free_temps before tcg_optimize
tcg/riscv: Fix StoreStore barrier generation
include/exec: Introduce fpst alias in helper-head.h.inc
target/sparc: Use memcpy() and remove memcpy32()

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmdbS7YdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV9pFgf/RB1zSPYiID5psp+S
# yL4raw8um4a3AbgI5g0wOY8PgIeN0anQxG0Yupo3Ka5rvhy9p7S36OOCJMFEJRbP
# Sf2o4DG9Bqt6ycLh/mjQ8OqvL31T6f02GrkbUrevYVR7mYKjj+aJSbkIGKQqUOy3
# eptf9bbgtEe87oTXFZPxh24eEGE01WpHqDx3KQCCLlnsAR5ad9E8StWswu+8MiA/
# HttTGj8zqGu1N+wMtYfUuHtv8JdDK5H25gVbX/f+mLwNdWMXntsTw08Td3eY3EB0
# u44sEE+NSO04UiIu8U7NRrBNbUJsKautG90q4ZTOk5l8qVGIFWOP9kl0K1JjJZdd
# jIR27g==
# =+5lt
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 12 Dec 2024 15:46:46 EST
# 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-20241212' of https://gitlab.com/rth7680/qemu:
  target/sparc: Use memcpy() and remove memcpy32()
  include/exec: Introduce fpst alias in helper-head.h.inc
  tcg/riscv: Fix StoreStore barrier generation
  tcg: Reset free_temps before tcg_optimize

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4 months agoMerge tag 'qtest-20241212-pull-request' of https://gitlab.com/farosas/qemu into staging
Stefan Hajnoczi [Thu, 12 Dec 2024 23:45:09 +0000 (18:45 -0500)]
Merge tag 'qtest-20241212-pull-request' of https://gitlab.com/farosas/qemu into staging

Qtest pull request

- TIMEOUT_MULTIPLIER setting to allow tests to take longer when asan is enabled
- New qtest_system_reset() wrapper to properly wait for a system reset
- Split of migration-test.c into multiple files under qtest/migration/

# -----BEGIN PGP SIGNATURE-----
#
# iQJEBAABCAAuFiEEqhtIsKIjJqWkw2TPx5jcdBvsMZ0FAmda+84QHGZhcm9zYXNA
# c3VzZS5kZQAKCRDHmNx0G+wxnXWZEACcxW/P9EiLxIeCf4ke7/qq+8HSOOLdQrEa
# hP5ZCzLlY0K8KQ9fhTGvc6UgRBsScXcLuj4eoR8Gke9e4tID39XVdkion/x6OCiv
# grC2Ll9/BNrWtR8DiXs3krsU1CXhav6qcT56bMiXV3Qo+KsTmB7RkpXpbkZLZxkn
# P2aqZlYFS0zZ3PZQceCasQEzB6Dls7o1wNXvgSJXr2E4IuIEcbyWtQpr5DfctnfN
# STbqGTgMXADyjlqh3CWwSLsZQvIVoN9+3twOrZn4j0D+fyEsTjKsZPlUpRtr72ap
# FVT+zVIUfxieBlDTsRSwcieD1ePFUUjl7ikQFwypGs33TI9VDTsB88IG7h0/080o
# 7dYbSMSG0pGEq9QIB8jkV26OZi3y00L/zmLMNDsN6nxKN4mSySlfVD/B/Jb70Smy
# lwbLklnr921kqsF89Bsq8YRyg8bbGXtx2ifGROgqF+JtrxRW0ElF9K/h4HQtPjuD
# nZJ4rtrDIv1iMTLJwbNu39fhxvuQowdBYTrbPMgw+xIv++LodqYJSDxbEX+FaDqI
# LMf772jiAgesl7qe1d9TJizhvonyi9PIdcUILg0SH0H1KvoSjpS3mlGgvo8zgvh+
# zvhhzkFGDIHmlCvOaIYyCpadJ5SMMS627q/Q13X3DHjUTkpPUhxGgc9oO7T39+iA
# 4dOLDRjUcg==
# =H6xv
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 12 Dec 2024 10:05:50 EST
# gpg:                using RSA key AA1B48B0A22326A5A4C364CFC798DC741BEC319D
# gpg:                issuer "farosas@suse.de"
# gpg: Good signature from "Fabiano Rosas <farosas@suse.de>" [unknown]
# gpg:                 aka "Fabiano Almeida Rosas <fabiano.rosas@suse.com>" [unknown]
# gpg: WARNING: The key's User ID is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: AA1B 48B0 A223 26A5 A4C3  64CF C798 DC74 1BEC 319D

* tag 'qtest-20241212-pull-request' of https://gitlab.com/farosas/qemu: (22 commits)
  tests/qtest/migration: Split validation tests + misc
  tests/qtest/migration-test: Fix and enable test_ignore_shared
  tests/qtest/migration: Split CPR tests
  tests/qtest/migration: Split precopy tests
  tests/qtest/migration: Split file tests
  tests/qtest/migration: Split postcopy tests
  tests/qtest/migration: Split compression tests from migration-test.c
  tests/qtest/migration: Split TLS tests from migration-test.c
  tests/qtest/migration: Move common test code
  tests/qtest/migration: Isolate test initialization
  tests/qtest/migration: Move kvm_dirty_ring_supported to utils
  tests/qtest/migration: Move ufd_version_check to utils
  tests/qtest/migration: Rename migration-helpers.c
  tests/qtest/migration: Move qmp helpers to a separate file
  tests/qtest/migration: Move bootfile code to its own file
  tests/migration: Disambiguate guestperf vs. a-b
  tests/qtest/migration: Stop calling everything "test"
  tests/qtest/migration: Standardize hook names
  tests/qtest: Use qtest_system_reset_nowait() where appropriate
  tests/qtest: Use qtest_system_reset() instead of open-coded versions
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4 months agoMerge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
Stefan Hajnoczi [Thu, 12 Dec 2024 23:40:32 +0000 (18:40 -0500)]
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging

* rust: better integration with clippy, rustfmt and rustdoc
* rust: interior mutability types
* rust: add a bit operations module
* rust: first part of QOM rework
* kvm: remove unnecessary #ifdef
* clock: small cleanups, improve handling of Clock lifetimes

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmdZqFkUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroOzRwf/SYUD+CJCn2x7kUH/JG893jwN1WbJ
# meGZ0PQDUpOZJFWg6T4g0MuW4O+Wevy2pF4SfGojgqaYxKBbTQVkeliDEMyNUxpr
# vSKXego0K3pkX3cRDXNVTaXFbsHsMt/3pfzMQM6ocF9qbL+Emvx7Og6WdAcyJ4hc
# lA17EHlnrWKUSnqN/Ow/pZXsa4ijCklXFFh4barfbdGVhMQc2QekUU45GsP2AvGT
# NkXTQC05HqxBaAIDeSxbprDSzNihyT71dAooVoxqKboprPu5uoUSJwgaD8rADPr4
# EOfsz61V4mji+DWDcIzTtYoAdY41vVXI9lvCKOcCFkimA29xO0W6P7mG2w==
# =JSh5
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 11 Dec 2024 09:57:29 EST
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (49 commits)
  rust: qom: change the parent type to an associated type
  rust: qom: split ObjectType from ObjectImpl trait
  rust: qom: move bridge for TypeInfo functions out of pl011
  rust: qdev: move bridge for realize and reset functions out of pl011
  rust: qdev: move device_class_init! body to generic function, ClassInitImpl implementation to macro
  rust: qom: move ClassInitImpl to the instance side
  rust: qom: convert type_info! macro to an associated const
  rust: qom: rename Class trait to ClassInitImpl
  rust: qom: add default definitions for ObjectImpl
  rust: add a bit operation module
  rust: add bindings for interrupt sources
  rust: define prelude
  rust: cell: add BQL-enforcing RefCell variant
  rust: cell: add BQL-enforcing Cell variant
  bql: check that the BQL is not dropped within marked sections
  qom/object: Remove type_register()
  script/codeconverter/qom_type_info: Deprecate MakeTypeRegisterStatic and MakeTypeRegisterNotStatic
  ui: Replace type_register() with type_register_static()
  target/xtensa: Replace type_register() with type_register_static()
  target/sparc: Replace type_register() with type_register_static()
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4 months agoMerge tag 'pull-target-arm-20241211' of https://git.linaro.org/people/pmaydell/qemu...
Stefan Hajnoczi [Thu, 12 Dec 2024 23:40:08 +0000 (18:40 -0500)]
Merge tag 'pull-target-arm-20241211' of https://git.linaro.org/people/pmaydell/qemu-arm into staging

target-arm queue:
 * hw/net/lan9118: Extract PHY model, reuse with imx_fec, fix bugs
 * fpu: Make muladd NaN handling runtime-selected, not compile-time
 * fpu: Make default NaN pattern runtime-selected, not compile-time
 * fpu: Minor NaN-related cleanups
 * MAINTAINERS: email address updates

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmdZu14ZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3mgiD/98Q+m7/t54FdCd2bx1cr2k
# dw+7DYhp+60Vo3OjlGtKWwPD67oN8e0jhOoArmJNW0Fmkcsvfvd4wv6kCf8zftLm
# 0/lPO687mvFNCAprTch+z2pGB7aS0HdIr126ytsyg5PlHtldd+OBA+yUUYafR3zo
# BECRSWZmMFxfl9uckJzntdntghTX5pnJDSGBYE9NEyRfo0Ntj1HvhaHSQJkqpf5B
# QwE8R965CXc4i34PqlOCju47AXwJc3x36ftdiNmpPvMS4odG9yb/OmhHSgVZlThb
# 1x0HEX69KF5FQbtVNDMmFyYehDzqYFpqOSa1IKtaNLmDSZJ5P8fWw4eBdMdr/QyD
# QKssgHAO6Z13MLppK4B1PFtSVlsLYUURYddYUFz4RUNOxrS/pzAIT0KhClYFytQo
# x9xid4fng1PY9doYEM3v4vEQCU6S+2aj2gU4EOwdB8GmMhtjSl8YlcEs7cysqkoQ
# gbGX97i6Eh616q9VsRzUwcY6u4XP/lssn6I98k4AEqgRpyFCMTLyFodV89d6J4EJ
# IJKsJf10gctpe1JdMgtDxuleKOZc+O5nOMJLKYwc9siakCBZsH7zmgS6m8QVoUSD
# 7R+4OtbaQwM0+GPbc0AhAlDtq3Q1QAtCYa94iICUixC4NjzfdC9B9yCz1XnA7sfS
# jPHU8INw6rz3psEnlFQdhA==
# =+ELh
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 11 Dec 2024 11:18:38 EST
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "peter.maydell@linaro.org"
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [full]
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>" [full]
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [full]
# gpg:                 aka "Peter Maydell <peter@archaic.org.uk>" [unknown]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20241211' of https://git.linaro.org/people/pmaydell/qemu-arm: (72 commits)
  MAINTAINERS: Add correct email address for Vikram Garhwal
  MAINTAINERS: update email address for Leif Lindholm
  softfloat: Replace WHICH with RET in parts_pick_nan
  softfloat: Sink frac_cmp in parts_pick_nan until needed
  softfloat: Share code between parts_pick_nan cases
  softfloat: Inline pickNaN
  softfloat: Use parts_pick_nan in propagateFloatx80NaN
  softfloat: Move propagateFloatx80NaN to softfloat.c
  softfloat: Pad array size in pick_nan_muladd
  softfloat: Remove which from parts_pick_nan_muladd
  softfloat: Use goto for default nan case in pick_nan_muladd
  softfloat: Inline pickNaNMulAdd
  fpu: Remove default handling for dnan_pattern
  target/tricore: Set default NaN pattern explicitly
  target/riscv: Set default NaN pattern explicitly
  target/hexagon: Set default NaN pattern explicitly
  target/xtensa: Set default NaN pattern explicitly
  target/sparc: Set default NaN pattern explicitly
  target/s390x: Set default NaN pattern explicitly
  target/rx: Set default NaN pattern explicitly
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4 months agoMerge tag 'pull-request-2024-12-11' of https://gitlab.com/thuth/qemu into staging
Stefan Hajnoczi [Thu, 12 Dec 2024 23:39:19 +0000 (18:39 -0500)]
Merge tag 'pull-request-2024-12-11' of https://gitlab.com/thuth/qemu into staging

* Add compat machines for QEMU 10.0
* Add s390x CPU model for the gen17 mainframe
* Convert some more avocado tests to the new functional framework
* Some minor clean-ups for functional tests

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCAAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmdZUu0RHHRodXRoQHJl
# ZGhhdC5jb20ACgkQLtnXdP5wLbVpzBAAo/xldyDvEBkQiHpw7YF5x6dipSdQmgbL
# 02Qq1p2A7LxGK7uv6HBtOwhxk2eB0F+o8ZNt79u6QJmrI7Anme40B6GRXKHpm+Nn
# 2zn6xzBKnKJSjI/mr3zNqQwCb+q68hL+0N9oNSlbl42uElnMNMr1elkW7W+YT70d
# w+P5UzV2AuvjC6ML1R6ULwJHdeoklAk87g7l3Ns5z8CPFCV3yMOzGHqgpYQdYl+U
# Cx0CT/xqkfoyustkbPSCUGDzZbLQLMHcCgGX9DVLUmP8I6U1MeZC3HIxYdI4ofX/
# ApFQ4ThMV5f0A6hnn2TRrP+74He6wjYkB3RUjXtchVizWm1FZhNNa//cWvoEmCFU
# ufwuAFNvTodli0/47GEmwu8t/jqXJ1SeC50VAPyzxpedJwkgaMAZiYAlDO/oxIY1
# BCNR5bDjf4pAzguHG4FnPxaOcb5UT+V+sukQMvxa03TGrTp2/U9sanCVVdGPOovI
# sf/nXsK6jYe1mvinLF9wTyAjjkXqboqfgRabQi2DRgP/FMKseGapy4fOOXzj5Flv
# 5FSdyzm4/3fnb2fl1cWSNqPCLwAtmPWx0weu7PBbhP7AwNEXbpJcHmjtJwxL5Slx
# c+qazS6lbeBphPlToEqhibOZAxMM6QYvFxhL8Ut36vyEBbO/LAjy9+od9/jb8QCd
# ijtWjauVpHc=
# =BG+s
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 11 Dec 2024 03:53:01 EST
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg:                issuer "thuth@redhat.com"
# gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full]
# gpg:                 aka "Thomas Huth <thuth@redhat.com>" [full]
# gpg:                 aka "Thomas Huth <huth@tuxfamily.org>" [full]
# gpg:                 aka "Thomas Huth <th.huth@posteo.de>" [unknown]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2024-12-11' of https://gitlab.com/thuth/qemu: (26 commits)
  tests/functional: remove pointless with statement
  tests/functional: remove unused system imports
  tests/functional: Convert the cubieboard avocado tests
  tests/functional: Convert the smdkc210 avocado test
  tests/functional: Convert the emcraft_sf2 avocado test
  tests/functional: Convert the xlnx_versal_virt avocado test
  MAINTAINERS: Cover the tests/functional/test_sh4eb_r2d.py file
  tests/functional: Bump the timeout of the sh4_tuxrun test
  s390x/cpumodel: gen17 model
  s390x/cpumodel: Add PLO-extension facility
  s390x/cpumodel: correct PLO feature wording
  s390x/cpumodel: Add Sequential-Instruction-Fetching facility
  s390x/cpumodel: add Ineffective-nonconstrained-transaction facility
  s390x/cpumodel: add Vector-Packed-Decimal-Enhancement facility 3
  s390x/cpumodel: add Miscellaneous-Instruction-Extensions Facility 4
  s390x/cpumodel: add Vector Enhancements facility 3
  s390x/cpumodel: add Concurrent-functions facility support
  linux-headers: Update to Linux 6.13-rc1
  s390x/cpumodel: Add ptff Query Time-Stamp Event (QTSE) support
  s390x/cpumodel: add msa13 subfunctions
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4 months agotarget/sparc: Use memcpy() and remove memcpy32()
Philippe Mathieu-Daudé [Thu, 5 Dec 2024 20:54:18 +0000 (21:54 +0100)]
target/sparc: Use memcpy() and remove memcpy32()

Rather than manually copying each register, use
the libc memcpy(), which is well optimized nowadays.

Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20241205205418.67613-1-philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 months agoinclude/exec: Introduce fpst alias in helper-head.h.inc
Richard Henderson [Wed, 11 Dec 2024 17:03:43 +0000 (11:03 -0600)]
include/exec: Introduce fpst alias in helper-head.h.inc

This allows targets to declare that the helper requires a
float_status pointer and instead of a generic void pointer.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 months agotcg/riscv: Fix StoreStore barrier generation
Roman Artemev [Wed, 11 Dec 2024 07:40:04 +0000 (07:40 +0000)]
tcg/riscv: Fix StoreStore barrier generation

On RISC-V to StoreStore barrier corresponds
`fence w, w` not `fence r, r`

Cc: qemu-stable@nongnu.org
Fixes: efbea94c76b ("tcg/riscv: Add slowpath load and store instructions")
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Denis Tomashev <denis.tomashev@syntacore.com>
Signed-off-by: Roman Artemev <roman.artemev@syntacore.com>
Message-ID: <e2f2131e294a49e79959d4fa9ec02cf4@syntacore.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 months agotcg: Reset free_temps before tcg_optimize
Richard Henderson [Sat, 7 Dec 2024 18:14:45 +0000 (18:14 +0000)]
tcg: Reset free_temps before tcg_optimize

When allocating new temps during tcg_optmize, do not re-use
any EBB temps that were used within the TB.  We do not have
any idea what span of the TB in which the temp was live.

Introduce tcg_temp_ebb_reset_freed and use before tcg_optimize,
as well as replacing the equivalent in plugin_gen_inject and
tcg_func_start.

Cc: qemu-stable@nongnu.org
Fixes: fb04ab7ddd8 ("tcg/optimize: Lower TCG_COND_TST{EQ,NE} if unsupported")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2711
Reported-by: wannacu <wannacu2049@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4 months agotests/qtest/migration: Split validation tests + misc
Fabiano Rosas [Wed, 27 Nov 2024 18:29:01 +0000 (15:29 -0300)]
tests/qtest/migration: Split validation tests + misc

Move the remaining tests into a misc-tests.c file. These tests are
mostly about validation of input and should be in the future replaced
by unit testing.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration-test: Fix and enable test_ignore_shared
Nicholas Piggin [Thu, 30 May 2024 09:54:06 +0000 (19:54 +1000)]
tests/qtest/migration-test: Fix and enable test_ignore_shared

This test is already starting to bitrot, so first remove it from ifdef
and fix compile issues. ppc64 transfers about 2MB, so bump the size
threshold too.

It was said to be broken on aarch64 but it may have been due to the
limited shm size under Gitlab CI.

Cc: Yury Kotov <yury-kotov@yandex-team.ru>
Cc: Dr. David Alan Gilbert <dave@treblig.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
[put it under flaky tests, we still don't have a solution for the CI]
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Split CPR tests
Fabiano Rosas [Wed, 27 Nov 2024 18:29:00 +0000 (15:29 -0300)]
tests/qtest/migration: Split CPR tests

Move the mode/reboot test into a separate file to hold all the CPR
tests. Currently there's just one test, but we're adding more CPR
modes and the feature is different enough from live migration that
it's worth it to have a separate file for it.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Split precopy tests
Fabiano Rosas [Wed, 27 Nov 2024 18:28:59 +0000 (15:28 -0300)]
tests/qtest/migration: Split precopy tests

Split the precopy tests from migration-test.c. This is the largest
group of tests and the more difficult one to break into smaller
groups, so move all of it.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Split file tests
Fabiano Rosas [Wed, 27 Nov 2024 18:28:58 +0000 (15:28 -0300)]
tests/qtest/migration: Split file tests

Split the file tests from migration-test.c. These are being moved to
their own file due to being special enough compared with the regular
stream migration. There is also the entire mapped-ram feature which
depends on file migration.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Split postcopy tests
Fabiano Rosas [Wed, 27 Nov 2024 18:28:57 +0000 (15:28 -0300)]
tests/qtest/migration: Split postcopy tests

Split the next group of tests from migration-test.c, the postcopy
tests. This is another well-defined group of tests and postcopy is a
unique enough feature that it deserves it's own file.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Split compression tests from migration-test.c
Fabiano Rosas [Wed, 27 Nov 2024 18:28:56 +0000 (15:28 -0300)]
tests/qtest/migration: Split compression tests from migration-test.c

Continuing the split of groups of tests from migration-test.c, split
the compression tests into their own file.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Split TLS tests from migration-test.c
Fabiano Rosas [Wed, 27 Nov 2024 18:28:55 +0000 (15:28 -0300)]
tests/qtest/migration: Split TLS tests from migration-test.c

The migration-test.c file has become unwieldy large. It's quite
confusing to navigate with all the test definitions mixed with hook
definitions. The TLS tests make this worse with ifdef'ery.

Since we're planning on having a smaller set of tests to run as smoke
testing on all architectures, I'm taking the time to split some tests
into their own file.

Move the TLS tests into a file of their own.

Acked-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Move common test code
Fabiano Rosas [Wed, 27 Nov 2024 18:28:54 +0000 (15:28 -0300)]
tests/qtest/migration: Move common test code

The migration tests have a set of core infrastructure routines. These
are functions that are called by (almost) all tests and centralize the
common operations of: starting migration on both sides, waiting for
guests to boot, performing guest initialization and teardown, guest
memory validation, etc.

Move this basic framework code (and a few static helpers) into a
separate file. Leave only individual test functions (and their own
static helpers) in migration-test.c.

Acked-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Isolate test initialization
Fabiano Rosas [Wed, 27 Nov 2024 18:28:53 +0000 (15:28 -0300)]
tests/qtest/migration: Isolate test initialization

We currently have some environment validation to perform and flags to
set during the initialization of the tests. To be able to add more
migration test binaries, we'll need these tasks to be in their own
function so they can be called from more than one place.

Move the initialization code to a function and introduce the
MigrationTestEnv structure to hold the flags that are accessed during
test registration.

Make the env object static to avoid have to change all the code to
pass it around. Similarly with the tmpfs variable, which is used
extensively.

Note: I'm keeping the new functions in migration-test.c because they
are going to be moved in the next patch to the correct place.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Move kvm_dirty_ring_supported to utils
Fabiano Rosas [Wed, 27 Nov 2024 18:28:52 +0000 (15:28 -0300)]
tests/qtest/migration: Move kvm_dirty_ring_supported to utils

Move kvm_dirty_ring_supported() to migration-util.c. Similarly to
ufd_version_check(), this function is used during test definition so
put it in the utils file.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Move ufd_version_check to utils
Fabiano Rosas [Wed, 27 Nov 2024 18:28:51 +0000 (15:28 -0300)]
tests/qtest/migration: Move ufd_version_check to utils

Move ufd_version_check() to migration-util.c file. This is a helper
function that is used during tests definition so it should be
available outside of migration-test.c

Since the function is moving to another file, change it to stop
accessing the global uffd_feature_thread_id and take it as argument
instead.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Rename migration-helpers.c
Fabiano Rosas [Wed, 27 Nov 2024 18:28:50 +0000 (15:28 -0300)]
tests/qtest/migration: Rename migration-helpers.c

Rename migration-helpers.c to migration-util.c to make its purpose
more explicit and avoid the "helper" terminology.

Move the file to the qtest/migration/ directory along with the rest of
the migration files.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Move qmp helpers to a separate file
Fabiano Rosas [Wed, 27 Nov 2024 18:28:49 +0000 (15:28 -0300)]
tests/qtest/migration: Move qmp helpers to a separate file

We current have a bunch of non-test functions in migration-test.c and
some others in migration-helpers.c. In order to split migration-test.c
into separate test binaries, these helpers need to go somewhere
else.

To avoid making migration-helpers even larger, move all QMP-related
functions into a new migration-qmp.c file and put it under the
qtest/migration/ directory.

The new file holds everything that has as its main responsibility to
call into QMP.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Move bootfile code to its own file
Fabiano Rosas [Wed, 27 Nov 2024 18:28:48 +0000 (15:28 -0300)]
tests/qtest/migration: Move bootfile code to its own file

Move the code that creates the guest binary out of migration-test and
into the qtest/migration/ directory, along with the rest of the
a-b-kernel code.

That code is part of the basic infrastructure of migration tests, it
shouldn't be among the tests themselves.

Also take the chance and rename migration-test.h, which is too generic
a name for this header which contains only values related to guest
memory offsets.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/migration: Disambiguate guestperf vs. a-b
Fabiano Rosas [Wed, 27 Nov 2024 18:28:47 +0000 (15:28 -0300)]
tests/migration: Disambiguate guestperf vs. a-b

The current build structure for migration tests is confusing. There is
the tests/migration directory, which contains two different guest code
implementations, one for the qtests (a-b-{bootblock|kernel}.S) and
another for the guestperf script (stress.c). One uses a Makefile,
while the other uses meson.

The next patches will add a new qtests/migration/ directory to hold
qtest code which will make the situation even more confusing.

Move the guest code used by qtests into a new qtests/migration/
directory and rename the old one to tests/migration-stress.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Stop calling everything "test"
Fabiano Rosas [Wed, 27 Nov 2024 18:28:46 +0000 (15:28 -0300)]
tests/qtest/migration: Stop calling everything "test"

Test frameworks usually prefix "test_" to the entry point of the test
code. Having every function prefixed with test_ makes it hard to
understand the code and to grep for the actual tests.

Remove the "test" prefix from everything that is not a test.

In order to still keep some namespacing, stick to the "migrate_"
prefix, which is the most used currently.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest/migration: Standardize hook names
Fabiano Rosas [Wed, 27 Nov 2024 18:28:45 +0000 (15:28 -0300)]
tests/qtest/migration: Standardize hook names

Standardize the hook names:

- change the names to .start|end_hook to match
  test_migrate_start|end()

- use the migrate_hook_start_ and migrate_hook_end_ prefixes

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest: Use qtest_system_reset_nowait() where appropriate
Peter Maydell [Fri, 15 Nov 2024 16:50:41 +0000 (16:50 +0000)]
tests/qtest: Use qtest_system_reset_nowait() where appropriate

In the device and drive plug/unplug tests we want to trigger
a system reset and then see if we get the appropriate
DEVICE_DELETED event. Use qtest_system_reset_nowait() here.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest: Use qtest_system_reset() instead of open-coded versions
Peter Maydell [Fri, 15 Nov 2024 16:50:40 +0000 (16:50 +0000)]
tests/qtest: Use qtest_system_reset() instead of open-coded versions

Use the qtest_system_reset() function in various tests that were
previously open-coding the system-reset. Note that in several
cases this fixes a bug where the test did not wait for the RESET
QMP event before continuing.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest: Add qtest_system_reset() utility function
Peter Maydell [Fri, 15 Nov 2024 16:50:39 +0000 (16:50 +0000)]
tests/qtest: Add qtest_system_reset() utility function

We have several qtest tests which want to reset the QEMU under test
during the course of testing something.  They currently generally
have their own functions to do this, which work by sending a
"system_reset" QMP command.  However, "system_reset" only requests a
reset, and many of the tests which send the QMP command forget the
"and then wait for the QMP RESET event" part which is needed to
ensure that the reset has completed.

Provide a qtest_system_reset() function in libqtest so that
we don't need to reimplement this in multiple different tests.

A few tests (for example device hotplug related tests) want to
perform the reset command and then wait for some other event that is
produced during the reset sequence.  For them we provide
qtest_system_reset_nowait() so they can clearly indicate that they
are deliberately not waiting for the RESET event.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agotests/qtest: add TIMEOUT_MULTIPLIER
Dmitry Frolov [Wed, 13 Nov 2024 09:43:40 +0000 (12:43 +0300)]
tests/qtest: add TIMEOUT_MULTIPLIER

Some tests need more time when qemu is built with
"--enable-asan --enable-ubsan"

As was discussed here:
https://patchew.org/QEMU/20241112120100.176492-2-frolov@swemel.ru/

TIMEOUT_MULTIPLIER enviroment variable will be
a useful option, allowing non-invasive timeouts
increasing for a specific build.

Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
Tested-by: Fabiano Rosas <farosas@suse.de>
[changed from ifndef to ?=]
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4 months agoMAINTAINERS: Add correct email address for Vikram Garhwal
Vikram Garhwal [Wed, 11 Dec 2024 15:31:09 +0000 (15:31 +0000)]
MAINTAINERS: Add correct email address for Vikram Garhwal

Previously, maintainer role was paused due to inactive email id. Commit id:
c009d715721861984c4987bcc78b7ee183e86d75.

Signed-off-by: Vikram Garhwal <vikram.garhwal@bytedance.com>
Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com>
Message-id: 20241204184205.12952-1-vikram.garhwal@bytedance.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agoMAINTAINERS: update email address for Leif Lindholm
Leif Lindholm [Wed, 11 Dec 2024 15:31:09 +0000 (15:31 +0000)]
MAINTAINERS: update email address for Leif Lindholm

I'm migrating to Qualcomm's new open source email infrastructure, so
update my email address, and update the mailmap to match.

Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20241205114047.1125842-1-leif.lindholm@oss.qualcomm.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agosoftfloat: Replace WHICH with RET in parts_pick_nan
Richard Henderson [Wed, 11 Dec 2024 15:31:09 +0000 (15:31 +0000)]
softfloat: Replace WHICH with RET in parts_pick_nan

Replace the "index" selecting between A and B with a result variable
of the proper type.  This improves clarity within the function.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20241203203949.483774-12-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agosoftfloat: Sink frac_cmp in parts_pick_nan until needed
Richard Henderson [Wed, 11 Dec 2024 15:31:09 +0000 (15:31 +0000)]
softfloat: Sink frac_cmp in parts_pick_nan until needed

Move the fractional comparison to the end of the
float_2nan_prop_x87 case.  This is not required for
any other 2nan propagation rule.  Reorganize the
x87 case itself to break out of the switch when the
fractional comparison is not required.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20241203203949.483774-11-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agosoftfloat: Share code between parts_pick_nan cases
Richard Henderson [Wed, 11 Dec 2024 15:31:09 +0000 (15:31 +0000)]
softfloat: Share code between parts_pick_nan cases

Remember if there was an SNaN, and use that to simplify
float_2nan_prop_s_{ab,ba} to only the snan component.
Then, fall through to the corresponding
float_2nan_prop_{ab,ba} case to handle any remaining
nans, which must be quiet.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20241203203949.483774-10-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agosoftfloat: Inline pickNaN
Richard Henderson [Wed, 11 Dec 2024 15:31:08 +0000 (15:31 +0000)]
softfloat: Inline pickNaN

Inline pickNaN into its only caller.  This makes one assert
redundant with the immediately preceding IF.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20241203203949.483774-9-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agosoftfloat: Use parts_pick_nan in propagateFloatx80NaN
Richard Henderson [Wed, 11 Dec 2024 15:31:08 +0000 (15:31 +0000)]
softfloat: Use parts_pick_nan in propagateFloatx80NaN

Unpacking and repacking the parts may be slightly more work
than we did before, but we get to reuse more code.  For a
code path handling exceptional values, this is an improvement.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241203203949.483774-8-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4 months agosoftfloat: Move propagateFloatx80NaN to softfloat.c
Richard Henderson [Wed, 11 Dec 2024 15:31:08 +0000 (15:31 +0000)]
softfloat: Move propagateFloatx80NaN to softfloat.c

This function is part of the public interface and
is not "specialized" to any target in any way.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20241203203949.483774-7-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agosoftfloat: Pad array size in pick_nan_muladd
Richard Henderson [Wed, 11 Dec 2024 15:31:08 +0000 (15:31 +0000)]
softfloat: Pad array size in pick_nan_muladd

While all indices into val[] should be in [0-2], the mask
applied is two bits.  To help static analysis see there is
no possibility of read beyond the end of the array, pad the
array to 4 entries, with the final being (implicitly) NULL.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20241203203949.483774-6-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agosoftfloat: Remove which from parts_pick_nan_muladd
Richard Henderson [Wed, 11 Dec 2024 15:31:08 +0000 (15:31 +0000)]
softfloat: Remove which from parts_pick_nan_muladd

Assign the pointer return value to 'a' directly,
rather than going through an intermediary index.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20241203203949.483774-5-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agosoftfloat: Use goto for default nan case in pick_nan_muladd
Richard Henderson [Wed, 11 Dec 2024 15:31:08 +0000 (15:31 +0000)]
softfloat: Use goto for default nan case in pick_nan_muladd

Remove "3" as a special case for which and simply
branch to return the desired value.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20241203203949.483774-4-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agosoftfloat: Inline pickNaNMulAdd
Richard Henderson [Wed, 11 Dec 2024 15:31:08 +0000 (15:31 +0000)]
softfloat: Inline pickNaNMulAdd

Inline pickNaNMulAdd into its only caller.  This makes
one assert redundant with the immediately preceding IF.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20241203203949.483774-3-richard.henderson@linaro.org
[PMM: keep comment from old code in new location]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agofpu: Remove default handling for dnan_pattern
Peter Maydell [Wed, 11 Dec 2024 15:31:08 +0000 (15:31 +0000)]
fpu: Remove default handling for dnan_pattern

Now that all our targets have bene converted to explicitly specify
their pattern for the default NaN value we can remove the remaining
fallback code in parts64_default_nan().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-55-peter.maydell@linaro.org

4 months agotarget/tricore: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:07 +0000 (15:31 +0000)]
target/tricore: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for tricore.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-54-peter.maydell@linaro.org

4 months agotarget/riscv: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:07 +0000 (15:31 +0000)]
target/riscv: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for riscv.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-53-peter.maydell@linaro.org

4 months agotarget/hexagon: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:07 +0000 (15:31 +0000)]
target/hexagon: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for hexagon.
Remove the ifdef from parts64_default_nan(); the only
remaining unconverted targets all use the default case.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-52-peter.maydell@linaro.org

4 months agotarget/xtensa: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:07 +0000 (15:31 +0000)]
target/xtensa: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for xtensa.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-51-peter.maydell@linaro.org

4 months agotarget/sparc: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:07 +0000 (15:31 +0000)]
target/sparc: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for SPARC, and remove
the ifdef from parts64_default_nan.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-50-peter.maydell@linaro.org

4 months agotarget/s390x: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:07 +0000 (15:31 +0000)]
target/s390x: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for s390x.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-49-peter.maydell@linaro.org

4 months agotarget/rx: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:07 +0000 (15:31 +0000)]
target/rx: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for rx.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-48-peter.maydell@linaro.org

4 months agotarget/sh4: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:06 +0000 (15:31 +0000)]
target/sh4: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for sh4. Note that sh4
is one of the only three targets (the others being HPPA and
sometimes MIPS) that has snan_bit_is_one set.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-47-peter.maydell@linaro.org

4 months agotarget/ppc: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:06 +0000 (15:31 +0000)]
target/ppc: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for ppc.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-46-peter.maydell@linaro.org

4 months agotarget/openrisc: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:06 +0000 (15:31 +0000)]
target/openrisc: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for openrisc.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-45-peter.maydell@linaro.org

4 months agotarget/mips: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:06 +0000 (15:31 +0000)]
target/mips: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for MIPS. Note that this
is our only target which currently changes the default NaN
at runtime (which it was previously doing indirectly when it
changed the snan_bit_is_one setting).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-44-peter.maydell@linaro.org

4 months agotarget/m68k: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:06 +0000 (15:31 +0000)]
target/m68k: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for m68k.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-43-peter.maydell@linaro.org

4 months agotarget/loongarch: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:05 +0000 (15:31 +0000)]
target/loongarch: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for loongarch.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-42-peter.maydell@linaro.org

4 months agotarget/arm: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:05 +0000 (15:31 +0000)]
target/arm: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for the arm target.
This includes setting it for the old linux-user nwfpe emulation.
For nwfpe, our default doesn't match the real kernel, but we
avoid making a behaviour change in this commit.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-41-peter.maydell@linaro.org

4 months agotarget/alpha: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:05 +0000 (15:31 +0000)]
target/alpha: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for the alpha target.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-40-peter.maydell@linaro.org

4 months agotarget/hppa: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:05 +0000 (15:31 +0000)]
target/hppa: Set default NaN pattern explicitly

Set the default NaN pattern explicitly, and remove the ifdef from
parts64_default_nan().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-39-peter.maydell@linaro.org

4 months agotarget/i386: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:04 +0000 (15:31 +0000)]
target/i386: Set default NaN pattern explicitly

Set the default NaN pattern explicitly, and remove the ifdef from
parts64_default_nan().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-38-peter.maydell@linaro.org

4 months agotarget/microblaze: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:04 +0000 (15:31 +0000)]
target/microblaze: Set default NaN pattern explicitly

Set the default NaN pattern explicitly, and remove the ifdef from
parts64_default_nan().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-37-peter.maydell@linaro.org

4 months agotests/fp: Set default NaN pattern explicitly
Peter Maydell [Wed, 11 Dec 2024 15:31:04 +0000 (15:31 +0000)]
tests/fp: Set default NaN pattern explicitly

Set the default NaN pattern explicitly for the tests/fp code.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-36-peter.maydell@linaro.org

4 months agofpu: Allow runtime choice of default NaN value
Peter Maydell [Wed, 11 Dec 2024 15:31:04 +0000 (15:31 +0000)]
fpu: Allow runtime choice of default NaN value

Currently we hardcode the default NaN value in parts64_default_nan()
using a compile-time ifdef ladder. This is awkward for two cases:
 * for single-QEMU-binary we can't hard-code target-specifics like this
 * for Arm FEAT_AFP the default NaN value depends on FPCR.AH
   (specifically the sign bit is different)

Add a field to float_status to specify the default NaN value; fall
back to the old ifdef behaviour if these are not set.

The default NaN value is specified by setting a uint8_t to a
pattern corresponding to the sign and upper fraction parts of
the NaN; the lower bits of the fraction are set from bit 0 of
the pattern.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-35-peter.maydell@linaro.org

4 months agotarget/arm: Copy entire float_status in is_ebf
Richard Henderson [Wed, 11 Dec 2024 15:31:03 +0000 (15:31 +0000)]
target/arm: Copy entire float_status in is_ebf

Now that float_status has a bunch of fp parameters,
it is easier to copy an existing structure than create
one from scratch.  Begin by copying the structure that
corresponds to the FPSR and make only the adjustments
required for BFloat16 semantics.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20241203203949.483774-2-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agotarget/ppc: Use env->fp_status in helper_compute_fprf functions
Peter Maydell [Wed, 11 Dec 2024 15:31:03 +0000 (15:31 +0000)]
target/ppc: Use env->fp_status in helper_compute_fprf functions

In the helper_compute_fprf functions, we pass a dummy float_status
in to the is_signaling_nan() function. This is unnecessary, because
we have convenient access to the CPU env pointer here and that
is already set up with the correct values for the snan_bit_is_one
and no_signaling_nans config settings. is_signaling_nan() doesn't
ever update the fp_status with any exception flags, so there is
no reason not to use env->fp_status here.

Use env->fp_status instead of the dummy fp_status.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-34-peter.maydell@linaro.org

4 months agotarget/sparc: Initialize local scratch float_status from env->fp_status
Peter Maydell [Wed, 11 Dec 2024 15:31:03 +0000 (15:31 +0000)]
target/sparc: Initialize local scratch float_status from env->fp_status

In the helper functions flcmps and flcmpd we use a scratch float_status
so that we don't change the CPU state if the comparison raises any
floating point exception flags. Instead of zero-initializing this
scratch float_status, initialize it as a copy of env->fp_status. This
avoids the need to explicitly initialize settings like the NaN
propagation rule or others we might add to softfloat in future.

To do this we need to pass the CPU env pointer in to the helper.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-33-peter.maydell@linaro.org

4 months agotarget/m68k: Init local float_status from env fp_status in gdb get/set reg
Peter Maydell [Wed, 11 Dec 2024 15:31:03 +0000 (15:31 +0000)]
target/m68k: Init local float_status from env fp_status in gdb get/set reg

In cf_fpu_gdb_get_reg() and cf_fpu_gdb_set_reg() we do the conversion
from float64 to floatx80 using a scratch float_status, because we
don't want the conversion to affect the CPU's floating point exception
status. Currently we use a zero-initialized float_status. This will
get steadily more awkward as we add config knobs to float_status
that the target must initialize. Avoid having to add any of that
configuration here by instead initializing our local float_status
from the env->fp_status.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-32-peter.maydell@linaro.org

4 months agotarget/m68k: In frem helper, initialize local float_status from env->fp_status
Peter Maydell [Wed, 11 Dec 2024 15:31:02 +0000 (15:31 +0000)]
target/m68k: In frem helper, initialize local float_status from env->fp_status

In the frem helper, we have a local float_status because we want to
execute the floatx80_div() with a custom rounding mode.  Instead of
zero-initializing the local float_status and then having to set it up
with the m68k standard behaviour (including the NaN propagation rule
and copying the rounding precision from env->fp_status), initialize
it as a complete copy of env->fp_status. This will avoid our having
to add new code in this function for every new config knob we add
to fp_status.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-31-peter.maydell@linaro.org

4 months agotarget/loongarch: Use normal float_status in fclass_s and fclass_d helpers
Peter Maydell [Wed, 11 Dec 2024 15:31:01 +0000 (15:31 +0000)]
target/loongarch: Use normal float_status in fclass_s and fclass_d helpers

In target/loongarch's helper_fclass_s() and helper_fclass_d() we pass
a zero-initialized float_status struct to float32_is_quiet_nan() and
float64_is_quiet_nan(), with the cryptic comment "for
snan_bit_is_one".

This pattern appears to have been copied from target/riscv, where it
is used because the functions there do not have ready access to the
CPU state struct. The comment presumably refers to the fact that the
main reason the is_quiet_nan() functions want the float_state is
because they want to know about the snan_bit_is_one config.

In the loongarch helpers, though, we have the CPU state struct
to hand. Use the usual env->fp_status here. This avoids our needing
to track that we need to update the initializer of the local
float_status structs when the core softfloat code adds new
options for targets to configure their behaviour.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-30-peter.maydell@linaro.org

4 months agosoftfloat: Create floatx80 default NaN from parts64_default_nan
Peter Maydell [Wed, 11 Dec 2024 15:31:00 +0000 (15:31 +0000)]
softfloat: Create floatx80 default NaN from parts64_default_nan

We create our 128-bit default NaN by calling parts64_default_nan()
and then adjusting the result.  We can do the same trick for creating
the floatx80 default NaN, which lets us drop a target ifdef.

floatx80 is used only by:
 i386
 m68k
 arm nwfpe old floating-point emulation emulation support
    (which is essentially dead, especially the parts involving floatx80)
 PPC (only in the xsrqpxp instruction, which just rounds an input
    value by converting to floatx80 and back, so will never generate
    the default NaN)

The floatx80 default NaN as currently implemented is:
 m68k: sign = 0, exp = 1...1, int = 1, frac = 1....1
 i386: sign = 1, exp = 1...1, int = 1, frac = 10...0

These are the same as the parts64_default_nan for these architectures.

This is technically a possible behaviour change for arm linux-user
nwfpe emulation emulation, because the default NaN will now have the
sign bit clear.  But we were already generating a different floatx80
default NaN from the real kernel emulation we are supposedly
following, which appears to use an all-bits-1 value:
 https://elixir.bootlin.com/linux/v6.12/source/arch/arm/nwfpe/softfloat-specialize#L267

This won't affect the only "real" use of the nwfpe emulation, which
is ancient binaries that used it as part of the old floating point
calling convention; that only uses loads and stores of 32 and 64 bit
floats, not any of the floatx80 behaviour the original hardware had.
We also get the nwfpe float64 default NaN value wrong:
 https://elixir.bootlin.com/linux/v6.12/source/arch/arm/nwfpe/softfloat-specialize#L166
so if we ever cared about this obscure corner the right fix would be
to correct that so nwfpe used its own default-NaN setting rather
than the Arm VFP one.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-29-peter.maydell@linaro.org

4 months agotarget/m68k: Don't pass NULL float_status to floatx80_default_nan()
Peter Maydell [Wed, 11 Dec 2024 15:30:59 +0000 (15:30 +0000)]
target/m68k: Don't pass NULL float_status to floatx80_default_nan()

Currently m68k_cpu_reset_hold() calls floatx80_default_nan(NULL)
to get the NaN bit pattern to reset the FPU registers. This
works because it happens that our implementation of
floatx80_default_nan() doesn't actually look at the float_status
pointer except for TARGET_MIPS. However, this isn't guaranteed,
and to be able to remove the ifdef in floatx80_default_nan()
we're going to need a real float_status here.

Rearrange m68k_cpu_reset_hold() so that we initialize env->fp_status
earlier, and thus can pass it to floatx80_default_nan().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-28-peter.maydell@linaro.org

4 months agofpu: Remove use_first_nan field from float_status
Peter Maydell [Wed, 11 Dec 2024 15:30:59 +0000 (15:30 +0000)]
fpu: Remove use_first_nan field from float_status

The use_first_nan field in float_status was an xtensa-specific way to
select at runtime from two different NaN propagation rules.  Now that
xtensa is using the target-agnostic NaN propagation rule selection
that we've just added, we can remove use_first_nan, because there is
no longer any code that reads it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-27-peter.maydell@linaro.org

4 months agotarget/hppa: Set Float3NaNPropRule explicitly
Peter Maydell [Wed, 11 Dec 2024 15:30:59 +0000 (15:30 +0000)]
target/hppa: Set Float3NaNPropRule explicitly

Set the Float3NaNPropRule explicitly for HPPA, and remove the
ifdef from pickNaNMulAdd().

HPPA is the only target that was using the default branch of the
ifdef ladder (other targets either do not use muladd or set
default_nan_mode), so we can remove the ifdef fallback entirely now
(allowing the "rule not set" case to fall into the default of the
switch statement and assert).

We add a TODO note that the HPPA rule is probably wrong; this is
not a behavioural change for this refactoring.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-26-peter.maydell@linaro.org

4 months agotarget/i386: Set Float3NaNPropRule explicitly
Peter Maydell [Wed, 11 Dec 2024 15:30:58 +0000 (15:30 +0000)]
target/i386: Set Float3NaNPropRule explicitly

Set the Float3NaNPropRule explicitly for i386.  We had no
i386-specific behaviour in the old ifdef ladder, so we were using the
default "prefer a then b then c" fallback; this is actually the
correct per-the-spec handling for i386.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-25-peter.maydell@linaro.org

4 months agotarget/xtensa: Set Float3NaNPropRule explicitly
Peter Maydell [Wed, 11 Dec 2024 15:30:58 +0000 (15:30 +0000)]
target/xtensa: Set Float3NaNPropRule explicitly

Set the Float3NaNPropRule explicitly for xtensa, and remove the
ifdef from pickNaNMulAdd().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-24-peter.maydell@linaro.org

4 months agotarget/mips: Set Float3NaNPropRule explicitly
Peter Maydell [Wed, 11 Dec 2024 15:30:58 +0000 (15:30 +0000)]
target/mips: Set Float3NaNPropRule explicitly

Set the Float3NaNPropRule explicitly for Arm, and remove the
ifdef from pickNaNMulAdd().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-23-peter.maydell@linaro.org

4 months agotarget/sparc: Set Float3NaNPropRule explicitly
Peter Maydell [Wed, 11 Dec 2024 15:30:58 +0000 (15:30 +0000)]
target/sparc: Set Float3NaNPropRule explicitly

Set the Float3NaNPropRule explicitly for SPARC, and remove the
ifdef from pickNaNMulAdd().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-22-peter.maydell@linaro.org

4 months agotarget/s390x: Set Float3NaNPropRule explicitly
Peter Maydell [Wed, 11 Dec 2024 15:30:57 +0000 (15:30 +0000)]
target/s390x: Set Float3NaNPropRule explicitly

Set the Float3NaNPropRule explicitly for s390x, and remove the
ifdef from pickNaNMulAdd().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-21-peter.maydell@linaro.org

4 months agotarget/ppc: Set Float3NaNPropRule explicitly
Peter Maydell [Wed, 11 Dec 2024 15:30:57 +0000 (15:30 +0000)]
target/ppc: Set Float3NaNPropRule explicitly

Set the Float3NaNPropRule explicitly for PPC, and remove the
ifdef from pickNaNMulAdd().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-20-peter.maydell@linaro.org

4 months agotarget/loongarch: Set Float3NaNPropRule explicitly
Peter Maydell [Wed, 11 Dec 2024 15:30:57 +0000 (15:30 +0000)]
target/loongarch: Set Float3NaNPropRule explicitly

Set the Float3NaNPropRule explicitly for loongarch, and remove the
ifdef from pickNaNMulAdd().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-19-peter.maydell@linaro.org

4 months agotarget/arm: Set Float3NaNPropRule explicitly
Peter Maydell [Wed, 11 Dec 2024 15:30:57 +0000 (15:30 +0000)]
target/arm: Set Float3NaNPropRule explicitly

Set the Float3NaNPropRule explicitly for Arm, and remove the
ifdef from pickNaNMulAdd().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-18-peter.maydell@linaro.org

4 months agotests/fp: Explicitly set 3-NaN propagation rule
Peter Maydell [Wed, 11 Dec 2024 15:30:57 +0000 (15:30 +0000)]
tests/fp: Explicitly set 3-NaN propagation rule

Explicitly set a rule in the softfloat tests for propagating NaNs in
the muladd case.  In meson.build we put -DTARGET_ARM in fpcflags, and
so we should select here the Arm rule of float_3nan_prop_s_cab.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-17-peter.maydell@linaro.org

4 months agosoftfloat: Allow runtime choice of NaN propagation for muladd
Peter Maydell [Wed, 11 Dec 2024 15:30:57 +0000 (15:30 +0000)]
softfloat: Allow runtime choice of NaN propagation for muladd

IEEE 758 does not define a fixed rule for which NaN to pick as the
result if both operands of a 3-operand fused multiply-add operation
are NaNs.  As a result different architectures have ended up with
different rules for propagating NaNs.

QEMU currently hardcodes the NaN propagation logic into the binary
because pickNaNMulAdd() has an ifdef ladder for different targets.
We want to make the propagation rule instead be selectable at
runtime, because:
 * this will let us have multiple targets in one QEMU binary
 * the Arm FEAT_AFP architectural feature includes letting
   the guest select a NaN propagation rule at runtime

In this commit we add an enum for the propagation rule, the field in
float_status, and the corresponding getters and setters.  We change
pickNaNMulAdd to honour this, but because all targets still leave
this field at its default 0 value, the fallback logic will pick the
rule type with the old ifdef ladder.

It's valid not to set a propagation rule if default_nan_mode is
enabled, because in that case there's no need to pick a NaN; all the
callers of pickNaNMulAdd() catch this case and skip calling it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-16-peter.maydell@linaro.org

4 months agosoftfloat: Pass have_snan to pickNaNMulAdd
Peter Maydell [Wed, 11 Dec 2024 15:30:57 +0000 (15:30 +0000)]
softfloat: Pass have_snan to pickNaNMulAdd

The new implementation of pickNaNMulAdd() will find it convenient
to know whether at least one of the three arguments to the muladd
was a signaling NaN. We already calculate that in the caller,
so pass it in as a new bool have_snan.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-15-peter.maydell@linaro.org

4 months agotarget/hppa: Set FloatInfZeroNaNRule explicitly
Peter Maydell [Wed, 11 Dec 2024 15:30:56 +0000 (15:30 +0000)]
target/hppa: Set FloatInfZeroNaNRule explicitly

Set the FloatInfZeroNaNRule explicitly for the HPPA target,
so we can remove the ifdef from pickNaNMulAdd().

As this is the last target to be converted to explicitly setting
the rule, we can remove the fallback code in pickNaNMulAdd()
entirely.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241202131347.498124-14-peter.maydell@linaro.org