Received: by 10.213.65.68 with SMTP id h4csp481482imn; Tue, 13 Mar 2018 10:24:31 -0700 (PDT) X-Google-Smtp-Source: AG47ELu9sYzOngYyn50lJe397xE7FIu//vt+SXOakqaCi2uqmYUm034v9XDTVAa4e9TAl/rmQid+ X-Received: by 10.101.88.197 with SMTP id e5mr1105730pgu.437.1520961871456; Tue, 13 Mar 2018 10:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520961871; cv=none; d=google.com; s=arc-20160816; b=Fmrd43N4Tg9YO4/gWmjsBa9nvsTcqnbWxx86wisdtr9Eu9YhuZgJGV6kmbRk1/2D3g G3GdwBnRGfshFIJHpu5g3/LLfXc/JxTzwvy1HPr91c4HYygQESv30kwjNsbulcJ1WCha ZWV53/8RxqTTedgJax5P2YZBMa3yPRfAvMiGTX7JS4zXe33BcEf/9Zwz4jisHIkmmJBf jMY/CjeSWbBdAFf3dtQPluNln6m6jj/gyzKfscnlgtN8FQuHnHxzHY99f7HY4hJRgCOb w596BiLFMpr/v58X3Fr2V+1lZE5trWkr4gw2CxwlteSAv1AhlC+OciHglW98w0K4nm8u 0crw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Vx5KxEtNPze9ARkYaXZJ/vn869LlqchObov5TyPujME=; b=e3uCCrWL3Otagt0ZPMZgMRc5DBSecjEcQfmIyPg1NEN/3wu3+6dIEH4sSjdAKL7Zdv DPi2/WSy+ZxXTNZx/ROcjR3WwAlcIqBFIlE0jPsLTNUMQI3PUhGNsCUmUsVSdGvFb1cv 4gRpFPNmwPxudoSyd36jpWZyhMiozDs0RTlkdh738LGQPGofKaB9t8tZQrMsWFq8Kolr i7X1Kz88/s8jixJbK8aFr7PmEgc0eHlklz/QY+Y7U/Ti3H46EzWZ5/rJecPZxUeE874t fxxljS1aAHAjZNZFmmj9tkmyVAuDn2I4Wvjh4Ns+RHysE69mZMIJUbk/I5WaunDT5p3p +cuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p6si397086pgc.456.2018.03.13.10.24.17; Tue, 13 Mar 2018 10:24:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932568AbeCMRVm (ORCPT + 99 others); Tue, 13 Mar 2018 13:21:42 -0400 Received: from foss.arm.com ([217.140.101.70]:42006 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932474AbeCMRVQ (ORCPT ); Tue, 13 Mar 2018 13:21:16 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 749611650; Tue, 13 Mar 2018 10:21:16 -0700 (PDT) Received: from approximate.cambridge.arm.com (approximate.cambridge.arm.com [10.1.207.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 42B063F487; Tue, 13 Mar 2018 10:21:15 -0700 (PDT) From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Jason Cooper , Thomas Gleixner , Grzegorz Jaszczyk , Mark Rutland Subject: [PATCH 2/3] irqchip/gic-v3: Reset APgRn registers at boot time Date: Tue, 13 Mar 2018 17:21:02 +0000 Message-Id: <20180313172103.24281-3-marc.zyngier@arm.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180313172103.24281-1-marc.zyngier@arm.com> References: <20180313172103.24281-1-marc.zyngier@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Booting a crash kernel while in an interrupt handler is likely to leave the Active Priority Registers with some state that is not relevant to the new kernel, and is likely to lead to erratic behaviours such as interrupts not firing as their priority is already active. As a sanity measure, wipe the APRs clean on startup. We make sure to wipe both group 0 and 1 registers in order to avoid any surprise. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/arch_gicv3.h | 41 +++++++++++++++++++++++++++++---------- drivers/irqchip/irq-gic-v3.c | 23 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/arch/arm/include/asm/arch_gicv3.h b/arch/arm/include/asm/arch_gicv3.h index 1070044f5c3f..27288bdbd840 100644 --- a/arch/arm/include/asm/arch_gicv3.h +++ b/arch/arm/include/asm/arch_gicv3.h @@ -35,6 +35,18 @@ #define ICC_IGRPEN1 __ACCESS_CP15(c12, 0, c12, 7) #define ICC_BPR1 __ACCESS_CP15(c12, 0, c12, 3) +#define __ICC_AP0Rx(x) __ACCESS_CP15(c12, 0, c8, 4 | x) +#define ICC_AP0R0 __ICC_AP0Rx(0) +#define ICC_AP0R1 __ICC_AP0Rx(1) +#define ICC_AP0R2 __ICC_AP0Rx(2) +#define ICC_AP0R3 __ICC_AP0Rx(3) + +#define __ICC_AP1Rx(x) __ACCESS_CP15(c12, 0, c9, x) +#define ICC_AP1R0 __ICC_AP1Rx(0) +#define ICC_AP1R1 __ICC_AP1Rx(1) +#define ICC_AP1R2 __ICC_AP1Rx(2) +#define ICC_AP1R3 __ICC_AP1Rx(3) + #define ICC_HSRE __ACCESS_CP15(c12, 4, c9, 5) #define ICH_VSEIR __ACCESS_CP15(c12, 4, c9, 4) @@ -86,17 +98,17 @@ #define ICH_LRC14 __LRC8(6) #define ICH_LRC15 __LRC8(7) -#define __AP0Rx(x) __ACCESS_CP15(c12, 4, c8, x) -#define ICH_AP0R0 __AP0Rx(0) -#define ICH_AP0R1 __AP0Rx(1) -#define ICH_AP0R2 __AP0Rx(2) -#define ICH_AP0R3 __AP0Rx(3) +#define __ICH_AP0Rx(x) __ACCESS_CP15(c12, 4, c8, x) +#define ICH_AP0R0 __ICH_AP0Rx(0) +#define ICH_AP0R1 __ICH_AP0Rx(1) +#define ICH_AP0R2 __ICH_AP0Rx(2) +#define ICH_AP0R3 __ICH_AP0Rx(3) -#define __AP1Rx(x) __ACCESS_CP15(c12, 4, c9, x) -#define ICH_AP1R0 __AP1Rx(0) -#define ICH_AP1R1 __AP1Rx(1) -#define ICH_AP1R2 __AP1Rx(2) -#define ICH_AP1R3 __AP1Rx(3) +#define __ICH_AP1Rx(x) __ACCESS_CP15(c12, 4, c9, x) +#define ICH_AP1R0 __ICH_AP1Rx(0) +#define ICH_AP1R1 __ICH_AP1Rx(1) +#define ICH_AP1R2 __ICH_AP1Rx(2) +#define ICH_AP1R3 __ICH_AP1Rx(3) /* A32-to-A64 mappings used by VGIC save/restore */ @@ -125,6 +137,15 @@ static inline u64 read_ ## a64(void) \ return val; \ } +CPUIF_MAP(ICC_AP0R0, ICC_AP0R0_EL1) +CPUIF_MAP(ICC_AP0R1, ICC_AP0R1_EL1) +CPUIF_MAP(ICC_AP0R2, ICC_AP0R2_EL1) +CPUIF_MAP(ICC_AP0R3, ICC_AP0R3_EL1) +CPUIF_MAP(ICC_AP1R0, ICC_AP1R0_EL1) +CPUIF_MAP(ICC_AP1R1, ICC_AP1R1_EL1) +CPUIF_MAP(ICC_AP1R2, ICC_AP1R2_EL1) +CPUIF_MAP(ICC_AP1R3, ICC_AP1R3_EL1) + CPUIF_MAP(ICH_HCR, ICH_HCR_EL2) CPUIF_MAP(ICH_VTR, ICH_VTR_EL2) CPUIF_MAP(ICH_MISR, ICH_MISR_EL2) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index d99cc07903ec..0ea02504115d 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -532,6 +532,7 @@ static void gic_cpu_sys_reg_init(void) int i, cpu = smp_processor_id(); u64 mpidr = cpu_logical_map(cpu); u64 need_rss = MPIDR_RS(mpidr); + u32 val; /* * Need to check that the SRE bit has actually been set. If @@ -562,6 +563,28 @@ static void gic_cpu_sys_reg_init(void) gic_write_ctlr(ICC_CTLR_EL1_EOImode_drop_dir); } + val = gic_read_ctlr(); + val &= ICC_CTLR_EL1_PRI_BITS_MASK; + val >>= ICC_CTLR_EL1_PRI_BITS_SHIFT; + + switch(val + 1) { + case 8: + case 7: + write_gicreg(0, ICC_AP0R3_EL1); + write_gicreg(0, ICC_AP1R3_EL1); + write_gicreg(0, ICC_AP0R2_EL1); + write_gicreg(0, ICC_AP1R2_EL1); + case 6: + write_gicreg(0, ICC_AP0R1_EL1); + write_gicreg(0, ICC_AP1R1_EL1); + case 5: + case 4: + write_gicreg(0, ICC_AP0R0_EL1); + write_gicreg(0, ICC_AP1R0_EL1); + } + + isb(); + /* ... and let's hit the road... */ gic_write_grpen1(1); -- 2.14.2