]> git.ipfire.org Git - thirdparty/qemu.git/log
thirdparty/qemu.git
7 weeks agovfio: Rename vfio_devices_all_dirty_tracking_started()
Cédric Le Goater [Wed, 26 Mar 2025 07:51:14 +0000 (08:51 +0100)] 
vfio: Rename vfio_devices_all_dirty_tracking_started()

Also rename vfio_devices_all_device_dirty_tracking_started() while at
it and use the prefix 'vfio_container_devices_' for routines simply
looping over the container's device list.

Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-30-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Make vfio_container_query_dirty_bitmap() static
Cédric Le Goater [Wed, 26 Mar 2025 07:51:13 +0000 (08:51 +0100)] 
vfio: Make vfio_container_query_dirty_bitmap() static

vfio_container_query_dirty_bitmap() is only used in "container-base.c".
Also, rename to vfio_container_iommu_query_dirty_bitmap() to reflect it
is using the VFIO IOMMU backend device ->query_dirty_bitmap() handler.

Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-29-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Make vfio_devices_query_dirty_bitmap() static
Cédric Le Goater [Wed, 26 Mar 2025 07:51:12 +0000 (08:51 +0100)] 
vfio: Make vfio_devices_query_dirty_bitmap() static

vfio_devices_query_dirty_bitmap() is only used in "container-base.c".
Also, rename to vfio_container_devices_query_dirty_bitmap() to reflect
with the prefix 'vfio_container_devices_' that it simply loops over
the container's device list.

Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-28-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Move dirty tracking related services into container-base.c
Cédric Le Goater [Wed, 26 Mar 2025 07:51:11 +0000 (08:51 +0100)] 
vfio: Move dirty tracking related services into container-base.c

Routines of common.c :

 vfio_devices_all_dirty_tracking_started
 vfio_devices_all_device_dirty_tracking
 vfio_devices_query_dirty_bitmap
 vfio_get_dirty_bitmap

are all related to dirty page tracking directly at the container level
or at the container device level. Naming is a bit confusing. We will
propose new names in the following changes.

Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-27-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Move vfio_reset_handler() into device.c
Cédric Le Goater [Wed, 26 Mar 2025 07:51:10 +0000 (08:51 +0100)] 
vfio: Move vfio_reset_handler() into device.c

Pass-through devices of a VM are not necessarily in the same group and
all groups/address_spaces need to be scanned when the machine is
reset. Commit f16f39c3fc97 ("Implement PCI hot reset") introduced a VM
reset handler for this purpose. Move it under device.c

Also reintroduce the comment which explained the context and was lost
along the way.

Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-26-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Move vfio_de/attach_device() into device.c
Cédric Le Goater [Wed, 26 Mar 2025 07:51:09 +0000 (08:51 +0100)] 
vfio: Move vfio_de/attach_device() into device.c

These routines are VFIODevice related. Move their definitions into
"device.c".

Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-24-clg@redhat.com
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-25-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Move vfio_device_list into device.c
Cédric Le Goater [Wed, 26 Mar 2025 07:51:08 +0000 (08:51 +0100)] 
vfio: Move vfio_device_list into device.c

'vfio_device_list' is VFIODevice related. Move its definitions into
"device.c".

Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-23-clg@redhat.com
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-24-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Move vfio_kvm_device_fd() into helpers.c
Cédric Le Goater [Wed, 26 Mar 2025 07:51:07 +0000 (08:51 +0100)] 
vfio: Move vfio_kvm_device_fd() into helpers.c

The vfio_kvm_device_add/del_fd() routines opening the VFIO pseudo
device are defined in "helpers.c". Move 'vfio_kvm_device_fd'
definition there and its declaration into "vfio-helpers.h" to reduce
exposure of VFIO internals in "hw/vfio/vfio-common.h".

Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-22-clg@redhat.com
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-23-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Introduce new files for CPR definitions and declarations
Cédric Le Goater [Wed, 26 Mar 2025 07:51:06 +0000 (08:51 +0100)] 
vfio: Introduce new files for CPR definitions and declarations

Gather all CPR related declarations into "vfio-cpr.h" to reduce exposure
of VFIO internals in "hw/vfio/vfio-common.h". These were introduced in
commit d9fa4223b30a ("vfio: register container for cpr").

Order file list in meson.build while at it.

Cc: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Steve Sistare <steven.sistare@oracle.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-22-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Introduce a new file for VFIODevice definitions
Cédric Le Goater [Wed, 26 Mar 2025 07:51:05 +0000 (08:51 +0100)] 
vfio: Introduce a new file for VFIODevice definitions

Move all VFIODevice related routines of "helpers.c" into a new "device.c"
file.

Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-21-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Move vfio_get_device_info() to helpers.c
Cédric Le Goater [Wed, 26 Mar 2025 07:51:04 +0000 (08:51 +0100)] 
vfio: Move vfio_get_device_info() to helpers.c

vfio_get_device_info() is a low level routine. Move it with the other
helpers.

Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-19-clg@redhat.com
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-20-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Move vfio_kvm_device_add/del_fd() to helpers.c
Cédric Le Goater [Wed, 26 Mar 2025 07:51:03 +0000 (08:51 +0100)] 
vfio: Move vfio_kvm_device_add/del_fd() to helpers.c

vfio_kvm_device_add/del_fd() are low level routines. Move them with
the other helpers.

Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-18-clg@redhat.com
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-19-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Move vfio_get_info_dma_avail() into helpers.c
Cédric Le Goater [Wed, 26 Mar 2025 07:51:02 +0000 (08:51 +0100)] 
vfio: Move vfio_get_info_dma_avail() into helpers.c

vfio_get_info_dma_avail() is a low level routine similar to the other
routines extracting capabilities from 'struct vfio_iommu_type1_info'.
It belongs to file "helpers.c".

Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-17-clg@redhat.com
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-18-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Introduce a new header file for helper services
Cédric Le Goater [Wed, 26 Mar 2025 07:51:01 +0000 (08:51 +0100)] 
vfio: Introduce a new header file for helper services

Gather all helper routine declarations into "vfio-helpers.h" to reduce
exposure of VFIO internals in "hw/vfio/vfio-common.h".

Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-16-clg@redhat.com
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-17-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Move Host IOMMU type declarations into their respective files
Cédric Le Goater [Wed, 26 Mar 2025 07:51:00 +0000 (08:51 +0100)] 
vfio: Move Host IOMMU type declarations into their respective files

These definitions don't have any use outside of their respective
submodules. There is no need to expose them externally. Keep them
private.

Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-15-clg@redhat.com
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-16-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Move VFIOAddressSpace helpers into container-base.c
Cédric Le Goater [Wed, 26 Mar 2025 07:50:59 +0000 (08:50 +0100)] 
vfio: Move VFIOAddressSpace helpers into container-base.c

VFIOAddressSpace is a common object used by VFIOContainerBase which is
declared in "hw/vfio/vfio-container-base.h". Move the VFIOAddressSpace
related services into "container-base.c".

While at it, rename :

  vfio_get_address_space -> vfio_address_space_get
  vfio_put_address_space -> vfio_address_space_put

to better reflect the namespace these routines belong to.

Reviewed-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-15-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Make vfio_group_list static
Cédric Le Goater [Wed, 26 Mar 2025 07:50:58 +0000 (08:50 +0100)] 
vfio: Make vfio_group_list static

vfio_group_list is only used in file "container.c".

Reviewed-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-13-clg@redhat.com
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-14-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Introduce a new header file for VFIOcontainer declarations
Cédric Le Goater [Wed, 26 Mar 2025 07:50:57 +0000 (08:50 +0100)] 
vfio: Introduce a new header file for VFIOcontainer declarations

Gather all VFIOcontainer related declarations into
"hw/vfio/vfio-container.h" to reduce exposure of VFIO internals in
"hw/vfio/vfio-common.h". These declarations were initially introduced
in commit 65501a745dba ("vfio: vfio-pci device assignment driver").
They are made available externally for PPC and s390x.

Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-12-clg@redhat.com
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-13-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Introduce new files for VFIORegion definitions and declarations
Cédric Le Goater [Wed, 26 Mar 2025 07:50:56 +0000 (08:50 +0100)] 
vfio: Introduce new files for VFIORegion definitions and declarations

Gather all VFIORegion related declarations and definitions into their
own files to reduce exposure of VFIO internals in "hw/vfio/vfio-common.h".
They were introduced for 'vfio-platform' support in commits
db0da029a185 ("vfio: Generalize region support") and a664477db8da
("hw/vfio/pci: Introduce VFIORegion").

To be noted that the 'vfio-platform' devices have been deprecated and
will be removed in QEMU 10.2. Until then, make the declarations
available externally for 'sysbus-fdt.c'.

Cc: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-12-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Introduce a new header file for VFIOIOMMUFD declarations
Cédric Le Goater [Wed, 26 Mar 2025 07:50:55 +0000 (08:50 +0100)] 
vfio: Introduce a new header file for VFIOIOMMUFD declarations

Gather all VFIOIOMMUFD related declarations introduced by commits
5ee3dc7af785 ("vfio/iommufd: Implement the iommufd backend") and
5b1e96e65403 ("vfio/iommufd: Introduce auto domain creation") into
"vfio-iommufd.h". This to reduce exposure of VFIO internals in
"hw/vfio/vfio-common.h".

Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Yi Liu <yi.l.liu@intel.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-10-clg@redhat.com
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-11-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Move VFIOHostDMAWindow definition into spapr.c
Cédric Le Goater [Wed, 26 Mar 2025 07:50:54 +0000 (08:50 +0100)] 
vfio: Move VFIOHostDMAWindow definition into spapr.c

VFIOHostDMAWindow is only used in file "spapr.c". Move it there.

Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-9-clg@redhat.com
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-10-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Introduce a new header file for VFIOdisplay declarations
Cédric Le Goater [Wed, 26 Mar 2025 07:50:53 +0000 (08:50 +0100)] 
vfio: Introduce a new header file for VFIOdisplay declarations

Gather all VFIOdisplay related declarations into "vfio-display.h" to
reduce exposure of VFIO internals in "hw/vfio/vfio-common.h".

Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-8-clg@redhat.com
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-9-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Move vfio_device_state_is_running/precopy() into migration.c
Cédric Le Goater [Wed, 26 Mar 2025 07:50:52 +0000 (08:50 +0100)] 
vfio: Move vfio_device_state_is_running/precopy() into migration.c

These routines are migration related. Move their declaration and
implementation under the migration files.

Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-8-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Introduce a new header file for internal migration services
Cédric Le Goater [Wed, 26 Mar 2025 07:50:51 +0000 (08:50 +0100)] 
vfio: Introduce a new header file for internal migration services

Gather all VFIO migration related declarations into
"vfio-migration-internal.h" to reduce exposure of VFIO internals in
"hw/vfio/vfio-common.h".

Cc: Kirti Wankhede <kwankhede@nvidia.com>
Cc: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Reviewed-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-7-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Make vfio_viommu_preset() static
Cédric Le Goater [Wed, 26 Mar 2025 07:50:50 +0000 (08:50 +0100)] 
vfio: Make vfio_viommu_preset() static

This routine is only used in file "migration.c". Move it there.

Reviewed-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-6-clg@redhat.com
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-6-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Make vfio_un/block_multiple_devices_migration() static
Cédric Le Goater [Wed, 26 Mar 2025 07:50:49 +0000 (08:50 +0100)] 
vfio: Make vfio_un/block_multiple_devices_migration() static

Both of these routines are only used in file "migration.c". Move them
there.

Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-5-clg@redhat.com
Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-5-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Introduce a new header file for external migration services
Cédric Le Goater [Wed, 26 Mar 2025 07:50:48 +0000 (08:50 +0100)] 
vfio: Introduce a new header file for external migration services

The migration core subsystem makes use of the VFIO migration API to
collect statistics on the number of bytes transferred. These services
are declared in "hw/vfio/vfio-common.h" which also contains VFIO
internal declarations. Move the migration declarations into a new
header file "hw/vfio/vfio-migration.h" to reduce the exposure of VFIO
internals.

While at it, use a 'vfio_migration_' prefix for these services.

To be noted, vfio_migration_add_bytes_transferred() is a VFIO
migration internal service which we will be moved in the subsequent
patches.

Cc: Kirti Wankhede <kwankhede@nvidia.com>
Cc: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Reviewed-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-4-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Rename vfio_reset_bytes_transferred()
Cédric Le Goater [Wed, 26 Mar 2025 07:50:47 +0000 (08:50 +0100)] 
vfio: Rename vfio_reset_bytes_transferred()

Enforce a 'vfio_mig_' prefix for the VFIO migration API to better
reflect the namespace these routines belong to.

Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-3-clg@redhat.com
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-3-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Move vfio_mig_active() into migration.c
Cédric Le Goater [Wed, 26 Mar 2025 07:50:46 +0000 (08:50 +0100)] 
vfio: Move vfio_mig_active() into migration.c

vfio_mig_active() is part of the VFIO migration API. Move the
definitions where VFIO migration is implemented.

Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-2-clg@redhat.com
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-2-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio/spapr: Fix L2 crash with PCI device passthrough and memory > 128G
Amit Machhiwal [Tue, 8 Apr 2025 12:40:42 +0000 (18:10 +0530)] 
vfio/spapr: Fix L2 crash with PCI device passthrough and memory > 128G

An L2 KVM guest fails to boot inside a pSeries LPAR when booted with a
memory more than 128 GB and PCI device passthrough. The L2 guest also
crashes when it is booted with a memory greater than 128 GB and a PCI
device is hotplugged later.

The issue arises from a conditional check for `levels > 1` in
`spapr_tce_create_table()` within L1 KVM. This check is meant to prevent
multi-level TCEs, which are not supported by the PowerVM hypervisor. As
a result, when QEMU makes a `VFIO_IOMMU_SPAPR_TCE_CREATE` ioctl call
with `levels > 1`, it triggers the conditional check and returns
`EINVAL`, causing the guest to crash with the following errors:

 2025-03-04T06:36:36.133117Z qemu-system-ppc64: Failed to create a window, ret = -1 (Invalid argument)
 2025-03-04T06:36:36.133176Z qemu-system-ppc64: Failed to create SPAPR window: Invalid argument
 qemu: hardware error: vfio: DMA mapping failed, unable to continue

Fix this by checking the supported DDW "levels" returned by the
VFIO_IOMMU_SPAPR_TCE_GET_INFO ioctl before attempting the TCE create
ioctl in KVM.

The patch has been tested on KVM guests with memory configurations of up
to 390GB, and 450GB on PowerVM and bare-metal environments respectively.

Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250408124042.2695955-3-amachhiw@linux.ibm.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio/spapr: Enhance error handling in vfio_spapr_create_window()
Amit Machhiwal [Tue, 8 Apr 2025 12:40:41 +0000 (18:10 +0530)] 
vfio/spapr: Enhance error handling in vfio_spapr_create_window()

Introduce an Error ** parameter to vfio_spapr_create_window() to enable
structured error reporting. This allows the function to propagate
detailed errors back to callers.

Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250408124042.2695955-2-amachhiw@linux.ibm.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio: Open code vfio_migration_set_error()
Cédric Le Goater [Mon, 24 Mar 2025 12:33:15 +0000 (13:33 +0100)] 
vfio: Open code vfio_migration_set_error()

VFIO uses migration_file_set_error() in a couple of places where an
'Error **' parameter is not provided. In MemoryListener handlers :

  vfio_listener_region_add
  vfio_listener_log_global_stop
  vfio_listener_log_sync

and in callback routines for IOMMU notifiers :

  vfio_iommu_map_notify
  vfio_iommu_map_dirty_notify

Hopefully, one day, we will be able to extend these callbacks with an
'Error **' parameter and avoid setting the global migration error.
Until then, it seems sensible to clearly identify the use cases, which
are limited, and open code vfio_migration_set_error(). One other
benefit is an improved error reporting when migration is running.

While at it, slightly modify error reporting to only report errors
when migration is not active and not always as is currently done.

Cc: Prasad Pandit <pjp@fedoraproject.org>
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Link: https://lore.kernel.org/qemu-devel/20250324123315.637827-1-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agovfio/igd: Update IGD passthrough documentation
Tomita Moeko [Thu, 13 Mar 2025 15:03:39 +0000 (23:03 +0800)] 
vfio/igd: Update IGD passthrough documentation

A previous change made the OpRegion and LPC quirks independent of the
existing legacy mode, update the documentation accordingly. More related
topics, like creating EFI Option ROM of IGD for OVMF, how to solve the
VFIO_DMA_MAP Invalid Argument warning, as well as details on IGD memory
internals, are also added.

Signed-off-by: Tomita Moeko <tomitamoeko@gmail.com>
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250313150339.358621-1-tomitamoeko@gmail.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
7 weeks agoMerge tag 'pull-misc-2025-04-24' of https://repo.or.cz/qemu/armbru into staging
Stefan Hajnoczi [Thu, 24 Apr 2025 17:44:57 +0000 (13:44 -0400)] 
Merge tag 'pull-misc-2025-04-24' of https://repo.or.cz/qemu/armbru into staging

Miscellaneous patches for 2025-04-24

# -----BEGIN PGP SIGNATURE-----
#
# iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmgJ7dYSHGFybWJydUBy
# ZWRoYXQuY29tAAoJEDhwtADrkYZTiZIP/1PFAg/s3SoiLQwH/ZrjyUkm1kiKnjOH
# CC5Stw6I9tuYnDAhASAdSymofLv0NNydNe5ai6ZZAWRyRYjIcfNigKAGK4Di+Uhe
# nYxT0Yk8hNGwMhl6NnBp4mmCUNCwcbjT9uXdiYQxFYO/qqYR1388xJjeN3c362l3
# AaLrE5bX5sqa6TAkTeRPjeIqxlyGT7jnCrN7I1hMhDvbc3ITF3AMfYFMjnmAQgr+
# mTWGS1QogqqkloODbR1DKD1CAWOlpK+0HibhNF+lz71P0HlwVvy+HPXso505Wf0B
# dMwlSrZ1DnqNVF/y5IhMEMslahKajbjbFVhBjmrGl/8T821etCxxgB20c0vyFRy8
# qTyJGwBZaEo0VWr70unSmq45TRoeQvdHAw/e+GtilR0ci80q2ly4gbObnw7L8le+
# gqZo4IWmrwp2sbPepE57sYKQpEndwbRayf/kcFd0LPPpeINu9ZooXkYX0pOo6Cdg
# vDKMaEB1/fmPhjSlknxkKN9LZdR+nDw8162S1CKsUdWanAOjmP8haN19aoHhIekZ
# q+r2qUq/U827yNy9/qbInmsoFYDz9s6sAOE63jibd5rZZ9Anei6NOSgLzA4CqCR1
# +d0+TXp19gP9mLMFs7/ZclwkXCz47OQYhXYphjI3wM9x+xbdRcI4n+DOH5u5coKx
# AsA6+2n0GF4Y
# =GaoH
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 24 Apr 2025 03:52:54 EDT
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* tag 'pull-misc-2025-04-24' of https://repo.or.cz/qemu/armbru:
  cleanup: Drop pointless label at end of function
  cleanup: Drop pointless return at end of function
  cleanup: Re-run return_directly.cocci

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 weeks agoMerge tag 'pull-loongarch-20250424' of https://github.com/gaosong715/qemu into staging
Stefan Hajnoczi [Thu, 24 Apr 2025 17:44:39 +0000 (13:44 -0400)] 
Merge tag 'pull-loongarch-20250424' of https://github.com/gaosong715/qemu into staging

pull-loongarch-20230424

# -----BEGIN PGP SIGNATURE-----
#
# iLMEAAEKAB0WIQS4/x2g0v3LLaCcbCxAov/yOSY+3wUCaAmmRQAKCRBAov/yOSY+
# 3yZoA/4udi9ZmLsaiPqfKCS+0eF8XScIT493lVD359lFTBTT7mshh9PPhTLzdtiC
# 8fcfYi7jSjfC9gGTjPgnNCOzKIg3Gbdl61AFDgIwd8q/5HQAgonHAywTUtmqDaPK
# bXZ/JkkJQby2dla6015XKQS/d/EXWHgYjrcb1JZIRoaLworZPw==
# =zBCJ
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 23 Apr 2025 22:47:33 EDT
# gpg:                using RSA key B8FF1DA0D2FDCB2DA09C6C2C40A2FFF239263EDF
# gpg: Good signature from "Song Gao <m17746591750@163.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: B8FF 1DA0 D2FD CB2D A09C  6C2C 40A2 FFF2 3926 3EDF

* tag 'pull-loongarch-20250424' of https://github.com/gaosong715/qemu:
  target/loongarch: Guard BCEQZ/BCNEZ instructions with FP feature
  target/loongarch: Add CRC feature flag and use it to gate CRC instructions
  linux-user/loongarch64: Decode BRK break codes for FPE signals
  target/loongarch: Move definition of TCG specified function to tcg directory
  target/loongarch: Add static definition with function loongarch_tlb_search()
  target/loongarch: Move function loongarch_tlb_search to directory tcg
  target/loongarch: Define function loongarch_get_addr_from_tlb() non-static
  target/loongarch: Set function loongarch_map_address() with common code
  target/loongarch: Add stub function loongarch_get_addr_from_tlb
  target/loongarch: Move function get_dir_base_width to common directory
  target/loongarch: Add function loongarch_get_addr_from_tlb
  target/loongarch: Move header file helper.h to directory tcg
  hw/intc/loongarch_pch_msi: Remove gpio input handler

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 weeks agoMerge tag 'pull-tcg-20250423' of https://gitlab.com/rth7680/qemu into staging
Stefan Hajnoczi [Thu, 24 Apr 2025 17:44:28 +0000 (13:44 -0400)] 
Merge tag 'pull-tcg-20250423' of https://gitlab.com/rth7680/qemu into staging

meson: Introduce top-level libuser_ss and libsystem_ss
meson: Add hw_common_arch dictionary
accel/tcg: Lots of cleanups to enable build once for:
    user-exec-stub.c,
    plugin-gen.c,
    translator.c
page-vary: Restrict scope of TARGET_PAGE_BITS_MIN
tcg: Always define TARGET_INSN_START_EXTRA_WORDS
tcg: Convert TARGET_GUEST_DEFAULT_MO to TCGCPUOps::guest_default_memory_order
tcg: Convert TARGET_SUPPORTS_MTTCG to TCGCPUOps::mttcg_supported field
target/riscv: Do not expose rv128 CPU on user mode emulation

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmgJikUdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+t0gf9E9OWD3oQ7NIl+azS
# imEFCKwuDxR0g07fH0aM9DW6e01mPQjxe3bmfxuYZbGUu0aJ/WzTbzfkX4qAiPeV
# S32e5wwuYOknzDgoI9r8QTFUdelvBgxtVbxyZWJcWZFbLu4oPUhVUvpLJTWaxefo
# VUL0g1LgJEYcWnzKFerb9kuiMXeDLsMd4eEX9g4XMAclHEDihND0hPKc3X7sYsmX
# N/MtZUY1Zth0c53aq7bP5MBwNIH3tH3o+xAFcBhxiBQ/HxfX7qeNgOTIKo92ApfL
# xcQul1AA/q9uQhCKsgfCxZDU4BhcR6sfmCOiDiTTEs+4zlWVDWjWwYtoednhf7ok
# v3l9+A==
# =qyvX
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 23 Apr 2025 20:48:05 EDT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* tag 'pull-tcg-20250423' of https://gitlab.com/rth7680/qemu: (148 commits)
  tcg: Convert TARGET_SUPPORTS_MTTCG to TCGCPUOps::mttcg_supported field
  target/i386: Remove AccelCPUClass::cpu_class_init need
  target/riscv: Remove AccelCPUClass::cpu_class_init need
  accel/tcg: Move mttcg warning to tcg_init_machine
  tcg: Convert TCGState::mttcg_enabled to TriState
  accel/tcg: Remove mttcg_enabled
  tcg: Move qemu_tcg_mttcg_enabled() to 'system/tcg.h'
  tcg: Pass max_threads not max_cpus to tcg_init
  tcg: Move cpu_req_mo() macro to target-agnostic 'backend-ldst.h'
  tcg: Remove the TCG_GUEST_DEFAULT_MO definition globally
  tcg: Have tcg_req_mo() use TCGCPUOps::guest_default_memory_order
  tcg: Propagate CPUState argument to cpu_req_mo()
  tcg: Remove use of TCG_GUEST_DEFAULT_MO in tb_gen_code()
  tcg: Define guest_default_memory_order in TCGCPUOps
  tcg: Simplify tcg_req_mo() macro
  tcg: Always define TCG_GUEST_DEFAULT_MO
  exec: Do not include 'accel/tcg/cpu-ldst.h' in 'exec-all.h'
  exec: Restrict 'cpu_ldst.h' to accel/tcg/
  exec: Restrict 'cpu-ldst-common.h' to accel/tcg/
  tcg: Always define TARGET_INSN_START_EXTRA_WORDS
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7 weeks agocleanup: Drop pointless label at end of function
Markus Armbruster [Mon, 7 Apr 2025 08:26:43 +0000 (10:26 +0200)] 
cleanup: Drop pointless label at end of function

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Corey Minyard <cminyard@mvista.com>
Message-ID: <20250407082643.2310002-4-armbru@redhat.com>

7 weeks agocleanup: Drop pointless return at end of function
Markus Armbruster [Mon, 7 Apr 2025 08:26:42 +0000 (10:26 +0200)] 
cleanup: Drop pointless return at end of function

A few functions now end with a label.  The next commit will clean them
up.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250407082643.2310002-3-armbru@redhat.com>
[Straightforward conflict with commit 988ad4ccebb6 (hw/loongarch/virt:
Fix cpuslot::cpu set at last in virt_cpu_plug()) resolved]

7 weeks agocleanup: Re-run return_directly.cocci
Markus Armbruster [Mon, 7 Apr 2025 08:26:41 +0000 (10:26 +0200)] 
cleanup: Re-run return_directly.cocci

Coccinelle's indentation of virt_create_plic() results in a long line.
Avoid that by mimicking the old indentation manually.

Don't touch tests/tcg/mips/user/.  I'm not sure these files are ours
to make style cleanups on.  They might be imported third-party code,
which we should leave as is to not complicate future updates.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250407082643.2310002-2-armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7 weeks agotarget/loongarch: Guard BCEQZ/BCNEZ instructions with FP feature
WANG Rui [Fri, 18 Apr 2025 08:21:02 +0000 (16:21 +0800)] 
target/loongarch: Guard BCEQZ/BCNEZ instructions with FP feature

The BCEQZ and BCNEZ instructions depend on access to condition codes
from floating-point comparisons. Previously, these instructions were
unconditionally enabled for 64-bit targets.

This patch updates their translation to be gated under the `FP` feature
flag instead, ensuring they are only available when the floating-point
unit is present.

This improves correctness for CPUs lacking floating-point support.

Signed-off-by: WANG Rui <wangrui@loongson.cn>
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Message-Id: <20250418082103.447780-3-wangrui@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
7 weeks agotarget/loongarch: Add CRC feature flag and use it to gate CRC instructions
WANG Rui [Fri, 18 Apr 2025 08:21:01 +0000 (16:21 +0800)] 
target/loongarch: Add CRC feature flag and use it to gate CRC instructions

This patch replaces the obsolete IOCSR_BRD bit with CRC in cpucfg1[25],
in both LA464 and LA132 CPU initialization functions. The corresponding
field macro in `cpu.h` is updated to reflect this change.

Additionally, the availability macro `avail_CRC()` is introduced in
`translate.h` to check the CRC feature flag.

All CRC-related instruction translations are updated to be gated by
the new CRC feature flag instead of hardcoded CPU features.

This ensures correctness and configurability when enabling CRC
instructions based on hardware capabilities.

Signed-off-by: WANG Rui <wangrui@loongson.cn>
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250418082103.447780-2-wangrui@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
7 weeks agolinux-user/loongarch64: Decode BRK break codes for FPE signals
WANG Rui [Mon, 14 Apr 2025 07:49:52 +0000 (15:49 +0800)] 
linux-user/loongarch64: Decode BRK break codes for FPE signals

Handle specific LoongArch BRK break codes in user-mode emulation
to deliver accurate floating-point exception signals. Specifically,
BRK_OVERFLOW (6) triggers TARGET_FPE_INTOVF, and BRK_DIVZERO (7)
triggers TARGET_FPE_INTDIV. Other BRK codes fall back to a generic
SIGTRAP.

This improves correctness for programs that rely on BRK to signal
overflow or divide-by-zero conditions.

Signed-off-by: WANG Rui <wangrui@loongson.cn>
Acked-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20250414074952.6253-1-wangrui@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
7 weeks agotarget/loongarch: Move definition of TCG specified function to tcg directory
Bibo Mao [Wed, 23 Apr 2025 08:04:17 +0000 (16:04 +0800)] 
target/loongarch: Move definition of TCG specified function to tcg directory

Function loongarch_cpu_tlb_fill() only works in TCG mode, move its
definition from header file internals.h to file tcg/tcg_loongarch.h

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250423080417.3739809-10-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
7 weeks agotarget/loongarch: Add static definition with function loongarch_tlb_search()
Bibo Mao [Wed, 23 Apr 2025 08:04:16 +0000 (16:04 +0800)] 
target/loongarch: Add static definition with function loongarch_tlb_search()

Function loongarch_tlb_search() is only referenced in file tcg/tlb_helper.c,
define this function with static attribution.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250423080417.3739809-9-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
7 weeks agotarget/loongarch: Move function loongarch_tlb_search to directory tcg
Bibo Mao [Wed, 23 Apr 2025 08:04:15 +0000 (16:04 +0800)] 
target/loongarch: Move function loongarch_tlb_search to directory tcg

Function loongarch_tlb_search() and loongarch_map_tlb_entry() works
only in TCG mode, move these functions to directory tcg.

There is no any function change, only code moving.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250423080417.3739809-8-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
7 weeks agotarget/loongarch: Define function loongarch_get_addr_from_tlb() non-static
Bibo Mao [Wed, 23 Apr 2025 08:04:14 +0000 (16:04 +0800)] 
target/loongarch: Define function loongarch_get_addr_from_tlb() non-static

Define function loongarch_get_addr_from_tlb() non-static, and add its
definition in header file tcg/tcg_loongarch.h

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250423080417.3739809-7-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
7 weeks agotarget/loongarch: Set function loongarch_map_address() with common code
Bibo Mao [Wed, 23 Apr 2025 08:04:13 +0000 (16:04 +0800)] 
target/loongarch: Set function loongarch_map_address() with common code

Function loongarch_map_address is to get physical address from virtual
address, it is used by qmp commands to dump memory from virtual
address.

It is used by kvm mode also, here move function loongarch_map_address()
out of macro CONFIG_TCG. And it is common code, the similar with
function loongarch_page_table_walker().

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250423080417.3739809-6-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
7 weeks agotarget/loongarch: Add stub function loongarch_get_addr_from_tlb
Bibo Mao [Wed, 23 Apr 2025 08:04:12 +0000 (16:04 +0800)] 
target/loongarch: Add stub function loongarch_get_addr_from_tlb

Stub function loongarch_get_addr_from_tlb() is added if option
CONFIG_TCG is not enabled, so this function can be called in KVM
only mode.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250423080417.3739809-5-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
7 weeks agotarget/loongarch: Move function get_dir_base_width to common directory
Bibo Mao [Wed, 23 Apr 2025 08:04:11 +0000 (16:04 +0800)] 
target/loongarch: Move function get_dir_base_width to common directory

Function get_dir_base_width() is used by loongarch_page_table_walker(),
so it is used by KVM mode also, here move this function from directory
tcg to common directory.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250423080417.3739809-4-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
7 weeks agotarget/loongarch: Add function loongarch_get_addr_from_tlb
Bibo Mao [Wed, 23 Apr 2025 08:04:10 +0000 (16:04 +0800)] 
target/loongarch: Add function loongarch_get_addr_from_tlb

Function loongarch_get_addr_from_tlb() is added to get physical address
from TLB tables. TLB table only works in TCG mode, in future this
function will be moved to TCG directory.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250423080417.3739809-3-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
7 weeks agotarget/loongarch: Move header file helper.h to directory tcg
Bibo Mao [Wed, 23 Apr 2025 08:04:09 +0000 (16:04 +0800)] 
target/loongarch: Move header file helper.h to directory tcg

Header file helper.h is specified for tcg mode, move this file to
directory tcg. And create new file helper.h to include header
file in tcg mode.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250423080417.3739809-2-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
7 weeks agohw/intc/loongarch_pch_msi: Remove gpio input handler
Bibo Mao [Thu, 10 Apr 2025 08:50:04 +0000 (16:50 +0800)] 
hw/intc/loongarch_pch_msi: Remove gpio input handler

MSI interrupt is triggered by writing message on specified memory address.
In generic it is used by PCI devices, and no device is connected pch MSI
irqchip with GPIO pin line method, here remove gpio input setting for MSI
controller.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
Tested-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20250410085004.3577627-1-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
7 weeks agotcg: Convert TARGET_SUPPORTS_MTTCG to TCGCPUOps::mttcg_supported field
Philippe Mathieu-Daudé [Sat, 5 Apr 2025 16:13:20 +0000 (18:13 +0200)] 
tcg: Convert TARGET_SUPPORTS_MTTCG to TCGCPUOps::mttcg_supported field

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

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250405161320.76854-17-philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotarget/i386: Remove AccelCPUClass::cpu_class_init need
Philippe Mathieu-Daudé [Sat, 5 Apr 2025 16:13:06 +0000 (18:13 +0200)] 
target/i386: Remove AccelCPUClass::cpu_class_init need

Expose x86_tcg_ops symbol, then directly set it as
CPUClass::tcg_ops in TYPE_X86_CPU's class_init(),
using CONFIG_TCG #ifdef'ry. No need for the
AccelCPUClass::cpu_class_init() handler anymore.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250405161320.76854-3-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotarget/riscv: Remove AccelCPUClass::cpu_class_init need
Philippe Mathieu-Daudé [Sat, 5 Apr 2025 16:13:05 +0000 (18:13 +0200)] 
target/riscv: Remove AccelCPUClass::cpu_class_init need

Expose riscv_tcg_ops symbol, then directly set it as
CPUClass::tcg_ops in TYPE_RISCV_CPU's class_init(),
using CONFIG_TCG #ifdef'ry. No need for the
AccelCPUClass::cpu_class_init() handler anymore.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250405161320.76854-2-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agoaccel/tcg: Move mttcg warning to tcg_init_machine
Richard Henderson [Sat, 5 Apr 2025 01:52:36 +0000 (18:52 -0700)] 
accel/tcg: Move mttcg warning to tcg_init_machine

Delay the warning to tcg_init_machine, because we will
have resolved the CPUClass at that point.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Convert TCGState::mttcg_enabled to TriState
Philippe Mathieu-Daudé [Wed, 2 Apr 2025 14:48:24 +0000 (16:48 +0200)] 
tcg: Convert TCGState::mttcg_enabled to TriState

Use the OnOffAuto type as 3-state.

Since the TCGState instance is zero-initialized, the
mttcg_enabled is initialzed as AUTO (ON_OFF_AUTO_AUTO).

In tcg_init_machine(), if mttcg_enabled is still AUTO,
set a default value (effectively inlining the
default_mttcg_enabled() method content).

In the tcg_get_thread() getter, consider AUTO / OFF states
as "single", otherwise ON is "multi".

Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agoaccel/tcg: Remove mttcg_enabled
Richard Henderson [Sat, 5 Apr 2025 01:10:53 +0000 (18:10 -0700)] 
accel/tcg: Remove mttcg_enabled

In qemu_tcg_mttcg_enabled, read the value from TCGState
and eliminate the separate global variable.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Move qemu_tcg_mttcg_enabled() to 'system/tcg.h'
Philippe Mathieu-Daudé [Thu, 3 Apr 2025 22:04:16 +0000 (00:04 +0200)] 
tcg: Move qemu_tcg_mttcg_enabled() to 'system/tcg.h'

qemu_tcg_mttcg_enabled() is specific to 1/ TCG and
2/ system emulation. Move the prototype declaration
to "system/tcg.h", reducing 'mttcg_enabled' variable
scope.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250403220420.78937-17-philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Pass max_threads not max_cpus to tcg_init
Richard Henderson [Fri, 4 Apr 2025 23:30:57 +0000 (16:30 -0700)] 
tcg: Pass max_threads not max_cpus to tcg_init

In effect, hoist the check for mttcg from tcg_n_regions()
to tcg_init_machine().

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Move cpu_req_mo() macro to target-agnostic 'backend-ldst.h'
Philippe Mathieu-Daudé [Sun, 23 Mar 2025 17:45:29 +0000 (18:45 +0100)] 
tcg: Move cpu_req_mo() macro to target-agnostic 'backend-ldst.h'

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Remove the TCG_GUEST_DEFAULT_MO definition globally
Philippe Mathieu-Daudé [Fri, 21 Mar 2025 18:02:35 +0000 (19:02 +0100)] 
tcg: Remove the TCG_GUEST_DEFAULT_MO definition globally

By directly using TCGCPUOps::guest_default_memory_order,
we don't need the TCG_GUEST_DEFAULT_MO definition anymore.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Have tcg_req_mo() use TCGCPUOps::guest_default_memory_order
Philippe Mathieu-Daudé [Fri, 21 Mar 2025 11:18:26 +0000 (12:18 +0100)] 
tcg: Have tcg_req_mo() use TCGCPUOps::guest_default_memory_order

In order to use TCG with multiple targets, replace the
compile time use of TCG_GUEST_DEFAULT_MO by a runtime access
to TCGCPUOps::guest_default_memory_order via CPUState.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Propagate CPUState argument to cpu_req_mo()
Philippe Mathieu-Daudé [Fri, 21 Mar 2025 17:52:37 +0000 (18:52 +0100)] 
tcg: Propagate CPUState argument to cpu_req_mo()

In preparation of having tcg_req_mo() access CPUState in
the next commit, pass it to cpu_req_mo(), its single caller.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Remove use of TCG_GUEST_DEFAULT_MO in tb_gen_code()
Philippe Mathieu-Daudé [Fri, 21 Mar 2025 18:05:31 +0000 (19:05 +0100)] 
tcg: Remove use of TCG_GUEST_DEFAULT_MO in tb_gen_code()

Use TCGCPUOps::guest_default_memory_order to set TCGContext::guest_mo.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Define guest_default_memory_order in TCGCPUOps
Philippe Mathieu-Daudé [Fri, 21 Mar 2025 18:01:52 +0000 (19:01 +0100)] 
tcg: Define guest_default_memory_order in TCGCPUOps

Add the TCGCPUOps::guest_default_memory_order field and have
each target initialize it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Simplify tcg_req_mo() macro
Philippe Mathieu-Daudé [Fri, 21 Mar 2025 11:16:28 +0000 (12:16 +0100)] 
tcg: Simplify tcg_req_mo() macro

Now that TCG_GUEST_DEFAULT_MO is always defined,
simplify the tcg_req_mo() macro.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Always define TCG_GUEST_DEFAULT_MO
Philippe Mathieu-Daudé [Fri, 21 Mar 2025 11:10:45 +0000 (12:10 +0100)] 
tcg: Always define TCG_GUEST_DEFAULT_MO

We only require the TCG_GUEST_DEFAULT_MO for MTTCG-enabled
frontends, otherwise we use a default value of TCG_MO_ALL.

In order to simplify, require the definition for all targets,
defining it for hexagon, m68k, rx, sh4 and tricore.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agoexec: Do not include 'accel/tcg/cpu-ldst.h' in 'exec-all.h'
Philippe Mathieu-Daudé [Tue, 1 Apr 2025 08:27:42 +0000 (10:27 +0200)] 
exec: Do not include 'accel/tcg/cpu-ldst.h' in 'exec-all.h'

Only 2 files requiring "accel/tcg/cpu-ldst.h" API do not
include it:
- accel/tcg/cpu-exec.c
- target/arm/tcg/sve_helper.c
Include it there and remove it from "exec/exec-all.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agoexec: Restrict 'cpu_ldst.h' to accel/tcg/
Philippe Mathieu-Daudé [Tue, 1 Apr 2025 08:14:36 +0000 (10:14 +0200)] 
exec: Restrict 'cpu_ldst.h' to accel/tcg/

Mechanical change using:

  $ sed -i -e 's,exec/cpu_ldst,accel/tcg/cpu-ldst,' \
        $(git grep -l exec/cpu_ldst.h)

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agoexec: Restrict 'cpu-ldst-common.h' to accel/tcg/
Philippe Mathieu-Daudé [Tue, 1 Apr 2025 08:13:20 +0000 (10:13 +0200)] 
exec: Restrict 'cpu-ldst-common.h' to accel/tcg/

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Always define TARGET_INSN_START_EXTRA_WORDS
Philippe Mathieu-Daudé [Wed, 19 Mar 2025 11:46:55 +0000 (12:46 +0100)] 
tcg: Always define TARGET_INSN_START_EXTRA_WORDS

Do not define TARGET_INSN_START_EXTRA_WORDS under the
hood, have each target explicitly define it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Declare TARGET_INSN_START_EXTRA_WORDS in 'cpu-param.h'
Philippe Mathieu-Daudé [Wed, 19 Mar 2025 11:46:47 +0000 (12:46 +0100)] 
tcg: Declare TARGET_INSN_START_EXTRA_WORDS in 'cpu-param.h'

To avoid including the huge "cpu.h" for a simple definition,
move TARGET_INSN_START_EXTRA_WORDS to "cpu-param.h".

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotcg: Include missing 'cpu.h' in translate-all.c
Philippe Mathieu-Daudé [Thu, 3 Apr 2025 21:37:54 +0000 (23:37 +0200)] 
tcg: Include missing 'cpu.h' in translate-all.c

tb_check_watchpoint() calls cpu_get_tb_cpu_state(),
which is declared in each "cpu.h" header. It is indirectly
included via "tcg/insn-start-words.h". Since we want to
rework "tcg/insn-start-words.h", removing "cpu.h" in the
next commit, add the missing header now, otherwise we'd
get:

  accel/tcg/translate-all.c:598:9: error: call to undeclared function 'cpu_get_tb_cpu_state' [-Wimplicit-function-declaration]
  598 |         cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);
      |         ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotarget/riscv: Do not expose rv128 CPU on user mode emulation
Philippe Mathieu-Daudé [Wed, 2 Apr 2025 14:37:26 +0000 (15:37 +0100)] 
target/riscv: Do not expose rv128 CPU on user mode emulation

As Richard mentioned:

  We should allow RV128 in user-mode at all until there's a
  kernel abi for it.

Remove the experimental 'x-rv128' CPU on user emulation
(since it is experimental, no deprecation period is required).

Reported-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agohw/arm: make most of the compilation units common
Pierrick Bouvier [Tue, 25 Mar 2025 04:59:14 +0000 (21:59 -0700)] 
hw/arm: make most of the compilation units common

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

7 weeks agohw/arm/xlnx-versal: prepare compilation unit to be common
Pierrick Bouvier [Tue, 25 Mar 2025 04:59:13 +0000 (21:59 -0700)] 
hw/arm/xlnx-versal: prepare compilation unit to be common

Remove kvm unused headers.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250325045915.994760-29-pierrick.bouvier@linaro.org>

7 weeks agohw/arm/xlnx-zynqmp: prepare compilation unit to be common
Pierrick Bouvier [Tue, 25 Mar 2025 04:59:12 +0000 (21:59 -0700)] 
hw/arm/xlnx-zynqmp: prepare compilation unit to be common

Remove kvm unused headers.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250325045915.994760-28-pierrick.bouvier@linaro.org>

7 weeks agohw/arm/digic_boards: prepare compilation unit to be common
Pierrick Bouvier [Tue, 25 Mar 2025 04:59:11 +0000 (21:59 -0700)] 
hw/arm/digic_boards: prepare compilation unit to be common

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

7 weeks agohw/arm/boot: make compilation unit hw common
Pierrick Bouvier [Tue, 25 Mar 2025 04:59:09 +0000 (21:59 -0700)] 
hw/arm/boot: make compilation unit hw common

Now we eliminated poisoned identifiers from headers, this file can now
be compiled once for all arm targets.

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

7 weeks agomeson: add common hw files
Pierrick Bouvier [Tue, 25 Mar 2025 04:59:08 +0000 (21:59 -0700)] 
meson: add common hw files

Those files will be compiled once per base architecture ("arm" in this
case), instead of being compiled for every variant/bitness of
architecture.

We make sure to not include target cpu definitions (exec/cpu-defs.h) by
defining header guard directly. This way, a given compilation unit can
access a specific cpu definition, but not access to compile time defines
associated.

Previous commits took care to clean up some headers to not rely on
cpu-defs.h content.

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

7 weeks agotarget/arm: Expose Aarch64 helpers unconditionally
Philippe Mathieu-Daudé [Thu, 3 Apr 2025 23:58:18 +0000 (01:58 +0200)] 
target/arm: Expose Aarch64 helpers unconditionally

At worst, for 32-bit arm binary, using these methods will
now produce a link time error, instead of a compile time one.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250403235821.9909-37-philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agotarget/arm/cpu: remove inline stubs for aarch32 emulation
Pierrick Bouvier [Tue, 25 Mar 2025 04:59:07 +0000 (21:59 -0700)] 
target/arm/cpu: remove inline stubs for aarch32 emulation

Directly condition associated calls in target/arm/helper.c for now.

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

7 weeks agotarget/arm/cpu: define same set of registers for aarch32 and aarch64
Pierrick Bouvier [Tue, 25 Mar 2025 04:59:06 +0000 (21:59 -0700)] 
target/arm/cpu: define same set of registers for aarch32 and aarch64

To eliminate TARGET_AARCH64, we need to make various definitions common
between 32 and 64 bit Arm targets.
Added registers are used only by aarch64 code, and the only impact is on
the size of CPUARMState, and added zarray
(ARMVectorReg zarray[ARM_MAX_VQ * 16]) member (+64KB)

It could be eventually possible to allocate this array only for aarch64
emulation, but I'm not sure it's worth the hassle to save a few KB per
vcpu. Running qemu-system takes already several hundreds of MB of
(resident) memory, and qemu-user takes dozens of MB of (resident) memory
anyway.

As part of this, we define ARM_MAX_VQ once for aarch32 and aarch64,
which will affect zregs field for aarch32.
This field is used for MVE and SVE implementations. MVE implementation
is clipping index value to 0 or 1 for zregs[*].d[],
so we should not touch the rest of data in this case anyway.

This change is safe regarding migration, because aarch64 registers still
have the same size, and for aarch32, only zregs is modified.
Migration code explicitly specify a size of 2 for env.vfp.zregs[0].d,
VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[0].d, ARMCPU, 0, 2). So extending
the storage size has no impact.

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

7 weeks agotarget/arm/cpu: flags2 is always uint64_t
Pierrick Bouvier [Tue, 25 Mar 2025 04:59:05 +0000 (21:59 -0700)] 
target/arm/cpu: flags2 is always uint64_t

Do not rely on target dependent type, but use a fixed type instead.
Since the original type is unsigned, it is safe to extend its size
without any side effect.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250325045915.994760-21-pierrick.bouvier@linaro.org>

7 weeks agotarget/arm/cpu: always define kvm related registers
Pierrick Bouvier [Tue, 25 Mar 2025 04:59:04 +0000 (21:59 -0700)] 
target/arm/cpu: always define kvm related registers

This does not hurt, even if they are not used.

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

7 weeks agoexec/poison: KVM_HAVE_MCE_INJECTION can now be poisoned
Pierrick Bouvier [Tue, 25 Mar 2025 04:59:03 +0000 (21:59 -0700)] 
exec/poison: KVM_HAVE_MCE_INJECTION can now be poisoned

We prevent common code to use this define by mistake.

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

7 weeks agoaccel/kvm: move KVM_HAVE_MCE_INJECTION define to kvm-all.c
Pierrick Bouvier [Tue, 25 Mar 2025 04:59:02 +0000 (21:59 -0700)] 
accel/kvm: move KVM_HAVE_MCE_INJECTION define to kvm-all.c

This define is used only in accel/kvm/kvm-all.c, so we push directly the
definition there. Add more visibility to kvm_arch_on_sigbus_vcpu() to
allow removing this define from any header.

The architectures defining KVM_HAVE_MCE_INJECTION are i386, x86_64 and
aarch64.

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

7 weeks agoexec/cpu-all: remove this header
Pierrick Bouvier [Tue, 25 Mar 2025 04:59:00 +0000 (21:59 -0700)] 
exec/cpu-all: remove this header

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

7 weeks agoexec/cpu-all: transfer exec/cpu-common include to cpu.h headers
Pierrick Bouvier [Tue, 25 Mar 2025 04:58:59 +0000 (21:58 -0700)] 
exec/cpu-all: transfer exec/cpu-common include to cpu.h headers

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250325045915.994760-15-pierrick.bouvier@linaro.org>

7 weeks agoexec/cpu-all: remove exec/target_page include
Pierrick Bouvier [Mon, 31 Mar 2025 21:40:55 +0000 (16:40 -0500)] 
exec/cpu-all: remove exec/target_page include

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7 weeks agoexec/cpu-all: remove cpu include
Pierrick Bouvier [Tue, 25 Mar 2025 04:58:58 +0000 (21:58 -0700)] 
exec/cpu-all: remove cpu include

Now we made sure important defines are included using their direct
path, we can remove cpu.h from cpu-all.h.

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

7 weeks agoaccel/tcg: fix missing includes for TARGET_HAS_PRECISE_SMC
Pierrick Bouvier [Tue, 25 Mar 2025 04:58:57 +0000 (21:58 -0700)] 
accel/tcg: fix missing includes for TARGET_HAS_PRECISE_SMC

We prepare to remove cpu.h from cpu-all.h, which will transitively
remove it from accel/tcg/tb-internal.h, and thus from most of tcg
compilation units.

Note: this was caught by a test regression for s390x-softmmu.

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

7 weeks agoaccel/tcg: fix missing includes for TCG_GUEST_DEFAULT_MO
Pierrick Bouvier [Tue, 25 Mar 2025 04:58:56 +0000 (21:58 -0700)] 
accel/tcg: fix missing includes for TCG_GUEST_DEFAULT_MO

We prepare to remove cpu.h from cpu-all.h, which will transitively
remove it from accel/tcg/tb-internal.h, and thus from most of tcg
compilation units.

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

7 weeks agoexec/cpu-all: remove exec/cpu-interrupt include
Pierrick Bouvier [Tue, 25 Mar 2025 04:58:52 +0000 (21:58 -0700)] 
exec/cpu-all: remove exec/cpu-interrupt include

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

7 weeks agoexec/cpu-all: remove tswap include
Pierrick Bouvier [Tue, 25 Mar 2025 04:58:51 +0000 (21:58 -0700)] 
exec/cpu-all: remove tswap include

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

7 weeks agoexec/cpu-all: remove exec/page-protection include
Pierrick Bouvier [Tue, 25 Mar 2025 04:58:50 +0000 (21:58 -0700)] 
exec/cpu-all: remove exec/page-protection include

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

7 weeks agoexec/cpu-all: remove system/memory include
Pierrick Bouvier [Tue, 25 Mar 2025 04:58:49 +0000 (21:58 -0700)] 
exec/cpu-all: remove system/memory include

We include this header where needed. When includes set already have
ifdef CONFIG_USER_ONLY, we add it here, else, we don't condition the
include.

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

7 weeks agoinclude/exec/cpu-all: move compile time check for CPUArchState to cpu-target.c
Pierrick Bouvier [Tue, 25 Mar 2025 04:58:48 +0000 (21:58 -0700)] 
include/exec/cpu-all: move compile time check for CPUArchState to cpu-target.c

Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250325045915.994760-4-pierrick.bouvier@linaro.org>

7 weeks agoexec/cpu-all: move cpu_copy to linux-user/qemu.h
Pierrick Bouvier [Tue, 25 Mar 2025 04:58:47 +0000 (21:58 -0700)] 
exec/cpu-all: move cpu_copy to linux-user/qemu.h

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