From nobody Tue Feb 10 07:20:07 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@nongnu.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@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150575146112016.157071458833116; Mon, 18 Sep 2017 09:17:41 -0700 (PDT) Received: from localhost ([::1]:37653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyjs-0004Kp-25 for importer@patchew.org; Mon, 18 Sep 2017 12:17:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUF-0007IC-1T for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyU9-00081H-48 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3239) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyU8-00080y-SV for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:25 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A44132D0FBE; Mon, 18 Sep 2017 16:01:23 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8320A5D6A8; Mon, 18 Sep 2017 16:01:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A44132D0FBE Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:57 +0200 Message-Id: <20170918160012.4317-13-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 18 Sep 2017 16:01:23 +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 v1 12/27] s390x/kvm: factor out storing of CPU status X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.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" Factor it out into s390_store_status(), to be used also by TCG later on. Signed-off-by: David Hildenbrand --- target/s390x/helper.c | 38 ++++++++++++++++++++++++++++++++++++++ target/s390x/internal.h | 2 ++ target/s390x/kvm.c | 47 +++------------------------------------------= -- 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 75ceb0bf2b..09468f85fa 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -245,6 +245,44 @@ void s390_cpu_recompute_watchpoints(CPUState *cs) } } =20 +#define SAVE_AREA_SIZE 512 +int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch) +{ + static const uint8_t ar_id =3D 1; + uint64_t ckc =3D cpu->env.ckc >> 8; + void *mem; + int i; + hwaddr len =3D SAVE_AREA_SIZE; + + mem =3D cpu_physical_memory_map(addr, &len, 1); + if (!mem) { + return -EFAULT; + } + if (len !=3D SAVE_AREA_SIZE) { + cpu_physical_memory_unmap(mem, len, 1, 0); + return -EFAULT; + } + + if (store_arch) { + cpu_physical_memory_write(offsetof(LowCore, ar_access_id), &ar_id,= 1); + } + for (i =3D 0; i < 16; ++i) { + *((uint64_t *)mem + i) =3D get_freg(&cpu->env, i)->ll; + } + memcpy(mem + 128, &cpu->env.regs, 128); + memcpy(mem + 256, &cpu->env.psw, 16); + memcpy(mem + 280, &cpu->env.psa, 4); + memcpy(mem + 284, &cpu->env.fpc, 4); + memcpy(mem + 292, &cpu->env.todpr, 4); + memcpy(mem + 296, &cpu->env.cputm, 8); + memcpy(mem + 304, &ckc, 8); + memcpy(mem + 320, &cpu->env.aregs, 64); + memcpy(mem + 384, &cpu->env.cregs, 128); + + 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 8fdeb867e1..30bcd7b662 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -339,6 +339,8 @@ void s390_cpu_recompute_watchpoints(CPUState *cs); void s390x_tod_timer(void *opaque); void s390x_cpu_timer(void *opaque); void do_restart_interrupt(CPUS390XState *env); +#define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area) +int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch); #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 66a56db175..a6bc27eb28 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1545,46 +1545,6 @@ static int do_store_adtl_status(S390CPU *cpu, hwaddr= addr, hwaddr len) return 0; } =20 -#define KVM_S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_= area) -#define SAVE_AREA_SIZE 512 -static int kvm_s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arc= h) -{ - static const uint8_t ar_id =3D 1; - uint64_t ckc =3D cpu->env.ckc >> 8; - void *mem; - int i; - hwaddr len =3D SAVE_AREA_SIZE; - - mem =3D cpu_physical_memory_map(addr, &len, 1); - if (!mem) { - return -EFAULT; - } - if (len !=3D SAVE_AREA_SIZE) { - cpu_physical_memory_unmap(mem, len, 1, 0); - return -EFAULT; - } - - if (store_arch) { - cpu_physical_memory_write(offsetof(LowCore, ar_access_id), &ar_id,= 1); - } - for (i =3D 0; i < 16; ++i) { - *((uint64_t *)mem + i) =3D get_freg(&cpu->env, i)->ll; - } - memcpy(mem + 128, &cpu->env.regs, 128); - memcpy(mem + 256, &cpu->env.psw, 16); - memcpy(mem + 280, &cpu->env.psa, 4); - memcpy(mem + 284, &cpu->env.fpc, 4); - memcpy(mem + 292, &cpu->env.todpr, 4); - memcpy(mem + 296, &cpu->env.cputm, 8); - memcpy(mem + 304, &ckc, 8); - memcpy(mem + 320, &cpu->env.aregs, 64); - memcpy(mem + 384, &cpu->env.cregs, 128); - - 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); @@ -1604,7 +1564,7 @@ static void sigp_stop_and_store_status(CPUState *cs, = run_on_cpu_data arg) case CPU_STATE_STOPPED: /* already stopped, just store the status */ cpu_synchronize_state(cs); - kvm_s390_store_status(cpu, KVM_S390_STORE_STATUS_DEF_ADDR, true); + s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); break; } si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; @@ -1624,7 +1584,7 @@ static void sigp_store_status_at_address(CPUState *cs= , run_on_cpu_data arg) =20 cpu_synchronize_state(cs); =20 - if (kvm_s390_store_status(cpu, address, false)) { + if (s390_store_status(cpu, address, false)) { set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); return; } @@ -2005,8 +1965,7 @@ static int handle_intercept(S390CPU *cpu) qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN= ); } if (cpu->env.sigp_order =3D=3D SIGP_STOP_STORE_STATUS) { - kvm_s390_store_status(cpu, KVM_S390_STORE_STATUS_DEF_ADDR, - true); + s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); } cpu->env.sigp_order =3D 0; r =3D EXCP_HALTED; --=20 2.13.5