From nobody Mon Feb 9 16:12:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513790639188145.65839268441914; Wed, 20 Dec 2017 09:23:59 -0800 (PST) Received: from localhost ([::1]:60366 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRi5t-0002Kf-T2 for importer@patchew.org; Wed, 20 Dec 2017 12:23:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRhy8-0004RC-U7 for qemu-devel@nongnu.org; Wed, 20 Dec 2017 12:15:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eRhy7-00077b-Vg for qemu-devel@nongnu.org; Wed, 20 Dec 2017 12:15:48 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:43968) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eRhy7-00077D-Oj for qemu-devel@nongnu.org; Wed, 20 Dec 2017 12:15:47 -0500 Received: by mail-wr0-x244.google.com with SMTP id w68so10468667wrc.10 for ; Wed, 20 Dec 2017 09:15:47 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-251-125.clienti.tiscali.it. [78.12.251.125]) by smtp.gmail.com with ESMTPSA id f125sm2751101wme.45.2017.12.20.09.15.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Dec 2017 09:15:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=dxT5I7s1r4b5lDBIqSlx7RhiCQ9uy3KMADH6ZbZLR2k=; b=NeFX2pvr0UGtSvlYZ22qCrthckHwMRyyG2n+Q/zIMFumr3/1dbI3o+gauxSjR8TUpM ETFZ09bYa3HUsp7C3FU0SnvMuMWdLqJZKP3Fhgs/MdGNIMTrXCEYroE/c5TCVvz7DayE nK6cCz2GvI2ugwRT0W74qT3Gl7/T24RugK5fUNb/ceU4WhqL8DUHXfPDuaCZP+7PyL3g 8R2G32FLXW8rjVvjOsUNY++ZXz7IL0HOBrVH6fAaLKeU2tDzWgi6gMypPf111QPj5ALU HkosaKQFzbc/nXpLJc0e6X9fVwVIjM9IaCMabnCdwhRYOuY4xqfzVletDgU2h8G2GYE/ FWlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=dxT5I7s1r4b5lDBIqSlx7RhiCQ9uy3KMADH6ZbZLR2k=; b=MXDMqofDx6mMm7J7Ia27GNXdiLq+mELlnIA46e7+QAUHxvFeYbfTmHtQkDUcUtXVPS DpJdhXhaPK82I2DY7c5XKZ6AN0rqgyP0RQkVAFT/FcTldITFaxcm6PvoPNjrZfFzJE/Z 19VFNDwZNINSr3kQvb6GC5fDRWbryCB22DnwdlaPg0/4sAp1gxsGJUMjvTnQFtNF0T9p Kq3tEfOEYgH2KRLtbH/ZT798ab409eWdAkE/7EvVX95NbS1pYaysw+ECkQhF6a9C+pWy qsfYYt4q9O1zRQuI1T3vzRIRg3SMtFr91qeUcihHuQV/2GAR2sgRFm/kAKcAEyEM9JlR FhEA== X-Gm-Message-State: AKGB3mLp+Qh2uq+HjPwKTodY4blvXNEkx3waN493nQvFvAaqCvWI7Mwo ujx/RhBRpgZNuh9MLb5tJ88RPoXV X-Google-Smtp-Source: ACJfBouY8INy0szG1yKXy82lattIRGrdeEkueP2EvpTyUHfBtLXLcUH7DI96I+veYAPsVvWiqksZdQ== X-Received: by 10.223.139.3 with SMTP id n3mr1172061wra.44.1513790146505; Wed, 20 Dec 2017 09:15:46 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 20 Dec 2017 18:14:24 +0100 Message-Id: <1513790098-9815-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1513790098-9815-1-git-send-email-pbonzini@redhat.com> References: <1513790098-9815-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 12/46] cpus: make pause_all_cpus() play with SMP on single threaded TCG X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand pause_all_cpus() is sometimes called from a VCPU thread (e.g. s390x during special reset). It cannot deal with multiple VCPUs per Thread (single threaded TCG) yet. Booting an s390x guest with -smp 2 and single threaded TCG from disk currently fails. The DIAG 308 will issue a pause_all_cpus() and wait forever for the CPUs to actually stop. But it is waiting for itself. So let's stop all VCPUs belonging to the current thread. Factor out stopping of a VCPU. Signed-off-by: David Hildenbrand Message-Id: <20171129191215.11323-1-david@redhat.com> Signed-off-by: Paolo Bonzini --- cpus.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/cpus.c b/cpus.c index 114c29b..3740c4d 100644 --- a/cpus.c +++ b/cpus.c @@ -1057,13 +1057,22 @@ static void qemu_tcg_destroy_vcpu(CPUState *cpu) { } =20 +static void qemu_cpu_stop(CPUState *cpu, bool exit) +{ + g_assert(qemu_cpu_is_self(cpu)); + cpu->stop =3D false; + cpu->stopped =3D true; + if (exit) { + cpu_exit(cpu); + } + qemu_cond_broadcast(&qemu_pause_cond); +} + static void qemu_wait_io_event_common(CPUState *cpu) { atomic_mb_set(&cpu->thread_kicked, false); if (cpu->stop) { - cpu->stop =3D false; - cpu->stopped =3D true; - qemu_cond_broadcast(&qemu_pause_cond); + qemu_cpu_stop(cpu, false); } process_queued_cpu_work(cpu); } @@ -1610,12 +1619,12 @@ void pause_all_vcpus(void) =20 qemu_clock_enable(QEMU_CLOCK_VIRTUAL, false); CPU_FOREACH(cpu) { - cpu->stop =3D true; - qemu_cpu_kick(cpu); - } - - if (qemu_in_vcpu_thread()) { - cpu_stop_current(); + if (qemu_cpu_is_self(cpu)) { + qemu_cpu_stop(cpu, true); + } else { + cpu->stop =3D true; + qemu_cpu_kick(cpu); + } } =20 while (!all_vcpus_paused()) { @@ -1799,10 +1808,7 @@ void qemu_init_vcpu(CPUState *cpu) void cpu_stop_current(void) { if (current_cpu) { - current_cpu->stop =3D false; - current_cpu->stopped =3D true; - cpu_exit(current_cpu); - qemu_cond_broadcast(&qemu_pause_cond); + qemu_cpu_stop(current_cpu, true); } } =20 --=20 1.8.3.1