From patchwork Thu Jul 10 15:50:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 33459 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 66C7B203F4 for ; Thu, 10 Jul 2014 20:25:23 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id kq14sf736270pab.8 for ; Thu, 10 Jul 2014 13:25:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=VwMhQ3sG672RgfvdzLTUzTlnwcmt1r6yZ4QUxXNrXFo=; b=nLpbUMgWqetAKUO+5IodRjJrWfWsoyZ+cBBNp2lU+CoXtACwTiljlq+4KxeN7ezQ5z S+Ei7kFyqsolbT6i55+F6ndFPipHBtjXqnhpLmB1+CEwDE3vhT+r2PKjQw5LtNj60emm 5U1gXT8s+256VLN1mrvWqbxhTSVT4Rc/u36adWHv+Bok/XFD2cUyNJ37iEpSGhzkbL1+ O8bf/8RNpOInmKAfpXSHYA9IquRtgMiLyXBYBoLo71nl101eFnCRAC+9flGctuGbqYc9 /NItxiz0PF6Osi89Rf2DyPnVF+AbnEUjXEIYda4OreRzaPrOtljDqMwgRvfqIfUgrTyQ mQGA== X-Gm-Message-State: ALoCoQkCDkR3nmI9MXFKIOgP/7IoxPxe7MTeI9a0AxpB6jvLJdK18xnUiFngbJasfgblnbwwQ959 X-Received: by 10.66.145.33 with SMTP id sr1mr23531313pab.18.1405023922742; Thu, 10 Jul 2014 13:25:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.33 with SMTP id d30ls193473qgf.47.gmail; Thu, 10 Jul 2014 13:25:22 -0700 (PDT) X-Received: by 10.52.166.10 with SMTP id zc10mr2062270vdb.61.1405023922543; Thu, 10 Jul 2014 13:25:22 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id nu8si147771vcb.16.2014.07.10.13.25.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Jul 2014 13:25:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id im17so232667vcb.39 for ; Thu, 10 Jul 2014 13:25:22 -0700 (PDT) X-Received: by 10.221.26.10 with SMTP id rk10mr47462346vcb.0.1405023922433; Thu, 10 Jul 2014 13:25:22 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp165306vcb; Thu, 10 Jul 2014 13:25:22 -0700 (PDT) X-Received: by 10.224.123.71 with SMTP id o7mr83660608qar.38.1405023922080; Thu, 10 Jul 2014 13:25:22 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d16si257325qaa.115.2014.07.10.13.25.21 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 10 Jul 2014 13:25:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:38672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5GeO-0002bY-Se for patch@linaro.org; Thu, 10 Jul 2014 11:52:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5GbP-0001Uq-Pv for qemu-devel@nongnu.org; Thu, 10 Jul 2014 11:49:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X5GbK-0006zR-2F for qemu-devel@nongnu.org; Thu, 10 Jul 2014 11:49:43 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:35645 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5GbJ-0006zD-SF for qemu-devel@nongnu.org; Thu, 10 Jul 2014 11:49:37 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaro.local) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1X5GgA-0007L4-Gp; Thu, 10 Jul 2014 17:54:38 +0200 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 10 Jul 2014 16:50:00 +0100 Message-Id: <1405007407-23549-4-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1405007407-23549-1-git-send-email-alex.bennee@linaro.org> References: <1405007407-23549-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: alex.bennee@linaro.org X-SA-Exim-Scanned: No (on socrates.bennee.com); SAEximRunCond expanded to false X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 88.198.71.155 Cc: Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [Qemu-devel] [PATCH v2 03/10] target-arm: Support save/load for 64 bit CPUs 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.bennee@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This enables the saving and restoring of machine state by including the current program state (*psr) and xregs. The save_state_to_spsr hides the details of if the processor is in 32 or 64 bit mode at the time. Signed-off-by: Alex Bennée --- v2 (ajb) - use common state save functions - re-base to latest origin/master - clean up commented out code diff --git a/target-arm/machine.c b/target-arm/machine.c index 3bcc7cc..759610c 100644 --- a/target-arm/machine.c +++ b/target-arm/machine.c @@ -120,30 +120,27 @@ static const VMStateDescription vmstate_thumb2ee = { } }; -static int get_cpsr(QEMUFile *f, void *opaque, size_t size) +static int get_psr(QEMUFile *f, void *opaque, size_t size) { ARMCPU *cpu = opaque; CPUARMState *env = &cpu->env; uint32_t val = qemu_get_be32(f); - /* Avoid mode switch when restoring CPSR */ - env->uncached_cpsr = val & CPSR_M; - cpsr_write(env, val, 0xffffffff); + restore_state_from_spsr(env, val); return 0; } -static void put_cpsr(QEMUFile *f, void *opaque, size_t size) +static void put_psr(QEMUFile *f, void *opaque, size_t size) { ARMCPU *cpu = opaque; CPUARMState *env = &cpu->env; - - qemu_put_be32(f, cpsr_read(env)); + qemu_put_be32(f, save_state_to_spsr(env)); } -static const VMStateInfo vmstate_cpsr = { +static const VMStateInfo vmstate_psr = { .name = "cpsr", - .get = get_cpsr, - .put = put_cpsr, + .get = get_psr, + .put = put_psr, }; static void cpu_pre_save(void *opaque) @@ -218,17 +215,19 @@ static int cpu_post_load(void *opaque, int version_id) const VMStateDescription vmstate_arm_cpu = { .name = "cpu", - .version_id = 20, - .minimum_version_id = 20, + .version_id = 21, + .minimum_version_id = 21, .pre_save = cpu_pre_save, .post_load = cpu_post_load, .fields = (VMStateField[]) { VMSTATE_UINT32_ARRAY(env.regs, ARMCPU, 16), + VMSTATE_UINT64_ARRAY(env.xregs, ARMCPU, 32), + VMSTATE_UINT64(env.pc, ARMCPU), { - .name = "cpsr", + .name = "psr", .version_id = 0, .size = sizeof(uint32_t), - .info = &vmstate_cpsr, + .info = &vmstate_psr, .flags = VMS_SINGLE, .offset = 0, },