From nobody Tue Apr 30 18:43:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1574409654; cv=none; d=zoho.com; s=zohoarc; b=KBFSIw/8iCNYJlDSXIj5Jn3AZJ1SK2pOcnhCjJxjjMb6McpGgu2wzxfW1DX/FCTl2MaciSR4GYlN6Dq0OqBic5FzJONLfhzpKabWE2Hfr0qEmWa/jKvq6Bydq/MgQMpM3AtckzTogWUMLxPWrUq9LPgyrAXh0JjpRV3Dkppp2h4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574409654; 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=EeRJdn1BqEarmeLh0pE40ZtT6rvefSnnG5oL0/w2E3A=; b=dy6cIKvKV9+wm7HKNO08ZoBMOC4v8JKOiwWy2Ezns6BvaJft1iDaR82HH7MP7U13JRcujCtfZEyZsaLru7kUtIHnSKqhaI01Y8pM6aNtvsughKEZLk9+UsNh8qtlZITrfLfGg8/qJS8JnAq6sYZznQEzS46m+DEZq8bvIb6ufH4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1574409654678577.4839528141489; Fri, 22 Nov 2019 00:00:54 -0800 (PST) Received: from localhost ([::1]:48090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY3s5-0002G9-3H for importer@patchew.org; Fri, 22 Nov 2019 03:00:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40332) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY3kO-0002Jl-V1 for qemu-devel@nongnu.org; Fri, 22 Nov 2019 02:52:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iY3kN-0004OP-R3 for qemu-devel@nongnu.org; Fri, 22 Nov 2019 02:52:56 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:13422) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iY3kN-0004Nx-8Y for qemu-devel@nongnu.org; Fri, 22 Nov 2019 02:52:55 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAM7l5VM081033 for ; Fri, 22 Nov 2019 02:52:54 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wdqn0e0rt-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Nov 2019 02:52:54 -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 07:52:51 -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 07:52:49 -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 xAM7qmB944695762 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Nov 2019 07:52:48 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2874511C054; Fri, 22 Nov 2019 07:52:48 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 547D411C04C; Fri, 22 Nov 2019 07:52:46 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.41.23]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 22 Nov 2019 07:52:46 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 1/4] s390x: Don't do a normal reset on the initial cpu Date: Fri, 22 Nov 2019 02:52:15 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122075218.23935-1-frankja@linux.ibm.com> References: <20191122075218.23935-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112207-0008-0000-0000-0000033605BB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112207-0009-0000-0000-00004A5531FD Message-Id: <20191122075218.23935-2-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-21_07:2019-11-21,2019-11-21 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 clxscore=1015 suspectscore=1 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911220068 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 Tue Apr 30 18:43:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1574409848; cv=none; d=zoho.com; s=zohoarc; b=JESBMgi9MElpFwedZ8jpHzcepzMSdnfyHxZlcBBhXzdLO4EfNmzUpLaqgISEjOWTAf/CWToo5ocXKsI7GSCuh6jkTlgC2lBNxymemkuRfUciywWpl54Tvb0RcOjc2k/o4C3L1yweQbpZhWDoMDNEui/CB4infjwzIpLOz2F8OT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574409848; 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=JsMOSZmypvm9cv+LpGIn8c5FQs2HU5QtPlmWdjIPmE8=; b=X0Vn5nEd5kC2cIQaCuwRsqcYYaddwuAeQqigrZxsb6bVR0sU0hdVUIi1vKaLOj8msYic6xpzxYykvkOpx7YpQDjhHP19DbVEhZvXYYEI8U5RZ8umgDMIyrqGQgOgAHuuMZwqIK0YNZSyTEdYBITS33ZQ1CZyWjsszG0wqUzlzAk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 157440984870042.20048284374218; Fri, 22 Nov 2019 00:04:08 -0800 (PST) Received: from localhost ([::1]:48130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY3vC-00060X-8B for importer@patchew.org; Fri, 22 Nov 2019 03:04:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40366) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY3kR-0002Nq-AM for qemu-devel@nongnu.org; Fri, 22 Nov 2019 02:53:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iY3kP-0004Qb-P2 for qemu-devel@nongnu.org; Fri, 22 Nov 2019 02:52:59 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:25250 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 1iY3kP-0004QP-KK for qemu-devel@nongnu.org; Fri, 22 Nov 2019 02:52:57 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAM7l6Iv034926 for ; Fri, 22 Nov 2019 02:52:57 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wdfxvvfpu-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Nov 2019 02:52:57 -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 07:52:55 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) 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 07:52:52 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAM7qCfm44499318 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Nov 2019 07:52:12 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 997D111C05C; Fri, 22 Nov 2019 07:52:50 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 86E7411C04A; Fri, 22 Nov 2019 07:52:48 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.41.23]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 22 Nov 2019 07:52:48 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 2/4] s390x: Cleanup cpu resets Date: Fri, 22 Nov 2019 02:52:16 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122075218.23935-1-frankja@linux.ibm.com> References: <20191122075218.23935-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112207-0008-0000-0000-0000033605BC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112207-0009-0000-0000-00004A5531FF Message-Id: <20191122075218.23935-3-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-21_07:2019-11-21,2019-11-21 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 mlxlogscore=999 malwarescore=0 suspectscore=1 mlxscore=0 phishscore=0 spamscore=0 priorityscore=1501 bulkscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911220068 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 move the resets into one function and switch by type, so we can use fallthroughs for shared reset actions. Signed-off-by: Janosch Frank --- target/s390x/cpu.c | 110 ++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 62 deletions(-) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 3abe7e80fd..556afecbc1 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -82,67 +82,52 @@ static void s390_cpu_load_normal(CPUState *s) } #endif =20 -/* S390CPUClass::cpu_reset() */ -static void s390_cpu_reset(CPUState *s) +typedef enum cpu_reset_type { + S390_CPU_RESET_NORMAL, + S390_CPU_RESET_INITIAL, + S390_CPU_RESET_CLEAR, +} cpu_reset_type; + +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); -} =20 -/* S390CPUClass::initial_reset() */ -static void s390_cpu_initial_reset(CPUState *s) -{ - S390CPU *cpu =3D S390_CPU(s); - CPUS390XState *env =3D &cpu->env; + /* Set initial values after clearing */ + switch (type) { + case S390_CPU_RESET_CLEAR: + memset(env, 0, offsetof(CPUS390XState, start_initial_reset_fields)= ); + /* Fallthrough */ + case S390_CPU_RESET_INITIAL: + 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; =20 - s390_cpu_reset(s); - /* 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); + /* architectured initial value for Breaking-Event-Address register= */ + env->gbea =3D 1; + /* tininess for underflow is detected before rounding */ + set_float_detect_tininess(float_tininess_before_rounding, + &env->fpu_status); + /* Fallthrough */ + case S390_CPU_RESET_NORMAL: + env->pfault_token =3D -1UL; + env->bpbc =3D false; + break; + } =20 /* Reset state inside the kernel that we cannot access yet from QEMU. = */ - if (kvm_enabled()) { - kvm_s390_reset_vcpu(cpu); + if (kvm_enabled() && (type =3D=3D S390_CPU_RESET_CLEAR || + type =3D=3D S390_CPU_RESET_INITIAL)) { + kvm_s390_reset_vcpu(cpu); } -} - -/* 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; =20 #if defined(CONFIG_USER_ONLY) /* user mode should always be allowed to use the full FPU */ @@ -151,20 +136,21 @@ static void s390_cpu_full_reset(CPUState *s) env->cregs[0] |=3D CR0_VECTOR; } #endif +} =20 - /* architectured initial value for Breaking-Event-Address register */ - env->gbea =3D 1; +static void s390_cpu_reset_normal(CPUState *s) +{ + return s390_cpu_reset(s, S390_CPU_RESET_NORMAL); +} =20 - env->pfault_token =3D -1UL; +static void s390_cpu_reset_initial(CPUState *s) +{ + return s390_cpu_reset(s, S390_CPU_RESET_INITIAL); +} =20 - /* 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); - } +static void s390_cpu_reset_clear(CPUState *s) +{ + return s390_cpu_reset(s, S390_CPU_RESET_CLEAR); } =20 #if !defined(CONFIG_USER_ONLY) @@ -473,9 +459,9 @@ 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->initial_cpu_reset =3D s390_cpu_initial_reset; - cc->reset =3D s390_cpu_full_reset; + scc->cpu_reset =3D s390_cpu_reset_normal; + scc->initial_cpu_reset =3D s390_cpu_reset_initial; + 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 Tue Apr 30 18:43:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1574410159; cv=none; d=zoho.com; s=zohoarc; b=m9KkUJwRFPXA4+2DiD85OuIYBbpYViMwao7qypjt1FWRgIwnuQWeD95G27ZrVTuSu9c8OBU7ry4/D4DDTQ9RWlVyjaSgRZ/3LqF1oPnxJMosFt/FHHbzpk09iwLHi+pYxiAUOo2adui2d5s+42VdwcGRgAXJ121dsJCqDuGWIxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574410159; 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=cJeTBhFy1hKTRhbMOIZh2VLyEMTX/g3HW8djeruH7uY=; b=A03deINPal4yu85rydkORI/Iniyj73lYWXc6eyaNekWRItLEnN4+j6jWkvkJgnIU6oTgNqlgTohgc2h/VeRSOKFWKcCaO7RyXjLMvAhM/7Wi+abDttzIeTAwVzx+iFieGkukBHSOWBOxNcjKUhm0gx4pKM8MKy6ehkfryS/SDdY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1574410159934933.5351000964473; Fri, 22 Nov 2019 00:09:19 -0800 (PST) Received: from localhost ([::1]:48244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY40E-000567-Pl for importer@patchew.org; Fri, 22 Nov 2019 03:09:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40388) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY3kU-0002Sg-0s for qemu-devel@nongnu.org; Fri, 22 Nov 2019 02:53:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iY3kS-0004SL-QP for qemu-devel@nongnu.org; Fri, 22 Nov 2019 02:53:01 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49272 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 1iY3kS-0004SA-Lm for qemu-devel@nongnu.org; Fri, 22 Nov 2019 02:53:00 -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 xAM7l6rx076891 for ; Fri, 22 Nov 2019 02:53:00 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wd3fnkc3u-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Nov 2019 02:53:00 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Nov 2019 07:52:58 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp03.uk.ibm.com (192.168.101.133) 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 07:52:54 -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 xAM7qrq151839006 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Nov 2019 07:52:53 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F04E911C052; Fri, 22 Nov 2019 07:52:52 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC20D11C04C; Fri, 22 Nov 2019 07:52:50 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.41.23]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 22 Nov 2019 07:52:50 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 3/4] s390x: Beautify diag308 handling Date: Fri, 22 Nov 2019 02:52:17 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122075218.23935-1-frankja@linux.ibm.com> References: <20191122075218.23935-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112207-0012-0000-0000-0000036AA873 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112207-0013-0000-0000-000021A63F98 Message-Id: <20191122075218.23935-4-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-21_07:2019-11-21,2019-11-21 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 phishscore=0 spamscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 adultscore=0 bulkscore=0 suspectscore=3 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911220068 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 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..18d33c8492 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 From nobody Tue Apr 30 18:43:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1574409416; cv=none; d=zoho.com; s=zohoarc; b=IFVWjxdeRKwvsR2I7EgIye713oyY6yZoyMXnDwlN8ZqhjLzEtFd2/obMif8cmxaOyWKMafa14OVRBIR+sPxYjewiItZBJLqpU139KBigpoVgwDXGtHKyclbkggw/YM1VS/tNdzmg4vRVN3KDGNBE3fVpxcQ9svhKPXcTftyHkFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574409416; 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=bqay1CinTn/BVnSru+/qLjCCNMElVWT5oeXPKmbc1Yc=; b=nLvKoJy3W0igHJ6tQ+8IsjMfdxeeWu5ceUy3rPSSKzc8/MpABFwz16eBsf157eyOXu+XZLOyKWH/cLgwvz55CqIa0WW3lF6SzXkqRVMRv/yDy5vvIEJMdpg3cBwTUfoiGJ31VDoNBtWJHiSSxNB+9bi0lJAEYgGhz6uGyQbfda8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1574409416442995.6878083012789; Thu, 21 Nov 2019 23:56:56 -0800 (PST) Received: from localhost ([::1]:48032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY3oE-00065o-Vv for importer@patchew.org; Fri, 22 Nov 2019 02:56:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40409) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iY3kV-0002TR-2N for qemu-devel@nongnu.org; Fri, 22 Nov 2019 02:53:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iY3kT-0004Ta-T0 for qemu-devel@nongnu.org; Fri, 22 Nov 2019 02:53:02 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47482 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 1iY3kT-0004TC-Oh for qemu-devel@nongnu.org; Fri, 22 Nov 2019 02:53:01 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAM7mAlh063289 for ; Fri, 22 Nov 2019 02:53:01 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wdkdff3qv-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Nov 2019 02:53:01 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Nov 2019 07:52:59 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp01.uk.ibm.com (192.168.101.131) 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 07:52:57 -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 xAM7qtmY50069650 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Nov 2019 07:52:55 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6972011C050; Fri, 22 Nov 2019 07:52:55 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5934011C05B; Fri, 22 Nov 2019 07:52:53 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.41.23]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 22 Nov 2019 07:52:53 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 4/4] s390x: Beautify machine reset Date: Fri, 22 Nov 2019 02:52:18 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122075218.23935-1-frankja@linux.ibm.com> References: <20191122075218.23935-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112207-4275-0000-0000-00000384C27D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112207-4276-0000-0000-000038984231 Message-Id: <20191122075218.23935-5-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-21_07:2019-11-21,2019-11-21 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 adultscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=1 malwarescore=0 priorityscore=1501 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911220068 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" * Add comments that tell you which diag308 subcode caused the reset * Sort by diag308 reset subcode Signed-off-by: Janosch Frank --- hw/s390x/s390-virtio-ccw.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index c1d1440272..88f7758721 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -330,15 +330,7 @@ static void s390_machine_reset(MachineState *machine) s390_cmma_reset(); =20 switch (reset_type) { - case S390_RESET_EXTERNAL: - case S390_RESET_REIPL: - qemu_devices_reset(); - s390_crypto_reset(); - - /* configure and start the ipl CPU only */ - run_on_cpu(cs, s390_do_cpu_ipl, RUN_ON_CPU_NULL); - break; - case S390_RESET_MODIFIED_CLEAR: + case S390_RESET_MODIFIED_CLEAR: /* Subcode 0 */ CPU_FOREACH(t) { run_on_cpu(t, s390_do_cpu_full_reset, RUN_ON_CPU_NULL); } @@ -346,7 +338,7 @@ static void s390_machine_reset(MachineState *machine) s390_crypto_reset(); run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL); break; - case S390_RESET_LOAD_NORMAL: + case S390_RESET_LOAD_NORMAL: /* Subcode 1 */ CPU_FOREACH(t) { if (t =3D=3D cs) { continue; @@ -357,6 +349,14 @@ static void s390_machine_reset(MachineState *machine) run_on_cpu(cs, s390_do_cpu_initial_reset, RUN_ON_CPU_NULL); run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL); break; + case S390_RESET_EXTERNAL: /* Externally triggered reboot */ + case S390_RESET_REIPL: /* Subcode 4 */ + qemu_devices_reset(); + s390_crypto_reset(); + + /* configure and start the ipl CPU only */ + run_on_cpu(cs, s390_do_cpu_ipl, RUN_ON_CPU_NULL); + break; default: g_assert_not_reached(); } --=20 2.20.1