qemu.git
11 months agovfio/container: Make vfio_get_device() return bool
Zhenzhong Duan [Tue, 7 May 2024 06:42:49 +0000 (14:42 +0800)]
vfio/container: Make vfio_get_device() return bool

This is to follow the coding standand to return bool if 'Error **'
is used to pass error.

Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/container: Make vfio_set_iommu() return bool
Zhenzhong Duan [Tue, 7 May 2024 06:42:48 +0000 (14:42 +0800)]
vfio/container: Make vfio_set_iommu() return bool

This is to follow the coding standand to return bool if 'Error **'
is used to pass error.

Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/container: Make vfio_connect_container() return bool
Zhenzhong Duan [Tue, 7 May 2024 06:42:47 +0000 (14:42 +0800)]
vfio/container: Make vfio_connect_container() return bool

This is to follow the coding standand to return bool if 'Error **'
is used to pass error.

Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio: Make VFIOIOMMUClass::add_window() and its wrapper return bool
Zhenzhong Duan [Tue, 7 May 2024 06:42:46 +0000 (14:42 +0800)]
vfio: Make VFIOIOMMUClass::add_window() and its wrapper return bool

Make VFIOIOMMUClass::add_window() and its wrapper function
vfio_container_add_section_window() return bool.

This is to follow the coding standand to return bool if 'Error **'
is used to pass error.

Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio: Make VFIOIOMMUClass::setup() return bool
Zhenzhong Duan [Tue, 7 May 2024 06:42:45 +0000 (14:42 +0800)]
vfio: Make VFIOIOMMUClass::setup() return bool

This is to follow the coding standand to return bool if 'Error **'
is used to pass error.

Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio: Make VFIOIOMMUClass::attach_device() and its wrapper return bool
Zhenzhong Duan [Tue, 7 May 2024 06:42:44 +0000 (14:42 +0800)]
vfio: Make VFIOIOMMUClass::attach_device() and its wrapper return bool

Make VFIOIOMMUClass::attach_device() and its wrapper function
vfio_attach_device() return bool.

This is to follow the coding standand to return bool if 'Error **'
is used to pass error.

Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/pci: Use g_autofree in iommufd_cdev_get_info_iova_range()
Zhenzhong Duan [Tue, 7 May 2024 06:42:43 +0000 (14:42 +0800)]
vfio/pci: Use g_autofree in iommufd_cdev_get_info_iova_range()

Local pointer info is freed before return from
iommufd_cdev_get_info_iova_range().

Use 'g_autofree' to avoid the g_free() calls.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/pci: Use g_autofree in vfio_realize
Zhenzhong Duan [Tue, 7 May 2024 06:42:42 +0000 (14:42 +0800)]
vfio/pci: Use g_autofree in vfio_realize

Local pointer name is allocated before vfio_attach_device() call
and freed after the call.

Same for tmp when calling realpath().

Use 'g_autofree' to avoid the g_free() calls.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/migration: Enhance VFIO migration state tracing
Avihai Horon [Wed, 15 May 2024 13:21:38 +0000 (16:21 +0300)]
vfio/migration: Enhance VFIO migration state tracing

Move trace_vfio_migration_set_state() to the top of the function, add
recover_state to it, and add a new trace event to
vfio_migration_set_device_state().

This improves tracing of device state changes as state changes are now
also logged when vfio_migration_set_state() fails (covering recover
state and device reset transitions) and in no-op state transitions to
the same state.

Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/migration: Don't emit STOP_COPY VFIO migration QAPI event twice
Avihai Horon [Wed, 15 May 2024 13:21:37 +0000 (16:21 +0300)]
vfio/migration: Don't emit STOP_COPY VFIO migration QAPI event twice

When migrating a VFIO device that supports pre-copy, it is transitioned
to STOP_COPY twice: once in vfio_vmstate_change() and second time in
vfio_save_complete_precopy().

The second transition is harmless, as it's a STOP_COPY->STOP_COPY no-op
transition. However, with the newly added VFIO migration QAPI event, the
STOP_COPY event is undesirably emitted twice.

Prevent this by returning early in vfio_migration_set_state() if
new_state is the same as current device state.

Note that the STOP_COPY transition in vfio_save_complete_precopy() is
essential for VFIO devices that don't support pre-copy, for migrating an
already stopped guest and for snapshots.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/migration: Emit VFIO migration QAPI event
Avihai Horon [Wed, 15 May 2024 13:21:36 +0000 (16:21 +0300)]
vfio/migration: Emit VFIO migration QAPI event

Emit VFIO migration QAPI event when a VFIO device changes its migration
state. This can be used by management applications to get updates on the
current state of the VFIO device for their own purposes.

A new per VFIO device capability, "migration-events", is added so events
can be enabled only for the required devices. It is disabled by default.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agoqapi/vfio: Add VFIO migration QAPI event
Avihai Horon [Wed, 15 May 2024 13:21:35 +0000 (16:21 +0300)]
qapi/vfio: Add VFIO migration QAPI event

Add a new QAPI event for VFIO migration. This event will be emitted when
a VFIO device changes its migration state, for example, during migration
or when stopping/starting the guest.

This event can be used by management applications to get updates on the
current state of the VFIO device for their own purposes.

Note that this new event is introduced since VFIO devices have a unique
set of migration states which cannot be described as accurately by other
existing events such as run state or migration status.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/pci: migration: Skip config space check for Vendor Specific Information in VSC...
Vinayak Kale [Fri, 3 May 2024 14:51:42 +0000 (20:21 +0530)]
vfio/pci: migration: Skip config space check for Vendor Specific Information in VSC during restore/load

In case of migration, during restore operation, qemu checks config space of the
pci device with the config space in the migration stream captured during save
operation. In case of config space data mismatch, restore operation is failed.

config space check is done in function get_pci_config_device(). By default VSC
(vendor-specific-capability) in config space is checked.

Due to qemu's config space check for VSC, live migration is broken across NVIDIA
vGPU devices in situation where source and destination host driver is different.
In this situation, Vendor Specific Information in VSC varies on the destination
to ensure vGPU feature capabilities exposed to the guest driver are compatible
with destination host.

If a vfio-pci device is migration capable and vfio-pci vendor driver is OK with
volatile Vendor Specific Info in VSC then qemu should exempt config space check
for Vendor Specific Info. It is vendor driver's responsibility to ensure that
VSC is consistent across migration. Here consistency could mean that VSC format
should be same on source and destination, however actual Vendor Specific Info
may not be byte-to-byte identical.

This patch skips the check for Vendor Specific Information in VSC for VFIO-PCI
device by clearing pdev->cmask[] offsets. Config space check is still enforced
for 3 byte VSC header. If cmask[] is not set for an offset, then qemu skips
config space check for that offset.

VSC check is skipped for machine types >= 9.1. The check would be enforced on
older machine types (<= 9.0).

Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Vinayak Kale <vkale@nvidia.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/ccw: Make vfio_ccw_register_irq_notifier() return a bool
Cédric Le Goater [Thu, 25 Apr 2024 09:02:14 +0000 (11:02 +0200)]
vfio/ccw: Make vfio_ccw_register_irq_notifier() return a bool

Since vfio_ccw_register_irq_notifier() takes an 'Error **' argument,
best practices suggest to return a bool. See the qapi/error.h Rules
section.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/ccw: Use g_autofree variable in vfio_ccw_register_irq_notifier()
Cédric Le Goater [Thu, 25 Apr 2024 09:02:13 +0000 (11:02 +0200)]
vfio/ccw: Use g_autofree variable in vfio_ccw_register_irq_notifier()

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/ap: Make vfio_ap_register_irq_notifier() return a bool
Cédric Le Goater [Thu, 25 Apr 2024 09:02:12 +0000 (11:02 +0200)]
vfio/ap: Make vfio_ap_register_irq_notifier() return a bool

Since vfio_ap_register_irq_notifier() takes and 'Error **' argument,
best practices suggest to return a bool. See the qapi/error.h Rules
section.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/ap: Use g_autofree variable in vfio_ap_register_irq_notifier()
Cédric Le Goater [Thu, 25 Apr 2024 09:02:11 +0000 (11:02 +0200)]
vfio/ap: Use g_autofree variable in vfio_ap_register_irq_notifier()

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio: Also trace event failures in vfio_save_complete_precopy()
Cédric Le Goater [Thu, 16 May 2024 12:46:58 +0000 (14:46 +0200)]
vfio: Also trace event failures in vfio_save_complete_precopy()

vfio_save_complete_precopy() currently returns before doing the trace
event. Change that.

Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio: Add Error** argument to .get_dirty_bitmap() handler
Cédric Le Goater [Thu, 16 May 2024 12:46:57 +0000 (14:46 +0200)]
vfio: Add Error** argument to .get_dirty_bitmap() handler

Let the callers do the error reporting. Add documentation while at it.

Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agomemory: Add Error** argument to memory_get_xlat_addr()
Cédric Le Goater [Thu, 16 May 2024 12:46:56 +0000 (14:46 +0200)]
memory: Add Error** argument to memory_get_xlat_addr()

Let the callers do the reporting. This will be useful in
vfio_iommu_map_dirty_notify().

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio: Reverse test on vfio_get_xlat_addr()
Cédric Le Goater [Thu, 16 May 2024 12:46:55 +0000 (14:46 +0200)]
vfio: Reverse test on vfio_get_xlat_addr()

It will simplify the changes coming after.

Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/migration: Add Error** argument to .vfio_save_config() handler
Cédric Le Goater [Thu, 16 May 2024 12:46:54 +0000 (14:46 +0200)]
vfio/migration: Add Error** argument to .vfio_save_config() handler

Use vmstate_save_state_with_err() to improve error reporting in the
callers and store a reported error under the migration stream. Add
documentation while at it.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio/migration: Add an Error** argument to vfio_migration_set_state()
Cédric Le Goater [Thu, 16 May 2024 12:46:53 +0000 (14:46 +0200)]
vfio/migration: Add an Error** argument to vfio_migration_set_state()

Add an Error** argument to vfio_migration_set_state() and adjust
callers, including vfio_save_setup(). The error will be propagated up
to qemu_savevm_state_setup() where the save_setup() handler is
executed.

Modify vfio_vmstate_change_prepare() and vfio_vmstate_change() to
store a reported error under the migration stream if a migration is in
progress.

Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agomigration: Extend migration_file_set_error() with Error* argument
Cédric Le Goater [Thu, 16 May 2024 12:46:52 +0000 (14:46 +0200)]
migration: Extend migration_file_set_error() with Error* argument

Use it to update the current error of the migration stream if
available and if not, simply print out the error. Next changes will
update with an error to report.

Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Acked-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio: Add Error** argument to vfio_devices_dma_logging_start()
Cédric Le Goater [Thu, 16 May 2024 12:46:51 +0000 (14:46 +0200)]
vfio: Add Error** argument to vfio_devices_dma_logging_start()

This allows to update the Error argument of the VFIO log_global_start()
handler. Errors for container based logging will also be propagated to
qemu_savevm_state_setup() when the ram save_setup() handler is executed.
Also, errors from vfio_container_set_dirty_page_tracking() are now
collected and reported.

The vfio_set_migration_error() call becomes redundant in
vfio_listener_log_global_start(). Remove it.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agovfio: Add Error** argument to .set_dirty_page_tracking() handler
Cédric Le Goater [Thu, 16 May 2024 12:46:50 +0000 (14:46 +0200)]
vfio: Add Error** argument to .set_dirty_page_tracking() handler

We will use the Error object to improve error reporting in the
.log_global*() handlers of VFIO. Add documentation while at it.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
11 months agoMerge tag 'pull-maintainer-may24-160524-2' of https://gitlab.com/stsquad/qemu into...
Richard Henderson [Thu, 16 May 2024 08:02:56 +0000 (10:02 +0200)]
Merge tag 'pull-maintainer-may24-160524-2' of https://gitlab.com/stsquad/qemu into staging

plugin and testing updates

 - don't duplicate options for microbit test
 - don't spam the linux source tree when importing headers
 - add STORE_U64 inline op to TCG plugins
 - add conditional callback op to TCG plugins

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmZFvCMACgkQ+9DbCVqe
# KkSrYQf/aj9+eCWCKZk3Hym0lT+qNKxUeNSx3juUN8h7iG1vkA1f/XaQle5XvKDr
# ROIdo8urcr8onJ4PBH+4C7VZhUmnpL8zLH80pCuuTkF03MCNhaW/5qJ67niWmPVM
# QJHVqNomkykKOMBh+WtD5M0m/BYPT5lsa10sE3bDH8ziGjp0An2v24R89tzYEXnf
# 1QePItQN5vzEvhrZj6oKWVmeucqLsqS6yqS8V3sEpmF0+zqNjGZlrI86A4SAp74k
# 8vuduVuRbeyki7zWBTOLUeoiuHM2Zmh7v74zm/Hc1ITBaDjWMwPctcI/vFjsrCI/
# yoFRhgrV87DtIZdkrJzk5qBYFOWoeQ==
# =znN0
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 16 May 2024 09:56:19 AM CEST
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [full]

* tag 'pull-maintainer-may24-160524-2' of https://gitlab.com/stsquad/qemu:
  plugins: remove op from qemu_plugin_inline_cb
  plugins: extract cpu_index generate
  plugins: distinct types for callbacks
  tests/plugin/inline: add test for conditional callback
  plugins: conditional callbacks
  tests/plugin/inline: add test for STORE_U64 inline op
  plugins: add new inline op STORE_U64
  plugins: extract generate ptr for qemu_plugin_u64
  plugins: prepare introduction of new inline ops
  scripts/update-linux-header.sh: be more src tree friendly
  tests/tcg: don't append QEMU_OPTS for armv6m-undef test

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agoplugins: remove op from qemu_plugin_inline_cb
Pierrick Bouvier [Tue, 14 May 2024 17:42:53 +0000 (18:42 +0100)]
plugins: remove op from qemu_plugin_inline_cb

This field is not needed as the callback type already holds this
information.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240502211522.346467-10-pierrick.bouvier@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240514174253.694591-12-alex.bennee@linaro.org>

11 months agoplugins: extract cpu_index generate
Pierrick Bouvier [Tue, 14 May 2024 17:42:52 +0000 (18:42 +0100)]
plugins: extract cpu_index generate

Factorizes function to access current cpu index for a given vcpu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240502211522.346467-9-pierrick.bouvier@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240514174253.694591-11-alex.bennee@linaro.org>

11 months agoplugins: distinct types for callbacks
Pierrick Bouvier [Tue, 14 May 2024 17:42:51 +0000 (18:42 +0100)]
plugins: distinct types for callbacks

To prevent errors when writing new types of callbacks or inline
operations, we split callbacks data to distinct types.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240502211522.346467-8-pierrick.bouvier@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240514174253.694591-10-alex.bennee@linaro.org>

11 months agotests/plugin/inline: add test for conditional callback
Pierrick Bouvier [Tue, 14 May 2024 17:42:50 +0000 (18:42 +0100)]
tests/plugin/inline: add test for conditional callback

Count number of tb and insn executed using a conditional callback. We
ensure the callback has been called expected number of time (per vcpu).

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240502211522.346467-7-pierrick.bouvier@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240514174253.694591-9-alex.bennee@linaro.org>

11 months agoplugins: conditional callbacks
Pierrick Bouvier [Tue, 14 May 2024 17:42:49 +0000 (18:42 +0100)]
plugins: conditional callbacks

Extend plugins API to support callback called with a given criteria
(evaluated inline).

Added functions:
- qemu_plugin_register_vcpu_tb_exec_cond_cb
- qemu_plugin_register_vcpu_insn_exec_cond_cb

They expect as parameter a condition, a qemu_plugin_u64_t (op1) and an
immediate (op2). Callback is called if op1 |cond| op2 is true.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240502211522.346467-6-pierrick.bouvier@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
[AJB: fix re-base conflict with tb_is_mem_only()]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240514174253.694591-8-alex.bennee@linaro.org>

11 months agotests/plugin/inline: add test for STORE_U64 inline op
Pierrick Bouvier [Tue, 14 May 2024 17:42:48 +0000 (18:42 +0100)]
tests/plugin/inline: add test for STORE_U64 inline op

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240502211522.346467-5-pierrick.bouvier@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240514174253.694591-7-alex.bennee@linaro.org>

11 months agoplugins: add new inline op STORE_U64
Pierrick Bouvier [Tue, 14 May 2024 17:42:47 +0000 (18:42 +0100)]
plugins: add new inline op STORE_U64

This new operation can store an immediate u64 value to a given
scoreboard.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240502211522.346467-4-pierrick.bouvier@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240514174253.694591-6-alex.bennee@linaro.org>

11 months agoplugins: extract generate ptr for qemu_plugin_u64
Pierrick Bouvier [Tue, 14 May 2024 17:42:46 +0000 (18:42 +0100)]
plugins: extract generate ptr for qemu_plugin_u64

Plugin operations can access a scoreboard. This function factorizes code
generation for accessing entry associated to a given vcpu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240502211522.346467-3-pierrick.bouvier@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240514174253.694591-5-alex.bennee@linaro.org>

11 months agoplugins: prepare introduction of new inline ops
Pierrick Bouvier [Tue, 14 May 2024 17:42:45 +0000 (18:42 +0100)]
plugins: prepare introduction of new inline ops

Until now, only add_u64 was available, and all functions assumed this or
were named uniquely.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240514174253.694591-4-alex.bennee@linaro.org>

11 months agoscripts/update-linux-header.sh: be more src tree friendly
Alex Bennée [Tue, 14 May 2024 17:42:44 +0000 (18:42 +0100)]
scripts/update-linux-header.sh: be more src tree friendly

Running "install_headers" in the Linux source tree is fairly
unfriendly as out-of-tree builds will start complaining about the
kernel source being non-pristine. As we have a temporary directory for
the install we should also do the build step here. So now we have:

  $tmpdir/
    $blddir/
    $hdrdir/

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240514174253.694591-3-alex.bennee@linaro.org>

11 months agotests/tcg: don't append QEMU_OPTS for armv6m-undef test
Alex Bennée [Tue, 14 May 2024 17:42:43 +0000 (18:42 +0100)]
tests/tcg: don't append QEMU_OPTS for armv6m-undef test

We don't want to build on the default machine setup here but define a
custom one for the microbit.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240514174253.694591-2-alex.bennee@linaro.org>

11 months agoMerge tag 'pull-hppa-20240515' of https://gitlab.com/rth7680/qemu into staging
Richard Henderson [Wed, 15 May 2024 09:46:58 +0000 (11:46 +0200)]
Merge tag 'pull-hppa-20240515' of https://gitlab.com/rth7680/qemu into staging

target/hppa:
  - Use TCG_COND_TST where applicable.
  - Use CF_BP_PAGE instead of a local breakpoint search.
  - Clean up IAOQ handling during translation.
  - Implement CF_PCREL.
  - Implement PSW.B.
  - Implement PSW.X.
  - Log cpu state on interrupt and rfi.

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmZEgnwdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+43gf8CakQdMSqfGV2nGP+
# 7wWZOAV04IyfkJ38F/CH0ihUkblEOzXJ1shTFkrHEw257j0D10MctSSbjrqz5BwU
# obQcwoVlxzTGXqzhkZ6wagkcqjv3TtlPtznZIk6JssdlrtwIKDmE2/3t1dzHnyBD
# WTrS0SK3YvVRovq/ai51raUbiBsNq7XG3skHEsMKsFxp4EaDP5JTbputdQWdffjh
# TBmXImhHC3gm09KWIUZwfEBHlaa7YXk2orzB8kBE8S2kQj9vrGXEaC4jYnBcQLPw
# NDDkBYRqxHYQr0vIAHee+5cUgt1jDBr5rXnAnJwzK0wyEEc4Mi4OTPhNE604iu2y
# SDxS8Q==
# =A4Qf
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 15 May 2024 11:38:04 AM CEST
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate]

* tag 'pull-hppa-20240515' of https://gitlab.com/rth7680/qemu: (43 commits)
  target/hppa: Log cpu state on return-from-interrupt
  target/hppa: Log cpu state at interrupt
  target/hppa: Implement CF_PCREL
  target/hppa: Adjust priv for B,GATE at runtime
  target/hppa: Drop tlb_entry return from hppa_get_physical_address
  target/hppa: Implement PSW_X
  target/hppa: Implement PSW_B
  target/hppa: Manage PSW_X and PSW_B in translator
  target/hppa: Split PSW X and B into their own field
  target/hppa: Improve hppa_cpu_dump_state
  target/hppa: Do not mask in copy_iaoq_entry
  target/hppa: Store full iaoq_f and page offset of iaoq_b in TB
  linux-user/hppa: Force all code addresses to PRIV_USER
  target/hppa: Use delay_excp for conditional trap on overflow
  target/hppa: Use delay_excp for conditional traps
  target/hppa: Introduce DisasDelayException
  target/hppa: Remove cond_free
  target/hppa: Use TCG_COND_TST* in trans_ftest
  target/hppa: Use registerfields.h for FPSR
  target/hppa: Use TCG_COND_TST* in trans_bb_imm
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agoMerge tag 'pull-tcg-20240515' of https://gitlab.com/rth7680/qemu into staging
Richard Henderson [Wed, 15 May 2024 09:46:36 +0000 (11:46 +0200)]
Merge tag 'pull-tcg-20240515' of https://gitlab.com/rth7680/qemu into staging

tcg/loongarch64: Fill out tcg_out_{ld,st} for vector regs
accel/tcg: Improve disassembly for target and plugin

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmZEXT0dHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV/FbQf+P3ppcAA+5smxaQyi
# dsfCJaGOMqRTWYuSmNsJ7AlxQobxLKVsJrAHraNU1AnDfwKrX3XXJcU4Gwt0eQyN
# lGiF/24KLElvb+w6fkjuLdK+DbGWTrNabXJAnBw1h21x+go0mvVCVSuQQw7a/RDS
# btPnGkmoi0H340JC1MVSDRgFkB3RV0kOMXGGm70S+mw0WhjVgdInhLv0jjnj2QFM
# tYzJ5g+00v0HPo8Lun5kRSaI7EGG7J/XfGa71WHIHrB0o7FAzslap4fGTcfOB+7a
# f2jTGErezJQj1pvJLvFTNX4YQ02ORnDKsz4EC0G9QU8rk+S1bD2vTVoi5IY5ayfJ
# oqxyRw==
# =Q16M
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 15 May 2024 08:59:09 AM CEST
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate]

* tag 'pull-tcg-20240515' of https://gitlab.com/rth7680/qemu: (34 commits)
  tcg/loongarch64: Fill out tcg_out_{ld,st} for vector regs
  accel/tcg: Remove cpu_ldsb_code / cpu_ldsw_code
  target/s390x: Use translator_lduw in get_next_pc
  target/xtensa: Use translator_ldub in xtensa_insn_len
  target/rx: Use translator_ld*
  target/riscv: Use translator_ld* for everything
  target/cris: Use cris_fetch in translate_v10.c.inc
  target/cris: Use translator_ld* in cris_fetch
  target/avr: Use translator_lduw
  target/i386: Use translator_ldub for everything
  target/microblaze: Use translator_ldl
  target/hexagon: Use translator_ldl in pkt_crosses_page
  target/s390x: Disassemble EXECUTEd instructions
  target/s390x: Fix translator_fake_ld length
  accel/tcg: Introduce translator_fake_ld
  disas: Use translator_st to get disassembly data
  disas: Split disas.c
  accel/tcg: Return bool from TranslatorOps.disas_log
  accel/tcg: Provide default implementation of disas_log
  plugins: Merge  alloc_tcg_plugin_context into plugin_gen_tb_start
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Log cpu state on return-from-interrupt
Richard Henderson [Wed, 17 Apr 2024 04:32:24 +0000 (21:32 -0700)]
target/hppa: Log cpu state on return-from-interrupt

Inverse of the logging on taking an interrupt.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Log cpu state at interrupt
Richard Henderson [Wed, 17 Apr 2024 04:27:56 +0000 (21:27 -0700)]
target/hppa: Log cpu state at interrupt

This contains all of the information logged before, plus more.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Implement CF_PCREL
Richard Henderson [Sun, 14 Apr 2024 03:57:13 +0000 (20:57 -0700)]
target/hppa: Implement CF_PCREL

Now that the groundwork has been laid, enabling CF_PCREL within the
translator proper is a simple matter of updating copy_iaoq_entry
and install_iaq_entries.

We also need to modify the unwind info, since we no longer have
absolute addresses to install.

As expected, this reduces the runtime overhead of compilation when
running a Linux kernel with address space randomization enabled.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Adjust priv for B,GATE at runtime
Richard Henderson [Sun, 14 Apr 2024 03:39:15 +0000 (20:39 -0700)]
target/hppa: Adjust priv for B,GATE at runtime

Do not compile in the priv change based on the first translation;
look up the PTE at execution time.  This is required for CF_PCREL,
where a page may be mapped multiple times with different attributes.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Drop tlb_entry return from hppa_get_physical_address
Richard Henderson [Sat, 13 Apr 2024 23:50:58 +0000 (16:50 -0700)]
target/hppa: Drop tlb_entry return from hppa_get_physical_address

The return-by-reference is never used.

Reviewed-by: Helge Deller <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Implement PSW_X
Richard Henderson [Wed, 17 Apr 2024 00:39:25 +0000 (17:39 -0700)]
target/hppa: Implement PSW_X

Use PAGE_WRITE_INV to temporarily enable write permission
on for a given page, driven by PSW_X being set.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Implement PSW_B
Richard Henderson [Wed, 17 Apr 2024 03:50:30 +0000 (20:50 -0700)]
target/hppa: Implement PSW_B

PSW_B causes B,GATE to trap as an illegal instruction, removing our
previous sequential execution test that was merely an approximation.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Manage PSW_X and PSW_B in translator
Richard Henderson [Wed, 17 Apr 2024 03:43:00 +0000 (20:43 -0700)]
target/hppa: Manage PSW_X and PSW_B in translator

PSW_X is cleared after every instruction, and only set by RFI.
PSW_B is cleared after every non-branch, or branch not taken,
and only set by taken branches.  We can clear both bits with a
single store, at most once per TB.  Taken branches set PSW_B,
at most once per TB.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Split PSW X and B into their own field
Richard Henderson [Wed, 17 Apr 2024 03:23:16 +0000 (20:23 -0700)]
target/hppa: Split PSW X and B into their own field

Generally, both of these bits are cleared at the end of each
instruction.  By separating these, we will be able to clear
both with a single insn, instead of 2 or 3.

Reviewed-by: Helge Deller <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Improve hppa_cpu_dump_state
Richard Henderson [Thu, 28 Mar 2024 21:06:38 +0000 (11:06 -1000)]
target/hppa: Improve hppa_cpu_dump_state

Print both raw IAQ_Front and IAQ_Back as well as the GVAs.
Print control registers in system mode.
Print floating point registers if CPU_DUMP_FPU.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Do not mask in copy_iaoq_entry
Richard Henderson [Wed, 27 Mar 2024 23:04:00 +0000 (13:04 -1000)]
target/hppa: Do not mask in copy_iaoq_entry

As with loads and stores, code offsets are kept intact until the
full gva is formed.  In qemu, this is in cpu_get_tb_cpu_state.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Store full iaoq_f and page offset of iaoq_b in TB
Richard Henderson [Wed, 27 Mar 2024 21:52:21 +0000 (11:52 -1000)]
target/hppa: Store full iaoq_f and page offset of iaoq_b in TB

In preparation for CF_PCREL. store the iaoq_f in 3 parts: high
bits in cs_base, middle bits in pc, and low bits in priv.
For iaoq_b, set a bit for either of space or page differing,
else the page offset.

Install iaq entries before goto_tb. The change to not record
the full direct branch difference in TB means that we have to
store at least iaoq_b before goto_tb.  But since a later change
to enable CF_PCREL will require both iaoq_f and iaoq_b to be
updated before goto_tb, go ahead and update both fields now.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agolinux-user/hppa: Force all code addresses to PRIV_USER
Richard Henderson [Wed, 27 Mar 2024 20:54:06 +0000 (10:54 -1000)]
linux-user/hppa: Force all code addresses to PRIV_USER

The kernel does this along the return path to user mode.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Use delay_excp for conditional trap on overflow
Richard Henderson [Tue, 26 Mar 2024 23:54:01 +0000 (13:54 -1000)]
target/hppa: Use delay_excp for conditional trap on overflow

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Use delay_excp for conditional traps
Richard Henderson [Tue, 26 Mar 2024 23:16:15 +0000 (13:16 -1000)]
target/hppa: Use delay_excp for conditional traps

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Introduce DisasDelayException
Richard Henderson [Tue, 26 Mar 2024 22:47:11 +0000 (12:47 -1000)]
target/hppa: Introduce DisasDelayException

Allow an exception to be emitted at the end of the TranslationBlock,
leaving only the conditional branch inline.  Use it for simple
exception instructions like break, which happen to be nullified.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Remove cond_free
Richard Henderson [Mon, 25 Mar 2024 23:50:11 +0000 (13:50 -1000)]
target/hppa: Remove cond_free

Now that we do not need to free tcg temporaries, the only
thing cond_free does is reset the condition to never.
Instead, simply write a new condition over the old, which
may be simply cond_make_f() for the never condition.

The do_*_cond functions do the right thing with c or cf == 0,
so there's no need for a special case anymore.

Reviewed-by: Helge Deller <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Use TCG_COND_TST* in trans_ftest
Richard Henderson [Mon, 25 Mar 2024 23:26:10 +0000 (13:26 -1000)]
target/hppa: Use TCG_COND_TST* in trans_ftest

Reviewed-by: Helge Deller <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Use registerfields.h for FPSR
Richard Henderson [Mon, 25 Mar 2024 22:20:31 +0000 (12:20 -1000)]
target/hppa: Use registerfields.h for FPSR

Define all of the context dependent field definitions.
Use FIELD_EX32 and FIELD_DP32 with named fields instead
of extract32 and deposit32 with raw constants.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Use TCG_COND_TST* in trans_bb_imm
Richard Henderson [Mon, 25 Mar 2024 21:22:59 +0000 (11:22 -1000)]
target/hppa: Use TCG_COND_TST* in trans_bb_imm

Reviewed-by: Helge Deller <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Use TCG_COND_TST* in do_unit_addsub
Richard Henderson [Mon, 25 Mar 2024 21:05:46 +0000 (11:05 -1000)]
target/hppa: Use TCG_COND_TST* in do_unit_addsub

Reviewed-by: Helge Deller <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Use TCG_COND_TST* in do_unit_zero_cond
Richard Henderson [Mon, 25 Mar 2024 21:04:06 +0000 (11:04 -1000)]
target/hppa: Use TCG_COND_TST* in do_unit_zero_cond

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Use TCG_COND_TST* in do_log_cond
Richard Henderson [Mon, 25 Mar 2024 21:00:36 +0000 (11:00 -1000)]
target/hppa: Use TCG_COND_TST* in do_log_cond

We can directly test bits of a 32-bit comparison without
zero or sign-extending an intermediate result.
We can directly test bit 0 for odd/even.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Use TCG_COND_TST* in do_cond
Richard Henderson [Mon, 25 Mar 2024 20:27:12 +0000 (10:27 -1000)]
target/hppa: Use TCG_COND_TST* in do_cond

We can directly test bits of a 32-bit comparison without
zero or sign-extending an intermediate result.
We can directly test bit 0 for odd/even.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Rename cond_make_* helpers
Richard Henderson [Mon, 25 Mar 2024 17:30:19 +0000 (07:30 -1000)]
target/hppa: Rename cond_make_* helpers

Use 'v' for a variable that needs copying, 't' for a temp that
doesn't need copying, and 'i' for an immediate, and use this
naming for both arguments of the comparison.  So:

   cond_make_tmp -> cond_make_tt
   cond_make_0_tmp -> cond_make_ti
   cond_make_0 -> cond_make_vi
   cond_make -> cond_make_vv

Pass 0 explictly, rather than implicitly in the function name.

Reviewed-by: Helge Deller <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Use displacements in DisasIAQE
Richard Henderson [Fri, 22 Mar 2024 02:47:14 +0000 (16:47 -1000)]
target/hppa: Use displacements in DisasIAQE

This is a first step in enabling CF_PCREL, but for now
we regenerate the absolute address before writeback.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Introduce and use DisasIAQE for branch management
Richard Henderson [Thu, 21 Mar 2024 23:56:44 +0000 (13:56 -1000)]
target/hppa: Introduce and use DisasIAQE for branch management

Wrap offset and space together in one structure, ensuring
that they're copied together as required.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Always make a copy in do_ibranch_priv
Richard Henderson [Wed, 27 Mar 2024 22:50:07 +0000 (12:50 -1000)]
target/hppa: Always make a copy in do_ibranch_priv

This simplifies callers, which might otherwise have
to make another copy.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Use umax in do_ibranch_priv
Richard Henderson [Wed, 27 Mar 2024 22:53:06 +0000 (12:53 -1000)]
target/hppa: Use umax in do_ibranch_priv

Using umax is clearer than the same operation using movcond.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Add space argument to do_ibranch
Richard Henderson [Sat, 23 Mar 2024 07:29:47 +0000 (21:29 -1000)]
target/hppa: Add space argument to do_ibranch

This allows unification of BE, BLR, BV, BVE with a common helper.
Since we can now track space with IAQ_Next, we can now let the
TranslationBlock continue across the delay slot with BE, BVE.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Add space arguments to install_iaq_entries
Richard Henderson [Sat, 23 Mar 2024 07:04:24 +0000 (21:04 -1000)]
target/hppa: Add space arguments to install_iaq_entries

Move space assighments to a central location.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Add IASQ entries to DisasContext
Richard Henderson [Sat, 23 Mar 2024 06:45:21 +0000 (20:45 -1000)]
target/hppa: Add IASQ entries to DisasContext

Add variable to track space changes to IAQ.  So far, no such changes
are introduced, but the new checks vs ctx->iasq_b may eliminate an
unnecessary copy to cpu_iasq_f with e.g. BLR.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Simplify TB end
Richard Henderson [Sat, 23 Mar 2024 06:13:40 +0000 (20:13 -1000)]
target/hppa: Simplify TB end

Minimize the amount of code in hppa_tr_translate_insn advancing the
insn queue for the next insn.  Move the goto_tb path to hppa_tr_tb_stop.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Skip nullified insns in unconditional dbranch path
Richard Henderson [Sat, 13 Apr 2024 20:07:06 +0000 (13:07 -0700)]
target/hppa: Skip nullified insns in unconditional dbranch path

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Delay computation of IAQ_Next
Richard Henderson [Sat, 23 Mar 2024 01:38:32 +0000 (15:38 -1000)]
target/hppa: Delay computation of IAQ_Next

We no longer have to allocate a temp and perform an
addition before translation of the rest of the insn.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Add install_link
Richard Henderson [Fri, 22 Mar 2024 06:30:12 +0000 (20:30 -1000)]
target/hppa: Add install_link

Add a common routine for writing the return address.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Add install_iaq_entries
Richard Henderson [Fri, 22 Mar 2024 04:40:54 +0000 (18:40 -1000)]
target/hppa: Add install_iaq_entries

Instead of two separate cpu_iaoq_entry calls, use one call to update
both IAQ_Front and IAQ_Back.  Simplify with an argument combination
that automatically handles a simple increment from Front to Back.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Use CF_BP_PAGE instead of cpu_breakpoint_test
Richard Henderson [Fri, 22 Mar 2024 02:59:40 +0000 (16:59 -1000)]
target/hppa: Use CF_BP_PAGE instead of cpu_breakpoint_test

The generic tcg driver will have already checked for breakpoints.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Allow prior nullification in do_ibranch
Richard Henderson [Fri, 22 Mar 2024 00:33:28 +0000 (14:33 -1000)]
target/hppa: Allow prior nullification in do_ibranch

Simplify the function by not attempting a conditional move
on the branch destination -- just use nullify_over normally.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Pass displacement to do_dbranch
Richard Henderson [Thu, 21 Mar 2024 06:02:42 +0000 (20:02 -1000)]
target/hppa: Pass displacement to do_dbranch

Pass a displacement instead of an absolute value.

In trans_be, remove the user-only do_dbranch case.  The branch we are
attempting to optimize is to the zero page, which is perforce on a
different page than the code currently executing, which means that
we will *not* use a goto_tb.  Use a plain indirect branch instead,
which is what we got out of the attempted direct branch anyway.

Reviewed-by: Helge Deller <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Move constant destination check into use_goto_tb
Richard Henderson [Wed, 20 Mar 2024 19:23:35 +0000 (09:23 -1000)]
target/hppa: Move constant destination check into use_goto_tb

Share this check between gen_goto_tb and hppa_tr_translate_insn.

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Use hppa_form_gva_psw in hppa_cpu_get_pc
Richard Henderson [Thu, 28 Mar 2024 05:09:05 +0000 (19:09 -1000)]
target/hppa: Use hppa_form_gva_psw in hppa_cpu_get_pc

This function is for log_pc(), which needs to produce a
similar result to cpu_get_tb_cpu_state().

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hppa: Move cpu_get_tb_cpu_state out of line
Richard Henderson [Thu, 28 Mar 2024 02:53:57 +0000 (16:53 -1000)]
target/hppa: Move cpu_get_tb_cpu_state out of line

Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotcg/loongarch64: Fill out tcg_out_{ld,st} for vector regs
Richard Henderson [Fri, 10 May 2024 09:03:41 +0000 (09:03 +0000)]
tcg/loongarch64: Fill out tcg_out_{ld,st} for vector regs

TCG register spill/fill uses tcg_out_ld/st with all types,
not necessarily going through INDEX_op_{ld,st}_vec.

Cc: qemu-stable@nongnu.org
Fixes: 16288ded944 ("tcg/loongarch64: Lower basic tcg vec ops to LSX")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2336
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Song Gao <gaosong@loongson.cn>
Tested-by: Song Gao <gaosong@loongson.cn>
11 months agoaccel/tcg: Remove cpu_ldsb_code / cpu_ldsw_code
Philippe Mathieu-Daudé [Fri, 5 Apr 2024 13:15:32 +0000 (15:15 +0200)]
accel/tcg: Remove cpu_ldsb_code / cpu_ldsw_code

Previous commits replaced them by translator_ld* calls.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20240405131532.40913-1-philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/s390x: Use translator_lduw in get_next_pc
Richard Henderson [Fri, 5 Apr 2024 10:00:59 +0000 (00:00 -1000)]
target/s390x: Use translator_lduw in get_next_pc

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/xtensa: Use translator_ldub in xtensa_insn_len
Richard Henderson [Fri, 5 Apr 2024 09:53:24 +0000 (23:53 -1000)]
target/xtensa: Use translator_ldub in xtensa_insn_len

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/rx: Use translator_ld*
Richard Henderson [Fri, 5 Apr 2024 09:42:29 +0000 (23:42 -1000)]
target/rx: Use translator_ld*

Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/riscv: Use translator_ld* for everything
Richard Henderson [Fri, 5 Apr 2024 09:22:27 +0000 (23:22 -1000)]
target/riscv: Use translator_ld* for everything

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/cris: Use cris_fetch in translate_v10.c.inc
Richard Henderson [Fri, 5 Apr 2024 09:17:02 +0000 (23:17 -1000)]
target/cris: Use cris_fetch in translate_v10.c.inc

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/cris: Use translator_ld* in cris_fetch
Richard Henderson [Fri, 5 Apr 2024 09:11:25 +0000 (23:11 -1000)]
target/cris: Use translator_ld* in cris_fetch

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/avr: Use translator_lduw
Richard Henderson [Fri, 5 Apr 2024 09:03:49 +0000 (23:03 -1000)]
target/avr: Use translator_lduw

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/i386: Use translator_ldub for everything
Richard Henderson [Fri, 5 Apr 2024 09:01:59 +0000 (23:01 -1000)]
target/i386: Use translator_ldub for everything

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/microblaze: Use translator_ldl
Richard Henderson [Tue, 2 Apr 2024 19:20:35 +0000 (09:20 -1000)]
target/microblaze: Use translator_ldl

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/hexagon: Use translator_ldl in pkt_crosses_page
Richard Henderson [Tue, 2 Apr 2024 19:24:14 +0000 (09:24 -1000)]
target/hexagon: Use translator_ldl in pkt_crosses_page

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/s390x: Disassemble EXECUTEd instructions
Richard Henderson [Wed, 3 Apr 2024 18:05:09 +0000 (08:05 -1000)]
target/s390x: Disassemble EXECUTEd instructions

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/s390x: Fix translator_fake_ld length
Richard Henderson [Wed, 3 Apr 2024 17:39:31 +0000 (07:39 -1000)]
target/s390x: Fix translator_fake_ld length

The ilen value extracted from ex_value is the length of the
EXECUTE instruction itself, and so is the increment to the pc.
However, the length of the synthetic insn is located in the
opcode like all other instructions.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agoaccel/tcg: Introduce translator_fake_ld
Richard Henderson [Wed, 3 Apr 2024 17:29:37 +0000 (07:29 -1000)]
accel/tcg: Introduce translator_fake_ld

Replace translator_fake_ldb, which required multiple calls,
with translator_fake_ld, which can take all data at once.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agodisas: Use translator_st to get disassembly data
Richard Henderson [Wed, 3 Apr 2024 09:44:53 +0000 (23:44 -1000)]
disas: Use translator_st to get disassembly data

Read from already translated pages, or saved mmio data.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agodisas: Split disas.c
Richard Henderson [Fri, 5 Apr 2024 06:46:32 +0000 (20:46 -1000)]
disas: Split disas.c

The routines in disas-common.c are also used from disas-mon.c.
Otherwise the rest of disassembly is only used from tcg.
While we're at it, put host and target code into separate files.

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