From patchwork Wed Feb 26 18:02:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 25383 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AB86420636 for ; Wed, 26 Feb 2014 18:15:12 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i11sf4436815oag.4 for ; Wed, 26 Feb 2014 10:15:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references: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; bh=YU21r0nBDUuYu2gh36963tSmJyEAHfbKr1ZtG2svt/k=; b=cN5qu52HucwbyCinp25rStKZfY0dq14QFseQgA7sMJ7ZaKIZBpC+KaAE2XIQwzt4LH 1otFznrITs18tNKnu1EuN4X4FJnnUT5lCaFqVJB459jVlQBfm8JB9EFC2p7X8hlToSHz 6QehJ77EFmR6e5eFFW+i4XzZBPvwj7OtVLzA8qWpmS+3WEnfXnQvjHZGAU/Ozs1idD3w GjQDWVD/M0LqT+9BADHIzQnnu9k4KRd6IxqI9+BX4fwX7bvRb1QVSi+PXQ292UU992aD beaUKG5+APsm7xEO0uy+qDDWiEVpt6la74H8CAoROKP4Wq4+n5II6QoCLuilY0Z8fPqW josA== X-Gm-Message-State: ALoCoQkZEgJROBAxW5EgIzfo26lxq7ZZT3eyQCnrRuQyIi5iIxq4Yel5KBAzHZgcJh2+VcA9L8qE X-Received: by 10.182.219.226 with SMTP id pr2mr1935592obc.44.1393438512229; Wed, 26 Feb 2014 10:15:12 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.36.200 with SMTP id p66ls330621qgp.74.gmail; Wed, 26 Feb 2014 10:15:12 -0800 (PST) X-Received: by 10.220.247.68 with SMTP id mb4mr957257vcb.37.1393438511760; Wed, 26 Feb 2014 10:15:11 -0800 (PST) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id tr5si433100vdc.104.2014.02.26.10.15.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Feb 2014 10:15:11 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ij19so1322345vcb.20 for ; Wed, 26 Feb 2014 10:15:11 -0800 (PST) X-Received: by 10.52.74.5 with SMTP id p5mr28258vdv.71.1393438511680; Wed, 26 Feb 2014 10:15:11 -0800 (PST) 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.220.174.196 with SMTP id u4csp45214vcz; Wed, 26 Feb 2014 10:15:11 -0800 (PST) X-Received: by 10.140.89.167 with SMTP id v36mr1173075qgd.27.1393438511043; Wed, 26 Feb 2014 10:15:11 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id de8si444833qcb.43.2014.02.26.10.15.10 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 26 Feb 2014 10:15:11 -0800 (PST) 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]:42276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIj0g-0008Px-HG for patch@linaro.org; Wed, 26 Feb 2014 13:15:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIiop-0000xe-DQ for qemu-devel@nongnu.org; Wed, 26 Feb 2014 13:02:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WIioo-0007Po-Bt for qemu-devel@nongnu.org; Wed, 26 Feb 2014 13:02:55 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:46191) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIioo-0007Eu-5S for qemu-devel@nongnu.org; Wed, 26 Feb 2014 13:02:54 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WIioV-00069m-Un; Wed, 26 Feb 2014 18:02:35 +0000 From: Peter Maydell To: Anthony Liguori Date: Wed, 26 Feb 2014 18:02:04 +0000 Message-Id: <1393437755-23586-15-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1393437755-23586-1-git-send-email-peter.maydell@linaro.org> References: <1393437755-23586-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: Blue Swirl , qemu-devel@nongnu.org, Aurelien Jarno Subject: [Qemu-devel] [PULL 14/45] target-arm: Fix raw read and write functions on AArch64 registers 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: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.175 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 Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 The raw read and write functions were using the ARM_CP_64BIT flag in ri->type to determine whether to treat the register's state field as uint32_t or uint64_t; however AArch64 register info structs don't use that flag. Abstract out the "how big is the field?" test into a function and fix it to work for AArch64 registers. For this to work we must ensure that the reginfo structs put into the hashtable have the correct state field for their use, not the placeholder STATE_BOTH. Signed-off-by: Peter Maydell --- target-arm/cpu.c | 2 +- target-arm/cpu.h | 8 ++++++++ target-arm/helper.c | 8 ++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 6e7ce89..fe18b65 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -60,7 +60,7 @@ static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque) return; } - if (ri->type & ARM_CP_64BIT) { + if (cpreg_field_is_64bit(ri)) { CPREG_FIELD64(&cpu->env, ri) = ri->resetvalue; } else { CPREG_FIELD32(&cpu->env, ri) = ri->resetvalue; diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 3c8a2db..4473fad 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -959,6 +959,14 @@ uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri); */ void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque); +/* Return true if this reginfo struct's field in the cpu state struct + * is 64 bits wide. + */ +static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri) +{ + return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT); +} + static inline bool cp_access_ok(int current_pl, const ARMCPRegInfo *ri, int isread) { diff --git a/target-arm/helper.c b/target-arm/helper.c index b44aa1b..965a338 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -109,7 +109,7 @@ static int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg) static uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri) { - if (ri->type & ARM_CP_64BIT) { + if (cpreg_field_is_64bit(ri)) { return CPREG_FIELD64(env, ri); } else { return CPREG_FIELD32(env, ri); @@ -119,7 +119,7 @@ static uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri) static void raw_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - if (ri->type & ARM_CP_64BIT) { + if (cpreg_field_is_64bit(ri)) { CPREG_FIELD64(env, ri) = value; } else { CPREG_FIELD32(env, ri) = value; @@ -1962,6 +1962,10 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, if (opaque) { r2->opaque = opaque; } + /* reginfo passed to helpers is correct for the actual access, + * and is never ARM_CP_STATE_BOTH: + */ + r2->state = state; /* Make sure reginfo passed to helpers for wildcarded regs * has the correct crm/opc1/opc2 for this reg, not CP_ANY: */