From patchwork Wed Nov 27 17:50:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 1201713 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47NT7p3QqZz9sST for ; Thu, 28 Nov 2019 05:00:06 +1100 (AEDT) Received: from localhost ([::1]:41194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia1be-0005xF-5T for incoming@patchwork.ozlabs.org; Wed, 27 Nov 2019 13:00:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46973) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia1Sz-000886-Dp for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ia1Sw-0003IH-GX for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:05 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:27416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ia1Sw-0003HU-77 for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:02 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xARHkXMV035889 for ; Wed, 27 Nov 2019 12:51:01 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2whhgct7g7-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Nov 2019 12:51:01 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Nov 2019 17:50:59 -0000 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 27 Nov 2019 17:50:56 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xARHotu740632710 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Nov 2019 17:50:55 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E0344A4055; Wed, 27 Nov 2019 17:50:54 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E1281A404D; Wed, 27 Nov 2019 17:50:52 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.82.185]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 27 Nov 2019 17:50:52 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH v4 1/6] s390x: Don't do a normal reset on the initial cpu Date: Wed, 27 Nov 2019 12:50:41 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191127175046.4911-1-frankja@linux.ibm.com> References: <20191127175046.4911-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19112717-0028-0000-0000-000003C0C677 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112717-0029-0000-0000-00002483CE47 Message-Id: <20191127175046.4911-2-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95, 18.0.572 definitions=2019-11-27_04:2019-11-27, 2019-11-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 malwarescore=0 adultscore=0 impostorscore=0 suspectscore=1 spamscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911270145 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, pmorel@linux.ibm.com, david@redhat.com, cohuck@redhat.com, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, mihajlov@linux.ibm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The initiating cpu needs to be reset with an initial reset. While doing a normal reset followed by a initial reset is not wrong per se, the Ultravisor will only allow the correct reset to be performed. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck --- hw/s390x/s390-virtio-ccw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index d3edeef0ad..c1d1440272 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -348,6 +348,9 @@ static void s390_machine_reset(MachineState *machine) break; case S390_RESET_LOAD_NORMAL: CPU_FOREACH(t) { + if (t == cs) { + continue; + } run_on_cpu(t, s390_do_cpu_reset, RUN_ON_CPU_NULL); } subsystem_reset(); From patchwork Wed Nov 27 17:50:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 1201707 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47NSyQ429Qz9sSS for ; Thu, 28 Nov 2019 04:51:56 +1100 (AEDT) Received: from localhost ([::1]:41142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia1Tl-0008CE-GF for incoming@patchwork.ozlabs.org; Wed, 27 Nov 2019 12:51:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47021) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia1T9-00089G-5o for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ia1T5-0003Nb-Jq for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:14 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34526) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ia1Sz-0003J8-Cn for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:07 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xARHkWEg081129 for ; Wed, 27 Nov 2019 12:51:03 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2whhyfvbws-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Nov 2019 12:51:03 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Nov 2019 17:51:00 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 27 Nov 2019 17:50:58 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xARHovjG42926288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Nov 2019 17:50:57 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5A401A404D; Wed, 27 Nov 2019 17:50:57 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5B68BA4055; Wed, 27 Nov 2019 17:50:55 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.82.185]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 27 Nov 2019 17:50:55 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH v4 2/6] s390x: Move reset normal to shared reset handler Date: Wed, 27 Nov 2019 12:50:42 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191127175046.4911-1-frankja@linux.ibm.com> References: <20191127175046.4911-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19112717-0008-0000-0000-000003390CA1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112717-0009-0000-0000-00004A581612 Message-Id: <20191127175046.4911-3-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95, 18.0.572 definitions=2019-11-27_04:2019-11-27, 2019-11-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=1 clxscore=1015 priorityscore=1501 lowpriorityscore=0 bulkscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911270145 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, pmorel@linux.ibm.com, david@redhat.com, cohuck@redhat.com, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, mihajlov@linux.ibm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Let's start moving the cpu reset functions into a single function with a switch/case, so we can use fallthroughs and share more code between resets. This patch introduces the reset function by renaming cpu_reset() and cleaning up leftovers. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Reviewed-by: Thomas Huth --- target/s390x/cpu-qom.h | 6 +++++- target/s390x/cpu.c | 19 +++++++++++++------ target/s390x/cpu.h | 2 +- target/s390x/sigp.c | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h index b809ec8418..f3b71bac67 100644 --- a/target/s390x/cpu-qom.h +++ b/target/s390x/cpu-qom.h @@ -34,6 +34,10 @@ typedef struct S390CPUModel S390CPUModel; typedef struct S390CPUDef S390CPUDef; +typedef enum cpu_reset_type { + S390_CPU_RESET_NORMAL, +} cpu_reset_type; + /** * S390CPUClass: * @parent_realize: The parent class' realize handler. @@ -57,7 +61,7 @@ typedef struct S390CPUClass { DeviceRealize parent_realize; void (*parent_reset)(CPUState *cpu); void (*load_normal)(CPUState *cpu); - void (*cpu_reset)(CPUState *cpu); + void (*reset)(CPUState *cpu, cpu_reset_type type); void (*initial_cpu_reset)(CPUState *cpu); } S390CPUClass; diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 3abe7e80fd..67d6fbfa44 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -82,18 +82,25 @@ static void s390_cpu_load_normal(CPUState *s) } #endif -/* S390CPUClass::cpu_reset() */ -static void s390_cpu_reset(CPUState *s) +/* S390CPUClass::reset() */ +static void s390_cpu_reset(CPUState *s, cpu_reset_type type) { S390CPU *cpu = S390_CPU(s); S390CPUClass *scc = S390_CPU_GET_CLASS(cpu); CPUS390XState *env = &cpu->env; - env->pfault_token = -1UL; - env->bpbc = false; scc->parent_reset(s); cpu->env.sigp_order = 0; s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); + + switch (type) { + case S390_CPU_RESET_NORMAL: + env->pfault_token = -1UL; + env->bpbc = false; + break; + default: + g_assert_not_reached(); + } } /* S390CPUClass::initial_reset() */ @@ -102,7 +109,7 @@ static void s390_cpu_initial_reset(CPUState *s) S390CPU *cpu = S390_CPU(s); CPUS390XState *env = &cpu->env; - s390_cpu_reset(s); + s390_cpu_reset(s, S390_CPU_RESET_NORMAL); /* initial reset does not clear everything! */ memset(&env->start_initial_reset_fields, 0, offsetof(CPUS390XState, end_reset_fields) - @@ -473,7 +480,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) #if !defined(CONFIG_USER_ONLY) scc->load_normal = s390_cpu_load_normal; #endif - scc->cpu_reset = s390_cpu_reset; + scc->reset = s390_cpu_reset; scc->initial_cpu_reset = s390_cpu_initial_reset; cc->reset = s390_cpu_full_reset; cc->class_by_name = s390_cpu_class_by_name, diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 17460ed7b3..18123dfd5b 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -741,7 +741,7 @@ static inline void s390_do_cpu_reset(CPUState *cs, run_on_cpu_data arg) { S390CPUClass *scc = S390_CPU_GET_CLASS(cs); - scc->cpu_reset(cs); + scc->reset(cs, S390_CPU_RESET_NORMAL); } static inline void s390_do_cpu_initial_reset(CPUState *cs, run_on_cpu_data arg) diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 2ce22d4dc1..850139b9cd 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -266,7 +266,7 @@ static void sigp_cpu_reset(CPUState *cs, run_on_cpu_data arg) SigpInfo *si = arg.host_ptr; cpu_synchronize_state(cs); - scc->cpu_reset(cs); + scc->reset(cs, S390_CPU_RESET_NORMAL); cpu_synchronize_post_reset(cs); si->cc = SIGP_CC_ORDER_CODE_ACCEPTED; } From patchwork Wed Nov 27 17:50:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 1201708 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47NSyS364yz9sSL for ; Thu, 28 Nov 2019 04:52:00 +1100 (AEDT) Received: from localhost ([::1]:41146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia1To-0008EL-Sh for incoming@patchwork.ozlabs.org; Wed, 27 Nov 2019 12:51:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47024) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia1T9-00089J-6K for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ia1T5-0003O3-RD for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:14 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:11688) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ia1T5-0003Kt-J4 for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:11 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xARHkUcB080934 for ; Wed, 27 Nov 2019 12:51:06 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2whhyfvc0j-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Nov 2019 12:51:06 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Nov 2019 17:51:04 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 27 Nov 2019 17:51:01 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xARHoxgI55181556 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Nov 2019 17:50:59 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 96234A4053; Wed, 27 Nov 2019 17:50:59 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B029CA4055; Wed, 27 Nov 2019 17:50:57 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.82.185]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 27 Nov 2019 17:50:57 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH v4 3/6] s390x: Move initial reset Date: Wed, 27 Nov 2019 12:50:43 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191127175046.4911-1-frankja@linux.ibm.com> References: <20191127175046.4911-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19112717-0016-0000-0000-000002CD1055 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112717-0017-0000-0000-0000332EF1A0 Message-Id: <20191127175046.4911-4-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95, 18.0.572 definitions=2019-11-27_04:2019-11-27, 2019-11-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=1 clxscore=1015 priorityscore=1501 lowpriorityscore=0 bulkscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911270145 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, pmorel@linux.ibm.com, david@redhat.com, cohuck@redhat.com, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, mihajlov@linux.ibm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Let's move the intial reset into the reset handler and cleanup afterwards. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand --- target/s390x/cpu-qom.h | 2 +- target/s390x/cpu.c | 44 ++++++++++++++++-------------------------- target/s390x/cpu.h | 2 +- target/s390x/sigp.c | 2 +- 4 files changed, 20 insertions(+), 30 deletions(-) diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h index f3b71bac67..6f0a12042e 100644 --- a/target/s390x/cpu-qom.h +++ b/target/s390x/cpu-qom.h @@ -36,6 +36,7 @@ typedef struct S390CPUDef S390CPUDef; typedef enum cpu_reset_type { S390_CPU_RESET_NORMAL, + S390_CPU_RESET_INITIAL, } cpu_reset_type; /** @@ -62,7 +63,6 @@ typedef struct S390CPUClass { void (*parent_reset)(CPUState *cpu); void (*load_normal)(CPUState *cpu); void (*reset)(CPUState *cpu, cpu_reset_type type); - void (*initial_cpu_reset)(CPUState *cpu); } S390CPUClass; typedef struct S390CPU S390CPU; diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 67d6fbfa44..55e2d1fe7b 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -94,6 +94,23 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type) s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); switch (type) { + case S390_CPU_RESET_INITIAL: + /* initial reset does not clear everything! */ + memset(&env->start_initial_reset_fields, 0, + offsetof(CPUS390XState, end_reset_fields) - + offsetof(CPUS390XState, start_initial_reset_fields)); + + /* architectured initial value for Breaking-Event-Address register */ + env->gbea = 1; + + /* architectured initial values for CR 0 and 14 */ + env->cregs[0] = CR0_RESET; + env->cregs[14] = CR14_RESET; + + /* tininess for underflow is detected before rounding */ + set_float_detect_tininess(float_tininess_before_rounding, + &env->fpu_status); + /* fall through */ case S390_CPU_RESET_NORMAL: env->pfault_token = -1UL; env->bpbc = false; @@ -101,32 +118,6 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type) default: g_assert_not_reached(); } -} - -/* S390CPUClass::initial_reset() */ -static void s390_cpu_initial_reset(CPUState *s) -{ - S390CPU *cpu = S390_CPU(s); - CPUS390XState *env = &cpu->env; - - s390_cpu_reset(s, S390_CPU_RESET_NORMAL); - /* initial reset does not clear everything! */ - memset(&env->start_initial_reset_fields, 0, - offsetof(CPUS390XState, end_reset_fields) - - offsetof(CPUS390XState, start_initial_reset_fields)); - - /* architectured initial values for CR 0 and 14 */ - env->cregs[0] = CR0_RESET; - env->cregs[14] = CR14_RESET; - - /* architectured initial value for Breaking-Event-Address register */ - env->gbea = 1; - - env->pfault_token = -1UL; - - /* tininess for underflow is detected before rounding */ - set_float_detect_tininess(float_tininess_before_rounding, - &env->fpu_status); /* Reset state inside the kernel that we cannot access yet from QEMU. */ if (kvm_enabled()) { @@ -481,7 +472,6 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) scc->load_normal = s390_cpu_load_normal; #endif scc->reset = s390_cpu_reset; - scc->initial_cpu_reset = s390_cpu_initial_reset; cc->reset = s390_cpu_full_reset; cc->class_by_name = s390_cpu_class_by_name, cc->has_work = s390_cpu_has_work; diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 18123dfd5b..d2af13b345 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -748,7 +748,7 @@ static inline void s390_do_cpu_initial_reset(CPUState *cs, run_on_cpu_data arg) { S390CPUClass *scc = S390_CPU_GET_CLASS(cs); - scc->initial_cpu_reset(cs); + scc->reset(cs, S390_CPU_RESET_INITIAL); } static inline void s390_do_cpu_load_normal(CPUState *cs, run_on_cpu_data arg) diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 850139b9cd..727875bb4a 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -254,7 +254,7 @@ static void sigp_initial_cpu_reset(CPUState *cs, run_on_cpu_data arg) SigpInfo *si = arg.host_ptr; cpu_synchronize_state(cs); - scc->initial_cpu_reset(cs); + scc->reset(cs, S390_CPU_RESET_INITIAL); cpu_synchronize_post_reset(cs); si->cc = SIGP_CC_ORDER_CODE_ACCEPTED; } From patchwork Wed Nov 27 17:50:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 1201711 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47NT2q40SHz9sSS for ; Thu, 28 Nov 2019 04:55:47 +1100 (AEDT) Received: from localhost ([::1]:41178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia1XT-0002og-HR for incoming@patchwork.ozlabs.org; Wed, 27 Nov 2019 12:55:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47042) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia1TA-00089L-1I for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ia1T5-0003OB-SK for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:14 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:14058) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ia1T5-0003Lt-N7 for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:11 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xARHkOTZ088055 for ; Wed, 27 Nov 2019 12:51:08 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2whrgmc0vq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Nov 2019 12:51:08 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Nov 2019 17:51:06 -0000 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 27 Nov 2019 17:51:03 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xARHp1vr35062100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Nov 2019 17:51:01 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 879E3A405B; Wed, 27 Nov 2019 17:51:01 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E206BA4053; Wed, 27 Nov 2019 17:50:59 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.82.185]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 27 Nov 2019 17:50:59 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH v4 4/6] s390x: Move clear reset Date: Wed, 27 Nov 2019 12:50:44 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191127175046.4911-1-frankja@linux.ibm.com> References: <20191127175046.4911-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19112717-0028-0000-0000-000003C0C67B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112717-0029-0000-0000-00002483CE4B Message-Id: <20191127175046.4911-5-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95, 18.0.572 definitions=2019-11-27_04:2019-11-27, 2019-11-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 phishscore=0 suspectscore=1 adultscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911270145 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, pmorel@linux.ibm.com, david@redhat.com, cohuck@redhat.com, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, mihajlov@linux.ibm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Let's also move the clear reset function into the reset handler. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Reviewed-by: Thomas Huth --- target/s390x/cpu-qom.h | 1 + target/s390x/cpu.c | 58 +++++++++++++----------------------------- 2 files changed, 18 insertions(+), 41 deletions(-) diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h index 6f0a12042e..dbe5346ec9 100644 --- a/target/s390x/cpu-qom.h +++ b/target/s390x/cpu-qom.h @@ -37,6 +37,7 @@ typedef struct S390CPUDef S390CPUDef; typedef enum cpu_reset_type { S390_CPU_RESET_NORMAL, S390_CPU_RESET_INITIAL, + S390_CPU_RESET_CLEAR, } cpu_reset_type; /** diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 55e2d1fe7b..3e745e8ecc 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -94,6 +94,9 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type) s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); switch (type) { + case S390_CPU_RESET_CLEAR: + memset(env, 0, offsetof(CPUS390XState, start_initial_reset_fields)); + /* fall through */ case S390_CPU_RESET_INITIAL: /* initial reset does not clear everything! */ memset(&env->start_initial_reset_fields, 0, @@ -107,6 +110,14 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type) env->cregs[0] = CR0_RESET; env->cregs[14] = CR14_RESET; +#if defined(CONFIG_USER_ONLY) + /* user mode should always be allowed to use the full FPU */ + env->cregs[0] |= CR0_AFP; + if (s390_has_feat(S390_FEAT_VECTOR)) { + env->cregs[0] |= CR0_VECTOR; + } +#endif + /* tininess for underflow is detected before rounding */ set_float_detect_tininess(float_tininess_before_rounding, &env->fpu_status); @@ -125,46 +136,6 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type) } } -/* CPUClass:reset() */ -static void s390_cpu_full_reset(CPUState *s) -{ - S390CPU *cpu = S390_CPU(s); - S390CPUClass *scc = S390_CPU_GET_CLASS(cpu); - CPUS390XState *env = &cpu->env; - - scc->parent_reset(s); - cpu->env.sigp_order = 0; - s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); - - memset(env, 0, offsetof(CPUS390XState, end_reset_fields)); - - /* architectured initial values for CR 0 and 14 */ - env->cregs[0] = CR0_RESET; - env->cregs[14] = CR14_RESET; - -#if defined(CONFIG_USER_ONLY) - /* user mode should always be allowed to use the full FPU */ - env->cregs[0] |= CR0_AFP; - if (s390_has_feat(S390_FEAT_VECTOR)) { - env->cregs[0] |= CR0_VECTOR; - } -#endif - - /* architectured initial value for Breaking-Event-Address register */ - env->gbea = 1; - - env->pfault_token = -1UL; - - /* tininess for underflow is detected before rounding */ - set_float_detect_tininess(float_tininess_before_rounding, - &env->fpu_status); - - /* Reset state inside the kernel that we cannot access yet from QEMU. */ - if (kvm_enabled()) { - kvm_s390_reset_vcpu(cpu); - } -} - #if !defined(CONFIG_USER_ONLY) static void s390_cpu_machine_reset_cb(void *opaque) { @@ -456,6 +427,11 @@ static Property s390x_cpu_properties[] = { DEFINE_PROP_END_OF_LIST() }; +static void s390_cpu_reset_full(CPUState *s) +{ + return s390_cpu_reset(s, S390_CPU_RESET_CLEAR); +} + static void s390_cpu_class_init(ObjectClass *oc, void *data) { S390CPUClass *scc = S390_CPU_CLASS(oc); @@ -472,7 +448,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) scc->load_normal = s390_cpu_load_normal; #endif scc->reset = s390_cpu_reset; - cc->reset = s390_cpu_full_reset; + cc->reset = s390_cpu_reset_full; cc->class_by_name = s390_cpu_class_by_name, cc->has_work = s390_cpu_has_work; #ifdef CONFIG_TCG From patchwork Wed Nov 27 17:50:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 1201717 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47NTFX62dZz9sSb for ; Thu, 28 Nov 2019 05:05:04 +1100 (AEDT) Received: from localhost ([::1]:41248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia1gU-00016O-8C for incoming@patchwork.ozlabs.org; Wed, 27 Nov 2019 13:05:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47048) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia1TA-00089U-33 for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ia1T8-0003Pf-1n for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:15 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:63942 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ia1T6-0003Nv-1S for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:12 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xARHkW3u068028 for ; Wed, 27 Nov 2019 12:51:11 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2whcy82ha9-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Nov 2019 12:51:10 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Nov 2019 17:51:09 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 27 Nov 2019 17:51:06 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xARHp4rE17367212 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Nov 2019 17:51:04 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B1D87A4053; Wed, 27 Nov 2019 17:51:04 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 21FACA406D; Wed, 27 Nov 2019 17:51:02 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.82.185]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 27 Nov 2019 17:51:01 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH v4 5/6] s390x: Beautify diag308 handling Date: Wed, 27 Nov 2019 12:50:45 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191127175046.4911-1-frankja@linux.ibm.com> References: <20191127175046.4911-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19112717-0016-0000-0000-000002CD1056 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112717-0017-0000-0000-0000332EF1A3 Message-Id: <20191127175046.4911-6-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95, 18.0.572 definitions=2019-11-27_04:2019-11-27, 2019-11-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 adultscore=0 priorityscore=1501 phishscore=0 suspectscore=3 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911270145 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, pmorel@linux.ibm.com, david@redhat.com, cohuck@redhat.com, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, mihajlov@linux.ibm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Let's improve readability by: * Using constants for the subcodes * Moving parameter checking into a function * Removing subcode > 6 check as the default case catches that Signed-off-by: Janosch Frank Reviewed-by: Cornelia Huck Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand --- target/s390x/diag.c | 54 +++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/target/s390x/diag.c b/target/s390x/diag.c index 53c2f81f2a..b5aec06d6b 100644 --- a/target/s390x/diag.c +++ b/target/s390x/diag.c @@ -53,6 +53,29 @@ int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3) #define DIAG_308_RC_NO_CONF 0x0102 #define DIAG_308_RC_INVALID 0x0402 +#define DIAG308_RESET_MOD_CLR 0 +#define DIAG308_RESET_LOAD_NORM 1 +#define DIAG308_LOAD_CLEAR 3 +#define DIAG308_LOAD_NORMAL_DUMP 4 +#define DIAG308_SET 5 +#define DIAG308_STORE 6 + +static int diag308_parm_check(CPUS390XState *env, uint64_t r1, uint64_t addr, + uintptr_t ra, bool write) +{ + if ((r1 & 1) || (addr & ~TARGET_PAGE_MASK)) { + s390_program_interrupt(env, PGM_SPECIFICATION, ra); + return -1; + } + if (!address_space_access_valid(&address_space_memory, addr, + sizeof(IplParameterBlock), write, + MEMTXATTRS_UNSPECIFIED)) { + s390_program_interrupt(env, PGM_ADDRESSING, ra); + return -1; + } + return 0; +} + void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra) { CPUState *cs = env_cpu(env); @@ -65,30 +88,24 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra) return; } - if ((subcode & ~0x0ffffULL) || (subcode > 6)) { + if (subcode & ~0x0ffffULL) { s390_program_interrupt(env, PGM_SPECIFICATION, ra); return; } switch (subcode) { - case 0: + case DIAG308_RESET_MOD_CLR: s390_ipl_reset_request(cs, S390_RESET_MODIFIED_CLEAR); break; - case 1: + case DIAG308_RESET_LOAD_NORM: s390_ipl_reset_request(cs, S390_RESET_LOAD_NORMAL); break; - case 3: + case DIAG308_LOAD_CLEAR: + /* Well we still lack the clearing bit... */ s390_ipl_reset_request(cs, S390_RESET_REIPL); break; - case 5: - if ((r1 & 1) || (addr & 0x0fffULL)) { - s390_program_interrupt(env, PGM_SPECIFICATION, ra); - return; - } - if (!address_space_access_valid(&address_space_memory, addr, - sizeof(IplParameterBlock), false, - MEMTXATTRS_UNSPECIFIED)) { - s390_program_interrupt(env, PGM_ADDRESSING, ra); + case DIAG308_SET: + if (diag308_parm_check(env, r1, addr, ra, false)) { return; } iplb = g_new0(IplParameterBlock, 1); @@ -110,15 +127,8 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra) out: g_free(iplb); return; - case 6: - if ((r1 & 1) || (addr & 0x0fffULL)) { - s390_program_interrupt(env, PGM_SPECIFICATION, ra); - return; - } - if (!address_space_access_valid(&address_space_memory, addr, - sizeof(IplParameterBlock), true, - MEMTXATTRS_UNSPECIFIED)) { - s390_program_interrupt(env, PGM_ADDRESSING, ra); + case DIAG308_STORE: + if (diag308_parm_check(env, r1, addr, ra, true)) { return; } iplb = s390_ipl_get_iplb(); From patchwork Wed Nov 27 17:50:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 1201712 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47NT2v466tz9sSS for ; Thu, 28 Nov 2019 04:55:51 +1100 (AEDT) Received: from localhost ([::1]:41176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia1XZ-0002mN-9L for incoming@patchwork.ozlabs.org; Wed, 27 Nov 2019 12:55:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47097) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia1TB-0008Bh-Fp for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ia1TA-0003Rs-9b for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:17 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56244) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ia1TA-0003PL-0o for qemu-devel@nongnu.org; Wed, 27 Nov 2019 12:51:16 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xARHkVIF097406 for ; Wed, 27 Nov 2019 12:51:13 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2whcxqv0x8-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Nov 2019 12:51:12 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Nov 2019 17:51:10 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 27 Nov 2019 17:51:09 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xARHp73K50331876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Nov 2019 17:51:07 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5B88FA4057; Wed, 27 Nov 2019 17:51:07 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1389BA404D; Wed, 27 Nov 2019 17:51:05 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.82.185]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 27 Nov 2019 17:51:04 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH v4 6/6] s390x: kvm: Make kvm_sclp_service_call void Date: Wed, 27 Nov 2019 12:50:46 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191127175046.4911-1-frankja@linux.ibm.com> References: <20191127175046.4911-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19112717-0028-0000-0000-000003C0C680 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112717-0029-0000-0000-00002483CE4E Message-Id: <20191127175046.4911-7-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95, 18.0.572 definitions=2019-11-27_04:2019-11-27, 2019-11-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 suspectscore=1 spamscore=0 phishscore=0 mlxlogscore=866 bulkscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911270145 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, pmorel@linux.ibm.com, david@redhat.com, cohuck@redhat.com, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, mihajlov@linux.ibm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" It defaults to returning 0 anyway and that return value is not necessary, as 0 is also the default rc that the caller would return. While doing that we can simplify the logic a bit and return early if we inject a PGM exception. Also we always set a 0 cc, so let's not base it on the rc of the sclp emulation functions. Signed-off-by: Janosch Frank Reviewed-by: Thomas Huth --- target/s390x/kvm.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 0c9d14b4b1..08bb1edca0 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1159,13 +1159,13 @@ void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code) kvm_s390_vcpu_interrupt(cpu, &irq); } -static int kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run, +static void kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run, uint16_t ipbh0) { CPUS390XState *env = &cpu->env; uint64_t sccb; uint32_t code; - int r = 0; + int r; sccb = env->regs[ipbh0 & 0xf]; code = env->regs[(ipbh0 & 0xf0) >> 4]; @@ -1173,11 +1173,9 @@ static int kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run, r = sclp_service_call(env, sccb, code); if (r < 0) { kvm_s390_program_interrupt(cpu, -r); - } else { - setcc(cpu, r); + return; } - - return 0; + setcc(cpu, 0); } static int handle_b2(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1) @@ -1240,7 +1238,7 @@ static int handle_b2(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1) setcc(cpu, 3); break; case PRIV_B2_SCLP_CALL: - rc = kvm_sclp_service_call(cpu, run, ipbh0); + kvm_sclp_service_call(cpu, run, ipbh0); break; default: rc = -1;