From patchwork Tue May 19 18:33:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 48762 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 85D592121F for ; Tue, 19 May 2015 18:33:40 +0000 (UTC) Received: by laat2 with SMTP id t2sf8979184laa.2 for ; Tue, 19 May 2015 11:33:39 -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=jOFtL7nSrIiLW4pB5VlFNVpxkhPIVcaZxUQeU4hBmNY=; b=gkkfNFE4XhSNWNGbe/XY14fdkjIQvts0sJ7jBUSMbOPmliA1LSMwk/pBQ35bzhM1JH eS7vYPaTzEIih28XH8+C2HwemmUU+D/wbM7uCqX2uUQCTW3hSaO7S9iF3yYUPtbyeGQx FUE8n0JAkra0AS9CgBir/SdLvjvovvbQ7wqylL9hgE3X3XtxI4Y/mZg8tLDlvP0eMKvN pZolM/WJAsDzMJPN6ijDO49T4ofNGQR1Fn4ff9/5jUC16IZ6pMvVIOZDBVwcrDtYe+7v bhQo1CRFBbe64HiIp/kWnhf42TjsalGsJkbt+lBc973ZO6Ld65M5rZQc+UwP3w2OFNar KVGQ== X-Gm-Message-State: ALoCoQk8WDjTRtXJJ2NwGf/9FzUgfOojyaDP7iWv1Bnqzzugp2uWteKozDdetSJIc2hNvZcTaWMU X-Received: by 10.152.26.134 with SMTP id l6mr22978070lag.10.1432060419184; Tue, 19 May 2015 11:33:39 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.193 with SMTP id 1ls105600law.41.gmail; Tue, 19 May 2015 11:33:39 -0700 (PDT) X-Received: by 10.112.214.202 with SMTP id oc10mr20526384lbc.80.1432060419041; Tue, 19 May 2015 11:33:39 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id y5si9582595lay.123.2015.05.19.11.33.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 May 2015 11:33:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by labbd9 with SMTP id bd9so38638757lab.2 for ; Tue, 19 May 2015 11:33:38 -0700 (PDT) X-Received: by 10.112.29.36 with SMTP id g4mr23361168lbh.56.1432060418563; Tue, 19 May 2015 11:33:38 -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 hn6csp992839lbb; Tue, 19 May 2015 11:33:37 -0700 (PDT) X-Received: by 10.194.57.40 with SMTP id f8mr37140756wjq.86.1432060417717; Tue, 19 May 2015 11:33:37 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id o7si25040732wjy.103.2015.05.19.11.33.36 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 19 May 2015 11:33:37 -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-0001Mm-Hj; 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 08/14] target-arm: Allow cp access functions to indicate traps to EL2 or EL3 Date: Tue, 19 May 2015 19:33:28 +0100 Message-Id: <1432060414-5195-9-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.53 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: , Some coprocessor access functions will need to indicate that the instruction should trap to EL2 or EL3 rather than the default target exception level; add corresponding CPAccessResult enum entries and handling code. Signed-off-by: Peter Maydell --- target-arm/cpu.h | 6 +++++- target-arm/op_helper.c | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 9119a94..e431372 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -1252,7 +1252,8 @@ typedef enum CPAccessResult { /* Access fails due to a configurable trap or enable which would * result in a categorized exception syndrome giving information about * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, - * 0xc or 0x18). + * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or + * PL1 if in EL0, otherwise to the current EL). */ CP_ACCESS_TRAP = 1, /* Access fails and results in an exception syndrome 0x0 ("uncategorized"). @@ -1260,6 +1261,9 @@ typedef enum CPAccessResult { * result in this failure is specifically defined by the architecture. */ CP_ACCESS_TRAP_UNCATEGORIZED = 2, + /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ + CP_ACCESS_TRAP_EL2 = 3, + CP_ACCESS_TRAP_EL3 = 4, } CPAccessResult; /* Access functions for coprocessor registers. These cannot fail and diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index d693b01..5963f3b 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -335,6 +335,7 @@ void HELPER(set_user_reg)(CPUARMState *env, uint32_t regno, uint32_t val) void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome) { const ARMCPRegInfo *ri = rip; + int target_el; if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14 && extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) { @@ -349,6 +350,17 @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome) case CP_ACCESS_OK: return; case CP_ACCESS_TRAP: + target_el = exception_target_el(env); + break; + case CP_ACCESS_TRAP_EL2: + /* Requesting a trap to EL2 when we're in EL3 or S-EL0/1 is + * a bug in the access function. + */ + assert(!arm_is_secure(env) && !arm_current_el(env) == 3); + target_el = 2; + break; + case CP_ACCESS_TRAP_EL3: + target_el = 3; break; case CP_ACCESS_TRAP_UNCATEGORIZED: syndrome = syn_uncategorized(); @@ -357,7 +369,7 @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome) g_assert_not_reached(); } - raise_exception(env, EXCP_UDEF, syndrome, exception_target_el(env)); + raise_exception(env, EXCP_UDEF, syndrome, target_el); } void HELPER(set_cp_reg)(CPUARMState *env, void *rip, uint32_t value)