From patchwork Mon Feb 19 18:58:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13562986 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C62A2C48BC3 for ; Mon, 19 Feb 2024 18:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=E2QTMhLDeDoBz5CZqsJCdDpXmJu5+ZMt/KgRdi19Z+0=; b=wLmtGryQQRNu+5 eqVsmTYUdDQI/756by38V0rDutH6UQTuqKqJyVOCO834SMRdnLzLZAkuYFusuv+RDhOpI/kuL+Sey aCaFij+WqV1N85kPoCEaJaO/UL8B9VYLOlEBz9yFohl/XVdh9o2my9VSmXJkRrqpBeR4LqJc7MzAB /nOV8IiMv8eTOTwk4DuD/7lwbqxO2pNunkUFnHKLuzuKBGL6bzJ2gafMwxSLam12OzY3Gx0TrFkxm iKM+Lw6A/YN1WaBM7zBR0ISPv17fDY4TTt0+gJ+gLkLvMgrmkxdeFyYe7Y8TjDTIXChKQ+yClwWgY 30u+d4o9oTLAj1HG2H3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rc8qc-0000000BoEf-3Urr; Mon, 19 Feb 2024 18:58:38 +0000 Received: from out-170.mta0.migadu.com ([2001:41d0:1004:224b::aa]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rc8qQ-0000000Bo6P-1xNa for linux-arm-kernel@lists.infradead.org; Mon, 19 Feb 2024 18:58:27 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708369103; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=malznfxmTFeYI5AQuBOcx//3J2Klq63IEw4UgO+FW8I=; b=TymjM0U4219Zm3uEd/Lb8NxsD72R3xzRJZRLZBjvd9XHgLBu8YMPWhynBzrl8JRv3paxch lwj9pWCJOssGT/aTbkmYfA4DY/0hoWqJyMUQMa+NXEZkMY7B5s52UXj0Q2QgC1umO8It4y kkbdXBlbN4LMCE9vFrfXl6eQVykFEc8= From: Oliver Upton To: Thomas Gleixner Cc: Marc Zyngier , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, Jing Zhang , Oliver Upton , stable@vger.kernel.org, George Cherian Subject: [PATCH 1/3] irqchip/gic-v3-its: Do not assume vPE tables are preallocated Date: Mon, 19 Feb 2024 18:58:06 +0000 Message-ID: <20240219185809.286724-2-oliver.upton@linux.dev> In-Reply-To: <20240219185809.286724-1-oliver.upton@linux.dev> References: <20240219185809.286724-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240219_105826_678664_95AC988E X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We go through quite a bit of trouble to make sure we pick up any preallocated LPI tables on the redistributors, as enabling LPIs is a one-way switch. There is no such restriction for vLPIs, and for GICv4.1 we expect to allocate a new vPE table at boot. This works as intended when initializing an ITS, however when setting up a redistributor in its_cpu_init_lpis() the early return for preallocated RD tables skips straight past GICv4 setup. This all comes to a head when trying to kexec into a new kernel, as the new kernel silently fails to set up GICv4, leading to a complete loss of SGIs and LPIs for KVM VMs (ouch). Slap a band-aid on the problem by ensuring its_cpu_init_lpis() always initializes GICv4 on the way out, even if the other RD tables were preallocated. Cc: stable@vger.kernel.org Fixes: 6479450f72c1 ("irqchip/gic-v4: Fix occasional VLPI drop") Reported-by: George Cherian Co-developed-by: Marc Zyngier Signed-off-by: Marc Zyngier Signed-off-by: Oliver Upton --- I debated a bit on the fixes tag between the blamed commit and commit 5e5168461c22 ("irqchip/gic-v4.1: VPE table (aka GICR_VPROPBASER) allocation"), although it would appear GICv4 could be left in an unknown state after kexec too. drivers/irqchip/irq-gic-v3-its.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index d097001c1e3e..0022852ce494 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -3172,6 +3172,7 @@ static void its_cpu_init_lpis(void) val |= GICR_CTLR_ENABLE_LPIS; writel_relaxed(val, rbase + GICR_CTLR); +out: if (gic_rdists->has_vlpis && !gic_rdists->has_rvpeid) { void __iomem *vlpi_base = gic_data_rdist_vlpi_base(); @@ -3207,7 +3208,6 @@ static void its_cpu_init_lpis(void) /* Make sure the GIC has seen the above */ dsb(sy); -out: gic_data_rdist()->flags |= RD_LOCAL_LPI_ENABLED; pr_info("GICv3: CPU%d: using %s LPI pending table @%pa\n", smp_processor_id(), From patchwork Mon Feb 19 18:58:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13562985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A76BC48BF8 for ; Mon, 19 Feb 2024 18:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1dIBvgj69ECjwYEODITA8Y2rICEjVyBipaLDgIveGC4=; b=VYvRFhYB5LJid2 HRGhp6KvGt+fggxoSwjeplJrVJqOjkTMkybtmVVH87nxv+BDWcwDFeBX5pdjrNNME12BYkR/oNdfB 2O8tYkJ0QenWKrPOgFXgE4QmP/aGPjWaz2G+P3mMSf5KftWz5G1hJ8lpLncc6fPIFVAbvl9p2WV9x WoL++W+v5kAEUlKf3NlsbMC2lu09m7GZT1aq+a3xBHc+/CsJxHuwWyNkfoFO3nzYnnML9qz//g+h6 Mw6wVynkR323CTNZbbJ+WkFkweaNIMXLM/5HMUfDzlEpf2BsJr9gpjSP0wFs0lJQu1kPZ+OUcgrfm a4vuLTzb01ZgWg3E/qLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rc8qd-0000000BoFB-2qHC; Mon, 19 Feb 2024 18:58:39 +0000 Received: from out-182.mta0.migadu.com ([91.218.175.182]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rc8qS-0000000Bo7b-0eSl for linux-arm-kernel@lists.infradead.org; Mon, 19 Feb 2024 18:58:31 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708369105; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n0uvz70joVA5h7nCkx+6qjmdsOAE7FpYRNnHlS3lny0=; b=MRaf230xQXz2XUHhNl+qaNg7U148naafFkbpIjvX5ofDIryb/ebMbKl5AfD5yIdB2kC01m TSiy2qQWMMmXuqWaBa+9n70/T2Rb0eTsoKGEIAtME5P0eyHqLqsVN+VLPwaNManRBOUCU+ QyOgXYqz7O7W3v3Lo+/zZnKrDywl9lU= From: Oliver Upton To: Thomas Gleixner Cc: Marc Zyngier , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, Jing Zhang , Oliver Upton Subject: [PATCH 2/3] irqchip/gic-v3-its: Spin off GICv4 init into a separate function Date: Mon, 19 Feb 2024 18:58:07 +0000 Message-ID: <20240219185809.286724-3-oliver.upton@linux.dev> In-Reply-To: <20240219185809.286724-1-oliver.upton@linux.dev> References: <20240219185809.286724-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240219_105828_434258_49D9EDB1 X-CRM114-Status: GOOD ( 11.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Burying the GICv4 redistributor initialization into the routine for LPIs is a bit confusing, and can lead to sillies where unexpected codepaths may not fully initialize the RD. Hoist it out of its_cpu_init_lpis() into a dedicated function. Signed-off-by: Oliver Upton --- drivers/irqchip/irq-gic-v3-its.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 0022852ce494..63d1743f08cc 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -3173,8 +3173,25 @@ static void its_cpu_init_lpis(void) writel_relaxed(val, rbase + GICR_CTLR); out: - if (gic_rdists->has_vlpis && !gic_rdists->has_rvpeid) { + /* Make sure the GIC has seen the above */ + dsb(sy); + gic_data_rdist()->flags |= RD_LOCAL_LPI_ENABLED; + pr_info("GICv3: CPU%d: using %s LPI pending table @%pa\n", + smp_processor_id(), + gic_data_rdist()->flags & RD_LOCAL_PENDTABLE_PREALLOCATED ? + "reserved" : "allocated", + &paddr); +} + +static void its_cpu_init_vlpis(void) +{ + /* No vLPIs? No problem. */ + if (!gic_rdists->has_vlpis) + return; + + if (!gic_rdists->has_rvpeid) { void __iomem *vlpi_base = gic_data_rdist_vlpi_base(); + u64 val; /* * It's possible for CPU to receive VLPIs before it is @@ -3193,7 +3210,8 @@ static void its_cpu_init_lpis(void) * ancient programming gets left in and has possibility of * corrupting memory. */ - val = its_clear_vpend_valid(vlpi_base, 0, 0); + its_clear_vpend_valid(vlpi_base, 0, 0); + return; } if (allocate_vpe_l1_table()) { @@ -3205,15 +3223,6 @@ static void its_cpu_init_lpis(void) gic_rdists->has_rvpeid = false; gic_rdists->has_vlpis = false; } - - /* Make sure the GIC has seen the above */ - dsb(sy); - gic_data_rdist()->flags |= RD_LOCAL_LPI_ENABLED; - pr_info("GICv3: CPU%d: using %s LPI pending table @%pa\n", - smp_processor_id(), - gic_data_rdist()->flags & RD_LOCAL_PENDTABLE_PREALLOCATED ? - "reserved" : "allocated", - &paddr); } static void its_cpu_init_collection(struct its_node *its) @@ -5265,6 +5274,7 @@ int its_cpu_init(void) return ret; its_cpu_init_lpis(); + its_cpu_init_vlpis(); its_cpu_init_collections(); } From patchwork Mon Feb 19 18:58:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13562987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD1C9C54764 for ; Mon, 19 Feb 2024 18:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MgaWVBiY/D08Eo8rCScSHO4SLuHNk3NsvLLbMi4v8Lw=; b=z0rYNkOgZ4YpMP RfGf4DfTgmQPNWipdFnv/DzyaaqSfLVjisoMLRR4+bPVvhN1DJ6yz+LG+rThtu+1yOmJCh+SRGeYp n+fOoN9PhgG/6Vjr8LYLqkjuxdq134dVxE1JegN02TpZ/qrR9tm2+7y7gOvHHS9VLtUOVJuhdYyNn v8LUc2gezMoaeKEg10pC+7GkZFGEw+9g7wNRxz0dHbxztFI2Z1LnxUNE8Aux7xgSBnIrBDxgF4Q6P 10z6Lzw7TmThL0WludvC+P2/tQsQv86GaZW77J7BxzjnFlmM50E8WLnVh0HoYJSII5wdMcq4RV8nL +XFFyQhZYN15vvFPzAeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rc8qe-0000000BoGZ-48Fo; Mon, 19 Feb 2024 18:58:40 +0000 Received: from out-181.mta0.migadu.com ([2001:41d0:1004:224b::b5]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rc8qU-0000000Bo8h-02pl for linux-arm-kernel@lists.infradead.org; Mon, 19 Feb 2024 18:58:31 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708369107; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O6mYbl34iGDajSSuwNwYK5N248BsKIXOEJAXAf9uLUE=; b=erdwcROxjTVj9GYsF9NxwZtHNpUShYCx45EDDOMeS+jAJihxWdrPa0U1lhk/4/FnuC7+2g 6JUYy8lf8giYc6dFvutLvzVCiE2tKOwcceN27OylehFuPrm9rlUze2Uoy930paO+8vWiFX OVADPtybepCZRTctZIlkmbbnW0WSTKY= From: Oliver Upton To: Thomas Gleixner Cc: Marc Zyngier , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, Jing Zhang , Oliver Upton Subject: [PATCH 3/3] irqchip/gic-v3-its: Print the vPE table installed in redistributor Date: Mon, 19 Feb 2024 18:58:08 +0000 Message-ID: <20240219185809.286724-4-oliver.upton@linux.dev> In-Reply-To: <20240219185809.286724-1-oliver.upton@linux.dev> References: <20240219185809.286724-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240219_105830_356152_CF03546B X-CRM114-Status: GOOD ( 13.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hindsight is 20/20 of course, but the recent vPE table programming bug could've been root caused a bit more quickly if we print the table getting installed at every redistributor. Promote to pr_info() and add some additional context, such as the provenance of the installed vPE table. Signed-off-by: Oliver Upton --- drivers/irqchip/irq-gic-v3-its.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 63d1743f08cc..c3ef9665a2ad 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -2835,7 +2835,8 @@ static int allocate_vpe_l1_table(void) u64 val, gpsz, npg, pa; unsigned int psz = SZ_64K; unsigned int np, epp, esz; - struct page *page; + struct page *page = NULL; + bool from_its = false; if (!gic_rdists->has_rvpeid) return 0; @@ -2865,8 +2866,10 @@ static int allocate_vpe_l1_table(void) return -ENOMEM; val = inherit_vpe_l1_table_from_its(); - if (val & GICR_VPROPBASER_4_1_VALID) + if (val & GICR_VPROPBASER_4_1_VALID) { + from_its = true; goto out; + } /* First probe the page size */ val = FIELD_PREP(GICR_VPROPBASER_4_1_PAGE_SIZE, GIC_PAGE_SIZE_64K); @@ -2945,9 +2948,12 @@ static int allocate_vpe_l1_table(void) gicr_write_vpropbaser(val, vlpi_base + GICR_VPROPBASER); cpumask_set_cpu(smp_processor_id(), gic_data_rdist()->vpe_table_mask); - pr_debug("CPU%d: VPROPBASER = %llx %*pbl\n", - smp_processor_id(), val, - cpumask_pr_args(gic_data_rdist()->vpe_table_mask)); + pr_info("CPU%d: Using %s vPE table @%llx (%s)\n", + smp_processor_id(), + (val & GICR_VPROPBASER_4_1_INDIRECT) ? "indirect" : "direct", + val & GICR_VPROPBASER_4_1_ADDR, + (page) ? "allocated" : + ((from_its) ? "inherited from ITS" : "inherited from RD")); return 0; }