From patchwork Mon Sep 18 15:59:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 815014 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=208.118.235.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xwrgf5VGGz9s7G for ; Tue, 19 Sep 2017 02:14:54 +1000 (AEST) Received: from localhost ([::1]:37635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyhA-0001ZG-Mj for incoming@patchwork.ozlabs.org; Mon, 18 Sep 2017 12:14:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUJ-0007LV-Ta for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUI-00085r-SV for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35826) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUI-00085L-Kx for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:34 -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 8C3FEC070E2D; Mon, 18 Sep 2017 16:01:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8C3FEC070E2D Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2970C5D6A8; Mon, 18 Sep 2017 16:01:30 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:59 +0200 Message-Id: <20170918160012.4317-15-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.31]); Mon, 18 Sep 2017 16:01:33 +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 14/27] s390x/kvm: factor out storing of adtl 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_Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Called from SIGP code to be factored out, so let's move it. Add a FIXME for TCG code in the future. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson Reviewed-by: Richard Henderson --- 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 e44d54b932..4d5a92c2ca 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -290,6 +290,35 @@ int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch) 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 = len; + void *mem; + + mem = cpu_physical_memory_map(addr, &save, 1); + if (!mem) { + return -EFAULT; + } + if (save != 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 >= ADTL_GS_MIN_SIZE) { + memcpy(mem + ADTL_GS_OFFSET, &cpu->env.gscb, 32); + } + + cpu_physical_memory_unmap(mem, len, 1, len); + + return 0; +} #endif /* CONFIG_USER_ONLY */ void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 30bcd7b662..1d86f48990 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -341,6 +341,7 @@ 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); +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 a6bc27eb28..01c4125d21 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1517,34 +1517,6 @@ static void sigp_stop(CPUState *cs, run_on_cpu_data arg) si->cc = SIGP_CC_ORDER_CODE_ACCEPTED; } -#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 = len; - void *mem; - - mem = cpu_physical_memory_map(addr, &save, 1); - if (!mem) { - return -EFAULT; - } - if (save != 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 >= ADTL_GS_MIN_SIZE) { - 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 = S390_CPU(cs); @@ -1637,7 +1609,7 @@ static void sigp_store_adtl_status(CPUState *cs, run_on_cpu_data arg) cpu_synchronize_state(cs); - 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; }