From patchwork Mon Jun 30 23:09:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 32823 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3AF24203C0 for ; Tue, 1 Jul 2014 00:27:43 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id y10sf42918073pdj.5 for ; Mon, 30 Jun 2014 17:27:42 -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:cc: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=zJfXPw0luXtIGYbBDT/gw63uSK72V8wmzSNg6pWsFtU=; b=Anrr+PRn1hJH9LP/l+qSf3xwUydlgy9D00IiBfILCi2JAQUZE6TskDTWL8zL/4PEmE qTDk4TZ3WRJKqo5/TfgKZbeY1hLVR727jSZbSjaGXtfOvFc72FHXkRjgjf0WhW/PKLrm 85bu1oV5k/f8nzb7iQvd/2nCjclGGLxmIX3UmI4+QvJ7yAZz+5pkBRcYYSosW2phkK5x 0UhQ6jQbtREiHpApstrcwNk8KVw6NLE+Cqq5bPcJjrFr+tv9Jytb+c1vx8NWHQ2pOH/8 5a4NTmB/Gz7kF6V7cfWU+es+z5tcPOKQJwal3dJ/7T1gEDVpkj7zh57mEZEQ7Gmf05KE jrnA== X-Gm-Message-State: ALoCoQmKjVdoOQHUr3WOpOuVNm+sBsyc8Jl9rBa6WwFafAooUZAobsDcTChKxrCi6sDnZQzKbpMR X-Received: by 10.68.230.193 with SMTP id ta1mr23740147pbc.6.1404174462238; Mon, 30 Jun 2014 17:27:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.22.198 with SMTP id 64ls1356677qgn.8.gmail; Mon, 30 Jun 2014 17:27:42 -0700 (PDT) X-Received: by 10.52.27.133 with SMTP id t5mr35058703vdg.9.1404174462118; Mon, 30 Jun 2014 17:27:42 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id d3si10771885vck.42.2014.06.30.17.27.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Jun 2014 17:27:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.173 as permitted sender) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id db11so8925970veb.18 for ; Mon, 30 Jun 2014 17:27:42 -0700 (PDT) X-Received: by 10.52.0.177 with SMTP id 17mr9164572vdf.12.1404174462003; Mon, 30 Jun 2014 17:27:42 -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.221.37.5 with SMTP id tc5csp178108vcb; Mon, 30 Jun 2014 17:27:41 -0700 (PDT) X-Received: by 10.224.29.201 with SMTP id r9mr66416851qac.25.1404174461559; Mon, 30 Jun 2014 17:27:41 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k1si12653845qan.109.2014.06.30.17.27.41 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 30 Jun 2014 17:27:41 -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]:37032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1klm-0000Fo-O1 for patch@linaro.org; Mon, 30 Jun 2014 19:13:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1kin-0005cb-1o for qemu-devel@nongnu.org; Mon, 30 Jun 2014 19:10:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1kih-0003GG-Qz for qemu-devel@nongnu.org; Mon, 30 Jun 2014 19:10:48 -0400 Received: from mail-ob0-f172.google.com ([209.85.214.172]:63318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1kih-0003F4-Ai for qemu-devel@nongnu.org; Mon, 30 Jun 2014 19:10:43 -0400 Received: by mail-ob0-f172.google.com with SMTP id uy5so9734289obc.31 for ; Mon, 30 Jun 2014 16:10:43 -0700 (PDT) X-Received: by 10.60.42.162 with SMTP id p2mr46330958oel.27.1404169843055; Mon, 30 Jun 2014 16:10:43 -0700 (PDT) Received: from gbellows-linaro.bellowshome.net (99-179-1-128.lightspeed.austtx.sbcglobal.net. [99.179.1.128]) by mx.google.com with ESMTPSA id cu7sm76370192oec.12.2014.06.30.16.10.41 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Jun 2014 16:10:42 -0700 (PDT) From: greg.bellows@linaro.org To: qemu-devel@nongnu.org Date: Mon, 30 Jun 2014 18:09:10 -0500 Message-Id: <1404169773-20264-11-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1404169773-20264-1-git-send-email-greg.bellows@linaro.org> References: <1404169773-20264-1-git-send-email-greg.bellows@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.214.172 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, Fabian Aggeler , Greg Bellows , serge.fdrv@gmail.com, edgar.iglesias@gmail.com, christoffer.dall@linaro.org Subject: [Qemu-devel] [PATCH v4 10/33] target-arm: extend Aarch64 SCR.{FIQ|IRQ} handling 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: greg.bellows@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.128.173 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: Fabian Aggeler If EL3 is using Aarch64 IRQ/FIQ masking is ignored in all exception levels other than EL3 if SCR.{FIQ|IRQ} is set to 1 (routed to EL3). Signed-off-by: Fabian Aggeler Signed-off-by: Greg Bellows --- target-arm/cpu.h | 98 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 26 deletions(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index fbd7cad..7b2817c 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -1211,20 +1211,43 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx) * (table G1-18/G1-19) */ switch (excp_idx) { case EXCP_FIQ: + if (arm_feature(env, ARM_FEATURE_EL3) && arm_el_is_aa64(env, 3)) { + /* If EL3 is using Aarch64 and FIQs are routed to EL3 masking is + * ignored in all exception levels except EL3. + */ + if ((env->cp15.scr_el3 & SCR_FIQ) && cur_el < 3) { + return true; + } + /* If we are in EL3 but FIQs are not routed to EL3 the exception + * is not taken but remains pending. + */ + if (!(env->cp15.scr_el3 & SCR_FIQ) && cur_el == 3) { + return false; + } + } if (!secure) { - if (arm_feature(env, ARM_FEATURE_EL2) && - (env->cp15.hcr_el2 & HCR_FMO)) { - /* CPSR.F/PSTATE.F ignored if - * - exception is taken from Non-secure state - * - HCR.FMO == 1 - * - either: - not in Hyp mode - * - SCR.FIQ routes exception to monitor mode - */ - if (cur_el < 2) { - return true; - } else if (arm_feature(env, ARM_FEATURE_EL3) && - (env->cp15.scr_el3 & SCR_FIQ)) { - return true; + if (arm_feature(env, ARM_FEATURE_EL2)) { + if (env->cp15.hcr_el2 & HCR_FMO) { + /* CPSR.F/PSTATE.F ignored if + * - exception is taken from Non-secure state + * - HCR.FMO == 1 + * - either: - not in Hyp mode + * - SCR.FIQ routes exception to monitor mode + * (EL3 in Aarch32) + */ + if (cur_el < 2) { + return true; + } else if (arm_feature(env, ARM_FEATURE_EL3) && + (env->cp15.scr_el3 & SCR_FIQ) && + !arm_el_is_aa64(env, 3)) { + return true; + } + } else if (arm_el_is_aa64(env, 3) && + (env->cp15.scr_el3 & SCR_RW) && + cur_el == 2) { + /* FIQs not routed to EL2 but currently in EL2 (A64). + * Exception is not taken but remains pending. */ + return false; } } /* In ARMv7 only applies if both Security Extensions (EL3) and @@ -1252,20 +1275,43 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx) } return !(env->daif & PSTATE_F); case EXCP_IRQ: + if (arm_feature(env, ARM_FEATURE_EL3) && arm_el_is_aa64(env, 3)) { + /* If EL3 is using Aarch64 and IRQs are routed to EL3 masking is + * ignored in all exception levels except EL3. + */ + if ((env->cp15.scr_el3 & SCR_IRQ) && cur_el < 3) { + return true; + } + /* If we are in EL3 but IRQ s are not routed to EL3 the exception + * is not taken but remains pending. + */ + if (!(env->cp15.scr_el3 & SCR_IRQ) && cur_el == 3) { + return false; + } + } if (!secure) { - if (arm_feature(env, ARM_FEATURE_EL2) && - (env->cp15.hcr_el2 & HCR_IMO)) { - /* CPSR.I/PSTATE.I ignored if - * - exception is taken from Non-secure state - * - HCR.IMO == 1 - * - either: - not in Hyp mode - * - SCR.IRQ routes exception to monitor mode - */ - if (cur_el < 2) { - return true; - } else if (arm_feature(env, ARM_FEATURE_EL3) && - (env->cp15.scr_el3 & SCR_IRQ)) { - return true; + if (arm_feature(env, ARM_FEATURE_EL2)) { + if (env->cp15.hcr_el2 & HCR_IMO) { + /* CPSR.I/PSTATE.I ignored if + * - exception is taken from Non-secure state + * - HCR.IMO == 1 + * - either: - not in Hyp mode + * - SCR.IRQ routes exception to monitor mode + * (EL3 in Aarch32) + */ + if (cur_el < 2) { + return true; + } else if (arm_feature(env, ARM_FEATURE_EL3) && + (env->cp15.scr_el3 & SCR_IRQ) && + !arm_el_is_aa64(env, 3)) { + return true; + } + } else if (arm_el_is_aa64(env, 3) && + (env->cp15.scr_el3 & SCR_RW) && + cur_el == 2) { + /* IRQs not routed to EL2 but currently in EL2 (A64). + * Exception is not taken but remains pending. */ + return false; } } }