From patchwork Mon Apr 8 14:43:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 234807 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 459D22C010E for ; Tue, 9 Apr 2013 01:14:08 +1000 (EST) Received: from localhost ([::1]:33774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPDlm-0006Rm-A5 for incoming@patchwork.ozlabs.org; Mon, 08 Apr 2013 11:14:06 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPDkO-0004yC-6I for qemu-devel@nongnu.org; Mon, 08 Apr 2013 11:12:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPDkC-0003MH-Bq for qemu-devel@nongnu.org; Mon, 08 Apr 2013 11:12:40 -0400 Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:1d0::1]:33679 helo=mnementh.archaic.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPDkC-0003Ly-4g for qemu-devel@nongnu.org; Mon, 08 Apr 2013 11:12:28 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1UPDIV-0005DZ-3A; Mon, 08 Apr 2013 15:43:51 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 8 Apr 2013 15:43:50 +0100 Message-Id: <1365432230-20028-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1365432230-20028-1-git-send-email-peter.maydell@linaro.org> References: <1365432230-20028-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: Paolo Bonzini , Anthony Liguori , Juan Quintela , patches@linaro.org Subject: [Qemu-devel] [PATCH 3/3] target-arm: Correctly restore FPSCR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use the helper functions to save and restore the FPSCR, so that we correctly propagate rounding mode and flushing behaviour into the float_status fields. This also allows us to stop saving the vector length/stride fields separately. Signed-off-by: Peter Maydell --- target-arm/machine.c | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/target-arm/machine.c b/target-arm/machine.c index 2dd48d7..4dd057c 100644 --- a/target-arm/machine.c +++ b/target-arm/machine.c @@ -9,17 +9,51 @@ static bool vfp_needed(void *opaque) return arm_feature(env, ARM_FEATURE_VFP); } +static int get_fpscr(QEMUFile *f, void *opaque, size_t size) +{ + ARMCPU *cpu = opaque; + CPUARMState *env = &cpu->env; + uint32_t val = qemu_get_be32(f); + + vfp_set_fpscr(env, val); + return 0; +} + +static void put_fpscr(QEMUFile *f, void *opaque, size_t size) +{ + ARMCPU *cpu = opaque; + CPUARMState *env = &cpu->env; + + qemu_put_be32(f, vfp_get_fpscr(env)); +} + +static const VMStateInfo vmstate_fpscr = { + .name = "fpscr", + .get = get_fpscr, + .put = put_fpscr, +}; + static const VMStateDescription vmstate_vfp = { .name = "cpu/vfp", - .version_id = 1, - .minimum_version_id = 1, - .minimum_version_id_old = 1, + .version_id = 2, + .minimum_version_id = 2, + .minimum_version_id_old = 2, .fields = (VMStateField[]) { VMSTATE_FLOAT64_ARRAY(env.vfp.regs, ARMCPU, 32), - VMSTATE_UINT32_ARRAY(env.vfp.xregs, ARMCPU, 16), - /* TODO: Should use proper FPSCR access functions. */ - VMSTATE_INT32(env.vfp.vec_len, ARMCPU), - VMSTATE_INT32(env.vfp.vec_stride, ARMCPU), + /* The xregs array is a little awkward because element 1 (FPSCR) + * requires a specific accessor, so we have to split it up in + * the vmstate: + */ + VMSTATE_UINT32(env.vfp.xregs[0], ARMCPU), + VMSTATE_UINT32_SUB_ARRAY(env.vfp.xregs, ARMCPU, 2, 14), + { + .name = "fpscr", + .version_id = 0, + .size = sizeof(uint32_t), + .info = &vmstate_fpscr, + .flags = VMS_SINGLE, + .offset = 0, + }, VMSTATE_END_OF_LIST() } };