From patchwork Wed Apr 1 15:39:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 46632 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1A6162159A for ; Wed, 1 Apr 2015 15:42:25 +0000 (UTC) Received: by lbbug6 with SMTP id ug6sf11430872lbb.3 for ; Wed, 01 Apr 2015 08:42:23 -0700 (PDT) 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=LpNQOW9sjHxAuWjvhJbPb/PC13EtY+X9eTOef84CukI=; b=GuBZFW5Nfw6qSYS2sUTODPLRHVsca+rAZ3msg6Xkp3twjvY7U/+LwVmMV+nlmBKEqJ lsu9ps8LVzF35/Fp5HBid7+DzZhjMXcsgH6klkudvwmjM3SdrFRzp4Wwh8bYKqLavx+L R6U8kJ12gjRfH0HRNFA3wbnIYAweF1aRonhz5JVsNLSXtwTg2Ttufki4DyktZaHO966Z zstcBqFh9yd1sxFaFbZZIqM+JEd4y1doHRprCdP9lsH1Amthas3B5UsQgRQysisCgK5C o+JS5uGcYMFivb8Fkw6rzu4JQkVQnhyhBo0XV5esMnjPNAzCavnfBspD1XpdEDh4ZDDi 8FMg== X-Gm-Message-State: ALoCoQlgtKlEWwBbxcvZ9QhaLmP50S1GXW7uH3m8hHkVJmlpd++F5J/H9OMDBUTTi2UQkIan7B/7 X-Received: by 10.152.184.73 with SMTP id es9mr150955lac.4.1427902943129; Wed, 01 Apr 2015 08:42:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.42 with SMTP id j10ls89298laf.45.gmail; Wed, 01 Apr 2015 08:42:22 -0700 (PDT) X-Received: by 10.152.198.203 with SMTP id je11mr35504551lac.85.1427902942681; Wed, 01 Apr 2015 08:42:22 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id lc10si1921612lab.10.2015.04.01.08.42.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 08:42:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbbug6 with SMTP id ug6so39375824lbb.3 for ; Wed, 01 Apr 2015 08:42:22 -0700 (PDT) X-Received: by 10.152.5.72 with SMTP id q8mr18843193laq.73.1427902942588; Wed, 01 Apr 2015 08:42: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.112.57.201 with SMTP id k9csp746033lbq; Wed, 1 Apr 2015 08:42:21 -0700 (PDT) X-Received: by 10.140.18.175 with SMTP id 44mr34027705qgf.80.1427902941133; Wed, 01 Apr 2015 08:42:21 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 3si2159135qkr.116.2015.04.01.08.42.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 01 Apr 2015 08:42:21 -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]:53452 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdKma-0006VX-AG for patch@linaro.org; Wed, 01 Apr 2015 11:42:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdKjn-0002WW-A2 for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:39:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdKjd-0007ke-0v for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:39:27 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:36084 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdKjc-0007kS-Qf for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:39:16 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaroharston) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1YdLq2-0006ck-WB; Wed, 01 Apr 2015 18:49:59 +0200 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Wed, 1 Apr 2015 16:39:12 +0100 Message-Id: <1427902756-30567-2-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.3.4 In-Reply-To: <1427902756-30567-1-git-send-email-alex.bennee@linaro.org> References: <1427902756-30567-1-git-send-email-alex.bennee@linaro.org> 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: christoffer.dall@linaro.org, greg.bellows@linaro.org Subject: [Qemu-devel] [PATCH v6 1/5] target-arm: Store SPSR_EL1 state in banked_spsr[1] (SPSR_svc) 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.217.173 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 From: Peter Maydell The AArch64 SPSR_EL1 register is architecturally mandated to be mapped to the AArch32 SPSR_svc register. This means its state should live in QEMU's env->banked_spsr[1] field. Correct the various places in the code that incorrectly put it in banked_spsr[0]. Signed-off-by: Peter Maydell diff --git a/target-arm/helper-a64.c b/target-arm/helper-a64.c index 7e0d038..861f6fa 100644 --- a/target-arm/helper-a64.c +++ b/target-arm/helper-a64.c @@ -523,7 +523,7 @@ void aarch64_cpu_do_interrupt(CPUState *cs) aarch64_save_sp(env, arm_current_el(env)); env->elr_el[new_el] = env->pc; } else { - env->banked_spsr[0] = cpsr_read(env); + env->banked_spsr[aarch64_banked_spsr_index(new_el)] = cpsr_read(env); if (!env->thumb) { env->cp15.esr_el[new_el] |= 1 << 25; } diff --git a/target-arm/helper.c b/target-arm/helper.c index 10886c5..d77c6de 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -2438,7 +2438,7 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "SPSR_EL1", .state = ARM_CP_STATE_AA64, .type = ARM_CP_ALIAS, .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 0, .opc2 = 0, - .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[0]) }, + .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[1]) }, /* We rely on the access checks not allowing the guest to write to the * state field when SPSel indicates that it's being used as the stack * pointer. diff --git a/target-arm/internals.h b/target-arm/internals.h index bb171a7..2cc3017 100644 --- a/target-arm/internals.h +++ b/target-arm/internals.h @@ -82,11 +82,14 @@ static inline void arm_log_exception(int idx) /* * For AArch64, map a given EL to an index in the banked_spsr array. + * Note that this mapping and the AArch32 mapping defined in bank_number() + * must agree such that the AArch64<->AArch32 SPSRs have the architecturally + * mandated mapping between each other. */ static inline unsigned int aarch64_banked_spsr_index(unsigned int el) { static const unsigned int map[4] = { - [1] = 0, /* EL1. */ + [1] = 1, /* EL1. */ [2] = 6, /* EL2. */ [3] = 7, /* EL3. */ };