Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp1498802rdb; Sat, 26 Aug 2023 05:22:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHchwETcVeITMNjXBx/bV8yaXKNLWkFG6FYjTku0riqckB8ayTzqvvPQr4it0bnRCecKcH6 X-Received: by 2002:a05:6512:3dac:b0:500:8249:161a with SMTP id k44-20020a0565123dac00b005008249161amr15694072lfv.19.1693052522101; Sat, 26 Aug 2023 05:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693052522; cv=none; d=google.com; s=arc-20160816; b=VZ7j2TP+tqQrN2PNHwXInPr/yJ7rGZmdlU0XAs6xXxzR3mPofySRoUcWAZKZnVhpnc PxIX1VngGUq3Whsf94FPuWpCNbs7AYskedXtl7SCz0UClP3VC24T1VKgg+QZhPiQXgm8 h4p2Yd8jhoucyyezu53wvyGN8/tHQR9IqIjxcE/IWL0aQmYbnFqmWhdyxiyJwtwWNk7V cDh6OuVgNlFOeebK1sPeMAABAaVQWJAlwC8Mzs8OSjEncXV5U5pze0Q2kWDj3MKrxnUN UMzyRkM3vsN3kfMAiR3K1wnib2zTeQh7KT+yKF3HLj8h6nIGD/kBVd6tnike5rPgl/zg /ScQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=6NQAb0EA9zs3gKJrb80A9QlrJn4UKcoF4EzmZje4yKg=; fh=aavJ2fADzZzBdDUVorNlZPwvZ7Q+hR8KSxdqM7Oc1QM=; b=NokinBBRqv7RqfKTYZDC+1+hECAPQmCYq4kjmCWoss1z5L2viEdUeVIlQdF6403iPc iqnFJTJLm7SwdedBg4f3TakPu5pL2sgRcm6GaAgADwnV2kaNu1h1LYp2JnEkAdSxTlRQ 4HX3CUzLR9PF69YBy4Bror5hFC4dLfAGBkwRhoFw+VmOFcRUfuP70s8rr6++CcwhfoW/ 44UHfawWt/MrTIgyFOwBLs4P72+r50raUQsAqXHrn1uJiQBq6x4OiV46F9FNVLKCgfNH yqKj3tf0lPsf3zzd0F/0YCnEScun3I5l7OfW6lu94chT8NUxHqUMnRK2RRsQr4MiAjrd jXIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="INzayd/C"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p7-20020a056402074700b005234011bb47si2235591edy.679.2023.08.26.05.21.28; Sat, 26 Aug 2023 05:22:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="INzayd/C"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232245AbjHZKhD (ORCPT + 99 others); Sat, 26 Aug 2023 06:37:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232251AbjHZKhA (ORCPT ); Sat, 26 Aug 2023 06:37:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0C951FEC; Sat, 26 Aug 2023 03:36:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 46FB760F1E; Sat, 26 Aug 2023 10:36:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9021CC433C7; Sat, 26 Aug 2023 10:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693046216; bh=x1hOMfWCNnRRZv1VfAf0PBdXlkAf5G9BLURODcZBglk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=INzayd/CTmJb+InHsokVpOULz3x6muV25aBm0mPqEw5jfo+8CgFASIKNwIygd2qRz ASLD4A6FPW2/bVKVqRWz9Tmnq3x/ryEhj7kB5JqwIIljpwsz0XyBaigRicvQ2MUxZ6 9SeIUiYTlUSOqPcXab93ZFCURk9AEjjZFPX74JkMLwEW6HV0sDIcL0L+UsNC0CW+Nd ejD8KU80BIUMYLKxmIZusLkv+rADwxfx8fUZvvHSUgEcd64pNj+32X8SCWfv+DFrbE K6iWQ3Csc4DwvMEQ8c/gLicqpfOPlgawDltamb847SQOFnwV6M/U2XavLzVM7jB+NL xuWH/NY09ITuQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qZqez-008Gjw-Rk; Sat, 26 Aug 2023 11:36:54 +0100 Date: Sat, 26 Aug 2023 11:36:53 +0100 Message-ID: <86bkeuf5tm.wl-maz@kernel.org> From: Marc Zyngier To: Douglas Anderson Cc: Mark Rutland , Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , "Rafael J . Wysocki" , Ard Biesheuvel , Thomas Gleixner , kgdb-bugreport@lists.sourceforge.net, Lecopzer Chen , linux-perf-users@vger.kernel.org, Masayoshi Mizuma , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, ito-yuichi@fujitsu.com, Stephen Boyd , Peter Zijlstra , linux-kernel@vger.kernel.org Subject: Re: [PATCH v11 1/6] irqchip/gic-v3: Enable support for SGIs to act as NMIs In-Reply-To: <20230824083012.v11.1.I1223c11c88937bd0cbd9b086d4ef216985797302@changeid> References: <20230824153233.1006420-1-dianders@chromium.org> <20230824083012.v11.1.I1223c11c88937bd0cbd9b086d4ef216985797302@changeid> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: dianders@chromium.org, mark.rutland@arm.com, catalin.marinas@arm.com, will@kernel.org, sumit.garg@linaro.org, daniel.thompson@linaro.org, rafael.j.wysocki@intel.com, ardb@kernel.org, tglx@linutronix.de, kgdb-bugreport@lists.sourceforge.net, lecopzer.chen@mediatek.com, linux-perf-users@vger.kernel.org, msys.mizuma@gmail.com, wens@csie.org, linux-arm-kernel@lists.infradead.org, ito-yuichi@fujitsu.com, swboyd@chromium.org, peterz@infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 24 Aug 2023 16:30:27 +0100, Douglas Anderson wrote: > > As of commit 6abbd6988971 ("irqchip/gic, gic-v3: Make SGIs use > handle_percpu_devid_irq()") SGIs are treated the same as PPIs/EPPIs > and use handle_percpu_devid_irq() by default. Unfortunately, > handle_percpu_devid_irq() isn't NMI safe, and so to run in an NMI > context those should use handle_percpu_devid_fasteoi_nmi(). > > In order to accomplish this, we just have to make room for SGIs in the > array of refcounts that keeps track of which interrupts are set as > NMI. We also rename the array and create a new indexing scheme that > accounts for SGIs. > > Also, enable NMI support prior to gic_smp_init() as allocation of SGIs > as IRQs/NMIs happen as part of this routine. > > Co-developed-by: Sumit Garg > Signed-off-by: Sumit Garg > Signed-off-by: Douglas Anderson > --- > In v10 I removed the previous Reviewed-by and Tested-by tags since the > patch contents changed pretty drastically. > > I'll also note that this change is a little more black magic to me > than others in this series. I don't have a massive amounts of > familiarity with all the moving parts of gic-v3, so I mostly just > followed Mark Rutland's advice [1]. Please pay extra attention to make > sure I didn't do anything too terrible. > > Mark's advice wasn't a full patch and I ended up doing a bit of work > to translate it to reality, so I did not add him as "Co-developed-by" > here. Mark: if you would like this tag then please provide it and your > Signed-off-by. I certainly won't object. > > [1] https://lore.kernel.org/r/ZNC-YRQopO0PaIIo@FVFF77S0Q05N.cambridge.arm.com > > (no changes since v10) > > Changes in v10: > - Rewrite as needed for 5.11+ as per Mark Rutland and Sumit. > > drivers/irqchip/irq-gic-v3.c | 54 ++++++++++++++++++++++++------------ > 1 file changed, 36 insertions(+), 18 deletions(-) > > diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c > index eedfa8e9f077..49d18cf3f636 100644 > --- a/drivers/irqchip/irq-gic-v3.c > +++ b/drivers/irqchip/irq-gic-v3.c > @@ -78,6 +78,8 @@ static DEFINE_STATIC_KEY_TRUE(supports_deactivate_key); > #define GIC_LINE_NR min(GICD_TYPER_SPIS(gic_data.rdists.gicd_typer), 1020U) > #define GIC_ESPI_NR GICD_TYPER_ESPIS(gic_data.rdists.gicd_typer) > > +#define SGI_NR 16 Why 16? We only allocate 8, as the other 8 are potentially stolen by the secure side. We do try and initialise them all so that they have a known state if they were actually configured as Group-1NS, but we don't use them. I understand that this simplifies the indexing in the rdist_nmi_refs array and I'm not going to cry over 32 wasted bytes, but this definitely deserves a comment. M. -- Without deviation from the norm, progress is not possible.