From patchwork Thu Apr 10 16:15:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 28226 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AE93220671 for ; Thu, 10 Apr 2014 16:17:28 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id lx4sf19210686iec.3 for ; Thu, 10 Apr 2014 09:17:28 -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:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=KgDDg5M5PlwEfJ5gWBflwZEQEk3qlNb0IBWaWlqB6GI=; b=bmnWpOCeAgSeWSof8hcvMSwTDI5Wk/j4DrwOk8yeJn9aoFRtZ3cKV4FHqc627OIPGl pLC1EAyDskqAf460tTmcpcDJeXPAou7My+GlGa+Au7k2S2ALHk3zQwmdO1uaD4RVi8A6 ZLqd1HZm0tL1Q+gneU19ukLXBnLzz0n2+Sz8+dfmVNeU8QKiXXDXvYGXNGzxA+JY8tO5 IhwewTigu9MM5IwoSUsRM/BFoZSSF/L/vr+KLV8XvUsLzTgIZi0cMJsqXxdIbCAvUiOh qRmQKYX9Jf2B31LfOvumx9XQQpvwTOjTvRkA6Wyz7npLUpH5C41Agiy8jYya5XZTwUsa lmVw== X-Gm-Message-State: ALoCoQl6onoMqdVWqoKFRrzq5P7fcWB0Dnsem7WXC6ZrLs8gYawUEVwgMfZJHUb097QCFF3+uHNq X-Received: by 10.43.163.199 with SMTP id mp7mr7470976icc.6.1397146648137; Thu, 10 Apr 2014 09:17:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.30.163 with SMTP id d32ls1197379qgd.44.gmail; Thu, 10 Apr 2014 09:17:27 -0700 (PDT) X-Received: by 10.220.105.4 with SMTP id r4mr1153973vco.27.1397146547253; Thu, 10 Apr 2014 09:15:47 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id kr17si774267vcb.133.2014.04.10.09.15.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Apr 2014 09:15:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id db12so3548918veb.24 for ; Thu, 10 Apr 2014 09:15:47 -0700 (PDT) X-Received: by 10.52.0.193 with SMTP id 1mr12776494vdg.0.1397146547184; Thu, 10 Apr 2014 09:15:47 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp72238vcb; Thu, 10 Apr 2014 09:15:46 -0700 (PDT) X-Received: by 10.15.35.66 with SMTP id f42mr2227585eev.93.1397146544325; Thu, 10 Apr 2014 09:15:44 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id p8si6681611eew.66.2014.04.10.09.15.42 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 10 Apr 2014 09:15:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WYHdY-0007qb-Kp; Thu, 10 Apr 2014 17:15:36 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Alexander Graf , Laurent Desnogues , kvmarm@lists.cs.columbia.edu, Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Christoffer Dall , Peter Crosthwaite , Greg Bellows Subject: [PATCH v6 06/37] target-arm: Provide syndrome information for MMU faults Date: Thu, 10 Apr 2014 17:15:05 +0100 Message-Id: <1397146536-30116-7-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1397146536-30116-1-git-send-email-peter.maydell@linaro.org> References: <1397146536-30116-1-git-send-email-peter.maydell@linaro.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.128.179 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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