From patchwork Fri Mar 28 16:09:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 27354 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C258B2066E for ; Fri, 28 Mar 2014 16:27:26 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id jy13sf5727892veb.10 for ; Fri, 28 Mar 2014 09:27:26 -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=W7UjFQJczumiSDZPvLWBjoTRCL8xTnMZXU8kGfQp37s=; b=TlIb3L3mEWpDFJL4odriXUZMEuIM4tFpsuj8GEtPqyKC5k/5tPbUaaMnkHd44OGfe9 4RTIfOM6W9cDY7ap2/Vb7LeEgUxy+4XT2t7xGvWmrlBTcFZqsNlnk2qtR/BnmAlIbns/ 6X07jMLSPgPWsUDmBVjGCMZCMmvvbCZuPGFAsphuGt0ZpPHi0qRu+Qfe8dMYxeBoGe6G EDPqlZUwb8+NI5Wo1WisvIlFu/aNFU/motciC3Mx+AD7jvubnA3gVzPFzGyOP7qg+B57 Nnkaj7Er07dt5NLcnrQcAOM4RDE3YOWqIB5pzZXpNAeiYqEvzvQDQVAPfRjecKT42+Iw sIug== X-Gm-Message-State: ALoCoQkTpvYmSwBASvQNv98KO4dSWGlCuIxBZfRb6J3Lksq80Q7GYFeUKsv/CbFi12LdtQtB3Eck X-Received: by 10.236.182.230 with SMTP id o66mr2857897yhm.12.1396024046473; Fri, 28 Mar 2014 09:27:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.20 with SMTP id b20ls1543738qga.5.gmail; Fri, 28 Mar 2014 09:27:26 -0700 (PDT) X-Received: by 10.52.191.100 with SMTP id gx4mr6683900vdc.4.1396024046412; Fri, 28 Mar 2014 09:27:26 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id tc5si1228626vcb.107.2014.03.28.09.27.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 09:27:26 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.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.220.179; Received: by mail-vc0-f179.google.com with SMTP id ij19so6009437vcb.24 for ; Fri, 28 Mar 2014 09:27:26 -0700 (PDT) X-Received: by 10.52.249.105 with SMTP id yt9mr884469vdc.34.1396024046340; Fri, 28 Mar 2014 09:27:26 -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.12.8 with SMTP id v8csp21822vcv; Fri, 28 Mar 2014 09:27:25 -0700 (PDT) X-Received: by 10.69.31.171 with SMTP id kn11mr9628901pbd.47.1396024031721; Fri, 28 Mar 2014 09:27:11 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id sf3si3992175pac.1.2014.03.28.09.27.09 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 28 Mar 2014 09:27:11 -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 1WTZMO-0000bL-QH; Fri, 28 Mar 2014 16:10:24 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Alexander Graf , Michael Matz , Dirk Mueller , Laurent Desnogues , kvmarm@lists.cs.columbia.edu, Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Christoffer Dall , Will Newton , Peter Crosthwaite Subject: [PATCH v5 06/37] target-arm: Provide syndrome information for MMU faults Date: Fri, 28 Mar 2014 16:09:53 +0000 Message-Id: <1396023024-2262-7-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1396023024-2262-1-git-send-email-peter.maydell@linaro.org> References: <1396023024-2262-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.220.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 --- 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..e8d98a1 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(bool 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(bool 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