From patchwork Mon Feb 18 14:30:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 158626 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2608191jaa; Mon, 18 Feb 2019 07:16:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IaSEpipHFJRrflQ9nMGFRMas9QyZ5U/BEEi53bZ8/ooto0Hb6VCvhFMycbNj/NmlSarIIan X-Received: by 2002:a0d:e105:: with SMTP id k5mr18937208ywe.196.1550503005264; Mon, 18 Feb 2019 07:16:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550503005; cv=none; d=google.com; s=arc-20160816; b=nZICko9fESIey3tXg0OanUXznjtJFZmbIsE7S7ODQ7fzu6T2X1TeJcJqgOqs+S1vOA stDLckXClscFeUpmNEi8e136q+dV7yhDk/v6J+nsXE4Yhf5VtR4k336H9sEnFaGjSqd1 h1Bn6pZPuQCQAH0LzzNqFD0Zunfq5M2kTWfqoV74Pm1iLR8A3L6eJAHaXQCKsT0Sprpj cn1YVKDfW9WYLcXStqvz7wMbzNnXjQ5xvGf5UIjXuhbLm7QGU8b3gKfbUAMgTzMjzPtF FW17zgq+ewkKPy5yV+j6UW1u3BSMXXIhtZYYPmn+sbDofO/+J/xa5RjTzd+4xsXfjVkZ vkVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=T5q6/axCPk/TX85ha2kr35ego4qxLfmWvAgNZOpwOTY=; b=G+2R0rLwnv627wn3mnKSupCw6cLrL9HZM8VdD0cx3zpdEa4xQp0zuDZJnuyq9mJLNn tDBbgOP9vp1iB4Urgfl2fs9JwfbxJ8GhGOwnz2vlrjs005K7YKmO4kAjGuyLVeKE6bMs pYeyJ9EmIF/ZgvfdC83UEMD/xlIfGmzbX6ykA+zhqpsY2QzA8XtsMyWfH+ptqbzF8idn hnzct2cZc/4xTyVxyXKk1JZL2a5j6QPtK7f8Kmgs0H/s6p9tt9+lOFrea7gvUkOFYlAU y475az+wASMOl+eO08HDgI9MGmGon7ZzMD+7or1AFjV6cwEvMP0rk+nfoJKPAfWvNZBr 0Ttw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gibson.dropbear.id.au header.s=201602 header.b=L1v4W3Bv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l189si6996508ywg.418.2019.02.18.07.16.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 18 Feb 2019 07:16:45 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gibson.dropbear.id.au header.s=201602 header.b=L1v4W3Bv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:60315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvkey-0000g7-N6 for patch@linaro.org; Mon, 18 Feb 2019 10:16:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvjyF-0006qy-Ro for qemu-devel@nongnu.org; Mon, 18 Feb 2019 09:32:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvjxx-0003Gx-Gg for qemu-devel@nongnu.org; Mon, 18 Feb 2019 09:32:27 -0500 Received: from ozlabs.org ([203.11.71.1]:52461) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvjxw-0003Ds-QR; Mon, 18 Feb 2019 09:32:17 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4435s30k9Dz9sQm; Tue, 19 Feb 2019 01:31:18 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1550500279; bh=3dZ+99kwfp6L+lvyxQtGfMWD/0+jLACIq9+NuLPc/dM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L1v4W3Bv06d6KeBsQoW8dqjNqsW/h6O3mHCX1/koEnGKbKeaxlw36+eQ0NxQr3lkW FG2YZ2eHIrQa+4gqXuluJNDCh07Se6lhRb7CIAlYrFk6AFg9yjD4YtWYemyNVU0ETV 984otIMwCuJ7iUf5ZfievQfWDsNMYLcqX3Ag450Y= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 19 Feb 2019 01:30:45 +1100 Message-Id: <20190218143049.17142-40-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218143049.17142-1-david@gibson.dropbear.id.au> References: <20190218143049.17142-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 39/43] target/ppc: Use mtvscr/mfvscr for vmstate 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: Richard Henderson , groug@kaod.org, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This is required before changing the representation of the register. Signed-off-by: Richard Henderson Acked-by: David Gibson Message-Id: <20190215100058.20015-14-mark.cave-ayland@ilande.co.uk> Signed-off-by: David Gibson --- target/ppc/machine.c | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/target/ppc/machine.c b/target/ppc/machine.c index eff30053b0..756b6d2971 100644 --- a/target/ppc/machine.c +++ b/target/ppc/machine.c @@ -10,6 +10,7 @@ #include "migration/cpu.h" #include "qapi/error.h" #include "kvm_ppc.h" +#include "exec/helper-proto.h" static int cpu_load_old(QEMUFile *f, void *opaque, int version_id) { @@ -17,7 +18,7 @@ static int cpu_load_old(QEMUFile *f, void *opaque, int version_id) CPUPPCState *env = &cpu->env; unsigned int i, j; target_ulong sdr1; - uint32_t fpscr; + uint32_t fpscr, vscr; #if defined(TARGET_PPC64) int32_t slb_nr; #endif @@ -84,7 +85,8 @@ static int cpu_load_old(QEMUFile *f, void *opaque, int version_id) if (!cpu->vhyp) { ppc_store_sdr1(env, sdr1); } - qemu_get_be32s(f, &env->vscr); + qemu_get_be32s(f, &vscr); + helper_mtvscr(env, vscr); qemu_get_be64s(f, &env->spe_acc); qemu_get_be32s(f, &env->spe_fscr); qemu_get_betls(f, &env->msr_mask); @@ -429,6 +431,28 @@ static bool altivec_needed(void *opaque) return (cpu->env.insns_flags & PPC_ALTIVEC); } +static int get_vscr(QEMUFile *f, void *opaque, size_t size, + const VMStateField *field) +{ + PowerPCCPU *cpu = opaque; + helper_mtvscr(&cpu->env, qemu_get_be32(f)); + return 0; +} + +static int put_vscr(QEMUFile *f, void *opaque, size_t size, + const VMStateField *field, QJSON *vmdesc) +{ + PowerPCCPU *cpu = opaque; + qemu_put_be32(f, helper_mfvscr(&cpu->env)); + return 0; +} + +static const VMStateInfo vmstate_vscr = { + .name = "cpu/altivec/vscr", + .get = get_vscr, + .put = put_vscr, +}; + static const VMStateDescription vmstate_altivec = { .name = "cpu/altivec", .version_id = 1, @@ -436,7 +460,21 @@ static const VMStateDescription vmstate_altivec = { .needed = altivec_needed, .fields = (VMStateField[]) { VMSTATE_AVR_ARRAY(env.vsr, PowerPCCPU, 32), - VMSTATE_UINT32(env.vscr, PowerPCCPU), + /* + * Save the architecture value of the vscr, not the internally + * expanded version. Since this architecture value does not + * exist in memory to be stored, this requires a but of hoop + * jumping. We want OFFSET=0 so that we effectively pass CPU + * to the helper functions. + */ + { + .name = "vscr", + .version_id = 0, + .size = sizeof(uint32_t), + .info = &vmstate_vscr, + .flags = VMS_SINGLE, + .offset = 0 + }, VMSTATE_END_OF_LIST() }, };