[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/20] hw/s390x/s390-virtio-ccw: Fix a record/replay deadlock
From: |
Thomas Huth |
Subject: |
[PULL 10/20] hw/s390x/s390-virtio-ccw: Fix a record/replay deadlock |
Date: |
Thu, 30 Jan 2025 14:15:24 +0100 |
From: Ilya Leoshkevich <iii@linux.ibm.com>
Booting an s390x VM in record/replay mode hangs due to a deadlock
between rr_cpu_thread_fn() and s390_machine_reset(). The former needs
the record/replay mutex held by the latter, and the latter waits until
the former completes its run_on_cpu() request.
Fix by temporarily dropping the record/replay mutex, like it's done in
pause_all_vcpus().
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-ID: <20250124112625.23050-1-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
hw/s390x/s390-virtio-ccw.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 3af613d4e9..b069303592 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -48,6 +48,7 @@
#include "kvm/kvm_s390x.h"
#include "hw/virtio/virtio-md-pci.h"
#include "hw/s390x/virtio-ccw-md.h"
+#include "system/replay.h"
#include CONFIG_DEVICES
static Error *pv_mig_blocker;
@@ -454,6 +455,18 @@ static void s390_machine_reset(MachineState *machine,
ResetType type)
CPUState *cs, *t;
S390CPU *cpu;
+ /*
+ * Temporarily drop the record/replay mutex to let rr_cpu_thread_fn()
+ * process the run_on_cpu() requests below. This is safe, because at this
+ * point one of the following is true:
+ * - All CPU threads are not running, either because the machine is being
+ * initialized, or because the guest requested a reset using diag 308.
+ * There is no risk to desync the record/replay state.
+ * - A snapshot is about to be loaded. The record/replay state consistency
+ * is not important.
+ */
+ replay_mutex_unlock();
+
/* get the reset parameters, reset them once done */
s390_ipl_get_reset_request(&cs, &reset_type);
@@ -533,7 +546,7 @@ static void s390_machine_reset(MachineState *machine,
ResetType type)
* went wrong.
*/
s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu);
- return;
+ goto out_lock;
}
run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL);
@@ -546,6 +559,15 @@ static void s390_machine_reset(MachineState *machine,
ResetType type)
run_on_cpu(t, s390_do_cpu_set_diag318, RUN_ON_CPU_HOST_ULONG(0));
}
s390_ipl_clear_reset_request();
+
+out_lock:
+ /*
+ * Re-take the record/replay mutex, temporarily dropping the BQL in order
+ * to satisfy the ordering requirements.
+ */
+ bql_unlock();
+ replay_mutex_lock();
+ bql_lock();
}
static void s390_machine_device_pre_plug(HotplugHandler *hotplug_dev,
--
2.48.1
- [PULL 02/20] tests/functional: Fix broken decorators with lamda functions, (continued)
- [PULL 02/20] tests/functional: Fix broken decorators with lamda functions, Thomas Huth, 2025/01/30
- [PULL 04/20] tests/functional: Fix the aarch64_tcg_plugins test, Thomas Huth, 2025/01/30
- [PULL 05/20] tests/functional: Add a ppc64 mac99 test, Thomas Huth, 2025/01/30
- [PULL 09/20] tests/tcg/s390x: Test modifying code using the MVC instruction, Thomas Huth, 2025/01/30
- [PULL 14/20] tests/functional: Extend PPC 40p test with Linux boot, Thomas Huth, 2025/01/30
- [PULL 15/20] tests/functional: Add a decorator for skipping long running tests, Thomas Huth, 2025/01/30
- [PULL 16/20] tests/functional: Add the ReplayKernelBase class, Thomas Huth, 2025/01/30
- [PULL 11/20] virtio-balloon-pci: Allow setting nvectors, so we can use MSI-X, Thomas Huth, 2025/01/30
- [PULL 13/20] s390x/s390-virtio-ccw: Support plugging PCI-based virtio memory devices, Thomas Huth, 2025/01/30
- [PULL 17/20] tests/functional/test_mipsel_malta: Convert the mipsel replay tests, Thomas Huth, 2025/01/30
- [PULL 10/20] hw/s390x/s390-virtio-ccw: Fix a record/replay deadlock,
Thomas Huth <=
- [PULL 20/20] net/slirp: libslirp 4.9.0 compatibility, Thomas Huth, 2025/01/30
- [PULL 08/20] target/s390x: Fix MVC not always invalidating translation blocks, Thomas Huth, 2025/01/30
- [PULL 12/20] virtio-mem-pci: Allow setting nvectors, so we can use MSI-X, Thomas Huth, 2025/01/30
- [PULL 18/20] tests/functional/test_mips64el_malta: Convert the mips64el replay tests, Thomas Huth, 2025/01/30
- [PULL 19/20] tests/functional/test_mips_malta: Convert the mips big endian replay tests, Thomas Huth, 2025/01/30
- [PULL 07/20] target/s390x: Fix PPNO execution with icount, Thomas Huth, 2025/01/30