From patchwork Thu Apr 17 10:33:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 28553 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2C62920674 for ; Thu, 17 Apr 2014 11:54:01 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rd18sf1645551iec.8 for ; Thu, 17 Apr 2014 04:54:00 -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: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=P0yH1SbMz3flF9q8a/kdjVGSi96z+3QMzst31AloRN8=; b=BoXG/5BlgcaEz5deff61R/aurLVn3xVW8J08OCNauDUhvdeNRwyAEouFiWVY2DbsVC R5O6rCDxWIHFYWCC8dLxA1OlJlZ/XQNIsSf+ecUHp0U+PwUvXz8B2wMInrgNWxvP98BD qPIsGlT6gm+FNHew+Wzhbb2l4cvLopzfEfPsTJ8b0jbowOsp0ydShCNb/nZN29hnSo5v PNMyjku/V8AFedIEsjX1o7fmF93FUgw9FBul4MgTtJ7+lo4ZNEMm3uN66NAIkM8M8x5T sbi+P1uGSgag2+FDP4jC4eYpkzP0VmR/7hoIH0+db9M4Ol0E53rBP8H3zlBJMxyp2kkI UMrA== X-Gm-Message-State: ALoCoQkzjhWmfWU+MmtTNdUYCGs0AYLDX1xLaBSP1pkeB1Z6/vKi+Sb03213pdn7VMo15uEyIsgF X-Received: by 10.50.70.66 with SMTP id k2mr5305182igu.7.1397735640540; Thu, 17 Apr 2014 04:54:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.232 with SMTP id 95ls1093304qgp.68.gmail; Thu, 17 Apr 2014 04:54:00 -0700 (PDT) X-Received: by 10.220.12.66 with SMTP id w2mr7268683vcw.15.1397735640395; Thu, 17 Apr 2014 04:54:00 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id tz5si4401813vdc.7.2014.04.17.04.54.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 17 Apr 2014 04:54:00 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.181 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.181; Received: by mail-vc0-f181.google.com with SMTP id id10so359246vcb.12 for ; Thu, 17 Apr 2014 04:54:00 -0700 (PDT) X-Received: by 10.52.113.1 with SMTP id iu1mr990071vdb.35.1397735640322; Thu, 17 Apr 2014 04:54:00 -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.220.221.72 with SMTP id ib8csp28823vcb; Thu, 17 Apr 2014 04:54:00 -0700 (PDT) X-Received: by 10.224.161.83 with SMTP id q19mr10055927qax.56.1397735639186; Thu, 17 Apr 2014 04:53:59 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l5si10398668qai.169.2014.04.17.04.53.59 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 17 Apr 2014 04:53:59 -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]:59590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wajvj-0002Cs-IO for patch@linaro.org; Thu, 17 Apr 2014 06:52:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WajeL-00083a-8k for qemu-devel@nongnu.org; Thu, 17 Apr 2014 06:34:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WajeK-0002ZO-Cp for qemu-devel@nongnu.org; Thu, 17 Apr 2014 06:34:33 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:47842) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WajeK-0002OB-6k for qemu-devel@nongnu.org; Thu, 17 Apr 2014 06:34:32 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Wajdv-0001z8-9b for qemu-devel@nongnu.org; Thu, 17 Apr 2014 11:34:07 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 17 Apr 2014 11:33:21 +0100 Message-Id: <1397730846-7576-7-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1397730846-7576-1-git-send-email-peter.maydell@linaro.org> References: <1397730846-7576-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 Subject: [Qemu-devel] [PULL 06/51] target-arm: Provide syndrome information for MMU faults 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.181 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 From: Rob Herring Set up the required syndrome information when we detect an MMU fault. Signed-off-by: Rob Herring [PMM: split out from exception handling patch, tweaked to bring in line with how we create other kinds of syndrome information] Signed-off-by: Peter Maydell Reviewed-by: Peter Crosthwaite --- target-arm/helper.c | 12 ++++++++++++ target-arm/internals.h | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/target-arm/helper.c b/target-arm/helper.c index fe642df..9866e50 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -3696,6 +3696,8 @@ int arm_cpu_handle_mmu_fault(CPUState *cs, vaddr address, target_ulong page_size; int prot; int ret, is_user; + uint32_t syn; + bool same_el = (arm_current_pl(env) != 0); is_user = mmu_idx == MMU_USER_IDX; ret = get_phys_addr(env, address, access_type, is_user, &phys_addr, &prot, @@ -3708,14 +3710,24 @@ int arm_cpu_handle_mmu_fault(CPUState *cs, vaddr address, return 0; } + /* AArch64 syndrome does not have an LPAE bit */ + syn = ret & ~(1 << 9); + + /* For insn and data aborts we assume there is no instruction syndrome + * information; this is always true for exceptions reported to EL1. + */ if (access_type == 2) { + syn = syn_insn_abort(same_el, 0, 0, syn); cs->exception_index = EXCP_PREFETCH_ABORT; } else { + syn = syn_data_abort(same_el, 0, 0, 0, access_type == 1, syn); if (access_type == 1 && arm_feature(env, ARM_FEATURE_V6)) { ret |= (1 << 11); } cs->exception_index = EXCP_DATA_ABORT; } + + env->exception.syndrome = syn; env->exception.vaddress = address; env->exception.fsr = ret; return 1; diff --git a/target-arm/internals.h b/target-arm/internals.h index 0300ba3..fad203b 100644 --- a/target-arm/internals.h +++ b/target-arm/internals.h @@ -188,4 +188,17 @@ static inline uint32_t syn_cp15_rrt_trap(int cv, int cond, int opc1, int crm, | (rt2 << 10) | (rt << 5) | (crm << 1) | isread; } +static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc) +{ + return (EC_INSNABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT) + | (ea << 9) | (s1ptw << 7) | fsc; +} + +static inline uint32_t syn_data_abort(int same_el, int ea, int cm, int s1ptw, + int wnr, int fsc) +{ + return (EC_DATAABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT) + | (ea << 9) | (cm << 8) | (s1ptw << 7) | (wnr << 6) | fsc; +} + #endif