From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72D8E3CE4A5 for ; Tue, 14 Apr 2026 10:14:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776161667; cv=none; b=cL/ZlxKsByPCsvmgHLzhzwuVdO6ljXbXGutEJ58nbds/dURvHCWSVHqMH88YpfQtw+5PDPNa2qikE3mQF7V7bijR091ggeA1eHi2t6RSvhhpS1n2i0TrEjMhB2+w2q0svjaIUQqqHT9GQ2OUz9L/JJ3EDC8YE7mlRajcW3X7nrY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776161667; c=relaxed/simple; bh=VK3VFt4WRbprUF4XsRp2yxgJepPW6ly2Twk9W9fx6M8=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=id8ROgMd8ZEWwyQTI0lDotHMoKFZSjmRIH+M4ImydkOEDS9g7GC2VDbZ49fe5RxeMrVE0+EGtsuNJ4CtFRto28VhZcu9HzOeNEj09cs+7NmxxSO947rG+NDpcOyUAR4TrIccVzKjbKPR8Bg89IAyp9Ni5vNd8FQKKMrOh10h5NY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kDk481J4; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kDk481J4" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-43cfd96354aso3129007f8f.1 for ; Tue, 14 Apr 2026 03:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776161662; x=1776766462; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=NfhtP/TymotrhPrcOVkiPER8szRMYGC9sOoOX92Yt+I=; b=kDk481J4Lo5rYnqEfbURSqNbCI+uMRSZQF2IiryhRNBNL4PJy027TfRUo6SW7i5YbE mdMAqHlYgtHK5j3DeCrAqO1tZtlJGChB8HBN6whfDnFJ/9TNgUlSi8EUfO0i2WmTu/rN IIh0MtgzVHqZ4FpRRXN02p/QuTPqi+O15qE8POmLtDTCntiydpX6k1/01qRUzR7z4/r6 WfPKiye2jCsZ5oH/ZsuY5Ay1X5oK7IQSeYLxGntOyEyO4XivuHbfSJb0hjKet9tEE8Gq t7gRcyFkMszRGo47sPqhxBuPA96TkOgYmLH488lGyGfB8olMz6C95nk10eQMYfJAEJGI qP3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776161662; x=1776766462; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=NfhtP/TymotrhPrcOVkiPER8szRMYGC9sOoOX92Yt+I=; b=qYQ8tcZg1HJ1OS2GYRemMmsl1lQP9nQNJgpYGY2ZsRHUW8xblcKxQV+pT9EzVeIBUi hVbdsxl95iM9HNuKLnzyuTuKxVDO/SvpTZmjb95O1lUKn6k+WTIiHqWRQZfzxLN/hMcg oCZ8I/fwL4Zf90u+zYARKHizzSW01oPPLqgR6ScB5gPizHQyC9gK6rKBGkK0Ikn8lpzr MqEGb1veiTDb45mJFIsWG53hk/7Q/4AXMRr/Hu+mj5dpe1pE/it6JlwCTwIg/XwZFgHu 6yTu2ZijFj9NhDlEgr+wK2aWSQbksBEKoDeLiF3t5ESAnZhzPuqvotd5MasqE52wXd7f S7xA== X-Forwarded-Encrypted: i=1; AFNElJ8nvCkbQLMExEGAygHft/aks5wWkt1PaFVSycSKroWUX0c8CiCN9OFt59Zyd627FsEsiMhV4UPGNLGhuPc=@vger.kernel.org X-Gm-Message-State: AOJu0YyVZZ6WPzpmraqVusmDbhu3T41o4FMHuWIzde7d/9yYlaUEufBn wDvCUgEL083vWSb6g+gedkFKgaRlTGzT8NhVWf4hVSO5i5OpB180jBAU X-Gm-Gg: AeBDiesbfDnTFbh1Mgxi24J8PR6AFD65NwsyPJTgmH4KS2D0h6xNoClk19e5o/CBxQk TqngHxbu5ubftC+IFaM3JnZ7L56IYpw/aS1E+pjFyAPO7HFvg/NJCBHHGdVke6xZRDlU1hzj7+y f8i7id/fOikuqHjUVbOqcQ+qJkqH+bLOWXr4ycqkOf9HskKGwK8fuzZw0sUfqZn5jhpspRsqxwu OeETohQSfxDb1d0EfhANjr+GINE6xqKdVD1ijUIOBMFIfke/Ddugms2YvLg4zf4/p+8a3XPWr8+ 5l4AGaKxhaI4OPvlUKNdmZjwdiNe/esgwoctG0tlPwoHASrTp0NIn/ZVFqKt2GOWYlsD6UwXYC3 lSxbOdgM6LGGnzYPSrzl8o1XDNgSouTMXpA5Kc6/CRG1RgEIwuyRFaTz/qR1UGj82HEHHJJjdKn qrCU5lUq2UfSQhBmbXFeeP3lWFux7DNfmHMdNrSw1UzwJD+GK2xblZPZ8uXA== X-Received: by 2002:a05:6000:4387:b0:43d:7508:c9c1 with SMTP id ffacd0b85a97d-43d7508cd32mr14134342f8f.50.1776161662283; Tue, 14 Apr 2026 03:14:22 -0700 (PDT) Received: from osama ([2a02:908:1b6:8980:1aaa:ede0:d93f:dcaa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43ea764eff2sm2779121f8f.27.2026.04.14.03.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2026 03:14:21 -0700 (PDT) Date: Tue, 14 Apr 2026 12:14:19 +0200 From: Osama Abdelkader To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Ryo Takakura , Breno Leitao , Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] arm64: panic from init_IRQ if IRQ handler stacks cannot be allocated Message-ID: References: <20260326225755.50297-1-osama.abdelkader@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260326225755.50297-1-osama.abdelkader@gmail.com> On Thu, Mar 26, 2026 at 11:57:52PM +0100, Osama Abdelkader wrote: > init_irq_stacks() and init_irq_scs() may fail when arch_alloc_vmap_stack > or scs_alloc return NULL. Return -ENOMEM from both and call panic() once > from init_IRQ(), covering per-CPU IRQ stacks and shadow IRQ stacks > consistently. > > Signed-off-by: Osama Abdelkader > --- > v2: > - Add return -ENOMEM from both init_irq_stacks() and init_irq_scs() > - Call panic() once from init_IRQ() if either init_irq_stacks() or > init_irq_scs() returns -ENOMEM > --- > arch/arm64/kernel/irq.c | 29 ++++++++++++++++++++--------- > 1 file changed, 20 insertions(+), 9 deletions(-) > > diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c > index 15dedb385b9e..9fafd826002b 100644 > --- a/arch/arm64/kernel/irq.c > +++ b/arch/arm64/kernel/irq.c > @@ -10,6 +10,7 @@ > * Copyright (C) 2012 ARM Ltd. > */ > > +#include > #include > #include > #include > @@ -32,34 +33,43 @@ DEFINE_PER_CPU(struct nmi_ctx, nmi_contexts); > > DEFINE_PER_CPU(unsigned long *, irq_stack_ptr); > > - > DECLARE_PER_CPU(unsigned long *, irq_shadow_call_stack_ptr); > > #ifdef CONFIG_SHADOW_CALL_STACK > DEFINE_PER_CPU(unsigned long *, irq_shadow_call_stack_ptr); > #endif > > -static void init_irq_scs(void) > +static int __init init_irq_scs(void) > { > int cpu; > + void *s; > > if (!scs_is_enabled()) > - return; > + return 0; > + > + for_each_possible_cpu(cpu) { > + s = scs_alloc(early_cpu_to_node(cpu)); > + if (!s) > + return -ENOMEM; > + per_cpu(irq_shadow_call_stack_ptr, cpu) = s; > + } > > - for_each_possible_cpu(cpu) > - per_cpu(irq_shadow_call_stack_ptr, cpu) = > - scs_alloc(early_cpu_to_node(cpu)); > + return 0; > } > > -static void __init init_irq_stacks(void) > +static int __init init_irq_stacks(void) > { > int cpu; > unsigned long *p; > > for_each_possible_cpu(cpu) { > p = arch_alloc_vmap_stack(IRQ_STACK_SIZE, early_cpu_to_node(cpu)); > + if (!p) > + return -ENOMEM; > per_cpu(irq_stack_ptr, cpu) = p; > } > + > + return 0; > } > > #ifdef CONFIG_SOFTIRQ_ON_OWN_STACK > @@ -109,8 +119,9 @@ int __init set_handle_fiq(void (*handle_fiq)(struct pt_regs *)) > > void __init init_IRQ(void) > { > - init_irq_stacks(); > - init_irq_scs(); > + if (init_irq_stacks() || init_irq_scs()) > + panic("Failed to allocate IRQ stack resources\n"); > + > irqchip_init(); > > if (system_uses_irq_prio_masking()) { > -- > 2.43.0 > Hi All, Can you please review? Best regards, Osama