From patchwork Tue May 19 18:33:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 48774 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 14F502121F for ; Tue, 19 May 2015 18:51:57 +0000 (UTC) Received: by wiz9 with SMTP id 9sf11131144wiz.3 for ; Tue, 19 May 2015 11:51:56 -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=vhtGLEvvecRAxlqU4yVu5DKrnqGT5nyCGECok+L2xts=; b=TV+PPcPHg8lme6OCbu2wqsYPZ54A5oOxPVTOfJdLICYrm1dywdFWpwgCktxGLovwzi MDXFPwCkdEv2zwGnDKlzzonzS0/tAGIGYnWLxgJ9CE3neTMzRGsAitNop3+wcsGuDnSj 2HQchRuRZ/ktHoI0v9Az6c2PPI163RWNJ92bpan52FxE+DGAGf9JXlN+8YDO6h2ooObO 6nZ2ExzNe2qEEWw7KOrCYbEGm+HCuukezT1of/bz/36EEiCq6zbekrY293yeNrRtNXzl kzTqeqqz1Bohlc/TJyQ95dDRMzRsXOIEnQIpC085rMW8K6S6pT3/dJ5XQftCIkvCRC3A Ujng== X-Gm-Message-State: ALoCoQmf5vMwyNymo9l1X3darpaXKdCEIjawtPjy6KsL5Xx/9+9p9jOJM6x4KPJwJLf3H0n1aN2H X-Received: by 10.194.240.164 with SMTP id wb4mr23051432wjc.1.1432061516396; Tue, 19 May 2015 11:51:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.22.99 with SMTP id c3ls94339laf.96.gmail; Tue, 19 May 2015 11:51:56 -0700 (PDT) X-Received: by 10.153.7.66 with SMTP id da2mr19649302lad.94.1432061516240; Tue, 19 May 2015 11:51:56 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id yj8si9629921lab.53.2015.05.19.11.51.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 May 2015 11:51:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by laat2 with SMTP id t2so38753313laa.1 for ; Tue, 19 May 2015 11:51:56 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr23555664lbc.32.1432061516142; Tue, 19 May 2015 11:51:56 -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.112.108.230 with SMTP id hn6csp1002266lbb; Tue, 19 May 2015 11:51:55 -0700 (PDT) X-Received: by 10.152.20.200 with SMTP id p8mr13411953lae.69.1432061511232; Tue, 19 May 2015 11:51:51 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id g10si9624029lam.78.2015.05.19.11.51.50 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 19 May 2015 11:51:51 -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 1YumKc-0001MO-AP; Tue, 19 May 2015 19:33:34 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, alex.bennee@linaro.org, agraf@suse.de, serge.fdrv@gmail.com, edgar.iglesias@xilinx.com Subject: [PATCH 02/14] target-arm: Extend helpers to route exceptions Date: Tue, 19 May 2015 19:33:22 +0100 Message-Id: <1432060414-5195-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1432060414-5195-1-git-send-email-peter.maydell@linaro.org> References: <1432060414-5195-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=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) 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: Greg Bellows Updated the various helper routines to set the target EL as needed using a dedicated function. Signed-off-by: Greg Bellows Acked-by: Edgar E. Iglesias Message-id: 1429722561-12651-3-git-send-email-greg.bellows@linaro.org [PMM: Also set target_el in fault cases in access_check_cp_reg()] Signed-off-by: Peter Maydell --- target-arm/op_helper.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index 51b04bd..43e3457 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -33,6 +33,20 @@ static void raise_exception(CPUARMState *env, int tt) cpu_loop_exit(cs); } +static int exception_target_el(CPUARMState *env) +{ + int target_el = MAX(1, arm_current_el(env)); + + /* No such thing as secure EL1 if EL3 is aarch32, so update the target EL + * to EL3 in this case. + */ + if (arm_is_secure(env) && !arm_el_is_aa64(env, 3) && target_el == 1) { + target_el = 3; + } + + return target_el; +} + uint32_t HELPER(neon_tbl)(CPUARMState *env, uint32_t ireg, uint32_t def, uint32_t rn, uint32_t maxindex) { @@ -306,6 +320,7 @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome) if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14 && extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) { env->exception.syndrome = syndrome; + env->exception.target_el = exception_target_el(env); raise_exception(env, EXCP_UDEF); } @@ -318,9 +333,11 @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome) return; case CP_ACCESS_TRAP: env->exception.syndrome = syndrome; + env->exception.target_el = exception_target_el(env); break; case CP_ACCESS_TRAP_UNCATEGORIZED: env->exception.syndrome = syn_uncategorized(); + env->exception.target_el = exception_target_el(env); break; default: g_assert_not_reached(); @@ -363,6 +380,7 @@ void HELPER(msr_i_pstate)(CPUARMState *env, uint32_t op, uint32_t imm) * to catch that case at translate time. */ if (arm_current_el(env) == 0 && !(env->cp15.sctlr_el[1] & SCTLR_UMA)) { + env->exception.target_el = exception_target_el(env); raise_exception(env, EXCP_UDEF); } @@ -422,6 +440,7 @@ void HELPER(pre_hvc)(CPUARMState *env) if (undef) { env->exception.syndrome = syn_uncategorized(); + env->exception.target_el = exception_target_el(env); raise_exception(env, EXCP_UDEF); } } @@ -452,11 +471,13 @@ void HELPER(pre_smc)(CPUARMState *env, uint32_t syndrome) } else if (!secure && cur_el == 1 && (env->cp15.hcr_el2 & HCR_TSC)) { /* In NS EL1, HCR controlled routing to EL2 has priority over SMD. */ env->exception.syndrome = syndrome; + env->exception.target_el = 2; raise_exception(env, EXCP_HYP_TRAP); } if (undef) { env->exception.syndrome = syn_uncategorized(); + env->exception.target_el = exception_target_el(env); raise_exception(env, EXCP_UDEF); } }