From nobody Sun Feb 8 20:34:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@gnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@gnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506631481910608.7768791670528; Thu, 28 Sep 2017 13:44:41 -0700 (PDT) Received: from localhost ([::1]:60796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxffV-0000wv-Dy for importer@patchew.org; Thu, 28 Sep 2017 16:44:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxfZI-00048Y-JE for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxfZE-0003Hp-Lm for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:38:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58954) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxfZE-0003HO-DY for qemu-devel@nongnu.org; Thu, 28 Sep 2017 16:37:56 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C34885376; Thu, 28 Sep 2017 20:37:55 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 841E118C67; Thu, 28 Sep 2017 20:37:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6C34885376 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Thu, 28 Sep 2017 22:36:52 +0200 Message-Id: <20170928203708.9376-15-david@redhat.com> In-Reply-To: <20170928203708.9376-1-david@redhat.com> References: <20170928203708.9376-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 28 Sep 2017 20:37:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 14/30] s390x/kvm: factor out storing of adtl CPU status X-BeenThere: qemu-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, David Hildenbrand , cohuck@redhat.com, Richard Henderson , Alexander Graf , Christian Borntraeger Errors-To: qemu-devel-bounces+importer=patchew.org@gnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Called from SIGP code to be factored out, so let's move it. Add a FIXME for TCG code in the future. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/helper.c | 29 +++++++++++++++++++++++++++++ target/s390x/internal.h | 1 + target/s390x/kvm.c | 30 +----------------------------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 4c11822074..2505f3aec0 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -305,6 +305,35 @@ int s390_store_status(S390CPU *cpu, hwaddr addr, bool = store_arch) =20 return 0; } + +#define ADTL_GS_OFFSET 1024 /* offset of GS data in adtl save area */ +#define ADTL_GS_MIN_SIZE 2048 /* minimal size of adtl save area for GS */ +int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len) +{ + hwaddr save =3D len; + void *mem; + + mem =3D cpu_physical_memory_map(addr, &save, 1); + if (!mem) { + return -EFAULT; + } + if (save !=3D len) { + cpu_physical_memory_unmap(mem, len, 1, 0); + return -EFAULT; + } + + /* FIXME: as soon as TCG supports these features, convert cpu->be */ + if (s390_has_feat(S390_FEAT_VECTOR)) { + memcpy(mem, &cpu->env.vregs, 512); + } + if (s390_has_feat(S390_FEAT_GUARDED_STORAGE) && len >=3D ADTL_GS_MIN_S= IZE) { + memcpy(mem + ADTL_GS_OFFSET, &cpu->env.gscb, 32); + } + + cpu_physical_memory_unmap(mem, len, 1, len); + + return 0; +} #endif /* CONFIG_USER_ONLY */ =20 void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, diff --git a/target/s390x/internal.h b/target/s390x/internal.h index a301237c17..fb8ff6b078 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -355,6 +355,7 @@ void do_restart_interrupt(CPUS390XState *env); void s390_handle_wait(S390CPU *cpu); #define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area) int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch); +int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len); #ifndef CONFIG_USER_ONLY LowCore *cpu_map_lowcore(CPUS390XState *env); void cpu_unmap_lowcore(LowCore *lowcore); diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index c7d0145fa9..1aec1e26d4 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1519,34 +1519,6 @@ static void sigp_stop(CPUState *cs, run_on_cpu_data = arg) si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } =20 -#define ADTL_GS_OFFSET 1024 /* offset of GS data in adtl save area */ -#define ADTL_GS_MIN_SIZE 2048 /* minimal size of adtl save area for GS */ -static int do_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len) -{ - hwaddr save =3D len; - void *mem; - - mem =3D cpu_physical_memory_map(addr, &save, 1); - if (!mem) { - return -EFAULT; - } - if (save !=3D len) { - cpu_physical_memory_unmap(mem, len, 1, 0); - return -EFAULT; - } - - if (s390_has_feat(S390_FEAT_VECTOR)) { - memcpy(mem, &cpu->env.vregs, 512); - } - if (s390_has_feat(S390_FEAT_GUARDED_STORAGE) && len >=3D ADTL_GS_MIN_S= IZE) { - memcpy(mem + ADTL_GS_OFFSET, &cpu->env.gscb, 32); - } - - cpu_physical_memory_unmap(mem, len, 1, len); - - return 0; -} - static void sigp_stop_and_store_status(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu =3D S390_CPU(cs); @@ -1639,7 +1611,7 @@ static void sigp_store_adtl_status(CPUState *cs, run_= on_cpu_data arg) =20 cpu_synchronize_state(cs); =20 - if (do_store_adtl_status(cpu, addr, len)) { + if (s390_store_adtl_status(cpu, addr, len)) { set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); return; } --=20 2.13.5