From patchwork Fri May 29 13:10:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 49208 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 14FA3218E7 for ; Fri, 29 May 2015 13:28:37 +0000 (UTC) Received: by lbcue7 with SMTP id ue7sf19074729lbc.3 for ; Fri, 29 May 2015 06:28:36 -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=vhtGLEvvecRAxlqU4yVu5DKrnqGT5nyCGECok+L2xts=; b=QRbtuHWmJ0TxNkl3rrTH+xzXTNm6evJSXYjklMKrJgjJKzCVYe3vykVfbZ6oXblETD 7dcobNesMOWxxoP57IwYmUqa/jPAQAoDTBmWEka2HNoK4fd2bzSxvBc8vkmoZ7KhdYvx Rd8+LknH/y9i0KI5pF7BNNWVBM0PD70F3fQ28et54W87Fv5K2Hs2hchnyZEUzXTDI3Xp PVBG1yg0Ghewx60nuco5h/0HaGuwY4Qf6SSCWp7XyVKM6fLSFwZMdqgz185A5WfvfEgd guRxUXdvWj5PkohfWNENOqCOTvkneqgcOZP52EISofeu4Mph3nPrjFPUP2icpLaYTMFM SmZg== X-Gm-Message-State: ALoCoQm5jTESHuLNPInGa1avAb32o5UBfvY4Dj0hymB/4/3QQk91Twb8L0HdgsRztJqg5G2W7+Zz X-Received: by 10.112.55.104 with SMTP id r8mr7400993lbp.18.1432906115915; Fri, 29 May 2015 06:28:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.99 with SMTP id lf3ls132450lac.54.gmail; Fri, 29 May 2015 06:28:35 -0700 (PDT) X-Received: by 10.152.87.13 with SMTP id t13mr8126176laz.66.1432906115768; Fri, 29 May 2015 06:28:35 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id du6si4708102lbc.41.2015.05.29.06.28.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 May 2015 06:28:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by lagv1 with SMTP id v1so55715394lag.3 for ; Fri, 29 May 2015 06:28:35 -0700 (PDT) X-Received: by 10.152.4.137 with SMTP id k9mr7852331lak.29.1432906115396; Fri, 29 May 2015 06:28:35 -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.108.230 with SMTP id hn6csp334003lbb; Fri, 29 May 2015 06:28:34 -0700 (PDT) X-Received: by 10.55.33.23 with SMTP id h23mr15840051qkh.61.1432906113793; Fri, 29 May 2015 06:28:33 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g9si5580748qgf.41.2015.05.29.06.28.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 29 May 2015 06:28:33 -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]:35915 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyKKu-0003lz-Lx for patch@linaro.org; Fri, 29 May 2015 09:28:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyK42-00042c-Ja for qemu-devel@nongnu.org; Fri, 29 May 2015 09:11:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyK41-0003dk-06 for qemu-devel@nongnu.org; Fri, 29 May 2015 09:11:06 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:34304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyK40-0003US-Nn for qemu-devel@nongnu.org; Fri, 29 May 2015 09:11:04 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1YyK3h-0005lf-6O for qemu-devel@nongnu.org; Fri, 29 May 2015 14:10:45 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 29 May 2015 14:10:08 +0100 Message-Id: <1432905045-22138-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1432905045-22138-1-git-send-email-peter.maydell@linaro.org> References: <1432905045-22138-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 02/39] target-arm: Extend helpers to route exceptions 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=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 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: 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); } }