From patchwork Fri Oct 20 11:54:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 828636 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yJQ3h2F85z9t3f for ; Fri, 20 Oct 2017 23:25:04 +1100 (AEDT) Received: from localhost ([::1]:53524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5WMI-00058L-DF for incoming@patchwork.ozlabs.org; Fri, 20 Oct 2017 08:25:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5VuE-0003L7-NM for qemu-devel@nongnu.org; Fri, 20 Oct 2017 07:56:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5VuD-0003on-IL for qemu-devel@nongnu.org; Fri, 20 Oct 2017 07:56:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40340) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e5VuD-0003oG-AI; Fri, 20 Oct 2017 07:56:01 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4235440221; Fri, 20 Oct 2017 11:56:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4235440221 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=cohuck@redhat.com Received: from localhost (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DECB05D9CA; Fri, 20 Oct 2017 11:55:59 +0000 (UTC) From: Cornelia Huck To: peter.maydell@linaro.org Date: Fri, 20 Oct 2017 13:54:03 +0200 Message-Id: <20171020115418.2050-32-cohuck@redhat.com> In-Reply-To: <20171020115418.2050-1-cohuck@redhat.com> References: <20171020115418.2050-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 20 Oct 2017 11:56:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 31/46] target/s390x: special handling when starting a CPU with WAIT PSW 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: thuth@redhat.com, david@redhat.com, Cornelia Huck , agraf@suse.de, qemu-devel@nongnu.org, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, rth@twiddle.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand When we try to start a CPU with a WAIT PSW, we have to take care that TCG will actually try to continue executing instructions. We must therefore really only unhalt the CPU if we don't have a WAIT PSW. Also document the special order for restart interrupts, which load a new PSW and change the state to operating. To keep KVM working, simply don't have a look at the WAIT bit when loading the PSW. Otherwise the behavior of a restart interrupt when a CPU stopped would be changed. Signed-off-by: David Hildenbrand Message-Id: <20170928203708.9376-31-david@redhat.com> Reviewed-by: Richard Henderson Signed-off-by: Cornelia Huck --- target/s390x/cpu.c | 11 +++++++++-- target/s390x/sigp.c | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 92f6707bcb..95f4283188 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -337,8 +337,15 @@ unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu) break; case CPU_STATE_OPERATING: case CPU_STATE_LOAD: - /* unhalt the cpu for common infrastructure */ - s390_cpu_unhalt(cpu); + /* + * Starting a CPU with a PSW WAIT bit set: + * KVM: handles this internally and triggers another WAIT exit. + * TCG: will actually try to continue to run. Don't unhalt, will + * be done when the CPU actually has work (an interrupt). + */ + if (!tcg_enabled() || !(cpu->env.psw.mask & PSW_MASK_WAIT)) { + s390_cpu_unhalt(cpu); + } break; default: error_report("Requested CPU state is not a valid S390 CPU state: %u", diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 964c75a736..ac3f8e7dc2 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -232,8 +232,12 @@ static void sigp_restart(CPUState *cs, run_on_cpu_data arg) case CPU_STATE_STOPPED: /* the restart irq has to be delivered prior to any other pending irq */ cpu_synchronize_state(cs); - do_restart_interrupt(&cpu->env); + /* + * Set OPERATING (and unhalting) before loading the restart PSW. + * load_psw() will then properly halt the CPU again if necessary (TCG). + */ s390_cpu_set_state(CPU_STATE_OPERATING, cpu); + do_restart_interrupt(&cpu->env); break; case CPU_STATE_OPERATING: cpu_inject_restart(cpu);