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: 15976 Return-Path: X-Original-To: linaro@staging.patches.linaro.org Delivered-To: linaro@staging.patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 73CAE23900 for ; Mon, 8 Apr 2013 14:44:14 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id i13sf3184601qae.2 for ; Mon, 08 Apr 2013 07:43:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=rw45cL2NVr8Bs/9Zx7Y86lfdtUps8OGnSErp+BxFapM=; b=mXuHe1F28mSzadUFS8px0PhW4h7Kbk27bu9i3pGPO3yNwK6PNT5Qw6OSWHNg5Oyi9R M8WAzpqOOTRlpYgfb9iTWBcNRkZHY6wIBkJh9zUYyPIT0nWdcnPlbtz/fLBCMAUQ1KU2 ufFARbejDtPhTPd9T5m+32hx7a3laS9XGbXuvhlFbwbjxcPmPSA1hbygErovGEr5f4It Z6osjj+9tNZVuvKuZXDMxfYtX6FKE4Zzvpn+ueLbPKjJ98O8TXhCA/T5VPJtTLj2DX5g nae0mu6DGjcEUd2YpRRfqfbUTVswmIv8BzTSWhVMCWQGQG9cQxLj+igNpWQqdEW3HZvE ahDw== X-Received: by 10.236.231.141 with SMTP id l13mr10098069yhq.19.1365432239737; Mon, 08 Apr 2013 07:43:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.244 with SMTP id 20ls3209167qeh.77.gmail; Mon, 08 Apr 2013 07:43:59 -0700 (PDT) X-Received: by 10.52.179.105 with SMTP id df9mr5181775vdc.49.1365432239622; Mon, 08 Apr 2013 07:43:59 -0700 (PDT) Received: from mail-vb0-x22d.google.com (mail-vb0-x22d.google.com [2607:f8b0:400c:c02::22d]) by mx.google.com with ESMTPS id d10si18533215vdv.80.2013.04.08.07.43.59 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 08 Apr 2013 07:43:59 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::22d is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::22d; Received: by mail-vb0-f45.google.com with SMTP id w15so3886593vbf.32 for ; Mon, 08 Apr 2013 07:43:59 -0700 (PDT) X-Received: by 10.58.168.208 with SMTP id zy16mr16161448veb.3.1365432239491; Mon, 08 Apr 2013 07:43:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.85.136 with SMTP id h8csp21843vez; Mon, 8 Apr 2013 07:43:56 -0700 (PDT) X-Received: by 10.205.35.13 with SMTP id su13mr4510072bkb.40.1365432234425; Mon, 08 Apr 2013 07:43:54 -0700 (PDT) Received: from mnementh.archaic.org.uk (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]) by mx.google.com with ESMTPS id nu9si4005002bkb.203.2013.04.08.07.43.53 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 08 Apr 2013 07:43:54 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; 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 Cc: patches@linaro.org, Paolo Bonzini , Anthony Liguori , Juan Quintela Subject: [PATCH 3/3] target-arm: Correctly restore FPSCR 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-Gm-Message-State: ALoCoQnyOFF8Ekg1if2NkhTX2K1oFZ++IZwzdWm8+FFwKa8sEIdlq7+pGc59RbSZ4TagzkgWX/J+ X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::22d is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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() } };