From nobody Sat May 4 16:12:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1574431645; cv=none; d=zohomail.com; s=zohoarc; b=P9HjzRHnRgV51YBscy28eRG8MeoHSyxTe2Ix5DgUGQSzcKH+JWASLj9ctvbI4F236J+L2VrCSsRC/i0MCXVuIwAf/1m1tfdFC3/Oa2fj49tCrBsNSAiEddn0Dq+ygdjxr+IzxPB13w287kAtE6JHO16J0IneAKJDs2g3qRk3Ew0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574431645; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5dvhshdyF2mlQnh/3a1/sjikWzw6h1ha66beolRNSgU=; b=N6W68rvHOcyIwK9ULaXgXC4OfIJmIHxA6xqeNpZEbXK188jIJzxxbHYf3oD/pzkU/SnoyzR46iOL//hBU4v+cagWQv0aEqWxe4MCJj8Lzq7Qje4UM0pnVE7TYdDc/c63LdtrxW61snREoXkbq9k9FXF62LzX+SuAxB1k4SP0xFU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574431645046228.71547888846624; Fri, 22 Nov 2019 06:07:25 -0800 (PST) Received: from localhost ([::1]:51392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY9aj-0000hp-NB for importer@patchew.org; Fri, 22 Nov 2019 09:07:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58518) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY9U2-0001Ty-0E for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iY9Tw-0005MX-QC for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:25 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:4022) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iY9Tw-0005J1-0m for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:20 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAMDr3uG072263 for ; Fri, 22 Nov 2019 09:00:16 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wdqmjaj96-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Nov 2019 09:00:16 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Nov 2019 14:00:14 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) 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) Fri, 22 Nov 2019 14:00:11 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAME0ABF52101230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Nov 2019 14:00:10 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 252F911C075; Fri, 22 Nov 2019 14:00:10 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5BCC211C06E; Fri, 22 Nov 2019 14:00:08 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.41.23]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 22 Nov 2019 14:00:08 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH v2 1/5] s390x: Don't do a normal reset on the initial cpu Date: Fri, 22 Nov 2019 08:59:58 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122140002.42972-1-frankja@linux.ibm.com> References: <20191122140002.42972-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112214-0008-0000-0000-00000336291B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112214-0009-0000-0000-00004A5556E7 Message-Id: <20191122140002.42972-2-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-22_02:2019-11-21,2019-11-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 suspectscore=1 impostorscore=0 mlxscore=0 clxscore=1015 spamscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911220124 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The initiating cpu needs to be reset with an initial reset. While doing a normal reset followed by a initial reset is not wron per-se, the Ultravisor will only allow the correct reset to be performed. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand --- 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 =3D=3D cs) { + continue; + } run_on_cpu(t, s390_do_cpu_reset, RUN_ON_CPU_NULL); } subsystem_reset(); --=20 2.20.1 From nobody Sat May 4 16:12:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1574431493; cv=none; d=zohomail.com; s=zohoarc; b=Ef44TQFaB1Cqg6VJREFmDcHjKcCP6S2FKH2BNGemKh+ux35BY3W3B97Tuj/bXNAhw2ZfRoNIfh++xRyNnmkdJmy995nXjiFWObfCYXZVd5NDVuzwlYUQlOr2fo5OXqoqB7hGgEo4x8C2ouzCg7g6fAniuVvqK5f+2JEIFFHsPmk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574431493; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dYhs56ZFobIdCDZOXJfFXlE2W1ttvr1KmWu+AZu/79E=; b=O+xEdUnyCHlscCzccPXuKwS8NKIUsllnVjp1+jPKEv7xvEFiPNOwDYxcfZWJwYjdDkC7UejLivlaXIY09DYK1082/Ddb/vX0/5/FTYISQyBohQEYADuczEXGUn0clA64KgMdF88axf1vClm04PnBpvF/DuBbNS8XR3A9kn0eKk8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574431493372268.44939290682373; Fri, 22 Nov 2019 06:04:53 -0800 (PST) Received: from localhost ([::1]:51330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY9YI-0005j2-Cs for importer@patchew.org; Fri, 22 Nov 2019 09:04:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58523) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY9U2-0001UM-6l for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iY9Tw-0005Mu-S4 for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:26 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43988) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iY9Tw-0005KT-1g for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:20 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAMDt0Wj052637 for ; Fri, 22 Nov 2019 09:00:19 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wdu63kjmp-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Nov 2019 09:00:18 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Nov 2019 14:00:16 -0000 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.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) Fri, 22 Nov 2019 14:00:13 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAME0C6432178448 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Nov 2019 14:00:12 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3E71611C06C; Fri, 22 Nov 2019 14:00:12 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7C3A011C05B; Fri, 22 Nov 2019 14:00:10 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.41.23]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 22 Nov 2019 14:00:10 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH v2 2/5] s390x: Move reset normal to shared reset handler Date: Fri, 22 Nov 2019 08:59:59 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122140002.42972-1-frankja@linux.ibm.com> References: <20191122140002.42972-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112214-0008-0000-0000-00000336291D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112214-0009-0000-0000-00004A5556EA Message-Id: <20191122140002.42972-3-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-22_02:2019-11-21,2019-11-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 adultscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 clxscore=1015 bulkscore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911220124 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 --- target/s390x/cpu-qom.h | 6 +++++- target/s390x/cpu.c | 17 +++++++++++------ target/s390x/cpu.h | 2 +- target/s390x/sigp.c | 2 +- 4 files changed, 18 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; =20 +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; =20 diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 3abe7e80fd..cf13472472 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -82,18 +82,23 @@ static void s390_cpu_load_normal(CPUState *s) } #endif =20 -/* 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 =3D S390_CPU(s); S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); CPUS390XState *env =3D &cpu->env; =20 - env->pfault_token =3D -1UL; - env->bpbc =3D false; scc->parent_reset(s); cpu->env.sigp_order =3D 0; s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); + + switch (type) { + case S390_CPU_RESET_NORMAL: + env->pfault_token =3D -1UL; + env->bpbc =3D false; + break; + } } =20 /* S390CPUClass::initial_reset() */ @@ -102,7 +107,7 @@ static void s390_cpu_initial_reset(CPUState *s) S390CPU *cpu =3D S390_CPU(s); CPUS390XState *env =3D &cpu->env; =20 - 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 +478,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) #if !defined(CONFIG_USER_ONLY) scc->load_normal =3D s390_cpu_load_normal; #endif - scc->cpu_reset =3D s390_cpu_reset; + scc->reset =3D s390_cpu_reset; scc->initial_cpu_reset =3D s390_cpu_initial_reset; cc->reset =3D s390_cpu_full_reset; cc->class_by_name =3D 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 =3D S390_CPU_GET_CLASS(cs); =20 - scc->cpu_reset(cs); + scc->reset(cs, S390_CPU_RESET_NORMAL); } =20 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_dat= a arg) SigpInfo *si =3D arg.host_ptr; =20 cpu_synchronize_state(cs); - scc->cpu_reset(cs); + scc->reset(cs, S390_CPU_RESET_NORMAL); cpu_synchronize_post_reset(cs); si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } --=20 2.20.1 From nobody Sat May 4 16:12:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1574431380; cv=none; d=zohomail.com; s=zohoarc; b=CDDD022Kw+Fee6UPUuMwLt4b07C+c+U/WhvKHovDxzw8yFbOfCbBdOipWuLkbCCIlrOS5Jjkfsz62JmTIGKKv3D73kn5rYSkvGwCq8JD4VjeXiNuTT3IZs3CuYfUcrZE1j3jXLloJsk3pT9L10YToAdLBu9Y2A1DESF+6CCNVrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574431380; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a4eELFwPo/5K0oYbK8g9U8UlW7nK5LEpcyyfL+gKo+w=; b=aTTpzZ65JocZPoWPhAEJ5kejQnIf+1CmUFCuBRhyABQBd6OrUJ5xmQi1HuMvtnFJ7DuZH5NZ1jnzwbAZD3r0z3BlWfMrc9Gbu5VZXhNjbSeiDtDfg92UUU8D1gmL7s3hz0Vnx7makIwVNRLZNMag5aonrgfBsSiLgKd3tHME0V4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574431380841575.886281501382; Fri, 22 Nov 2019 06:03:00 -0800 (PST) Received: from localhost ([::1]:51258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY9WV-0003BT-BI for importer@patchew.org; Fri, 22 Nov 2019 09:02:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58598) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY9U5-0001ZD-7v for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iY9Tz-0005R3-W6 for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:29 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50160) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iY9Ty-0005NK-0Q for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:23 -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 xAMDr4Kl103464 for ; Fri, 22 Nov 2019 09:00:21 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wefdgut3q-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Nov 2019 09:00:20 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Nov 2019 14:00:18 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 22 Nov 2019 14:00:16 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAME0EAC60424322 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Nov 2019 14:00:14 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5826D11C05C; Fri, 22 Nov 2019 14:00:14 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8AE9A11C073; Fri, 22 Nov 2019 14:00:12 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.41.23]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 22 Nov 2019 14:00:12 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH v2 3/5] s390x: Move initial reset Date: Fri, 22 Nov 2019 09:00:00 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122140002.42972-1-frankja@linux.ibm.com> References: <20191122140002.42972-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112214-0020-0000-0000-0000038D5B32 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112214-0021-0000-0000-000021E39B99 Message-Id: <20191122140002.42972-4-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-22_02:2019-11-21,2019-11-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 adultscore=0 suspectscore=1 spamscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911220124 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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, 19 insertions(+), 31 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; =20 typedef enum cpu_reset_type { S390_CPU_RESET_NORMAL, + S390_CPU_RESET_INITIAL, } cpu_reset_type; =20 /** @@ -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; =20 typedef struct S390CPU S390CPU; diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index cf13472472..1f423fb676 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -94,37 +94,26 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type = type) s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); =20 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 =3D 1; + + /* architectured initial values for CR 0 and 14 */ + env->cregs[0] =3D CR0_RESET; + env->cregs[14] =3D CR14_RESET; + + /* tininess for underflow is detected before rounding */ + set_float_detect_tininess(float_tininess_before_rounding, + &env->fpu_status); case S390_CPU_RESET_NORMAL: env->pfault_token =3D -1UL; env->bpbc =3D false; - break; } -} - -/* S390CPUClass::initial_reset() */ -static void s390_cpu_initial_reset(CPUState *s) -{ - S390CPU *cpu =3D S390_CPU(s); - CPUS390XState *env =3D &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] =3D CR0_RESET; - env->cregs[14] =3D CR14_RESET; - - /* architectured initial value for Breaking-Event-Address register */ - env->gbea =3D 1; - - env->pfault_token =3D -1UL; - - /* tininess for underflow is detected before rounding */ - set_float_detect_tininess(float_tininess_before_rounding, - &env->fpu_status); =20 /* Reset state inside the kernel that we cannot access yet from QEMU. = */ if (kvm_enabled()) { @@ -479,7 +468,6 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) scc->load_normal =3D s390_cpu_load_normal; #endif scc->reset =3D s390_cpu_reset; - scc->initial_cpu_reset =3D s390_cpu_initial_reset; cc->reset =3D s390_cpu_full_reset; cc->class_by_name =3D s390_cpu_class_by_name, cc->has_work =3D 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 =3D S390_CPU_GET_CLASS(cs); =20 - scc->initial_cpu_reset(cs); + scc->reset(cs, S390_CPU_RESET_INITIAL); } =20 static inline void s390_do_cpu_load_normal(CPUState *cs, run_on_cpu_data a= rg) 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 =3D arg.host_ptr; =20 cpu_synchronize_state(cs); - scc->initial_cpu_reset(cs); + scc->reset(cs, S390_CPU_RESET_INITIAL); cpu_synchronize_post_reset(cs); si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } --=20 2.20.1 From nobody Sat May 4 16:12:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1574431513; cv=none; d=zohomail.com; s=zohoarc; b=OQ5gcBH5FAZbdp/3R3Ssa0kEiDKmOwKH95P37jPlOtx592oKjRIyNddX0OzvUBr4zzqvlF+FPlPM3iF9c6Pbw5bvrmJ4VtDNc8WP8JPXEA5P6s7NkhcB2/6+kRBN7QbOEvMR1PWyTDCKTX/DSBLgTvuqooYUlK9O6WmgE7iKrPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574431513; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bDkhjcyVjqFJIIKpsezeFyH9l1nqkNf0sZkghM1govM=; b=ccmaEx0di/L4jnARl55F14YZSa2qOMIZoghNgZJHLUdsQX2BGKyWUl74MSsQ1yO3htkJ7WfQ1HJ9voCSCJXtsVtvET1bdNss9SQ1ndCLNoOL3IFVKfnLIxFhWcbMoMJiK/w0vQI9ynUAVkcDW66m7A6lO1Vvc5IuycMqo5Ino08= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157443151356923.55400654128323; Fri, 22 Nov 2019 06:05:13 -0800 (PST) Received: from localhost ([::1]:51340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY9Yd-0006Dl-Hb for importer@patchew.org; Fri, 22 Nov 2019 09:05:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58556) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY9U3-0001Wk-Dw for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iY9U1-0005T5-UC for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:27 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53692 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 1iY9Tz-0005OU-V6 for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:25 -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 xAMDrU5Z020336 for ; Fri, 22 Nov 2019 09:00:22 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wefjwawfv-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Nov 2019 09:00:21 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Nov 2019 14:00:20 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) 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) Fri, 22 Nov 2019 14:00:18 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAME0GKC48955392 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Nov 2019 14:00:16 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE0C411C052; Fri, 22 Nov 2019 14:00:16 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C998811C066; Fri, 22 Nov 2019 14:00:14 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.41.23]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 22 Nov 2019 14:00:14 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH v2 4/5] s390x: Move clear reset Date: Fri, 22 Nov 2019 09:00:01 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122140002.42972-1-frankja@linux.ibm.com> References: <20191122140002.42972-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112214-0028-0000-0000-000003BE0CD2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112214-0029-0000-0000-000024813971 Message-Id: <20191122140002.42972-5-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-22_02:2019-11-21,2019-11-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 priorityscore=1501 mlxlogscore=999 adultscore=0 suspectscore=1 mlxscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911220124 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's also move the clear reset function into the reset handler. Signed-off-by: Janosch Frank --- target/s390x/cpu-qom.h | 1 + target/s390x/cpu.c | 50 ++++++++---------------------------------- 2 files changed, 10 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; =20 /** diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 1f423fb676..017181fe4a 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 ty= pe) s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); =20 switch (type) { + case S390_CPU_RESET_CLEAR: + memset(env, 0, offsetof(CPUS390XState, start_initial_reset_fields)= ); + /* Fallthrough */ case S390_CPU_RESET_INITIAL: /* initial reset does not clear everything! */ memset(&env->start_initial_reset_fields, 0, @@ -121,46 +124,6 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type= type) } } =20 -/* CPUClass:reset() */ -static void s390_cpu_full_reset(CPUState *s) -{ - S390CPU *cpu =3D S390_CPU(s); - S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); - CPUS390XState *env =3D &cpu->env; - - scc->parent_reset(s); - cpu->env.sigp_order =3D 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] =3D CR0_RESET; - env->cregs[14] =3D CR14_RESET; - -#if defined(CONFIG_USER_ONLY) - /* user mode should always be allowed to use the full FPU */ - env->cregs[0] |=3D CR0_AFP; - if (s390_has_feat(S390_FEAT_VECTOR)) { - env->cregs[0] |=3D CR0_VECTOR; - } -#endif - - /* architectured initial value for Breaking-Event-Address register */ - env->gbea =3D 1; - - env->pfault_token =3D -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) { @@ -452,6 +415,11 @@ static Property s390x_cpu_properties[] =3D { DEFINE_PROP_END_OF_LIST() }; =20 +static void s390_cpu_reset_clear(CPUState *s) +{ + return s390_cpu_reset(s, S390_CPU_RESET_CLEAR); +} + static void s390_cpu_class_init(ObjectClass *oc, void *data) { S390CPUClass *scc =3D S390_CPU_CLASS(oc); @@ -468,7 +436,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) scc->load_normal =3D s390_cpu_load_normal; #endif scc->reset =3D s390_cpu_reset; - cc->reset =3D s390_cpu_full_reset; + cc->reset =3D s390_cpu_reset_clear; cc->class_by_name =3D s390_cpu_class_by_name, cc->has_work =3D s390_cpu_has_work; #ifdef CONFIG_TCG --=20 2.20.1 From nobody Sat May 4 16:12:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1574431572; cv=none; d=zohomail.com; s=zohoarc; b=PSjG7erelKI2Aaj/QVwPHnifUXwVxL6vTMpqXFcvuhy+BRKdFwz9ptJROO7NvnTtLj0ggFAALDcgdRedGbGwFSfUYKX39k9SuNss5VeOo/Yek/KqljuK6YkfbHqdBdGXAbfB+dqjwbDa+pe7g+xf5RY2WClXXlfm7Wc3np2txUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574431572; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mkNVqSDuLJz8aQlHQIZQz+S+OemF1A5IbVB1Gx+Ebz8=; b=OlBk63VHWaoHXKleKIDubeUTJd6qsa1o0BlnrqZ6vQ2kVay+EpV0maMIl26F5ojzEFYe9aQAh+54p8dhoJtdeGaa3WZPvyQGv/iS0lb7scxQyHRtXb5v1pO0pM2Wn5AOSzzvdhR/bAemANAFeJfTuN1dDG6qtMoOxBF6Npjdioc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574431572618672.388104603705; Fri, 22 Nov 2019 06:06:12 -0800 (PST) Received: from localhost ([::1]:51368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY9Za-0007i7-KP for importer@patchew.org; Fri, 22 Nov 2019 09:06:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58571) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY9U3-0001XW-To for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iY9U2-0005Te-7t for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:27 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:48288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iY9U1-0005Sf-UA for qemu-devel@nongnu.org; Fri, 22 Nov 2019 09:00:26 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAMDswdU052467 for ; Fri, 22 Nov 2019 09:00:25 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wdu63kjw5-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Nov 2019 09:00:24 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Nov 2019 14:00:22 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) 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) Fri, 22 Nov 2019 14:00:20 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAME0Ito30474364 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Nov 2019 14:00:18 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C1C4611C06E; Fri, 22 Nov 2019 14:00:18 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 20DA511C066; Fri, 22 Nov 2019 14:00:17 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.41.23]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 22 Nov 2019 14:00:16 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH v2 5/5] s390x: Beautify diag308 handling Date: Fri, 22 Nov 2019 09:00:02 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122140002.42972-1-frankja@linux.ibm.com> References: <20191122140002.42972-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112214-0008-0000-0000-000003362921 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112214-0009-0000-0000-00004A5556ED Message-Id: <20191122140002.42972-6-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-22_02:2019-11-21,2019-11-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 adultscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=3 clxscore=1015 bulkscore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911220124 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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, uin= t64_t r3) #define DIAG_308_RC_NO_CONF 0x0102 #define DIAG_308_RC_INVALID 0x0402 =20 +#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 ad= dr, + 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 =3D env_cpu(env); @@ -65,30 +88,24 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, u= int64_t r3, uintptr_t ra) return; } =20 - if ((subcode & ~0x0ffffULL) || (subcode > 6)) { + if (subcode & ~0x0ffffULL) { s390_program_interrupt(env, PGM_SPECIFICATION, ra); return; } =20 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 =3D 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 =3D s390_ipl_get_iplb(); --=20 2.20.1