From mboxrd@z Thu Jan 1 00:00:00 1970 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 5E953ECE564 for ; Tue, 10 Sep 2024 07:51:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Qkm6FPfUEARj4yKYsyayzkMOFVWinsRye9/I3nZ8Wbo=; b=MOZXLDJtxK6HFfovfQ91KAvgr4 zrlyrEkNDcqxC5imip6kt/6g2Nr3GL+W/4jKl0g9yizr5Hw8f0qRmRMz0kWGQdtI4E9OCr6tbpDr0 hKV9UElDMydz7gWR8u5W8KCzxo6XBCUUAP3lRLpfNChr0afwYNcpjAZ0DdQPnE3ZDohEABiLLmpSd 2q+y4avzB9pqRQNhBbmIFOzrw6ECc1W3azp8xw8eDJMnREng2Bz7jmQgatRa9uxCSj7RiVdBH1Um9 zHZBJlIKoAidFCDQ+nEvrZcKQijSdC5ryGTR2SVsaNT9hLnRfZwScAlJRmdmMDb2OvU7ytMKI2qhW SbB8IPJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1snvf0-00000004g3u-0oI1; Tue, 10 Sep 2024 07:51:38 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1snvdy-00000004fz5-3sOj for linux-arm-kernel@lists.infradead.org; Tue, 10 Sep 2024 07:50:36 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9C0245C0525; Tue, 10 Sep 2024 07:50:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D80F3C4CEC6; Tue, 10 Sep 2024 07:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725954633; bh=vswE4xEmJQOfA6+wzXWKCkfpVFKdHaZzmFjzfjPBSrM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=iNM2M95TL/Sk6Qzjc5rDyQk6v/WTCQWeHB89NpvjAnD21uEyIwBiycKtIYkOx6gbY AWEZzrr3yqUBJXCVYA/jdVJcEu02SpMaYYgvZku8jIBaTcNDKIm/45SjlwFMblB+RP qQ7FoLiJYkpQoSCIkp1+H0JvBab/sYW2Jb/mceh79EBAUkoA8QJYQuM7aJYmPJ92Fa R9840lZ5yjie/4gT1lYpK50dMEqjU1Y9jOtNnwZR/yQ2Xeqgr5EuRB6q5Uh/KE4hNH o7qFoC/Zb6FLQAOX/C3KCUz2arCN9/p0I6jWiplZNhnJDPhBiAbxwBTdbt/2XvUzLa Eb61E0bN8gIEA== 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 1snvdv-00BeUN-T9; Tue, 10 Sep 2024 08:50:32 +0100 Date: Tue, 10 Sep 2024 08:50:30 +0100 Message-ID: <86y1406j7d.wl-maz@kernel.org> From: Marc Zyngier To: Sergey Shtylyov Cc: Thomas Gleixner , , Subject: Re: [PATCH] irqchip/gic: prevent buffer overflow in gic_ipi_send_mask() In-Reply-To: References: <048ff3bb-09d1-2e60-4f3b-611e2bfde7aa@omp.ru> <87cyli5zj7.ffs@tglx> 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/29.4 (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: s.shtylyov@omp.ru, tglx@linutronix.de, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240910_005035_119454_AE9B57B3 X-CRM114-Status: GOOD ( 23.49 ) 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 On Mon, 09 Sep 2024 20:23:21 +0100, Sergey Shtylyov wrote: > > On 9/5/24 10:29 AM, Thomas Gleixner wrote: > [...] > > >> ARM GIC arch v2 spec claims support for just 8 CPU interfaces. However, > >> looking at the GIC driver's irq_set_affinity() method, it seems that the > >> passed CPU mask may contain the logical CPU #s beyond 8, and that method > > s/8/7/, of course... :-< > > >> filters them out before reading gic_cpu_map[], bailing out with > >> -EINVAL. > > > > The reasoning is correct in theory, but in reality it's a non problem. > > Frankly, before finalizing this patch I had tried to ascertain whether > cpumask could contain CPUs with the logical #s higher than 8 but that was > taking way too much time and I gave up... :-) You can't really work it out form the source code. The trick is that the integration requirements prevent you from doing so. It is as simple as that. People have built GICv2-like interrupt controllers with more than 8 CPUs, but it is a different beast (see the hip04 driver for a good laugh). Another possible hack is to have 2 GICs side by side, and connect up to 8 CPUs to each. But then you cannot IPI one cluster from another, and you end-up with the hilarious situation that plagued the Axxia SoC, which Linux never really supported, because this is utter nonsense. > > > Simply because processors which use this GIC version cannot have more > > than 8 cores. > > And big.LITTLE not involved? In what sense? Asymmetric configurations don't impact the number of CPU interfaces that can be connected to a single GIC. > > > That means num_possible_cpus() <= 8 so the cpumask handed in cannot have > > bits >= 8 set. Ergo for_each_cpu() can't return a bit which is >= 8. > > Perhaps adding WARN_ON() would make some sense though? :-) But why? If someone builds something that cannot work, they have bigger problems than an extra bit in a bitmap, and the kernel is not a validation suite for idiotic integration (though I wonder at times). M. -- Without deviation from the norm, progress is not possible.