From nobody Sat May 4 18:17:30 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=1574251005; cv=none; d=zoho.com; s=zohoarc; b=lxbNy0XDOQJSs2asSf0oltel+92bG8RSisKF55QTaySJtgzo4b/CzMptVAWw98eVcBCZgRKcwqr8RgHee6HHkfYgVy3KiuWzX/YwxniKMDEefFgagTtlyXSzTRlhJWNCesz3iwOWACV+fjO7eZP3veySBYAnoIY6kHHRDgFQBqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574251005; 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=mqQaH3oh6unZGUkstKyyeVhqAGScPSTUE7r0ZmI+EWw=; b=jU3TfBXR5lxNKNYvcgscP3raKwF4FQii3txZstLewDwjwSf2Vo1z2G3StAXkuYZHe0U4uc687YbzSMPVEzsTIIAAts+OnIE86UE1hIShppy3Q+0Uv2o3rS8PnOOSeYPtcwPYd60V6G0t9GIDQsb+fk8wTpAMdviR1bvbwXsgtrc= 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 1574251005639129.68569969322414; Wed, 20 Nov 2019 03:56:45 -0800 (PST) Received: from localhost ([::1]:56916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXObC-0000iI-Hh for importer@patchew.org; Wed, 20 Nov 2019 06:56:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43332) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOOv-00038P-DT for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOOt-0003Bp-VS for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:01 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:3790) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXOOr-00031M-VX for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:43:59 -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 xAKBfvb0089577 for ; Wed, 20 Nov 2019 06:43:55 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wbxndrtjq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:43:55 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:43:53 -0000 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.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, 20 Nov 2019 11:43:49 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBhmo947120820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:43:48 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA6744C044; Wed, 20 Nov 2019 11:43:47 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C6B4D4C040; Wed, 20 Nov 2019 11:43:46 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:43:46 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 01/15] s390x: Cleanup cpu resets Date: Wed, 20 Nov 2019 06:43:20 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-0016-0000-0000-000002C9CC51 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-0017-0000-0000-0000332B8B7D Message-Id: <20191120114334.2287-2-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 clxscore=1015 adultscore=0 malwarescore=0 spamscore=0 mlxscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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 resets into one function and switch by type, so we can use fallthroughs for shared reset actions. Signed-off-by: Janosch Frank --- hw/s390x/s390-virtio-ccw.c | 3 + target/s390x/cpu.c | 111 ++++++++++++++++--------------------- 2 files changed, 52 insertions(+), 62 deletions(-) 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(); diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 3abe7e80fd..10d5b915d8 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -82,67 +82,53 @@ static void s390_cpu_load_normal(CPUState *s) } #endif =20 -/* S390CPUClass::cpu_reset() */ -static void s390_cpu_reset(CPUState *s) +enum { + S390_CPU_RESET_NORMAL, + S390_CPU_RESET_INITIAL, + S390_CPU_RESET_CLEAR, +}; + +static void s390_cpu_reset(CPUState *s, uint8_t 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: + /* Fallthrough will clear the rest */ + 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 +137,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 +460,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 Sat May 4 18:17:30 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=1574250683; cv=none; d=zoho.com; s=zohoarc; b=NdQ51jml4tnoO3x0DtZ9O73nafX+/13Z4EJcFlEU8dbynVEScmIkIAiXsKVIksnztZ0u00gB0uTPAWbNppSxBnxXy3/8cyDllAHvdKk4DaoiP4LyRbnda5Dk2sOicwGcMFOyqqp7G7TUILmy7AQQND3lXy2me6jklE9dsAUP5O4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574250683; 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=mGxWcgqaikkGGk1W1m5wWNCIru496ousWjlRwWKIny4=; b=KfAjucJ70ECueRdTrgXl8XCojQ8/QhJ5eSx6tOS/ss6IX5ydJFvcIHivzqRRP3W2sVVjPle4BoZqVONrogQKJyg0l/jOP83r/kag93BywK9dKS5FxyTmoLnHEsJO0mCPJVw6IIn3IXdUtDJEHuOjcGFu3RBQ0JB9BUfUmT11G90= 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 157425068354649.69876789994669; Wed, 20 Nov 2019 03:51:23 -0800 (PST) Received: from localhost ([::1]:56852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOW1-00018m-2r for importer@patchew.org; Wed, 20 Nov 2019 06:51:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43285) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOOu-00036G-22 for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOOs-000360-1F for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:43:59 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:61810 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 1iXOOq-000306-2N for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:43:57 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAKBg5PO174165 for ; Wed, 20 Nov 2019 06:43:55 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wcf35wd3e-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:43:54 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:43:53 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) 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, 20 Nov 2019 11:43:51 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBhBGH38601048 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:43:11 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EF074C046; Wed, 20 Nov 2019 11:43:49 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F45C4C044; Wed, 20 Nov 2019 11:43:48 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:43:48 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 02/15] s390x: Beautify diag308 handling Date: Wed, 20 Nov 2019 06:43:21 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-0016-0000-0000-000002C9CC52 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-0017-0000-0000-0000332B8B7E Message-Id: <20191120114334.2287-3-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 suspectscore=3 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 impostorscore=0 phishscore=0 spamscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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: David Hildenbrand Reviewed-by: Thomas Huth --- 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..067c667ba7 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_RES_MOD_CLR 0 +#define DIAG308_RES_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 -EINVAL; + } + if (!address_space_access_valid(&address_space_memory, addr, + sizeof(IplParameterBlock), write, + MEMTXATTRS_UNSPECIFIED)) { + s390_program_interrupt(env, PGM_ADDRESSING, ra); + return -EINVAL; + } + 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_RES_MOD_CLR: s390_ipl_reset_request(cs, S390_RESET_MODIFIED_CLEAR); break; - case 1: + case DIAG308_RES_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 Sat May 4 18:17:30 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=1574251108; cv=none; d=zoho.com; s=zohoarc; b=m3wEOLXVq+8JHro/cQE9D/crxHFUDXdrAnu9RJ2XhZpQUpm2MAqt7ixRlL+v/z4ABYdbRUeF7MRxGLVrv/MPjQxCSAy5D0eQI4GQR3o3KXTIvc2cvJ+4G1R4VtFs8sycmWBVTpfQvEJSKyWeFGpm8TcyyK+56ahe244kEqOaNK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574251108; 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=m2EV4+Vo0AjLi2yVPVlSDs0tATphunnHDCunAkD8t8M=; b=lh67mQEQxyVeumB/fGJqtoB12MF0RTKwEfBQXrupcgnl/h3jX7e/b7pedm8pLIWNZHFiychGBZJXutNBSMXyy6mz6D9Wi97e0qvR9F4nFDCd9Buh/IafwttUACvfCLyFzYcGhva/wbyjU8hUBhNdbTGNsnDNIi5+IFGSpGushlg= 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 1574251108132830.1418132154076; Wed, 20 Nov 2019 03:58:28 -0800 (PST) Received: from localhost ([::1]:56942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOcs-0003hq-3D for importer@patchew.org; Wed, 20 Nov 2019 06:58:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43351) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOOv-00039S-Vo for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOOu-0003DV-6o for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:01 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:1472 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 1iXOOt-0003AB-VC for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:00 -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 xAKBg315017539 for ; Wed, 20 Nov 2019 06:43:59 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wcf47duv9-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:43:59 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:43:56 -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, 20 Nov 2019 11:43:52 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBhoEf27263226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:43:50 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C77ED4C044; Wed, 20 Nov 2019 11:43:50 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 97D704C04A; Wed, 20 Nov 2019 11:43:49 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:43:49 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 03/15] s390x: protvirt: Add diag308 subcodes 8 - 10 Date: Wed, 20 Nov 2019 06:43:22 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-0008-0000-0000-00000335273D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-0009-0000-0000-00004A544B6F Message-Id: <20191120114334.2287-4-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 lowpriorityscore=0 mlxscore=0 mlxlogscore=999 suspectscore=3 spamscore=0 phishscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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" For diag308 subcodes 8 - 10 we have a new ipib of type 5. The ipib holds the address and length of the secure execution header, as well as a list of guest components. Each component is a block of memory, for example kernel or initrd, which needs to be decrypted by the Ultravisor in order to run a protected VM. The secure execution header instructs the Ultravisor on how to handle the protected VM and its components. Subcodes 8 and 9 are similiar to 5 and 6 and subcode 10 will finally start the protected guest. Subcodes 8-10 are not valid in protected mode, we have to do a subcode 3 and then the 8 and 10 combination for a protected reboot. Signed-off-by: Janosch Frank --- hw/s390x/ipl.c | 48 ++++++++++++++++++++++++++++++++++++++++++--- hw/s390x/ipl.h | 33 +++++++++++++++++++++++++++++++ target/s390x/diag.c | 26 ++++++++++++++++++++++-- 3 files changed, 102 insertions(+), 5 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index ca544d64c5..a077926f36 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -529,15 +529,56 @@ static bool is_virtio_scsi_device(IplParameterBlock *= iplb) return is_virtio_ccw_device_of_type(iplb, VIRTIO_ID_SCSI); } =20 +int s390_ipl_pv_check_comp(IplParameterBlock *iplb) +{ + int i; + IPLBlockPV *ipib_pv =3D &iplb->pv; + + if (ipib_pv->num_comp =3D=3D 0) { + return -EINVAL; + } + + for (i =3D 0; i < ipib_pv->num_comp; i++) { + + /* Addr must be 4k aligned */ + if (ipib_pv->components[i].addr & ~TARGET_PAGE_MASK) { + return -EINVAL; + } + + /* Tweak prefix is monotonously increasing with each component */ + if (i < ipib_pv->num_comp - 1 && + ipib_pv->components[i].tweak_pref > + ipib_pv->components[i + 1].tweak_pref) { + return -EINVAL; + } + } + return 1; +} + void s390_ipl_update_diag308(IplParameterBlock *iplb) { S390IPLState *ipl =3D get_ipl_device(); =20 - ipl->iplb =3D *iplb; - ipl->iplb_valid =3D true; + if (iplb->pbt =3D=3D 5) { + ipl->iplb_pbt5 =3D *iplb; + ipl->iplb_valid_pbt5 =3D true; + } else { + ipl->iplb =3D *iplb; + ipl->iplb_valid =3D true; + } ipl->netboot =3D is_virtio_net_device(iplb); } =20 +IplParameterBlock *s390_ipl_get_iplb_secure(void) +{ + S390IPLState *ipl =3D get_ipl_device(); + + if (!ipl->iplb_valid_pbt5) { + return NULL; + } + return &ipl->iplb_pbt5; +} + IplParameterBlock *s390_ipl_get_iplb(void) { S390IPLState *ipl =3D get_ipl_device(); @@ -552,7 +593,8 @@ void s390_ipl_reset_request(CPUState *cs, enum s390_res= et reset_type) { S390IPLState *ipl =3D get_ipl_device(); =20 - if (reset_type =3D=3D S390_RESET_EXTERNAL || reset_type =3D=3D S390_RE= SET_REIPL) { + if (reset_type =3D=3D S390_RESET_EXTERNAL || reset_type =3D=3D S390_RE= SET_REIPL || + reset_type =3D=3D S390_RESET_PV) { /* use CPU 0 for full resets */ ipl->reset_cpu_index =3D 0; } else { diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h index d4813105db..7b8a493509 100644 --- a/hw/s390x/ipl.h +++ b/hw/s390x/ipl.h @@ -15,6 +15,24 @@ #include "cpu.h" #include "hw/qdev-core.h" =20 +struct IPLBlockPVComp { + uint64_t tweak_pref; + uint64_t addr; + uint64_t size; +} QEMU_PACKED; +typedef struct IPLBlockPVComp IPLBlockPVComp; + +struct IPLBlockPV { + uint8_t reserved[84]; + uint8_t reserved67[3]; + uint8_t version; + uint32_t num_comp; + uint64_t pv_header_addr; + uint64_t pv_header_len; + struct IPLBlockPVComp components[]; +} QEMU_PACKED; +typedef struct IPLBlockPV IPLBlockPV; + struct IplBlockCcw { uint8_t reserved0[85]; uint8_t ssid; @@ -71,6 +89,7 @@ union IplParameterBlock { union { IplBlockCcw ccw; IplBlockFcp fcp; + IPLBlockPV pv; IplBlockQemuScsi scsi; }; } QEMU_PACKED; @@ -84,9 +103,11 @@ union IplParameterBlock { typedef union IplParameterBlock IplParameterBlock; =20 int s390_ipl_set_loadparm(uint8_t *loadparm); +int s390_ipl_pv_check_comp(IplParameterBlock *iplb); void s390_ipl_update_diag308(IplParameterBlock *iplb); void s390_ipl_prepare_cpu(S390CPU *cpu); IplParameterBlock *s390_ipl_get_iplb(void); +IplParameterBlock *s390_ipl_get_iplb_secure(void); =20 enum s390_reset { /* default is a reset not triggered by a CPU e.g. issued by QMP */ @@ -94,6 +115,7 @@ enum s390_reset { S390_RESET_REIPL, S390_RESET_MODIFIED_CLEAR, S390_RESET_LOAD_NORMAL, + S390_RESET_PV, }; void s390_ipl_reset_request(CPUState *cs, enum s390_reset reset_type); void s390_ipl_get_reset_request(CPUState **cs, enum s390_reset *reset_type= ); @@ -133,6 +155,7 @@ struct S390IPLState { /*< private >*/ DeviceState parent_obj; IplParameterBlock iplb; + IplParameterBlock iplb_pbt5; QemuIplParameters qipl; uint64_t start_addr; uint64_t compat_start_addr; @@ -140,6 +163,7 @@ struct S390IPLState { uint64_t compat_bios_start_addr; bool enforce_bios; bool iplb_valid; + bool iplb_valid_pbt5; bool netboot; /* reset related properties don't have to be migrated or reset */ enum s390_reset reset_type; @@ -161,9 +185,11 @@ QEMU_BUILD_BUG_MSG(offsetof(S390IPLState, iplb) & 3, "= alignment of iplb wrong"); =20 #define S390_IPL_TYPE_FCP 0x00 #define S390_IPL_TYPE_CCW 0x02 +#define S390_IPL_TYPE_PV 0x05 #define S390_IPL_TYPE_QEMU_SCSI 0xff =20 #define S390_IPLB_HEADER_LEN 8 +#define S390_IPLB_MIN_PV_LEN 148 #define S390_IPLB_MIN_CCW_LEN 200 #define S390_IPLB_MIN_FCP_LEN 384 #define S390_IPLB_MIN_QEMU_SCSI_LEN 200 @@ -185,4 +211,11 @@ static inline bool iplb_valid_fcp(IplParameterBlock *i= plb) iplb->pbt =3D=3D S390_IPL_TYPE_FCP; } =20 +static inline bool iplb_valid_se(IplParameterBlock *iplb) +{ + return be32_to_cpu(iplb->len) >=3D S390_IPLB_MIN_PV_LEN && + iplb->pbt =3D=3D S390_IPL_TYPE_PV; +} + + #endif diff --git a/target/s390x/diag.c b/target/s390x/diag.c index 067c667ba7..32049bb4ee 100644 --- a/target/s390x/diag.c +++ b/target/s390x/diag.c @@ -52,6 +52,8 @@ int handle_diag_288(CPUS390XState *env, uint64_t r1, uint= 64_t r3) #define DIAG_308_RC_OK 0x0001 #define DIAG_308_RC_NO_CONF 0x0102 #define DIAG_308_RC_INVALID 0x0402 +#define DIAG_308_RC_NO_PV_CONF 0x0a02 +#define DIAG_308_RC_INV_FOR_PV 0x0b02 =20 #define DIAG308_RES_MOD_CLR 0 #define DIAG308_RES_LOAD_NORM 1 @@ -59,6 +61,9 @@ int handle_diag_288(CPUS390XState *env, uint64_t r1, uint= 64_t r3) #define DIAG308_LOAD_NORMAL_DUMP 4 #define DIAG308_SET 5 #define DIAG308_STORE 6 +#define DIAG308_PV_SET 8 +#define DIAG308_PV_STORE 9 +#define DIAG308_PV_START 10 =20 static int diag308_parm_check(CPUS390XState *env, uint64_t r1, uint64_t ad= dr, uintptr_t ra, bool write) @@ -105,6 +110,7 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, u= int64_t r3, uintptr_t ra) s390_ipl_reset_request(cs, S390_RESET_REIPL); break; case DIAG308_SET: + case DIAG308_PV_SET: /* Set SE parms */ if (diag308_parm_check(env, r1, addr, ra, false)) { return; } @@ -117,7 +123,8 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, u= int64_t r3, uintptr_t ra) =20 cpu_physical_memory_read(addr, iplb, be32_to_cpu(iplb->len)); =20 - if (!iplb_valid_ccw(iplb) && !iplb_valid_fcp(iplb)) { + if (!iplb_valid_ccw(iplb) && !iplb_valid_fcp(iplb) && + !(iplb_valid_se(iplb) && s390_ipl_pv_check_comp(iplb) >=3D 0))= { env->regs[r1 + 1] =3D DIAG_308_RC_INVALID; goto out; } @@ -128,10 +135,15 @@ out: g_free(iplb); return; case DIAG308_STORE: + case DIAG308_PV_STORE: /* Get SE parms */ if (diag308_parm_check(env, r1, addr, ra, true)) { return; } - iplb =3D s390_ipl_get_iplb(); + if (subcode =3D=3D DIAG308_PV_STORE) { + iplb =3D s390_ipl_get_iplb_secure(); + } else { + iplb =3D s390_ipl_get_iplb(); + } if (iplb) { cpu_physical_memory_write(addr, iplb, be32_to_cpu(iplb->len)); env->regs[r1 + 1] =3D DIAG_308_RC_OK; @@ -139,6 +151,16 @@ out: env->regs[r1 + 1] =3D DIAG_308_RC_NO_CONF; } return; + break; + case DIAG308_PV_START: /* SE start */ + iplb =3D s390_ipl_get_iplb_secure(); + if (!iplb_valid_se(iplb)) { + env->regs[r1 + 1] =3D DIAG_308_RC_NO_PV_CONF; + return; + } + + s390_ipl_reset_request(cs, S390_RESET_PV); + break; default: s390_program_interrupt(env, PGM_SPECIFICATION, ra); break; --=20 2.20.1 From nobody Sat May 4 18:17:30 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=1574250881; cv=none; d=zoho.com; s=zohoarc; b=RQFbmzBWcM8zP7/wL0ajgEIREFh1MpZQZ4dxbfQkONKv9aG/7g0vxJ1tjr4VS3yxUuohH/sKlNiqVh10KDJbuDbnGO6QmMiU0Pe6CLqZYNiBpt1KS4ZYyFbGKKvkA6l/c367AUliYmeQCmH49gHejmnWmMXHtIvHv4P4dKhKWZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574250881; 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=O81wG6FKhpIov9fLeMwZcMfiEnJc6BttJ90anZNgE1Q=; b=frcO9XlnZblGPZf/I4eABC38CPSVJ3Dg/HZCnllEA4L8RkQe4qRZYRb3Krf0g0iCAetWpQcDcWiYfy/xngz5krkltRhMedPwX4Zm4d3wb6S6AX2YSrNtagTl3geWiMdaxMkXyGnp+M5XE118YsUqkrDCk0NPqwZCMTOEfgOpxBI= 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 1574250881411634.0006681088686; Wed, 20 Nov 2019 03:54:41 -0800 (PST) Received: from localhost ([::1]:56890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOZC-0005Sg-T6 for importer@patchew.org; Wed, 20 Nov 2019 06:54:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43342) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOOv-00038u-MD for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOOu-0003Ds-8m for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:01 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:23126) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXOOt-00039F-Us for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:00 -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 xAKBfvGC089583 for ; Wed, 20 Nov 2019 06:43:58 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wbxndrtn0-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:43:58 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:43:56 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) 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, 20 Nov 2019 11:43:53 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBhqwT36176082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:43:52 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E9244C040; Wed, 20 Nov 2019 11:43:52 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 15EC34C044; Wed, 20 Nov 2019 11:43:51 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:43:50 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 04/15] Header sync protvirt Date: Wed, 20 Nov 2019 06:43:23 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-0008-0000-0000-00000335273E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-0009-0000-0000-00004A544B71 Message-Id: <20191120114334.2287-5-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 clxscore=1015 adultscore=0 malwarescore=0 spamscore=0 mlxscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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 sync all the protvirt header changes Signed-off-by: Janosch Frank --- linux-headers/asm-s390/kvm.h | 3 ++- linux-headers/linux/kvm.h | 42 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/linux-headers/asm-s390/kvm.h b/linux-headers/asm-s390/kvm.h index 03ab5968c7..41976d33f0 100644 --- a/linux-headers/asm-s390/kvm.h +++ b/linux-headers/asm-s390/kvm.h @@ -255,7 +255,8 @@ struct kvm_sync_regs { __u8 reserved[512]; /* for future vector expansion */ __u32 fpc; /* valid on KVM_SYNC_VRS or KVM_SYNC_FPRS */ __u8 bpbc : 1; /* bp mode */ - __u8 reserved2 : 7; + __u8 pv : 1; /* pv mode */ + __u8 reserved2 : 6; __u8 padding1[51]; /* riccb needs to be 64byte aligned */ __u8 riccb[64]; /* runtime instrumentation controls block */ __u8 padding2[192]; /* sdnx needs to be 256byte aligned */ diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 18892d6541..d031051601 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -995,6 +995,8 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_ARM_SVE 170 #define KVM_CAP_ARM_PTRAUTH_ADDRESS 171 #define KVM_CAP_ARM_PTRAUTH_GENERIC 172 +#define KVM_CAP_S390_PROTECTED 180 +#define KVM_CAP_S390_VCPU_RESETS 181 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 @@ -1453,6 +1455,46 @@ struct kvm_enc_region { /* Available with KVM_CAP_ARM_SVE */ #define KVM_ARM_VCPU_FINALIZE _IOW(KVMIO, 0xc2, int) =20 +struct kvm_s390_pv_sec_parm { + __u64 origin; + __u64 length; +}; + +struct kvm_s390_pv_unp { + __u64 addr; + __u64 size; + __u64 tweak; +}; + +enum pv_cmd_id { + KVM_PV_VM_CREATE, + KVM_PV_VM_DESTROY, + KVM_PV_VM_SET_SEC_PARMS, + KVM_PV_VM_UNPACK, + KVM_PV_VM_VERIFY, + KVM_PV_VM_PERF_CLEAR_RESET, + KVM_PV_VM_UNSHARE, + KVM_PV_VCPU_CREATE, + KVM_PV_VCPU_DESTROY, +}; + +struct kvm_pv_cmd { + __u32 cmd; + __u16 rc; + __u16 rrc; + __u64 data; +}; + +/* Available with KVM_CAP_S390_PROTECTED */ +#define KVM_S390_PV_COMMAND _IOW(KVMIO, 0xc3, struct kvm_pv_cmd) +#define KVM_S390_PV_COMMAND_VCPU _IOW(KVMIO, 0xc4, struct kvm_pv_cmd) + +#define KVM_S390_VCPU_RESET_NORMAL 0 +#define KVM_S390_VCPU_RESET_INITIAL 1 +#define KVM_S390_VCPU_RESET_CLEAR 2 + +#define KVM_S390_VCPU_RESET _IO(KVMIO, 0xc5) + /* Secure Encrypted Virtualization command */ enum sev_cmd_id { /* Guest initialization commands */ --=20 2.20.1 From nobody Sat May 4 18:17:30 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=1574250400; cv=none; d=zoho.com; s=zohoarc; b=lQ6jp6lbab9SyW8EsoF3nyQAMBLAsolfRhANdoOoMMt2uDDs9tybSPg5+UxrXMsJ4nyGGkgP7DKgUf1JuJaiGnuN2W0aBZ/fR3ZaxOOhoJH6tgBFZgC76qx2PxOxaZHQnSho8u3DqBt6p1vELL1dvWy0Iuq7W7XQbTkFR942lW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574250400; 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=5XBs8+uW1ca96ngroG2dxNZSfD4U/vDFbjvULxFXq+w=; b=FFh0p3mjEyj0fmaZebnY5lqfJRtZcT28KnMEdQDUmFjPl2r0Y5CEi2YQaV2dUMBxmQnbcgk93EmSzi4MPhlGrZ/5pUz0HHHhRCoZAA9oRoFaNWiAt+GubIUWMGdnfswbH/jNaltffyTFjpg4hV//PxfUeNoY/4GCem3zwxU5yZs= 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 1574250400287412.6700378479368; Wed, 20 Nov 2019 03:46:40 -0800 (PST) Received: from localhost ([::1]:56810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXORS-0004xD-9r for importer@patchew.org; Wed, 20 Nov 2019 06:46:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43362) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOOw-0003A9-DA for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOOv-0003Hl-4M for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:02 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33438 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 1iXOOu-0003FZ-VP for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44: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 xAKBg0Cl017319 for ; Wed, 20 Nov 2019 06:44:00 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wcf47duxj-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:44:00 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:43:58 -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) Wed, 20 Nov 2019 11:43:55 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBhrvO58785966 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:43:53 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7873C4C04A; Wed, 20 Nov 2019 11:43:53 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 67C7C4C046; Wed, 20 Nov 2019 11:43:52 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:43:52 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 05/15] s390x: protvirt: Sync PV state Date: Wed, 20 Nov 2019 06:43:24 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-0008-0000-0000-00000335273F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-0009-0000-0000-00004A544B72 Message-Id: <20191120114334.2287-6-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 lowpriorityscore=0 mlxscore=0 mlxlogscore=957 suspectscore=1 spamscore=0 phishscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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" We do not always have the SIE intercept code handy at each place where we do emulation. Unfortunately emulation for secure guests often differ slightly from normal emulation and we need to make decisions based on the protected state of the VCPU. Let's sync the protected state and make it available. Signed-off-by: Janosch Frank --- linux-headers/asm-s390/kvm.h | 1 + target/s390x/cpu.h | 1 + target/s390x/kvm.c | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/linux-headers/asm-s390/kvm.h b/linux-headers/asm-s390/kvm.h index 41976d33f0..7c46cf6078 100644 --- a/linux-headers/asm-s390/kvm.h +++ b/linux-headers/asm-s390/kvm.h @@ -231,6 +231,7 @@ struct kvm_guest_debug_arch { #define KVM_SYNC_GSCB (1UL << 9) #define KVM_SYNC_BPBC (1UL << 10) #define KVM_SYNC_ETOKEN (1UL << 11) +#define KVM_SYNC_PV (1UL << 12) /* length and alignment of the sdnx as a power of two */ #define SDNXC 8 #define SDNXL (1UL << SDNXC) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 17460ed7b3..a787221772 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -116,6 +116,7 @@ struct CPUS390XState { =20 /* Fields up to this point are cleared by a CPU reset */ struct {} end_reset_fields; + bool pv; /* protected virtualization */ =20 #if !defined(CONFIG_USER_ONLY) uint32_t core_id; /* PoP "CPU address", same as cpu_index */ diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index c24c869e77..418154ccfe 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -676,6 +676,10 @@ int kvm_arch_get_registers(CPUState *cs) env->etoken_extension =3D cs->kvm_run->s.regs.etoken_extension; } =20 + if (can_sync_regs(cs, KVM_SYNC_PV)) { + env->pv =3D !!cs->kvm_run->s.regs.pv; + } + /* pfault parameters */ if (can_sync_regs(cs, KVM_SYNC_PFAULT)) { env->pfault_token =3D cs->kvm_run->s.regs.pft; --=20 2.20.1 From nobody Sat May 4 18:17:30 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=1574251176; cv=none; d=zoho.com; s=zohoarc; b=LuyiPo3MbccRvV6LhdT/0668bj2S2scFoJhRd07g7EkAFnadNC/Nw4X600H0zu48C6f1zZfPwdTQDXKGJ0c20biJNRCs2p60mj8M96/UKDMUeHgqhW4VIh4OZDbszX6ZO8oDZDuS/AVF8sJ7a7V2U2M2OAcG6N8weMRHda2Wr1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574251176; 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=++MA/TzyYLWM6/3UjMtsf5zfI98qeHeb9mmOl97V1so=; b=QJk9dCLqYWuQBWfA5nFWhD3hLuE7kv8jSlW/wZwzNz6sbS9pJfbxuQyfOiAOLdYBLDUpOveemchAM956+wjZa5b1xC0I6+32BP5ELR4XgKzrDJrcvtatVO/eNDaBKFPqB+CUvim3rPZBHSNlTaxW05lNPNy1cjEhuYgxiuZ+m8Y= 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 1574251176491889.7858010648888; Wed, 20 Nov 2019 03:59:36 -0800 (PST) Received: from localhost ([::1]:56946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOdy-0004RN-3r for importer@patchew.org; Wed, 20 Nov 2019 06:59:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43493) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOP1-0003Jg-Vn for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOP0-0003Vj-2P for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:07 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54534) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXOOz-0003SA-R5 for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:06 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAKBfwcm079157 for ; Wed, 20 Nov 2019 06:44:04 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wcendfxug-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:44:03 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:44:00 -0000 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.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) Wed, 20 Nov 2019 11:43:56 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBht9q31850772 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:43:55 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E8DD84C040; Wed, 20 Nov 2019 11:43:54 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BAA794C046; Wed, 20 Nov 2019 11:43:53 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:43:53 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 06/15] s390x: protvirt: Support unpack facility Date: Wed, 20 Nov 2019 06:43:25 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-0020-0000-0000-0000038C55AF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-0021-0000-0000-000021E288E0 Message-Id: <20191120114334.2287-7-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=3 malwarescore=0 phishscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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" When a guest has saved a ipib of type 5 and call diagnose308 with subcode 10, we have to setup the protected processing environment via Ultravisor calls. The calls are done by KVM and are exposed via an API. The following steps are necessary: 1. Create a VM (register it with the Ultravisor) 2. Create secure CPUs for all of our current cpus 3. Forward the secure header to the Ultravisor (has all information on how to decrypt the image and VM information) 4. Protect image pages from the host and decrypt them 5. Verify the image integrity Only after step 5 a protected VM is allowed to run. Signed-off-by: Janosch Frank --- hw/s390x/Makefile.objs | 1 + hw/s390x/ipl.c | 33 ++++++++ hw/s390x/ipl.h | 2 + hw/s390x/pv.c | 118 ++++++++++++++++++++++++++++ hw/s390x/pv.h | 26 ++++++ hw/s390x/s390-virtio-ccw.c | 45 ++++++++--- target/s390x/cpu_features_def.inc.h | 1 + 7 files changed, 216 insertions(+), 10 deletions(-) create mode 100644 hw/s390x/pv.c create mode 100644 hw/s390x/pv.h diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs index 94e57113d8..568bab9711 100644 --- a/hw/s390x/Makefile.objs +++ b/hw/s390x/Makefile.objs @@ -31,6 +31,7 @@ obj-y +=3D tod-qemu.o obj-$(CONFIG_KVM) +=3D tod-kvm.o obj-$(CONFIG_KVM) +=3D s390-skeys-kvm.o obj-$(CONFIG_KVM) +=3D s390-stattrib-kvm.o s390-mchk.o +obj-$(CONFIG_KVM) +=3D pv.o obj-y +=3D s390-ccw.o obj-y +=3D ap-device.o obj-y +=3D ap-bridge.o diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index a077926f36..50501fcd27 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -33,6 +33,7 @@ #include "qemu/cutils.h" #include "qemu/option.h" #include "exec/exec-all.h" +#include "pv.h" =20 #define KERN_IMAGE_START 0x010000UL #define LINUX_MAGIC_ADDR 0x010008UL @@ -668,6 +669,38 @@ static void s390_ipl_prepare_qipl(S390CPU *cpu) cpu_physical_memory_unmap(addr, len, 1, len); } =20 +int s390_ipl_prepare_pv_header(void) +{ + int rc; + IplParameterBlock *iplb =3D s390_ipl_get_iplb_secure(); + IPLBlockPV *ipib_pv =3D &iplb->pv; + void *hdr =3D g_malloc(ipib_pv->pv_header_len); + + cpu_physical_memory_read(ipib_pv->pv_header_addr, hdr, + ipib_pv->pv_header_len); + rc =3D s390_pv_set_sec_parms((uint64_t)hdr, + ipib_pv->pv_header_len); + g_free(hdr); + return rc; +} + +int s390_ipl_pv_unpack(void) +{ + int i, rc; + IplParameterBlock *iplb =3D s390_ipl_get_iplb_secure(); + IPLBlockPV *ipib_pv =3D &iplb->pv; + + for (i =3D 0; i < ipib_pv->num_comp; i++) { + rc =3D s390_pv_unpack(ipib_pv->components[i].addr, + TARGET_PAGE_ALIGN(ipib_pv->components[i].size), + ipib_pv->components[i].tweak_pref); + if (rc) { + return rc; + } + } + return rc; +} + void s390_ipl_prepare_cpu(S390CPU *cpu) { S390IPLState *ipl =3D get_ipl_device(); diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h index 7b8a493509..e848602c16 100644 --- a/hw/s390x/ipl.h +++ b/hw/s390x/ipl.h @@ -105,6 +105,8 @@ typedef union IplParameterBlock IplParameterBlock; int s390_ipl_set_loadparm(uint8_t *loadparm); int s390_ipl_pv_check_comp(IplParameterBlock *iplb); void s390_ipl_update_diag308(IplParameterBlock *iplb); +int s390_ipl_prepare_pv_header(void); +int s390_ipl_pv_unpack(void); void s390_ipl_prepare_cpu(S390CPU *cpu); IplParameterBlock *s390_ipl_get_iplb(void); IplParameterBlock *s390_ipl_get_iplb_secure(void); diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c new file mode 100644 index 0000000000..0218070322 --- /dev/null +++ b/hw/s390x/pv.c @@ -0,0 +1,118 @@ +/* + * Secure execution functions + * + * Copyright IBM Corp. 2019 + * Author(s): + * Janosch Frank + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ +#include "qemu/osdep.h" +#include + +#include + +#include "qemu/error-report.h" +#include "sysemu/kvm.h" +#include "pv.h" + +static int s390_pv_cmd(uint32_t cmd, void *data) +{ + int rc; + struct kvm_pv_cmd pv_cmd =3D { + .cmd =3D cmd, + .data =3D (uint64_t)data, + }; + + rc =3D kvm_vm_ioctl(kvm_state, KVM_S390_PV_COMMAND, &pv_cmd); + if (rc) { + error_report("KVM PV command failed cmd: %d rc: %d", cmd, rc); + exit(1); + } + return rc; +} + +static int s390_pv_cmd_vcpu(CPUState *cs, uint32_t cmd, void *data) +{ + int rc; + struct kvm_pv_cmd pv_cmd =3D { + .cmd =3D cmd, + .data =3D (uint64_t)data, + }; + + rc =3D kvm_vcpu_ioctl(cs, KVM_S390_PV_COMMAND_VCPU, &pv_cmd); + if (rc) { + error_report("KVM PV VCPU command failed cmd: %d rc: %d", cmd, rc); + exit(1); + } + return rc; +} + +int s390_pv_vm_create(void) +{ + return s390_pv_cmd(KVM_PV_VM_CREATE, NULL); +} + +int s390_pv_vm_destroy(void) +{ + return s390_pv_cmd(KVM_PV_VM_DESTROY, NULL); +} + +int s390_pv_vcpu_create(CPUState *cs) +{ + return s390_pv_cmd_vcpu(cs, KVM_PV_VCPU_CREATE, NULL); +} + +int s390_pv_vcpu_destroy(CPUState *cs) +{ + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + int rc; + + rc =3D s390_pv_cmd_vcpu(cs, KVM_PV_VCPU_DESTROY, NULL); + if (!rc) { + env->pv =3D false; + } + return rc; +} + +int s390_pv_set_sec_parms(uint64_t origin, uint64_t length) +{ + struct kvm_s390_pv_sec_parm args =3D { + .origin =3D origin, + .length =3D length, + }; + + return s390_pv_cmd(KVM_PV_VM_SET_SEC_PARMS, &args); +} + +/* + * Called for each component in the SE type IPL parameter block 0. + */ +int s390_pv_unpack(uint64_t addr, uint64_t size, uint64_t tweak) +{ + struct kvm_s390_pv_unp args =3D { + .addr =3D addr, + .size =3D size, + .tweak =3D tweak, + }; + + return s390_pv_cmd(KVM_PV_VM_UNPACK, &args); +} + +int s390_pv_perf_clear_reset(void) +{ + return s390_pv_cmd(KVM_PV_VM_PERF_CLEAR_RESET, NULL); +} + +int s390_pv_verify(void) +{ + return s390_pv_cmd(KVM_PV_VM_VERIFY, NULL); +} + +int s390_pv_unshare(void) +{ + return s390_pv_cmd(KVM_PV_VM_UNSHARE, NULL); +} diff --git a/hw/s390x/pv.h b/hw/s390x/pv.h new file mode 100644 index 0000000000..eb074e4bc9 --- /dev/null +++ b/hw/s390x/pv.h @@ -0,0 +1,26 @@ +/* + * Protected Virtualization header + * + * Copyright IBM Corp. 2019 + * Author(s): + * Janosch Frank + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ + +#ifndef HW_S390_PV_H +#define HW_S390_PV_H + +int s390_pv_vm_create(void); +int s390_pv_vm_destroy(void); +int s390_pv_vcpu_destroy(CPUState *cs); +int s390_pv_vcpu_create(CPUState *cs); +int s390_pv_set_sec_parms(uint64_t origin, uint64_t length); +int s390_pv_unpack(uint64_t addr, uint64_t size, uint64_t tweak); +int s390_pv_perf_clear_reset(void); +int s390_pv_verify(void); +int s390_pv_unshare(void); + +#endif /* HW_S390_PV_H */ diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index c1d1440272..7262453616 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -41,6 +41,7 @@ #include "hw/qdev-properties.h" #include "hw/s390x/tod.h" #include "sysemu/sysemu.h" +#include "hw/s390x/pv.h" =20 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr) { @@ -322,6 +323,7 @@ static void s390_machine_reset(MachineState *machine) { enum s390_reset reset_type; CPUState *cs, *t; + S390CPU *cpu; =20 /* get the reset parameters, reset them once done */ s390_ipl_get_reset_request(&cs, &reset_type); @@ -329,16 +331,10 @@ static void s390_machine_reset(MachineState *machine) /* all CPUs are paused and synchronized at this point */ s390_cmma_reset(); =20 - switch (reset_type) { - case S390_RESET_EXTERNAL: - case S390_RESET_REIPL: - qemu_devices_reset(); - s390_crypto_reset(); + cpu =3D S390_CPU(cs); =20 - /* 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: + switch (reset_type) { + 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 +342,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 +353,35 @@ 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: + 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; + case S390_RESET_PV: /* Subcode 10 */ + subsystem_reset(); + s390_crypto_reset(); + + CPU_FOREACH(t) { + run_on_cpu(t, s390_do_cpu_full_reset, RUN_ON_CPU_NULL); + } + + /* Create SE VM */ + s390_pv_vm_create(); + CPU_FOREACH(t) { + s390_pv_vcpu_create(t); + } + + /* Set SE header and unpack */ + s390_ipl_prepare_pv_header(); + /* Decrypt image */ + s390_ipl_pv_unpack(); + /* Verify integrity */ + s390_pv_verify(); + s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu); + break; default: g_assert_not_reached(); } diff --git a/target/s390x/cpu_features_def.inc.h b/target/s390x/cpu_feature= s_def.inc.h index 31dff0d84e..60db28351d 100644 --- a/target/s390x/cpu_features_def.inc.h +++ b/target/s390x/cpu_features_def.inc.h @@ -107,6 +107,7 @@ DEF_FEAT(DEFLATE_BASE, "deflate-base", STFL, 151, "Defl= ate-conversion facility ( DEF_FEAT(VECTOR_PACKED_DECIMAL_ENH, "vxpdeh", STFL, 152, "Vector-Packed-De= cimal-Enhancement Facility") DEF_FEAT(MSA_EXT_9, "msa9-base", STFL, 155, "Message-security-assist-exten= sion-9 facility (excluding subfunctions)") DEF_FEAT(ETOKEN, "etoken", STFL, 156, "Etoken facility") +DEF_FEAT(UNPACK, "unpack", STFL, 161, "Unpack facility") =20 /* Features exposed via SCLP SCCB Byte 80 - 98 (bit numbers relative to b= yte-80) */ DEF_FEAT(SIE_GSLS, "gsls", SCLP_CONF_CHAR, 40, "SIE: Guest-storage-limit-s= uppression facility") --=20 2.20.1 From nobody Sat May 4 18:17:30 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=1574250918; cv=none; d=zoho.com; s=zohoarc; b=CWJKJzT5TiUWqT+chA+/qku1jUi1vy9qN3pMXzLsP0SnNErcI7pkgGQi2uS510NIztxUQJvF4OhIK+eTTOZvYaxdbMwGbD0wMi3y4fh1BkK+DLGdBjnyHilnVkHpVceFJvv4ve2z5VmN2Unx/qhqmspQRk3//l4469p660lz7LM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574250918; 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=uEWWRXTdrrLEYsXJKlKr4M6BgSCH6eI3tKgx9JLxu9A=; b=WzJ1THO6QhymJjcJMlAzSUgnqQOjrF2daMSipMDEN8L27cyD+2ufnhXBoBWTrd25nNteUT8f+9IFzVUPBZtOGl0AM6WYSDEfIENvovhzhuhFA4kvsqetVZn0ap97Q3tqzSuXlgYu/9prPDUid33uwYcjlcvHWNSwh0caMlZDLkc= 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 1574250918379766.2516828480165; Wed, 20 Nov 2019 03:55:18 -0800 (PST) Received: from localhost ([::1]:56896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOZo-00073V-V1 for importer@patchew.org; Wed, 20 Nov 2019 06:55:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43408) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOOx-0003Bu-Hb for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOOw-0003Md-B4 for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:03 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39574 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 1iXOOw-0003Kk-4x for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:02 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAKBg516174138 for ; Wed, 20 Nov 2019 06:44:01 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wcf35wd9v-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:44:01 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:43:59 -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) Wed, 20 Nov 2019 11:43:57 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBhIUm21430660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:43:18 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 51E6E4C04E; Wed, 20 Nov 2019 11:43:56 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 37EA74C040; Wed, 20 Nov 2019 11:43:55 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:43:55 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 07/15] s390x: protvirt: Handle diag 308 subcodes 0,1,3,4 Date: Wed, 20 Nov 2019 06:43:26 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-0008-0000-0000-000003352740 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-0009-0000-0000-00004A544B73 Message-Id: <20191120114334.2287-8-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 suspectscore=1 mlxlogscore=985 priorityscore=1501 clxscore=1015 lowpriorityscore=0 impostorscore=0 phishscore=0 spamscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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" Now that we know the protection state off the cpus, we can start handling all diag 308 subcodes in the protected state. For subcodes 0 and 1 we need to unshare all pages before continuing, so the guest doesn't accidently expose data when dumping. For subcode 3/4 we tear down the protected VM and reboot into unprotected mode. We do not provide a secure reboot. Before we can do the unshare calls, we need to mark all cpus as stopped. Signed-off-by: Janosch Frank --- hw/s390x/s390-virtio-ccw.c | 30 +++++++++++++++++++++++++++--- target/s390x/diag.c | 4 ++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 7262453616..6fd50b4c42 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -319,11 +319,26 @@ static inline void s390_do_cpu_ipl(CPUState *cs, run_= on_cpu_data arg) s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu); } =20 +static void s390_pv_prepare_reset(CPUS390XState *env) +{ + CPUState *cs; + + if (!env->pv) { + return; + } + CPU_FOREACH(cs) { + s390_cpu_set_state(S390_CPU_STATE_STOPPED, S390_CPU(cs)); + } + s390_pv_unshare(); + s390_pv_perf_clear_reset(); +} + static void s390_machine_reset(MachineState *machine) { enum s390_reset reset_type; CPUState *cs, *t; S390CPU *cpu; + CPUS390XState *env; =20 /* get the reset parameters, reset them once done */ s390_ipl_get_reset_request(&cs, &reset_type); @@ -332,29 +347,38 @@ static void s390_machine_reset(MachineState *machine) s390_cmma_reset(); =20 cpu =3D S390_CPU(cs); + env =3D &cpu->env; =20 switch (reset_type) { case S390_RESET_MODIFIED_CLEAR: /* Subcode 0 */ + subsystem_reset(); + s390_crypto_reset(); + s390_pv_prepare_reset(env); CPU_FOREACH(t) { run_on_cpu(t, s390_do_cpu_full_reset, RUN_ON_CPU_NULL); } - subsystem_reset(); - s390_crypto_reset(); run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL); break; case S390_RESET_LOAD_NORMAL: /* Subcode 1*/ + subsystem_reset(); + s390_pv_prepare_reset(env); CPU_FOREACH(t) { if (t =3D=3D cs) { continue; } run_on_cpu(t, s390_do_cpu_reset, RUN_ON_CPU_NULL); } - subsystem_reset(); 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: case S390_RESET_REIPL: /* Subcode 4 */ + if (env->pv) { + CPU_FOREACH(t) { + s390_pv_vcpu_destroy(t); + } + s390_pv_vm_destroy(); + } qemu_devices_reset(); s390_crypto_reset(); /* configure and start the ipl CPU only */ diff --git a/target/s390x/diag.c b/target/s390x/diag.c index 32049bb4ee..db6d79cef3 100644 --- a/target/s390x/diag.c +++ b/target/s390x/diag.c @@ -68,6 +68,10 @@ int handle_diag_288(CPUS390XState *env, uint64_t r1, uin= t64_t r3) static int diag308_parm_check(CPUS390XState *env, uint64_t r1, uint64_t ad= dr, uintptr_t ra, bool write) { + /* Handled by the Ultravisor */ + if (env->pv) { + return 0; + } if ((r1 & 1) || (addr & ~TARGET_PAGE_MASK)) { s390_program_interrupt(env, PGM_SPECIFICATION, ra); return -EINVAL; --=20 2.20.1 From nobody Sat May 4 18:17:30 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=1574251039; cv=none; d=zoho.com; s=zohoarc; b=cBlQnADLpsh4KU8xogCQLZBXmmMTO8CIHJTKYPdXZavmbGBHEFju50te3kPiAWDNtQSQfrYeLFrHaY5KQNgv3ZMOcbY3RLYZ/yf+CSSSi2uZGWxFK/5qquN9/DiZlMZP+PU8JVkH2kZO6ZcFT21A7bbLg0yqrXSVRFIOjZwnce0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574251039; 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=Kmy64crDVd2+1mObclib4EQ7sQsrgGuVeaE2PA5sgI4=; b=GiYA8QFZ+Lehnv4IX3WCpmcoaPpsK4dYwJC+sg0HusaKkP44IStyPylm9EzyqBz+p+zo3ODU7cBWwpZ1ZNdIDHcbbfxcqjOPten4jY3kQJKXovViI2mfeVGgiBG7uHj2Kwsdx4fzL4VHPPN+uT8ktLgGvlvxm0Tl4o/Otwu7GhA= 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 1574251039961862.077103041692; Wed, 20 Nov 2019 03:57:19 -0800 (PST) Received: from localhost ([::1]:56918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXObm-0001z0-GS for importer@patchew.org; Wed, 20 Nov 2019 06:57:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43467) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOP1-0003I8-6i for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOP0-0003Vy-54 for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:07 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:15540) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXOOz-0003UZ-Tl for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:06 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAKBftON048542 for ; Wed, 20 Nov 2019 06:44:05 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wadmy9s3n-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:44:04 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:44:01 -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, 20 Nov 2019 11:43:59 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBhvlX55705628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:43:57 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 99E824C050; Wed, 20 Nov 2019 11:43:57 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B0484C046; Wed, 20 Nov 2019 11:43:56 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:43:56 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 08/15] s390x: protvirt: KVM intercept changes Date: Wed, 20 Nov 2019 06:43:27 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-0008-0000-0000-000003352741 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-0009-0000-0000-00004A544B74 Message-Id: <20191120114334.2287-9-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 mlxlogscore=938 impostorscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 spamscore=0 suspectscore=1 lowpriorityscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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" Secure guests no longer intercept with code 4 for an instruction interception. Instead they have codes 104 and 108 for secure instruction interception and secure instruction notification respectively. The 104 mirrors the 4, but the 108 is a notification, that something happened and the hypervisor might need to adjust its tracking data to that fact. An example for that is the set prefix notification interception, where KVM only reads the new prefix, but does not update the prefix in the state description. Signed-off-by: Janosch Frank --- target/s390x/kvm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 418154ccfe..58251c0229 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -115,6 +115,8 @@ #define ICPT_CPU_STOP 0x28 #define ICPT_OPEREXC 0x2c #define ICPT_IO 0x40 +#define ICPT_PV_INSTR 0x68 +#define ICPT_PV_INSTR_NOT 0x6c =20 #define NR_LOCAL_IRQS 32 /* @@ -151,6 +153,7 @@ static int cap_s390_irq; static int cap_ri; static int cap_gs; static int cap_hpage_1m; +static int cap_protvirt; =20 static int active_cmma; =20 @@ -336,6 +339,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_async_pf =3D kvm_check_extension(s, KVM_CAP_ASYNC_PF); cap_mem_op =3D kvm_check_extension(s, KVM_CAP_S390_MEM_OP); cap_s390_irq =3D kvm_check_extension(s, KVM_CAP_S390_INJECT_IRQ); + cap_protvirt =3D kvm_check_extension(s, KVM_CAP_S390_PROTECTED); =20 if (!kvm_check_extension(s, KVM_CAP_S390_GMAP) || !kvm_check_extension(s, KVM_CAP_S390_COW)) { @@ -1664,6 +1668,8 @@ static int handle_intercept(S390CPU *cpu) (long)cs->kvm_run->psw_addr); switch (icpt_code) { case ICPT_INSTRUCTION: + case ICPT_PV_INSTR: + case ICPT_PV_INSTR_NOT: r =3D handle_instruction(cpu, run); break; case ICPT_PROGRAM: --=20 2.20.1 From nobody Sat May 4 18:17:30 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=1574250407; cv=none; d=zoho.com; s=zohoarc; b=XGwfIrG96jOjygxFGh7UHA+k7qWi0w9vjJZxn/vOrqRSTzImeHzwYBU5OrpfFP3MEIX6GdJrqMaGRsy9L1ONrwMrBG5/cKqkZhAwAaGpCMQcQaANO0XsGQJsaDVJuEE6RBxAlMhJRg5J/3YUWxc3w2KmjX78lYq0l785MNZAPQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574250407; 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=UMkNNzzKQ7Lp7OIGeqg5rHwTrRDlkiM8rfBWlArspyE=; b=QzonieT472q53DK73ODyRZOJNQG6WcfORS8zszRLGV7sB1Srv4/xer9zFQCee3OROZhevR8PuGArgrnQsxTxgRAkJRCJHZ/InIVIeA6v5LMIoUPTyjzJp6c/rYwi3BicGpvBOlfzkvnYOo0LwhkLibZlXZ7Ihl/NfCGdUxXGT9o= 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 1574250407877461.6704004442322; Wed, 20 Nov 2019 03:46:47 -0800 (PST) Received: from localhost ([::1]:56816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXORa-0005HO-AO for importer@patchew.org; Wed, 20 Nov 2019 06:46:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43507) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOP2-0003L1-Q7 for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOP1-0003ZE-LS for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:08 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:7274) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXOP1-0003XE-Dj for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:07 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAKBfmAB048337 for ; Wed, 20 Nov 2019 06:44:06 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wadmy9s5f-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:44:06 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:44:03 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) 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) Wed, 20 Nov 2019 11:44:00 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBhxGs31850708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:43:59 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA3FF4C052; Wed, 20 Nov 2019 11:43:58 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC7AF4C04E; Wed, 20 Nov 2019 11:43:57 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:43:57 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 09/15] s390x: protvirt: SCLP interpretation Date: Wed, 20 Nov 2019 06:43:28 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-0020-0000-0000-0000038C55B1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-0021-0000-0000-000021E288E2 Message-Id: <20191120114334.2287-10-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 mlxlogscore=667 impostorscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 spamscore=0 suspectscore=1 lowpriorityscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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" SCLP for a protected guest is done over the SIDAD, so we need to use the s390_cpu_virt_mem_* functions to access the SIDAD instead of guest memory when reading/writing SCBs. To not confuse the sclp emulation, we set 0x42000 as the address, but ignore it for reading/writing the SCCB. Signed-off-by: Janosch Frank --- hw/s390x/sclp.c | 16 ++++++++++++++++ include/hw/s390x/sclp.h | 2 ++ target/s390x/kvm.c | 8 +++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index f57ce7b739..00d08adc7f 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -193,6 +193,22 @@ static void sclp_execute(SCLPDevice *sclp, SCCB *sccb,= uint32_t code) } } =20 +int sclp_service_call_protected(CPUS390XState *env, uint64_t sccb, + uint32_t code) +{ + SCLPDevice *sclp =3D get_sclp_device(); + SCLPDeviceClass *sclp_c =3D SCLP_GET_CLASS(sclp); + SCCB work_sccb; + hwaddr sccb_len =3D sizeof(SCCB); + + s390_cpu_virt_mem_read(env_archcpu(env), 0, 0, &work_sccb, sccb_len); + sclp_c->execute(sclp, &work_sccb, code); + s390_cpu_virt_mem_write(env_archcpu(env), 0, 0, &work_sccb, + be16_to_cpu(work_sccb.h.length)); + sclp_c->service_interrupt(sclp, sccb); + return 0; +} + int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code) { SCLPDevice *sclp =3D get_sclp_device(); diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h index c54413b78c..c0a3faa37d 100644 --- a/include/hw/s390x/sclp.h +++ b/include/hw/s390x/sclp.h @@ -217,5 +217,7 @@ void s390_sclp_init(void); void sclp_service_interrupt(uint32_t sccb); void raise_irq_cpu_hotplug(void); int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code); +int sclp_service_call_protected(CPUS390XState *env, uint64_t sccb, + uint32_t code); =20 #endif diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 58251c0229..0f2458b553 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1172,7 +1172,13 @@ static int kvm_sclp_service_call(S390CPU *cpu, struc= t kvm_run *run, sccb =3D env->regs[ipbh0 & 0xf]; code =3D env->regs[(ipbh0 & 0xf0) >> 4]; =20 - r =3D sclp_service_call(env, sccb, code); + if (run->s390_sieic.icptcode =3D=3D ICPT_PV_INSTR || + run->s390_sieic.icptcode =3D=3D ICPT_PV_INSTR_NOT) { + r =3D sclp_service_call_protected(env, 0x42000, code); + } else { + r =3D sclp_service_call(env, sccb, code); + } + if (r < 0) { kvm_s390_program_interrupt(cpu, -r); } else { --=20 2.20.1 From nobody Sat May 4 18:17:30 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=1574251462; cv=none; d=zoho.com; s=zohoarc; b=oXpyg46hgui+J9MyVcIJ7/Q1MSL2rO+qMemjW5EUNaYJabhltdRRXVx0v4+qhXccph7+qSlNML7SrBfxV/UJkGMXMHoiFTVKN4D5BBDRNFwaD9/Yfyaqw7MYj3hwatXmohumTwZSYsI5jd66ro4cz7O7hPLep28giRKhO1iihl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574251462; 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=odKySux0achAMxoV6CwwO/kD1mwxpa7tmy2/TPWtx8g=; b=od6BOL1P97CMBC2QruyNXxv7hIhfMtAJAI0g4aN+pgg0r383rzyue2MtOmMbEjIjEjtOQOTUZLLkrQBwf0FtcIKuhtkYfJz7OVX7K7Ow3T39sSCBjAzN4BX2dnNnaCQIbSqh0P7PHMnVY0MuuIOobDsm3EgI3m4/AUk8vpP06eg= 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 1574251462364499.57826135445885; Wed, 20 Nov 2019 04:04:22 -0800 (PST) Received: from localhost ([::1]:57010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOiY-0000ir-SR for importer@patchew.org; Wed, 20 Nov 2019 07:04:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43591) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOPD-0003dv-PP for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOPC-0003uo-Ag for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:19 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:11250) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXOPC-0003Yr-2n for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:18 -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 xAKBg7H4093132 for ; Wed, 20 Nov 2019 06:44:07 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2waygnf5xs-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:44:06 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:44:04 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) 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, 20 Nov 2019 11:44:01 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBi0Ka57147468 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:44:00 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5A0864C040; Wed, 20 Nov 2019 11:44:00 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B1FE4C04E; Wed, 20 Nov 2019 11:43:59 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:43:59 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 10/15] s390x: protvirt: Add new VCPU reset functions Date: Wed, 20 Nov 2019 06:43:29 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-0028-0000-0000-000003BD0734 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-0029-0000-0000-000024802A42 Message-Id: <20191120114334.2287-11-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 suspectscore=1 bulkscore=0 phishscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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" CPU resets for protected guests need to be done via Ultravisor calls. Hence we need a way to issue these calls for each reset. As we formerly had only one reset function and it was called for initial, as well as for the clear reset, we now need a new interface. Signed-off-by: Janosch Frank --- target/s390x/cpu.c | 15 ++++++++++++--- target/s390x/kvm-stub.c | 10 +++++++++- target/s390x/kvm.c | 38 ++++++++++++++++++++++++++++++++------ target/s390x/kvm_s390x.h | 4 +++- 4 files changed, 56 insertions(+), 11 deletions(-) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 10d5b915d8..ac04fdbba9 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -125,9 +125,18 @@ static void s390_cpu_reset(CPUState *s, uint8_t type) } =20 /* Reset state inside the kernel that we cannot access yet from QEMU. = */ - if (kvm_enabled() && (type =3D=3D S390_CPU_RESET_CLEAR || - type =3D=3D S390_CPU_RESET_INITIAL)) { - kvm_s390_reset_vcpu(cpu); + if (kvm_enabled()) { + switch (type) { + case S390_CPU_RESET_CLEAR: + kvm_s390_reset_vcpu_clear(cpu); + break; + case S390_CPU_RESET_INITIAL: + kvm_s390_reset_vcpu_initial(cpu); + break; + case S390_CPU_RESET_NORMAL: + kvm_s390_reset_vcpu_normal(cpu); + break; + } } =20 #if defined(CONFIG_USER_ONLY) diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c index 5152e2bdf1..c4cd497f85 100644 --- a/target/s390x/kvm-stub.c +++ b/target/s390x/kvm-stub.c @@ -83,7 +83,15 @@ void kvm_s390_cmma_reset(void) { } =20 -void kvm_s390_reset_vcpu(S390CPU *cpu) +void kvm_s390_reset_vcpu_initial(S390CPU *cpu) +{ +} + +void kvm_s390_reset_vcpu_clear(S390CPU *cpu) +{ +} + +void kvm_s390_reset_vcpu_normal(S390CPU *cpu) { } =20 diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 0f2458b553..190400df55 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -154,6 +154,7 @@ static int cap_ri; static int cap_gs; static int cap_hpage_1m; static int cap_protvirt; +static int cap_vcpu_resets; =20 static int active_cmma; =20 @@ -340,6 +341,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_mem_op =3D kvm_check_extension(s, KVM_CAP_S390_MEM_OP); cap_s390_irq =3D kvm_check_extension(s, KVM_CAP_S390_INJECT_IRQ); cap_protvirt =3D kvm_check_extension(s, KVM_CAP_S390_PROTECTED); + cap_vcpu_resets =3D kvm_check_extension(s, KVM_CAP_S390_VCPU_RESETS); =20 if (!kvm_check_extension(s, KVM_CAP_S390_GMAP) || !kvm_check_extension(s, KVM_CAP_S390_COW)) { @@ -401,20 +403,44 @@ int kvm_arch_destroy_vcpu(CPUState *cs) return 0; } =20 -void kvm_s390_reset_vcpu(S390CPU *cpu) +static void kvm_s390_reset_vcpu(S390CPU *cpu, unsigned long type) { CPUState *cs =3D CPU(cpu); =20 - /* The initial reset call is needed here to reset in-kernel - * vcpu data that we can't access directly from QEMU - * (i.e. with older kernels which don't support sync_regs/ONE_REG). - * Before this ioctl cpu_synchronize_state() is called in common kvm - * code (kvm-all) */ + /* + * The reset call is needed here to reset in-kernel vcpu data that + * we can't access directly from QEMU (i.e. with older kernels + * which don't support sync_regs/ONE_REG). Before this ioctl + * cpu_synchronize_state() is called in common kvm code + * (kvm-all). + */ + if (cap_vcpu_resets) { + if (kvm_vcpu_ioctl(cs, KVM_S390_VCPU_RESET, type)) { + error_report("CPU reset type %ld failed on CPU %i", + type, cs->cpu_index); + } + return; + } if (kvm_vcpu_ioctl(cs, KVM_S390_INITIAL_RESET, NULL)) { error_report("Initial CPU reset failed on CPU %i", cs->cpu_index); } } =20 +void kvm_s390_reset_vcpu_initial(S390CPU *cpu) +{ + kvm_s390_reset_vcpu(cpu, KVM_S390_VCPU_RESET_INITIAL); +} + +void kvm_s390_reset_vcpu_clear(S390CPU *cpu) +{ + kvm_s390_reset_vcpu(cpu, KVM_S390_VCPU_RESET_CLEAR); +} + +void kvm_s390_reset_vcpu_normal(S390CPU *cpu) +{ + kvm_s390_reset_vcpu(cpu, KVM_S390_VCPU_RESET_NORMAL); +} + static int can_sync_regs(CPUState *cs, int regs) { return cap_sync_regs && (cs->kvm_run->kvm_valid_regs & regs) =3D=3D re= gs; diff --git a/target/s390x/kvm_s390x.h b/target/s390x/kvm_s390x.h index caf985955b..0b21789796 100644 --- a/target/s390x/kvm_s390x.h +++ b/target/s390x/kvm_s390x.h @@ -34,7 +34,9 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifi= er, uint32_t sch, int vq, bool assign); int kvm_s390_cmma_active(void); void kvm_s390_cmma_reset(void); -void kvm_s390_reset_vcpu(S390CPU *cpu); +void kvm_s390_reset_vcpu_clear(S390CPU *cpu); +void kvm_s390_reset_vcpu_normal(S390CPU *cpu); +void kvm_s390_reset_vcpu_initial(S390CPU *cpu); int kvm_s390_set_mem_limit(uint64_t new_limit, uint64_t *hw_limit); void kvm_s390_set_max_pagesize(uint64_t pagesize, Error **errp); void kvm_s390_crypto_reset(void); --=20 2.20.1 From nobody Sat May 4 18:17:30 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=1574250934; cv=none; d=zoho.com; s=zohoarc; b=E9SGY9IxKQ0n29J3KbspsY1YoItfs7Gb+JfW8g5EeTe/xNCEx2TjG3xZ2/Py1BSND3Eg6hohV+sayuwZmclKZu3YHD3s6k5tuc8fOhb3JY2JiY77xT200eQ8JrlNxIe8knlGRBQLc4YDcC8uLH/4QtVLORs+TWQVhENM9HJMw9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574250934; 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=vm3XQOVJlMbQIkjWpqhJ7SUZJCh54p/DyP42sRxtOKY=; b=Gg+z1zyxfJilFILO9CONOeszfAGIlhTeJx3HTrKdrcb8axJp0gKPKtU0PhjzOczkonxRGqdf4pOGVi73Bh4tIhBWbAr0+HTbItISPrcp/C2I6mKgBRrLaE/k/+CXKzszD2SNmIa5B+7jziI4M0BY0UG4ztJAA3gmXT1WrCU0FPs= 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 1574250934161802.744993480916; Wed, 20 Nov 2019 03:55:34 -0800 (PST) Received: from localhost ([::1]:56898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOa5-0007dg-1u for importer@patchew.org; Wed, 20 Nov 2019 06:55:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43719) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOPM-0003t7-3X for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOPL-0004FD-0Z for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:27 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49660) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXOPK-0004DY-Qm for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:26 -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 xAKBg4v0103326 for ; Wed, 20 Nov 2019 06:44:26 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wact87t10-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:44:11 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:44:05 -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, 20 Nov 2019 11:44:03 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBi1Wu44761166 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:44:01 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA8A74C04E; Wed, 20 Nov 2019 11:44:01 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 930764C040; Wed, 20 Nov 2019 11:44:00 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:44:00 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 11/15] RFC: s390x: Exit on vcpu reset error Date: Wed, 20 Nov 2019 06:43:30 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-0028-0000-0000-000003BD0735 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-0029-0000-0000-000024802A43 Message-Id: <20191120114334.2287-12-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 suspectscore=1 adultscore=0 mlxscore=0 bulkscore=0 clxscore=1015 spamscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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" If a vcpu is not properly reset it might be better to just end the VM. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand --- target/s390x/kvm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 190400df55..0210b54157 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -418,11 +418,13 @@ static void kvm_s390_reset_vcpu(S390CPU *cpu, unsigne= d long type) if (kvm_vcpu_ioctl(cs, KVM_S390_VCPU_RESET, type)) { error_report("CPU reset type %ld failed on CPU %i", type, cs->cpu_index); + exit(1); } return; } if (kvm_vcpu_ioctl(cs, KVM_S390_INITIAL_RESET, NULL)) { error_report("Initial CPU reset failed on CPU %i", cs->cpu_index); + exit(1); } } =20 --=20 2.20.1 From nobody Sat May 4 18:17:31 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=1574250716; cv=none; d=zoho.com; s=zohoarc; b=mtgiIY8Z3dMhQ2Z0aUFe9Ts1KczEU4+kTSUQHKO8XGvLXmJXnod9Qyzw6AenaFZdjs02xaoUSW9wE+m93PhmNSHAqcIejqe1Vl6N1zJxLvFWTVcHpsJWBsyoQILTEkD8qRfdhfJ42Cygx43klL1MxB2gPkh8ow0juseNgRgo73Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574250716; 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=wUlqWA84pqsneM3XlEwu7MTDMHDD2ASJgWYQ/J9CHbQ=; b=YtNIhUnVJzb8ZZZI5uNxLxId+jCWO6GjyIE43YkUtAjN350PJnANWSO/wkay+3DxxkO1+ShLcxwAcetj1CD3hLJkbQCSH0EhiDG7oPeBGZY94xwdltpu/7NbuzppdPXA3lcXFp4UZCkRZtkMVf6whquWM1/7loiTCjycvtQjIeE= 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 1574250716078659.4305410141616; Wed, 20 Nov 2019 03:51:56 -0800 (PST) Received: from localhost ([::1]:56860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOWY-0001Wj-6E for importer@patchew.org; Wed, 20 Nov 2019 06:51:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43528) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOP5-0003Nh-2d for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOP3-0003dP-Ol for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:10 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60904 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 1iXOP3-0003ch-K6 for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:09 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAKBg4gD174067 for ; Wed, 20 Nov 2019 06:44:09 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wcf35wddy-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:44:08 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:44:06 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) 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) Wed, 20 Nov 2019 11:44:04 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBhPZ328115304 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:43:25 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0A3924C046; Wed, 20 Nov 2019 11:44:03 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E3EE94C040; Wed, 20 Nov 2019 11:44:01 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:44:01 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 12/15] s390x: protvirt: Set guest IPL PSW Date: Wed, 20 Nov 2019 06:43:31 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-4275-0000-0000-00000383E083 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-4276-0000-0000-000038975983 Message-Id: <20191120114334.2287-13-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 suspectscore=1 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 impostorscore=0 phishscore=0 spamscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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" Handling of CPU reset and setting of the IPL psw from guest storage at offset 0 is done by a Ultravisor call. Let's only fetch it if necessary. Signed-off-by: Janosch Frank Reviewed-by: Thomas Huth --- hw/s390x/pv.c | 5 +++++ hw/s390x/pv.h | 1 + hw/s390x/s390-virtio-ccw.c | 3 ++- linux-headers/linux/kvm.h | 1 + target/s390x/cpu.c | 9 ++++++++- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c index 0218070322..106252833f 100644 --- a/hw/s390x/pv.c +++ b/hw/s390x/pv.c @@ -88,6 +88,11 @@ int s390_pv_set_sec_parms(uint64_t origin, uint64_t leng= th) return s390_pv_cmd(KVM_PV_VM_SET_SEC_PARMS, &args); } =20 +int s390_pv_set_ipl_psw(CPUState *cs) +{ + return s390_pv_cmd_vcpu(cs, KVM_PV_VCPU_SET_IPL_PSW, NULL); +} + /* * Called for each component in the SE type IPL parameter block 0. */ diff --git a/hw/s390x/pv.h b/hw/s390x/pv.h index eb074e4bc9..e670c67270 100644 --- a/hw/s390x/pv.h +++ b/hw/s390x/pv.h @@ -18,6 +18,7 @@ int s390_pv_vm_destroy(void); int s390_pv_vcpu_destroy(CPUState *cs); int s390_pv_vcpu_create(CPUState *cs); int s390_pv_set_sec_parms(uint64_t origin, uint64_t length); +int s390_pv_set_ipl_psw(CPUState *cs); int s390_pv_unpack(uint64_t addr, uint64_t size, uint64_t tweak); int s390_pv_perf_clear_reset(void); int s390_pv_verify(void); diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 6fd50b4c42..e020b92854 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -404,7 +404,8 @@ static void s390_machine_reset(MachineState *machine) s390_ipl_pv_unpack(); /* Verify integrity */ s390_pv_verify(); - s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu); + env->pv =3D true; + run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL); break; default: g_assert_not_reached(); diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index d031051601..b5c7552016 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1476,6 +1476,7 @@ enum pv_cmd_id { KVM_PV_VM_UNSHARE, KVM_PV_VCPU_CREATE, KVM_PV_VCPU_DESTROY, + KVM_PV_VCPU_SET_IPL_PSW, }; =20 struct kvm_pv_cmd { diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index ac04fdbba9..c004987a87 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -37,6 +37,7 @@ #include "sysemu/hw_accel.h" #include "hw/qdev-properties.h" #ifndef CONFIG_USER_ONLY +#include "hw/s390x/pv.h" #include "hw/boards.h" #include "sysemu/arch_init.h" #include "sysemu/sysemu.h" @@ -76,7 +77,13 @@ static bool s390_cpu_has_work(CPUState *cs) static void s390_cpu_load_normal(CPUState *s) { S390CPU *cpu =3D S390_CPU(s); - cpu->env.psw.addr =3D ldl_phys(s->as, 4) & PSW_MASK_ESA_ADDR; + CPUS390XState *env =3D &cpu->env; + + if (!env->pv) { + cpu->env.psw.addr =3D ldl_phys(s->as, 4) & PSW_MASK_ESA_ADDR; + } else { + s390_pv_set_ipl_psw(s); + } cpu->env.psw.mask =3D PSW_MASK_32 | PSW_MASK_64; s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu); } --=20 2.20.1 From nobody Sat May 4 18:17:31 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=1574251625; cv=none; d=zoho.com; s=zohoarc; b=B2PowXU69Z6Gj1zY7Ze4LaEKIVgpQOtJ8bLHRFGL2HB9JtMJZisOrWq/An2cUoHnjgLcSEq/7PEl47P4BtrhcTcoxehXy7c7XUmoYSqQXVb8iE7fGO4bDOKMEH3rJJT0qxWS2QWUbkDZR0WPa+qRch4BTyKpCv7Lk3FamsJ4FlE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574251625; 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=+LIpPJlTA7WGz4mxF+1sXpsoY4f2FmjGiZc5uCzJMM4=; b=BZQCnp53cJueDuCyGYZsSdTZs09/4GIuaf9cJHHzc/Gy8Zl0mEmyPmCoFQJtI5NQOeC8qKIAxFHu5TgzUqkjNxxSgoeaV2ZiivM3cXqdLV22DLaqr0AfnbKKnQvu6XzxNvWN9H+9H1UTPjYjnh3c9Lc9/m/3nQYYLT8P997b/YA= 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 1574251625031215.3610277317233; Wed, 20 Nov 2019 04:07:05 -0800 (PST) Received: from localhost ([::1]:57036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOlC-0003EO-O2 for importer@patchew.org; Wed, 20 Nov 2019 07:07:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43646) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOPH-0003jQ-3x for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOPG-00041u-19 for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:23 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34286) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXOPF-0003g3-Ps for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:21 -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 xAKBfxGQ019667 for ; Wed, 20 Nov 2019 06:44:11 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wcf5a6vb3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:44:10 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:44:08 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) 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) Wed, 20 Nov 2019 11:44:05 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBi4B457082010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:44:04 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5B0704C052; Wed, 20 Nov 2019 11:44:04 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 42C1B4C04E; Wed, 20 Nov 2019 11:44:03 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:44:03 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 13/15] s390x: protvirt: Move diag 308 data over SIDAD Date: Wed, 20 Nov 2019 06:43:32 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-4275-0000-0000-00000383E084 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-4276-0000-0000-000038975985 Message-Id: <20191120114334.2287-14-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=1 mlxlogscore=825 impostorscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 clxscore=1015 bulkscore=0 spamscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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" For protected guests the IPIB is written/read to/from the sattelite block, so we need to make those accesses virtual to make them go through KBM mem ops. Signed-off-by: Janosch Frank --- target/s390x/diag.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/target/s390x/diag.c b/target/s390x/diag.c index db6d79cef3..d96d8bdc6c 100644 --- a/target/s390x/diag.c +++ b/target/s390x/diag.c @@ -88,6 +88,7 @@ static int diag308_parm_check(CPUS390XState *env, uint64_= t r1, uint64_t addr, void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr= _t ra) { CPUState *cs =3D env_cpu(env); + S390CPU *cpu =3D S390_CPU(cs); uint64_t addr =3D env->regs[r1]; uint64_t subcode =3D env->regs[r3]; IplParameterBlock *iplb; @@ -118,14 +119,27 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1,= uint64_t r3, uintptr_t ra) if (diag308_parm_check(env, r1, addr, ra, false)) { return; } + iplb =3D g_new0(IplParameterBlock, 1); - cpu_physical_memory_read(addr, iplb, sizeof(iplb->len)); + if (!env->pv) { + cpu_physical_memory_read(addr, iplb, sizeof(iplb->len)); + } else { + s390_cpu_virt_mem_read(cpu, 0, 0, iplb, sizeof(iplb->len)); + s390_cpu_virt_mem_handle_exc(cpu, ra); + } + if (!iplb_valid_len(iplb)) { env->regs[r1 + 1] =3D DIAG_308_RC_INVALID; goto out; } =20 - cpu_physical_memory_read(addr, iplb, be32_to_cpu(iplb->len)); + if (!env->pv) { + cpu_physical_memory_read(addr, iplb, be32_to_cpu(iplb->len)); + } else { + s390_cpu_virt_mem_read(cpu, 0, 0, iplb, be32_to_cpu(iplb->len)= ); + s390_cpu_virt_mem_handle_exc(cpu, ra); + } + =20 if (!iplb_valid_ccw(iplb) && !iplb_valid_fcp(iplb) && !(iplb_valid_se(iplb) && s390_ipl_pv_check_comp(iplb) >=3D 0))= { @@ -149,7 +163,13 @@ out: iplb =3D s390_ipl_get_iplb(); } if (iplb) { - cpu_physical_memory_write(addr, iplb, be32_to_cpu(iplb->len)); + if (!env->pv) { + cpu_physical_memory_write(addr, iplb, be32_to_cpu(iplb->le= n)); + } else { + s390_cpu_virt_mem_write(cpu, 0, 0, iplb, + be32_to_cpu(iplb->len)); + s390_cpu_virt_mem_handle_exc(cpu, ra); + } env->regs[r1 + 1] =3D DIAG_308_RC_OK; } else { env->regs[r1 + 1] =3D DIAG_308_RC_NO_CONF; --=20 2.20.1 From nobody Sat May 4 18:17:31 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=1574251271; cv=none; d=zoho.com; s=zohoarc; b=QheStL8gQCXe4wkXkGd7ko/goGyF4UgkfcKwU4mQ4Y9ZfWKd1VuX7n1HE4CfeOkP3uH3SBq9tERD6KXsBqQ7hc07PeWSMKzPYP7i2nS3n+AJTXOQu03zFhuDIn1khqbpvvk2cUEgpBfzx/Bm1KStb0VAekxeKHyxZgd0onkJHV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574251271; 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=DhC1bXtJwXWwDSVD5sVVyANAYn72Q6P76ZS0HCWotzQ=; b=X01vbYniT8rPt9GXeWBme35iPrPg+l/cu2Y8aqi2C2ifkM3LjQN80jk1rCE3U1ow28LQF5WgDqnPssMwQRZ9aqZJPbDV8oApdwegzD4/Rc3w7vroIeN2fKsmi/HuT5e17q4+ha9cqwrm+cSw1to88LIwSKvMH7L8lEEDpQYrXSU= 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 1574251271921479.8799941318521; Wed, 20 Nov 2019 04:01:11 -0800 (PST) Received: from localhost ([::1]:56974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOfV-0006TK-EF for importer@patchew.org; Wed, 20 Nov 2019 07:01:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43548) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOP7-0003S8-Gx for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOP6-0003iI-5b for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:13 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:30426 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 1iXOP6-0003hI-0s for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:12 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAKBhRd6132053 for ; Wed, 20 Nov 2019 06:44:11 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2wcf4867jf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:44:11 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:44:09 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) 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, 20 Nov 2019 11:44:07 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBi5xL41812022 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:44:05 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ADE434C046; Wed, 20 Nov 2019 11:44:05 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 940BA4C040; Wed, 20 Nov 2019 11:44:04 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:44:04 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 14/15] s390x: protvirt: Disable address checks for PV guest IO emulation Date: Wed, 20 Nov 2019 06:43:33 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-0016-0000-0000-000002C9CC58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-0017-0000-0000-0000332B8B84 Message-Id: <20191120114334.2287-15-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=613 spamscore=0 malwarescore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 suspectscore=1 phishscore=0 clxscore=1015 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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" IO instruction data is routed through SIDAD for protected guests, so adresses do not need to be checked, as this is kernel memory. Signed-off-by: Janosch Frank Reviewed-by: Thomas Huth --- target/s390x/ioinst.c | 46 +++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c index c437a1d8c6..d3bd422ddd 100644 --- a/target/s390x/ioinst.c +++ b/target/s390x/ioinst.c @@ -110,11 +110,13 @@ void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, = uint32_t ipb, uintptr_t ra) int cssid, ssid, schid, m; SubchDev *sch; SCHIB schib; - uint64_t addr; + uint64_t addr =3D 0; CPUS390XState *env =3D &cpu->env; - uint8_t ar; + uint8_t ar =3D 0; =20 - addr =3D decode_basedisp_s(env, ipb, &ar); + if (!env->pv) { + addr =3D decode_basedisp_s(env, ipb, &ar); + } if (addr & 3) { s390_program_interrupt(env, PGM_SPECIFICATION, ra); return; @@ -167,11 +169,13 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, = uint32_t ipb, uintptr_t ra) int cssid, ssid, schid, m; SubchDev *sch; ORB orig_orb, orb; - uint64_t addr; + uint64_t addr =3D 0; CPUS390XState *env =3D &cpu->env; - uint8_t ar; + uint8_t ar =3D 0; =20 - addr =3D decode_basedisp_s(env, ipb, &ar); + if (!env->pv) { + addr =3D decode_basedisp_s(env, ipb, &ar); + } if (addr & 3) { s390_program_interrupt(env, PGM_SPECIFICATION, ra); return; @@ -198,12 +202,14 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, = uint32_t ipb, uintptr_t ra) void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb, uintptr_t ra) { CRW crw; - uint64_t addr; + uint64_t addr =3D 0; int cc; CPUS390XState *env =3D &cpu->env; - uint8_t ar; + uint8_t ar =3D 0; =20 - addr =3D decode_basedisp_s(env, ipb, &ar); + if (!env->pv) { + addr =3D decode_basedisp_s(env, ipb, &ar); + } if (addr & 3) { s390_program_interrupt(env, PGM_SPECIFICATION, ra); return; @@ -228,13 +234,15 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1,= uint32_t ipb, { int cssid, ssid, schid, m; SubchDev *sch; - uint64_t addr; + uint64_t addr =3D 0; int cc; SCHIB schib; CPUS390XState *env =3D &cpu->env; - uint8_t ar; + uint8_t ar =3D 0; =20 - addr =3D decode_basedisp_s(env, ipb, &ar); + if (!env->pv) { + addr =3D decode_basedisp_s(env, ipb, &ar); + } if (addr & 3) { s390_program_interrupt(env, PGM_SPECIFICATION, ra); return; @@ -294,16 +302,18 @@ int ioinst_handle_tsch(S390CPU *cpu, uint64_t reg1, u= int32_t ipb, uintptr_t ra) int cssid, ssid, schid, m; SubchDev *sch; IRB irb; - uint64_t addr; + uint64_t addr =3D 0; int cc, irb_len; - uint8_t ar; + uint8_t ar =3D 0; =20 if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { s390_program_interrupt(env, PGM_OPERAND, ra); return -EIO; } trace_ioinst_sch_id("tsch", cssid, ssid, schid); - addr =3D decode_basedisp_s(env, ipb, &ar); + if (!env->pv) { + addr =3D decode_basedisp_s(env, ipb, &ar); + } if (addr & 3) { s390_program_interrupt(env, PGM_SPECIFICATION, ra); return -EIO; @@ -601,7 +611,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb, uin= tptr_t ra) { ChscReq *req; ChscResp *res; - uint64_t addr; + uint64_t addr =3D 0; int reg; uint16_t len; uint16_t command; @@ -610,7 +620,9 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb, uin= tptr_t ra) =20 trace_ioinst("chsc"); reg =3D (ipb >> 20) & 0x00f; - addr =3D env->regs[reg]; + if (!env->pv) { + addr =3D env->regs[reg]; + } /* Page boundary? */ if (addr & 0xfff) { s390_program_interrupt(env, PGM_SPECIFICATION, ra); --=20 2.20.1 From nobody Sat May 4 18:17:31 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=1574250774; cv=none; d=zoho.com; s=zohoarc; b=SW78CYv5PXmor6ilmHeTXt41MfRMzZLX5dw8raUKZ18/jMhpBSEaRmREiZnhLKdFEEhOtqqbrQDnCSr3Zl1ZgX1HJ5kBtq3OTsTxA2nw+JmO1kwKZ6oJbpWtCHfusW9udOSBlM5vykQvYKstUSYyxFAb4lgVMIVJ3iD0Do3Bxfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574250774; 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=Sq0bHPiy5y2PsYlTjaxPhYPZfKol8VOmVk++dEKEWRU=; b=ZpAVRgoQhZQzWbEq3+4+1GOb46zJdPupcnwBlI+WISNqhRKkH0HVMOi6pISkekyLR053Zohg9lwIa1jWT/rzFPD1WRIQIz2ewIBchpvJpgiekUqUF3yb0zvu7ZAU8GZLzCb9OQrRskDDwbu2YgKViUQatIyKdDLjrjpBsBA1elc= 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 1574250774789519.71193975704; Wed, 20 Nov 2019 03:52:54 -0800 (PST) Received: from localhost ([::1]:56867 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOXU-0003M6-9H for importer@patchew.org; Wed, 20 Nov 2019 06:52:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43698) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXOPK-0003pZ-FO for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXOPJ-0004AX-CT for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:26 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:64192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXOPJ-0003nP-42 for qemu-devel@nongnu.org; Wed, 20 Nov 2019 06:44:25 -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 xAKBfwXo019430 for ; Wed, 20 Nov 2019 06:44:14 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wcf5a6vd7-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Nov 2019 06:44:14 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Nov 2019 11:44:12 -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) Wed, 20 Nov 2019 11:44:08 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAKBi79c56164462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 11:44:07 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 011394C046; Wed, 20 Nov 2019 11:44:07 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E6CB24C040; Wed, 20 Nov 2019 11:44:05 +0000 (GMT) Received: from localhost.localdomain (unknown [9.152.224.205]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Nov 2019 11:44:05 +0000 (GMT) From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 15/15] s390x: protvirt: Handle SIGP store status correctly Date: Wed, 20 Nov 2019 06:43:34 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120114334.2287-1-frankja@linux.ibm.com> References: <20191120114334.2287-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19112011-0008-0000-0000-000003352748 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112011-0009-0000-0000-00004A544B7B Message-Id: <20191120114334.2287-16-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-20_03:2019-11-15,2019-11-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=1 mlxlogscore=788 impostorscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 clxscore=1015 bulkscore=0 spamscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911200107 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" Status storing is obviously not done by qemu anymore. Signed-off-by: Janosch Frank Reviewed-by: Thomas Huth --- target/s390x/sigp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 2ce22d4dc1..68634d694a 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -144,7 +144,9 @@ static void sigp_stop_and_store_status(CPUState *cs, ru= n_on_cpu_data arg) case S390_CPU_STATE_STOPPED: /* already stopped, just store the status */ cpu_synchronize_state(cs); - s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); + if (!cpu->env.pv) { + s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); + } break; } si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; @@ -497,7 +499,8 @@ void do_stop_interrupt(CPUS390XState *env) if (s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu) =3D=3D 0) { qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); } - if (cpu->env.sigp_order =3D=3D SIGP_STOP_STORE_STATUS) { + /* Storing will occur on next SIE entry for fmt 4 */ + if (cpu->env.sigp_order =3D=3D SIGP_STOP_STORE_STATUS && !env->pv) { s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); } env->sigp_order =3D 0; --=20 2.20.1