From patchwork Mon Aug 18 09:40:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 380940 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 283F81401B1 for ; Mon, 18 Aug 2014 19:51:34 +1000 (EST) Received: from localhost ([::1]:42702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJJbA-0002hR-C8 for incoming@patchwork.ozlabs.org; Mon, 18 Aug 2014 05:51:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJJZZ-0000LP-0g for qemu-devel@nongnu.org; Mon, 18 Aug 2014 05:49:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJJZU-0007tN-7b for qemu-devel@nongnu.org; Mon, 18 Aug 2014 05:49:52 -0400 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]:34610) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJJZU-0007tI-0o for qemu-devel@nongnu.org; Mon, 18 Aug 2014 05:49:48 -0400 Received: by mail-pa0-f46.google.com with SMTP id lj1so7443884pab.33 for ; Mon, 18 Aug 2014 02:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KDRIfQBr0KLeod9IqNIy24uv/xtzdEg+sLJ2q9iv1/U=; b=0dUZnO2mzhreOMemIvMy+PMCAK2QNdw7S17mKx7QqPPAcoo9DvHwPKHrcjLNRZevS3 GZCRqIaQB7B9BwetSTco4hTJS3kDeJlf9omq7Ia06FLRomRrILDWITTGPnNn7q2mdVt+ oufWrM3AoBykAwR1MOVV5El2Nts5wvPddULu1zIlCmhKlNL1cOwAlcaBPJHf7coAaho7 +iSvN5hiSR2Y/aRXe3tBi4d06QpS357dvVq8UbOFT+ayyxVI7NfmmukpAdxTAeKc1Wix fkJFTLDI8dVYowlevgfk1irkHRyjC4m6SHfklomSyk0hNBQWxVilc1aDFVa9cPpaW0SA 2PZA== X-Received: by 10.67.6.8 with SMTP id cq8mr34483311pad.66.1408355383756; Mon, 18 Aug 2014 02:49:43 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id a17sm15690048pbu.41.2014.08.18.02.49.37 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 18 Aug 2014 02:49:43 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Mon, 18 Aug 2014 19:40:29 +1000 Message-Id: <1408354830-1143-10-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408354830-1143-1-git-send-email-edgar.iglesias@gmail.com> References: <1408354830-1143-1-git-send-email-edgar.iglesias@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::22e Cc: rob.herring@linaro.org, peter.crosthwaite@xilinx.com, aggelerf@ethz.ch, agraf@suse.de, blauwirbel@gmail.com, greg.bellows@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org, christoffer.dall@linaro.org, rth@twiddle.net Subject: [Qemu-devel] [PATCH v5 09/10] target-arm: Add IRQ and FIQ routing to EL2 and 3 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Edgar E. Iglesias" Reviewed-by: Greg Bellows Signed-off-by: Edgar E. Iglesias --- target-arm/cpu.h | 12 ++++++++++++ target-arm/helper.c | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 683fd44..8ad23fa 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -1153,6 +1153,12 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx) CPUARMState *env = cs->env_ptr; unsigned int cur_el = arm_current_pl(env); unsigned int target_el = arm_excp_target_el(cs, excp_idx); + /* FIXME: Use actual secure state. */ + bool secure = false; + /* Interrupts can only be hypervised and routed to + * EL2 if we are in NS EL0/1. + */ + bool irq_can_hyp = !secure && cur_el < 2 && target_el == 2; /* Don't take exceptions if they target a lower EL. */ if (cur_el > target_el) { @@ -1161,8 +1167,14 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx) switch (excp_idx) { case EXCP_FIQ: + if (irq_can_hyp && (env->cp15.hcr_el2 & HCR_FMO)) { + return true; + } return !(env->daif & PSTATE_F); case EXCP_IRQ: + if (irq_can_hyp && (env->cp15.hcr_el2 & HCR_IMO)) { + return true; + } return ((IS_M(env) && env->regs[15] < 0xfffffff0) || !(env->daif & PSTATE_I)); default: diff --git a/target-arm/helper.c b/target-arm/helper.c index a2205d1..976fd89 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -3339,6 +3339,20 @@ unsigned int arm_excp_target_el(CPUState *cs, unsigned int excp_idx) target_el = 2; } break; + case EXCP_FIQ: + case EXCP_IRQ: + { + const uint64_t hcr_mask = excp_idx == EXCP_FIQ ? HCR_FMO : HCR_IMO; + const uint32_t scr_mask = excp_idx == EXCP_FIQ ? SCR_FIQ : SCR_IRQ; + + if (!secure && (env->cp15.hcr_el2 & hcr_mask)) { + target_el = 2; + } + if (env->cp15.scr_el3 & scr_mask) { + target_el = 3; + } + break; + } } return target_el; }