]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
4 months agoMerge tag 'migration-20240104-pull-request' of https://gitlab.com/peterx/qemu into...
Peter Maydell [Fri, 5 Jan 2024 13:35:25 +0000 (13:35 +0000)]
Merge tag 'migration-20240104-pull-request' of https://gitlab.com/peterx/qemu into staging

migration 1st pull for 9.0

- We lost Juan and Leo in the maintainers file
- Steven's suspend state fix
- Steven's fix for coverity on migrate_mode
- Avihai's migration cleanup series

# -----BEGIN PGP SIGNATURE-----
#
# iIgEABYKADAWIQS5GE3CDMRX2s990ak7X8zN86vXBgUCZZY0TxIccGV0ZXJ4QHJl
# ZGhhdC5jb20ACgkQO1/MzfOr1wbSxgEAoM5g3wkc22lpAlRpU+hJUqT9NVOVQSK+
# Fk7XJYTdSgABAKzykA6hAmU5Kj+yVI6jI874SVZbs2FWpFs4osvsKk4D
# =sfuM
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 04 Jan 2024 04:30:07 GMT
# gpg:                using EDDSA key B9184DC20CC457DACF7DD1A93B5FCCCDF3ABD706
# gpg:                issuer "peterx@redhat.com"
# gpg: Good signature from "Peter Xu <xzpeter@gmail.com>" [unknown]
# gpg:                 aka "Peter Xu <peterx@redhat.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: B918 4DC2 0CC4 57DA CF7D  D1A9 3B5F CCCD F3AB D706

* tag 'migration-20240104-pull-request' of https://gitlab.com/peterx/qemu: (26 commits)
  migration: fix coverity migrate_mode finding
  migration/multifd: Remove unnecessary usage of local Error
  migration: Remove unnecessary usage of local Error
  migration: Fix migration_channel_read_peek() error path
  migration/multifd: Remove error_setg() in migration_ioc_process_incoming()
  migration/multifd: Fix leaking of Error in TLS error flow
  migration/multifd: Simplify multifd_channel_connect() if else statement
  migration/multifd: Fix error message in multifd_recv_initial_packet()
  migration: Remove errp parameter in migration_fd_process_incoming()
  migration: Refactor migration_incoming_setup()
  migration: Remove nulling of hostname in migrate_init()
  migration: Remove migrate_max_downtime() declaration
  tests/qtest: postcopy migration with suspend
  tests/qtest: precopy migration with suspend
  tests/qtest: option to suspend during migration
  tests/qtest: migration events
  migration: preserve suspended for bg_migration
  migration: preserve suspended for snapshot
  migration: preserve suspended runstate
  migration: propagate suspended runstate
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agoMerge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
Peter Maydell [Thu, 4 Jan 2024 19:55:19 +0000 (19:55 +0000)]
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging

* configure: use a native non-cross compiler for linux-user
* meson: cleanups
* target/i386: miscellaneous cleanups and optimizations
* target/i386: implement CMPccXADD
* target/i386: the sgx_epc_get_section stub is reachable
* esp: check for NULL result from scsi_device_find()

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmWRImYUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroNd7AgAgcyJGiMfUkXqhefplpm06RDXQIa8
# FuoJqPb21lO75DQKfaFRAc4xGLagjJROMJGHMm9HvMu2VlwvOydkQlfFRspENxQ/
# 5XzGdb/X0A7HA/mwUfnMB1AZx0Vs32VI5IBSc6acc9fmgeZ84XQEoM3KBQHUik7X
# mSkE4eltR9gJ+4IaGo4voZtK+YoVD8nEcuqmnKihSPWizev0FsZ49aNMtaYa9qC/
# Xs3kiQd/zPibHDHJu0ulFsNZgxtUcvlLHTCf8gO4dHWxCFLXGubMush83McpRtNB
# Qoh6cTLH+PBXfrxMR3zmTZMNvo8Euls3s07Y8TkNP4vdIIE/kMeMDW1wJw==
# =mq30
# -----END PGP SIGNATURE-----
# gpg: Signature made Sun 31 Dec 2023 08:12:22 GMT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (46 commits)
  meson.build: report graphics backends separately
  configure, meson: rename targetos to host_os
  meson: rename config_all
  meson: remove CONFIG_ALL
  meson: remove config_targetos
  meson: remove CONFIG_POSIX and CONFIG_WIN32 from config_targetos
  meson: remove OS definitions from config_targetos
  meson: always probe u2f and canokey if the option is enabled
  meson: move subdirs to "Collect sources" section
  meson: move config-host.h definitions together
  meson: move CFI detection code with other compiler flags
  meson: keep subprojects together
  meson: move accelerator dependency checks together
  meson: move option validation together
  meson: move program checks together
  meson: add more sections to main meson.build
  configure: unify again the case arms in probe_target_compiler
  configure: remove unnecessary subshell
  Makefile: clean qemu-iotests output
  meson: use version_compare() to compare version
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agoMerge tag 'pull-20231230' of https://gitlab.com/rth7680/qemu into staging
Peter Maydell [Thu, 4 Jan 2024 10:23:34 +0000 (10:23 +0000)]
Merge tag 'pull-20231230' of https://gitlab.com/rth7680/qemu into staging

Mark VMStateField and VMStateDescription arrays const.

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmWPOFsdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV8cCQgAnQjy3Ic1i225AElh
# 0Ph3Aiw6WT9pECLoKmyroxHbTGuaEJoIXeaOhMAnowCTBLoKRR3/Ooq0DGOW+l/Z
# f5PwWSkjkb+OcS+dj/kgQBu58/Gk5G8ogksqKQvci8k2okhjHmITSQDu0dtwzDZr
# jVGh3gmGoat73jQyD/nAwgWFawlLkklOMR/yvnFX7EJIBepRVbkMPayoKlB+6W07
# 1kqhSwoI0vQCjhJ3Q7Q0GC4rrHK3KUq7o/25yvICf4EgPKfsaym1wAjDhdKToixl
# 9T+ALZG8SiZZkBlb6l3QZ7pqtqavxYtPdZ2Gx/nMu0RRu4G33d5AVGHRrXj9qttW
# 5mL7ZQ==
# =uQ4C
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 29 Dec 2023 21:21:31 GMT
# 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-20231230' of https://gitlab.com/rth7680/qemu: (71 commits)
  docs: Constify VMstate in examples
  tests/unit/test-vmstate: Constify VMState
  util/fifo8: Constify VMState
  replay: Constify VMState
  system: Constify VMState
  migration: Constify VMState
  cpu-target: Constify VMState
  backends: Constify VMState
  audio: Constify VMState
  hw/misc/macio: Constify VMState
  hw/watchdog: Constify VMState
  hw/virtio: Constify VMState
  hw/vfio: Constify VMState
  hw/usb: Constify VMState
  hw/tpm: Constify VMState
  hw/timer: Constify VMState
  hw/ssi: Constify VMState
  hw/sparc: Constify VMState
  hw/sensor: Constify VMState
  hw/sd: Constify VMState
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 months agomigration: fix coverity migrate_mode finding
Steve Sistare [Mon, 13 Nov 2023 20:23:45 +0000 (12:23 -0800)]
migration: fix coverity migrate_mode finding

Coverity diagnoses a possible out-of-range array index here ...

    static GSList *migration_blockers[MIG_MODE__MAX];

    fill_source_migration_info() {
        GSList *cur_blocker = migration_blockers[migrate_mode()];

... because it does not know that MIG_MODE__MAX will never be returned as
a migration mode.  To fix, assert so in migrate_mode().

Fixes: fa3673e497a1 ("migration: per-mode blockers")
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/1699907025-215450-1-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration/multifd: Remove unnecessary usage of local Error
Avihai Horon [Sun, 31 Dec 2023 09:30:16 +0000 (11:30 +0200)]
migration/multifd: Remove unnecessary usage of local Error

According to Error API, usage of ERRP_GUARD() or a local Error instead
of errp is needed if errp is passed to void functions, where it is later
dereferenced to see if an error occurred.

There are several places in multifd.c that use local Error although it
is not needed. Change these places to use errp directly.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/r/20231231093016.14204-12-avihaih@nvidia.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration: Remove unnecessary usage of local Error
Avihai Horon [Sun, 31 Dec 2023 09:30:15 +0000 (11:30 +0200)]
migration: Remove unnecessary usage of local Error

According to Error API, usage of ERRP_GUARD() or a local Error instead
of errp is needed if errp is passed to void functions, where it is later
dereferenced to see if an error occurred.

There are several places in migration.c that use local Error although it
is not needed. Change these places to use errp directly.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20231231093016.14204-11-avihaih@nvidia.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration: Fix migration_channel_read_peek() error path
Avihai Horon [Sun, 31 Dec 2023 09:30:14 +0000 (11:30 +0200)]
migration: Fix migration_channel_read_peek() error path

migration_channel_read_peek() calls qio_channel_readv_full() and handles
both cases of return value == 0 and return value < 0 the same way, by
calling error_setg() with errp. However, if return value < 0, errp is
already set, so calling error_setg() with errp will lead to an assert.

Fix it by handling these cases separately, calling error_setg() with
errp only in return value == 0 case.

Fixes: 6720c2b32725 ("migration: check magic value for deciding the mapping of channels")
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/r/20231231093016.14204-10-avihaih@nvidia.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration/multifd: Remove error_setg() in migration_ioc_process_incoming()
Avihai Horon [Sun, 31 Dec 2023 09:30:13 +0000 (11:30 +0200)]
migration/multifd: Remove error_setg() in migration_ioc_process_incoming()

If multifd_load_setup() fails in migration_ioc_process_incoming(),
error_setg() is called with errp. This will lead to an assert because in
that case errp already contains an error.

Fix it by removing the redundant error_setg().

Fixes: 6720c2b32725 ("migration: check magic value for deciding the mapping of channels")
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20231231093016.14204-9-avihaih@nvidia.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration/multifd: Fix leaking of Error in TLS error flow
Avihai Horon [Sun, 31 Dec 2023 09:30:12 +0000 (11:30 +0200)]
migration/multifd: Fix leaking of Error in TLS error flow

If there is an error in multifd TLS handshake task,
multifd_tls_outgoing_handshake() retrieves the error with
qio_task_propagate_error() but never frees it.

Fix it by freeing the obtained Error.

In addition, the error is not reported at all, so report it with
migrate_set_error().

Fixes: 29647140157a ("migration/tls: add support for multifd tls-handshake")
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20231231093016.14204-8-avihaih@nvidia.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration/multifd: Simplify multifd_channel_connect() if else statement
Avihai Horon [Sun, 31 Dec 2023 09:30:11 +0000 (11:30 +0200)]
migration/multifd: Simplify multifd_channel_connect() if else statement

The else branch in multifd_channel_connect() is redundant because when
the if branch is taken the function returns.

Simplify the code by removing the else branch.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/r/20231231093016.14204-7-avihaih@nvidia.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration/multifd: Fix error message in multifd_recv_initial_packet()
Avihai Horon [Sun, 31 Dec 2023 09:30:10 +0000 (11:30 +0200)]
migration/multifd: Fix error message in multifd_recv_initial_packet()

In multifd_recv_initial_packet(), if MultiFDInit_t->id is greater than
the configured number of multifd channels, an irrelevant error message
about multifd version is printed.

Change the error message to a relevant one about the channel id.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20231231093016.14204-6-avihaih@nvidia.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration: Remove errp parameter in migration_fd_process_incoming()
Avihai Horon [Sun, 31 Dec 2023 09:30:09 +0000 (11:30 +0200)]
migration: Remove errp parameter in migration_fd_process_incoming()

Errp parameter in migration_fd_process_incoming() is unused.
Remove it.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20231231093016.14204-5-avihaih@nvidia.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration: Refactor migration_incoming_setup()
Avihai Horon [Sun, 31 Dec 2023 09:30:08 +0000 (11:30 +0200)]
migration: Refactor migration_incoming_setup()

Commit 6720c2b32725 ("migration: check magic value for deciding the
mapping of channels") extracted the only code that could fail in
migration_incoming_setup().

Now migration_incoming_setup() can't fail, so refactor it to return void
and remove errp parameter.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/r/20231231093016.14204-4-avihaih@nvidia.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration: Remove nulling of hostname in migrate_init()
Avihai Horon [Sun, 31 Dec 2023 09:30:07 +0000 (11:30 +0200)]
migration: Remove nulling of hostname in migrate_init()

MigrationState->hostname is set to NULL in migrate_init(). This is
redundant because it is already freed and set to NULL in
migrade_fd_cleanup(). Remove it.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20231231093016.14204-3-avihaih@nvidia.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration: Remove migrate_max_downtime() declaration
Avihai Horon [Sun, 31 Dec 2023 09:30:06 +0000 (11:30 +0200)]
migration: Remove migrate_max_downtime() declaration

migrate_max_downtime() has been removed long ago, but its declaration
was mistakenly left. Remove it.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20231231093016.14204-2-avihaih@nvidia.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agotests/qtest: postcopy migration with suspend
Steve Sistare [Wed, 3 Jan 2024 20:05:41 +0000 (12:05 -0800)]
tests/qtest: postcopy migration with suspend

Add a test case to verify that the suspended state is handled correctly by
live migration postcopy.  The test suspends the src, migrates, then wakes
the dest.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/1704312341-66640-13-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agotests/qtest: precopy migration with suspend
Steve Sistare [Wed, 3 Jan 2024 20:05:40 +0000 (12:05 -0800)]
tests/qtest: precopy migration with suspend

Add a test case to verify that the suspended state is handled correctly
during live migration precopy.  The test suspends the src, migrates, then
wakes the dest.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/1704312341-66640-12-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agotests/qtest: option to suspend during migration
Steve Sistare [Wed, 3 Jan 2024 20:05:39 +0000 (12:05 -0800)]
tests/qtest: option to suspend during migration

Add an option to suspend the src in a-b-bootblock.S, which puts the guest
in S3 state after one round of writing to memory.  The option is enabled by
poking a 1 into the suspend_me word in the boot block prior to starting the
src vm.  Generate symbol offsets in a-b-bootblock.h so that the suspend_me
offset is known.  Generate the bootblock for each test, because suspend_me
may differ for each.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Acked-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/1704312341-66640-11-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agotests/qtest: migration events
Steve Sistare [Wed, 3 Jan 2024 20:05:38 +0000 (12:05 -0800)]
tests/qtest: migration events

Define a state object to capture events seen by migration tests, to allow
more events to be captured in a subsequent patch, and simplify event
checking in wait_for_migration_pass.  No functional change.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: "Daniel P. Berrangé" <berrange@redhat.com>
Link: https://lore.kernel.org/r/1704312341-66640-10-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration: preserve suspended for bg_migration
Steve Sistare [Wed, 3 Jan 2024 20:05:37 +0000 (12:05 -0800)]
migration: preserve suspended for bg_migration

Do not wake a suspended guest during bg_migration, and restore the prior
state at finish rather than unconditionally running.  Allow the additional
state transitions that occur.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/1704312341-66640-9-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration: preserve suspended for snapshot
Steve Sistare [Wed, 3 Jan 2024 20:05:36 +0000 (12:05 -0800)]
migration: preserve suspended for snapshot

Restoring a snapshot can break a suspended guest.  Snapshots suffer from
the same suspended-state issues that affect live migration, plus they must
handle an additional problematic scenario, which is that a running vm must
remain running if it loads a suspended snapshot.

To save, the existing vm_stop call now completely stops the suspended
state.  Finish with vm_resume to leave the vm in the state it had prior
to the save, correctly restoring the suspended state.

To load, if the snapshot is not suspended, then vm_stop + vm_resume
correctly handles all states, and leaves the vm in the state it had prior
to the load.  However, if the snapshot is suspended, restoration is
trickier.  First, call vm_resume to restore the state to suspended so the
current state matches the saved state.  Then, if the pre-load state is
running, call wakeup to resume running.

Prior to these changes, the vm_stop to RUN_STATE_SAVE_VM and
RUN_STATE_RESTORE_VM did not change runstate if the current state was
suspended, but now it does, so allow these transitions.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/1704312341-66640-8-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration: preserve suspended runstate
Steve Sistare [Wed, 3 Jan 2024 20:05:35 +0000 (12:05 -0800)]
migration: preserve suspended runstate

A guest that is migrated in the suspended state automaticaly wakes and
continues execution.  This is wrong; the guest should end migration in
the same state it started.  The root cause is that the outgoing migration
code automatically wakes the guest, then saves the RUNNING runstate in
global_state_store(), hence the incoming migration code thinks the guest is
running and continues the guest if autostart is true.

On the outgoing side, delete the call to qemu_system_wakeup_request().
Now that vm_stop completely stops a vm in the suspended state (from the
preceding patches), the existing call to vm_stop_force_state is sufficient
to correctly migrate all vmstate.

On the incoming side, call vm_start if the pre-migration state was running
or suspended.  For the latter, vm_start correctly restores the suspended
state, and a future system_wakeup monitor request will cause the vm to
resume running.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/1704312341-66640-7-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomigration: propagate suspended runstate
Steve Sistare [Wed, 3 Jan 2024 20:05:34 +0000 (12:05 -0800)]
migration: propagate suspended runstate

If the outgoing machine was previously suspended, propagate that to the
incoming side via global_state, so a subsequent vm_start restores the
suspended state.  To maintain backward and forward compatibility, reclaim
some space from the runstate member.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/1704312341-66640-6-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agocpus: vm_resume
Steve Sistare [Wed, 3 Jan 2024 20:05:33 +0000 (12:05 -0800)]
cpus: vm_resume

Define the vm_resume helper, for use in subsequent patches.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/1704312341-66640-5-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agocpus: check running not RUN_STATE_RUNNING
Steve Sistare [Wed, 3 Jan 2024 20:05:32 +0000 (12:05 -0800)]
cpus: check running not RUN_STATE_RUNNING

When a vm transitions from running to suspended, runstate notifiers are
not called, so the notifiers still think the vm is running.  Hence, when
we call vm_start to restore the suspended state, we call vm_state_notify
with running=1.  However, some notifiers check for RUN_STATE_RUNNING.
They must check the running boolean instead.

No functional change.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/1704312341-66640-4-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agocpus: stop vm in suspended runstate
Steve Sistare [Wed, 3 Jan 2024 20:05:31 +0000 (12:05 -0800)]
cpus: stop vm in suspended runstate

Currently, a vm in the suspended state is not completely stopped.  The VCPUs
have been paused, but the cpu clock still runs, and runstate notifiers for
the transition to stopped have not been called.  This causes problems for
live migration.  Stale cpu timers_state is saved to the migration stream,
causing time errors in the guest when it wakes from suspend, and state that
would have been modified by runstate notifiers is wrong.

Modify vm_stop to completely stop the vm if the current state is suspended,
transition to RUN_STATE_PAUSED, and remember that the machine was suspended.
Modify vm_start to restore the suspended state.

This affects all callers of vm_stop and vm_start, notably, the qapi stop and
cont commands:

  old behavior:
    RUN_STATE_SUSPENDED --> stop --> RUN_STATE_SUSPENDED

  new behavior:
    RUN_STATE_SUSPENDED --> stop --> RUN_STATE_PAUSED
    RUN_STATE_PAUSED    --> cont --> RUN_STATE_SUSPENDED

For example:

    (qemu) info status
    VM status: paused (suspended)

    (qemu) stop
    (qemu) info status
    VM status: paused

    (qemu) system_wakeup
    Error: Unable to wake up: guest is not in suspended state

    (qemu) cont
    (qemu) info status
    VM status: paused (suspended)

    (qemu) system_wakeup
    (qemu) info status
    VM status: running

Suggested-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/1704312341-66640-3-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agocpus: vm_was_suspended
Steve Sistare [Wed, 3 Jan 2024 20:05:30 +0000 (12:05 -0800)]
cpus: vm_was_suspended

Add a state variable to remember if a vm previously transitioned into a
suspended state.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/1704312341-66640-2-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agoMAINTAINERS: Remove myself as reviewer from Live Migration
Leonardo Bras [Thu, 21 Dec 2023 17:07:34 +0000 (14:07 -0300)]
MAINTAINERS: Remove myself as reviewer from Live Migration

I am currently focusing in kernel development, so I will probably not be
of much help in reviewing general Live Migration changes.

For above reason I am removing my Reviewer status from Migration and RDMA
Migration.

Signed-off-by: Leonardo Bras <leobras@redhat.com>
Link: https://lore.kernel.org/r/20231221170739.332378-1-leobras@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agoMAINTAINERS: Leaving Migration
Juan Quintela [Tue, 2 Jan 2024 20:19:07 +0000 (21:19 +0100)]
MAINTAINERS: Leaving Migration

I am leaving Red Hat, and as part of that I am leaving Migration
maintenarship.

You are left in good hands with Peter and Fabiano.

Thanks for all the fish.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Link: https://lore.kernel.org/r/20240102201908.1987-2-quintela@redhat.com
[peterx: prefix the subject]
Signed-off-by: Peter Xu <peterx@redhat.com>
4 months agomeson.build: report graphics backends separately
Alex Bennée [Fri, 22 Dec 2023 11:48:46 +0000 (11:48 +0000)]
meson.build: report graphics backends separately

To enable accelerated VirtIO GPUs for the guest we need the rendering
support on the host, which currently it's reported in the configuration
summary under the "dependencies" section. Add a graphics backend section
and report the status of the VirGL and Rutabaga support libraries.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231222114846.2850741-1-alex.bennee@linaro.org>
[Remove from dependencies as suggested by Philippe. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agoconfigure, meson: rename targetos to host_os
Paolo Bonzini [Fri, 3 Nov 2023 08:17:48 +0000 (09:17 +0100)]
configure, meson: rename targetos to host_os

This variable is about the host OS, not the target.  It is used a lot
more since the Meson conversion, but the original sin dates back to 2003.
Time to fix it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: rename config_all
Paolo Bonzini [Fri, 29 Sep 2023 09:40:03 +0000 (11:40 +0200)]
meson: rename config_all

config_all now lists only accelerators, rename it to indicate its actual
content.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: remove CONFIG_ALL
Paolo Bonzini [Thu, 31 Aug 2023 09:18:24 +0000 (11:18 +0200)]
meson: remove CONFIG_ALL

CONFIG_ALL is tricky to use and was ported over to Meson from the
recursive processing of Makefile variables.  Meson sourcesets
however have all_sources() and all_dependencies() methods that
remove the need for it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: remove config_targetos
Paolo Bonzini [Wed, 30 Aug 2023 09:52:43 +0000 (11:52 +0200)]
meson: remove config_targetos

config_targetos is now empty and can be removed; its use in sourcesets
that do not involve target-specific files can be replaced with an empty
dictionary.

In fact, at this point *all* sourcesets that do not involve
target-specific files are just glorified mutable arrays.  Enforce that
they never test for symbols in "when:" by computing the set of files
without "strict: false".

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: remove CONFIG_POSIX and CONFIG_WIN32 from config_targetos
Paolo Bonzini [Wed, 30 Aug 2023 09:29:54 +0000 (11:29 +0200)]
meson: remove CONFIG_POSIX and CONFIG_WIN32 from config_targetos

For consistency with other OSes, use if...endif for rules that are
target-independent.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: remove OS definitions from config_targetos
Paolo Bonzini [Fri, 26 May 2023 10:20:39 +0000 (12:20 +0200)]
meson: remove OS definitions from config_targetos

CONFIG_DARWIN, CONFIG_LINUX and CONFIG_BSD are used in some rules, but
only CONFIG_LINUX has substantial use.  Convert them all to if...endif.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: always probe u2f and canokey if the option is enabled
Paolo Bonzini [Fri, 8 Sep 2023 10:10:27 +0000 (12:10 +0200)]
meson: always probe u2f and canokey if the option is enabled

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: move subdirs to "Collect sources" section
Paolo Bonzini [Fri, 3 Nov 2023 08:33:57 +0000 (09:33 +0100)]
meson: move subdirs to "Collect sources" section

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: move config-host.h definitions together
Paolo Bonzini [Fri, 8 Sep 2023 10:10:08 +0000 (12:10 +0200)]
meson: move config-host.h definitions together

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: move CFI detection code with other compiler flags
Paolo Bonzini [Wed, 10 May 2023 12:54:30 +0000 (14:54 +0200)]
meson: move CFI detection code with other compiler flags

Keep it together with the other compiler modes, and before dependencies.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: keep subprojects together
Paolo Bonzini [Fri, 8 Sep 2023 10:09:22 +0000 (12:09 +0200)]
meson: keep subprojects together

And move away dependencies that are not subprojects anymore.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: move accelerator dependency checks together
Paolo Bonzini [Fri, 8 Sep 2023 10:08:53 +0000 (12:08 +0200)]
meson: move accelerator dependency checks together

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: move option validation together
Paolo Bonzini [Sat, 30 Dec 2023 17:42:30 +0000 (18:42 +0100)]
meson: move option validation together

Check options before compiler flags, because some compiler flags are
incompatible with modules.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: move program checks together
Paolo Bonzini [Fri, 8 Sep 2023 10:06:57 +0000 (12:06 +0200)]
meson: move program checks together

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: add more sections to main meson.build
Paolo Bonzini [Fri, 8 Sep 2023 10:06:12 +0000 (12:06 +0200)]
meson: add more sections to main meson.build

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agoconfigure: unify again the case arms in probe_target_compiler
Paolo Bonzini [Fri, 3 Nov 2023 08:48:21 +0000 (09:48 +0100)]
configure: unify again the case arms in probe_target_compiler

Remove assignments that match the default, and group the
targets for debian-legacy-test-cross and debian-all-test-cross
into a single arm.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agoconfigure: remove unnecessary subshell
Paolo Bonzini [Fri, 3 Nov 2023 09:06:08 +0000 (10:06 +0100)]
configure: remove unnecessary subshell

Do not use a subshell to hide the shadowing of $config_host_mak.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agoMakefile: clean qemu-iotests output
Paolo Bonzini [Fri, 3 Nov 2023 09:00:04 +0000 (10:00 +0100)]
Makefile: clean qemu-iotests output

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: use version_compare() to compare version
Paolo Bonzini [Wed, 13 Dec 2023 10:33:41 +0000 (11:33 +0100)]
meson: use version_compare() to compare version

While a simple lexicographic comparison usually works, it is less
robust than a more specific algorithm designed to compare versions.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: remove unused variable
Paolo Bonzini [Wed, 13 Dec 2023 10:30:50 +0000 (11:30 +0100)]
meson: remove unused variable

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agomeson: fix type of "relocatable" option
Paolo Bonzini [Wed, 13 Dec 2023 10:30:09 +0000 (11:30 +0100)]
meson: fix type of "relocatable" option

Since the option is of boolean type, the default value should be a boolean
rather than a string.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agoesp: check for NULL result from scsi_device_find()
Alexandra Diupina [Fri, 29 Dec 2023 15:26:47 +0000 (18:26 +0300)]
esp: check for NULL result from scsi_device_find()

Add a 'current_lun' check for a null value
to avoid null pointer dereferencing and
recover host if NULL return

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 4eb8606560 (esp: store lun coming from the MESSAGE OUT phase)
Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru>
Message-ID: <20231229152647.19699-1-adiupina@astralinux.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: the sgx_epc_get_section stub is reachable
Paolo Bonzini [Tue, 1 Feb 2022 19:09:41 +0000 (20:09 +0100)]
target/i386: the sgx_epc_get_section stub is reachable

The sgx_epc_get_section stub is reachable from cpu_x86_cpuid.  It
should not assert, instead it should just return true just like
the "real" sgx_epc_get_section does when SGX is disabled.

Reported-by: Vladimír Beneš <vbenes@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20220201190941.106001-1-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: implement CMPccXADD
Paolo Bonzini [Tue, 10 Oct 2023 08:31:39 +0000 (10:31 +0200)]
target/i386: implement CMPccXADD

The main difficulty here is that a page fault when writing to the destination
must not overwrite the flags.  Therefore, the flags computation must be
inlined instead of using gen_jcc1*.

For simplicity, I am using an unconditional cmpxchg operation, that becomes
a NOP if the comparison fails.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: introduce flags writeback mechanism
Paolo Bonzini [Wed, 11 Oct 2023 13:26:40 +0000 (15:26 +0200)]
target/i386: introduce flags writeback mechanism

ALU instructions can write to both memory and flags.  If the CC_SRC*
and CC_DST locations have been written already when a memory access
causes a fault, the value in CC_SRC* and CC_DST might be interpreted
with the wrong CC_OP (the one that is in effect before the instruction.

Besides just using the wrong result for the flags, something like
subtracting -1 can have disastrous effects if the current CC_OP is
CC_OP_EFLAGS: this is because QEMU does not expect bits outside the ALU
flags to be set in CC_SRC, and env->eflags can end up set to all-ones.
In the case of the attached testcase, this sets IOPL to 3 and would
cause an assertion failure if SUB is moved to the new decoder.

This mechanism is not really needed for BMI instructions, which can
only write to a register, but put it to use anyway for cleanliness.
In the case of BZHI, the code has to be modified slightly to ensure
that decode->cc_src is written, otherwise the new assertions trigger.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: adjust decoding of J operand
Paolo Bonzini [Wed, 11 Oct 2023 09:28:46 +0000 (11:28 +0200)]
target/i386: adjust decoding of J operand

gen_jcc() has been changed to accept a relative offset since the
new decoder was written.  Adjust the J operand, which is meant
to be used with jump instructions such as gen_jcc(), to not
include the program counter and to not truncate the result, as
both operations are now performed by common code.

The result is that J is now the same as the I operand.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: move operand load and writeback out of gen_cmovcc1
Paolo Bonzini [Fri, 27 Oct 2023 02:22:25 +0000 (04:22 +0200)]
target/i386: move operand load and writeback out of gen_cmovcc1

Similar to gen_setcc1, make gen_cmovcc1 receive TCGv.  This is more friendly
to simultaneous implementation in the old and the new decoder.

A small wart is that s->T0 of CMOV is currently the *second* argument (which
would ordinarily be in T1).  Therefore, the condition has to be inverted in
order to overwrite s->T0 with cpu_regs[reg] if the MOV is not performed.

This only applies to the old decoder, and this code will go away soon.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: prepare for implementation of STOS/SCAS in new decoder
Paolo Bonzini [Mon, 23 Oct 2023 06:52:36 +0000 (08:52 +0200)]
target/i386: prepare for implementation of STOS/SCAS in new decoder

Do not use gen_op, and pull the load from the accumulator into
disas_insn.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: do not use s->tmp0 for jumps on ECX ==/!= 0
Paolo Bonzini [Mon, 23 Oct 2023 08:21:20 +0000 (10:21 +0200)]
target/i386: do not use s->tmp0 for jumps on ECX ==/!= 0

Create a new temporary, to ease the register allocator's work.

Creation of the temporary is pushed into gen_ext_tl, which
also allows NULL as the first parameter now.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: do not use s->tmp4 for push
Paolo Bonzini [Fri, 20 Oct 2023 07:32:06 +0000 (09:32 +0200)]
target/i386: do not use s->tmp4 for push

Just create a temporary for the occasion.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: split eflags computation out of gen_compute_eflags
Paolo Bonzini [Wed, 11 Oct 2023 14:20:20 +0000 (16:20 +0200)]
target/i386: split eflags computation out of gen_compute_eflags

The new x86 decoder wants the gen_* functions to compute EFLAGS before
writeback, which can be an issue for instructions with a memory
destination such as ARPL or shifts.

Extract code to compute the EFLAGS without clobbering CC_SRC, in case
the memory write causes a fault.  The flags writeback mechanism will
take care of copying the result to CC_SRC.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: do not clobber T0 on string operations
Paolo Bonzini [Thu, 19 Oct 2023 14:55:39 +0000 (16:55 +0200)]
target/i386: do not clobber T0 on string operations

The new decoder would rather have the operand in T0 when expanding SCAS, rather
than use R_EAX directly as gen_scas currently does.  This makes SCAS more similar
to CMP and SUB, in that CC_DST = T0 - T1.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: do not clobber A0 in POP translation
Paolo Bonzini [Wed, 21 Sep 2022 12:13:01 +0000 (14:13 +0200)]
target/i386: do not clobber A0 in POP translation

The new decoder likes to compute the address in A0 very early, so the
gen_lea_v_seg in gen_pop_T0 would clobber the address of the memory
operand.  Instead use T0 since it is already available and will be
overwritten immediately after.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: do not decode string source/destination into decode->mem
Paolo Bonzini [Thu, 19 Oct 2023 12:51:16 +0000 (14:51 +0200)]
target/i386: do not decode string source/destination into decode->mem

decode->mem is only used if one operand has has_ea == true.  String
operations will not use decode->mem and will load A0 on their own, because
they are the only case of two memory operands in a single instruction.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: add X86_SPECIALs for MOVSX and MOVZX
Paolo Bonzini [Thu, 19 Oct 2023 13:40:54 +0000 (15:40 +0200)]
target/i386: add X86_SPECIALs for MOVSX and MOVZX

Usually the registers are just moved into s->T0 without much care for
their operand size.  However, in some cases we can get more efficient
code if the operand fetching logic syncs with the emission function
on what is nicer.

All the current uses are mostly demonstrative and only reduce the code
in the emission functions, because the instructions do not support
memory operands.  However the logic is generic and applies to several
more instructions such as MOVSXD (aka movslq), one-byte shift
instructions, multiplications, XLAT, and indirect calls/jumps.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: rename zext0/zext2 and make them closer to the manual
Paolo Bonzini [Thu, 19 Oct 2023 21:14:34 +0000 (23:14 +0200)]
target/i386: rename zext0/zext2 and make them closer to the manual

X86_SPECIAL_ZExtOp0 and X86_SPECIAL_ZExtOp2 are poorly named; they are a hack
that is needed by scalar insertion and extraction instructions, and not really
related to zero extension: for PEXTR the zero extension is done by the generation
functions, for PINSR the high bits are not used at all and in fact are *not*
filled with zeroes when loaded into s->T1.

Rename the values to match the effect described in the manual, and explain
better in the comments.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: avoid trunc and ext for MULX and RORX
Paolo Bonzini [Thu, 19 Oct 2023 16:25:40 +0000 (18:25 +0200)]
target/i386: avoid trunc and ext for MULX and RORX

Use _tl operations for 32-bit operands on 32-bit targets, and only go
through trunc and extu ops for 64-bit targets.  While the trunc/ext
ops should be pretty much free after optimization, the optimizer also
does not like having the same temporary used in multiple EBBs.
Therefore it is nicer to not use tmpN* unless necessary.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: reimplement check for validity of LOCK prefix
Paolo Bonzini [Thu, 19 Oct 2023 12:22:53 +0000 (14:22 +0200)]
target/i386: reimplement check for validity of LOCK prefix

The previous check erroneously allowed CMP to be modified with LOCK.
Instead, tag explicitly the instructions that do support LOCK.

Acked-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: document more deviations from the manual
Paolo Bonzini [Mon, 23 Oct 2023 07:58:48 +0000 (09:58 +0200)]
target/i386: document more deviations from the manual

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: clean up cpu_cc_compute_all
Paolo Bonzini [Wed, 25 Oct 2023 22:24:46 +0000 (00:24 +0200)]
target/i386: clean up cpu_cc_compute_all

cpu_cc_compute_all() has an argument that is always equal to CC_OP for historical
reasons (dating back to commit a7812ae4123, "TCG variable type checking.", 2008-11-17,
which added the argument to helper_cc_compute_all).  It does not make sense for the
argument to have any other value, so remove it and clean up some lines that are not
too long anymore.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: remove unnecessary truncations
Paolo Bonzini [Wed, 25 Oct 2023 18:38:16 +0000 (20:38 +0200)]
target/i386: remove unnecessary truncations

gen_lea_v_seg (called by gen_add_A0_ds_seg) already zeroes any
bits of s->A0 beyond s->aflag.  It does so before summing the
segment base and, if not in 64-bit mode, also after summing it.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: remove unnecessary arguments from raise_interrupt
Paolo Bonzini [Wed, 25 Oct 2023 15:59:46 +0000 (17:59 +0200)]
target/i386: remove unnecessary arguments from raise_interrupt

is_int is always 1, and error_code is always zero.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: speedup JO/SETO after MUL or IMUL
Paolo Bonzini [Wed, 25 Oct 2023 11:13:13 +0000 (13:13 +0200)]
target/i386: speedup JO/SETO after MUL or IMUL

OF is equal to the carry flag, so use the same CCPrepare.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agotarget/i386: optimize computation of JL and JLE from flags
Paolo Bonzini [Fri, 27 Oct 2023 02:12:59 +0000 (04:12 +0200)]
target/i386: optimize computation of JL and JLE from flags

Take advantage of the fact that there can be no 1 bits between SF and OF.
If they were adjacent, you could sum SF and get a carry only if SF was
already set.  Then the value of OF in the sum is the XOR of OF itself,
the carry (which is SF) and 0 (the value of the OF bit in the addend):
this is OF^SF exactly.

Because OF and SF are not adjacent, just place more 1 bits to the
left so that the carry propagates, which means summing CC_O - CC_S.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4 months agodocs: Constify VMstate in examples
Richard Henderson [Thu, 21 Dec 2023 03:16:52 +0000 (14:16 +1100)]
docs: Constify VMstate in examples

Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-72-richard.henderson@linaro.org>

4 months agotests/unit/test-vmstate: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:51 +0000 (14:16 +1100)]
tests/unit/test-vmstate: Constify VMState

While const data in tests is not particularly important,
this makes a grep test clear across the tree.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-71-richard.henderson@linaro.org>

4 months agoutil/fifo8: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:50 +0000 (14:16 +1100)]
util/fifo8: Constify VMState

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

4 months agoreplay: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:49 +0000 (14:16 +1100)]
replay: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-69-richard.henderson@linaro.org>

4 months agosystem: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:48 +0000 (14:16 +1100)]
system: Constify VMState

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

4 months agomigration: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:47 +0000 (14:16 +1100)]
migration: Constify VMState

Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-67-richard.henderson@linaro.org>

4 months agocpu-target: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:46 +0000 (14:16 +1100)]
cpu-target: Constify VMState

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Message-Id: <20231221031652.119827-66-richard.henderson@linaro.org>

4 months agobackends: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:45 +0000 (14:16 +1100)]
backends: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-65-richard.henderson@linaro.org>

4 months agoaudio: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:44 +0000 (14:16 +1100)]
audio: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-64-richard.henderson@linaro.org>

4 months agohw/misc/macio: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:43 +0000 (14:16 +1100)]
hw/misc/macio: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-63-richard.henderson@linaro.org>

4 months agohw/watchdog: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:42 +0000 (14:16 +1100)]
hw/watchdog: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-62-richard.henderson@linaro.org>

4 months agohw/virtio: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:41 +0000 (14:16 +1100)]
hw/virtio: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-61-richard.henderson@linaro.org>

4 months agohw/vfio: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:40 +0000 (14:16 +1100)]
hw/vfio: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Message-Id: <20231221031652.119827-60-richard.henderson@linaro.org>

4 months agohw/usb: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:39 +0000 (14:16 +1100)]
hw/usb: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-59-richard.henderson@linaro.org>

4 months agohw/tpm: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:38 +0000 (14:16 +1100)]
hw/tpm: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-58-richard.henderson@linaro.org>

4 months agohw/timer: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:37 +0000 (14:16 +1100)]
hw/timer: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-57-richard.henderson@linaro.org>

4 months agohw/ssi: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:36 +0000 (14:16 +1100)]
hw/ssi: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-56-richard.henderson@linaro.org>

4 months agohw/sparc: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:35 +0000 (14:16 +1100)]
hw/sparc: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-55-richard.henderson@linaro.org>

4 months agohw/sensor: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:34 +0000 (14:16 +1100)]
hw/sensor: Constify VMState

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

4 months agohw/sd: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:33 +0000 (14:16 +1100)]
hw/sd: Constify VMState

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

4 months agohw/scsi: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:32 +0000 (14:16 +1100)]
hw/scsi: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-52-richard.henderson@linaro.org>

4 months agohw/s390x: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:31 +0000 (14:16 +1100)]
hw/s390x: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-51-richard.henderson@linaro.org>

4 months agohw/rtc: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:30 +0000 (14:16 +1100)]
hw/rtc: Constify VMState

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

4 months agohw/riscv: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:29 +0000 (14:16 +1100)]
hw/riscv: Constify VMState

Acked-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-49-richard.henderson@linaro.org>

4 months agohw/ppc: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:28 +0000 (14:16 +1100)]
hw/ppc: Constify VMState

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-48-richard.henderson@linaro.org>

4 months agohw/pci-host: Constify VMState
Richard Henderson [Thu, 21 Dec 2023 03:16:27 +0000 (14:16 +1100)]
hw/pci-host: Constify VMState

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