From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 365C0289E06 for ; Thu, 26 Mar 2026 23:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774566151; cv=none; b=GM59412xdsVhPfnomR0o2jJv73l+8h1g91ZLkwFmSVFz7HQ0YLtM01FyFaYhVcug0A1I075/fVXaH8rxC2l6xE536IZ/lQod5+zHp/BTNjh40ln2mP9pKNBaRAiZUWSJ8P4dt4m93qR4/mxBFpuppqYpMxgxEbTylD48xHzsIL8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774566151; c=relaxed/simple; bh=81LPm++Pk5XlNwE3+/SLNDKzE7tus+vysQPTnb3navA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cFrLcWL6dtDZHKQ4do1WfKucNdojRFLh1UpcVEfxrOj9l93hL6td21abjlwoRyTb5CRKJMCJfCi8yDs2l8s+tucWGbbSm5t8fJJKMSSLdInw1qk5Q89oKZWaVNWEb0yGq+DLvNyhoTZ6KhlmFuJuiSymfPvlo2jjGTGptg+MCmw= 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=E/ZCfUiI; arc=none smtp.client-ip=209.85.128.54 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="E/ZCfUiI" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-486507134e4so17775025e9.0 for ; Thu, 26 Mar 2026 16:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774566138; x=1775170938; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=/jv9aN6G6rns4dN5LD+yA48hndk4jnLP3GApNEZEmMg=; b=E/ZCfUiIG70LwiA1Ddzp3gLJqbs+/0uJh/ecWHjQftnMU/YdEp4ih1biWGIXu1esqM ypBHTPAHO9pf3wogvF7ovpHr6FdcDI992nKeqJpDxSmWgmP2a7130fZ1bv1fIgcSH/V4 FIndKcz7WnHfHLB4m8O1/UFjN4+xZ6vOZAFlIzHNfuIRYixrk12FCExghAofPudPDRsW NKa6TrKQV96FycAYf+WxvZvdJBCFKtmGK9nA7pHjHHBerdwrQwaFItc6oqFUb8ZfkEc5 S+TEOie0K32Yq2tiZdPNDmWCIRTKEGyapzOzNL5xuoUemd3QbJapy+psEbuY9usV5YIr vKSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774566138; x=1775170938; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/jv9aN6G6rns4dN5LD+yA48hndk4jnLP3GApNEZEmMg=; b=gRov6VXJqJQqJlelcmhvuHD66vaMQft1HziChsc7dTzbbdKNllnpAGjKlxbgwIywT8 xEeAD5lWChDYGT4W8IVWdnYYrO4BDagt/6ipbFTrf0jSnDDHSUbmxNaGCNxmUMarf9j8 oVP381HrxSli73fQQMek+RbL34eEwAoyuzQ0KRDfrMJ0mNszBtFym3spWeAgf75XmWjr 0Aa9AjFHZcpLqfRjKFabb5lqmM4IPkAJZGW2c7FLdn7ftumRe7JvkucFmQHwlopAcbrY Bz30EY9sv4+XRiD32dMXVJHNfrJXZQzlFDEZPoTDnJKQhTHQwkyJeEt+ahLkUcfdFcUJ aNzQ== X-Forwarded-Encrypted: i=1; AJvYcCWAJtiCAsIrTErXvv/2oJAK/XBs3vZUsjfIBGOhss7tqmJemxZcLHek5P74mOwYCJ6SV6oArmf2lvBTTUY=@vger.kernel.org X-Gm-Message-State: AOJu0Yyso83PHXUMm+4HAL9+H3qgs88qwje7Cuie2n6zTENSfDT3Fk/o Pksz/VeriTOlVtpT0gKZUMg0bjkirJohjnXhxPGKHTKhx9W9XDP8jxavjcU5TQ== X-Gm-Gg: ATEYQzwxPme8DUBQFwupSzvS2fUXF2F9tfoZC2LQJrwgy9FWNOR3twNUMMXNsPg5voe dnPWZYB/l84sZ14Od+CVhK12JjqL4MBCt/lwxraDj42K9RWXxj7hadgWzq4+V/u5/b6w2BNpSMb Bk65wR6BZtDQya1u8sXfVpk0kLZwNnOUv9eTezkvHZc7wJBEUtVe8O5Qop6h4zzx9AZyfPe2Swu M2tLhu4bus79Fs8lKNxLO975n1RpzFXJUtkZ3+WxVSBA9k959oPBm7DbXuozXk3NV1cwmGBdsKG ycMAQsqWqRzExUlpY0SAxmToDFr4pnATvqyea0BYBbLw58tCNqFmy1VpApmsALipm0D6Src582O K7hZtb7WVa62S3duzqUyN5LK7l0XHQo4yUoPdrp6G3GdgBHF6sXHLfYZ9owTiqY3z0CssN1JMy9 kG794K465B9zZ4+WFhRxEs4B+/bYNzt5SooRK3GxCp9t16h+D5nkhJoWPpAg== X-Received: by 2002:a05:600c:c490:b0:479:1b0f:dfff with SMTP id 5b1f17b1804b1-48727e908e7mr6423875e9.10.1774566138214; Thu, 26 Mar 2026 16:02:18 -0700 (PDT) Received: from osama ([2a02:908:1b6:8980:8cd6:6329:c43d:2fcb]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b919df903sm11024636f8f.30.2026.03.26.16.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 16:02:16 -0700 (PDT) Date: Fri, 27 Mar 2026 00:02:14 +0100 From: Osama Abdelkader To: Breno Leitao Cc: Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Ryo Takakura , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: panic if IRQ shadow call stack allocation fails Message-ID: References: <20260324161545.5441-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: On Wed, Mar 25, 2026 at 01:54:32AM -0700, Breno Leitao wrote: > On Tue, Mar 24, 2026 at 05:15:41PM +0100, Osama Abdelkader wrote: > > scs_alloc() can return NULL when vmalloc fails. init_irq_scs() previously > > stored that NULL in per-cpu irq_shadow_call_stack_ptr, which IRQ entry > > would then use under CONFIG_SHADOW_CALL_STACK. Match other SCS setup paths > > (e.g. SDEI) by failing explicitly instead of continuing with a NULL > > pointer. > > Right, _init_sdei_scs() doesn't not assign the per cpu pointer with > NULL, but, at the same time it doesn't panic. SDEI propagates -ENOMEM > back up the call chain and even frees already allocated stacks via > free_sdei_scs(). Should it panic as well? > Thanks, I changed it to return -ENOMEM in v2 to address will's review. > > Mark init_irq_scs() __init since it is only called from init_IRQ(). > > > > Signed-off-by: Osama Abdelkader > > --- > > arch/arm64/kernel/irq.c | 14 +++++++++----- > > 1 file changed, 9 insertions(+), 5 deletions(-) > > > > diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c > > index 15dedb385b9e..b32ed7ef8e00 100644 > > --- a/arch/arm64/kernel/irq.c > > +++ b/arch/arm64/kernel/irq.c > > @@ -14,6 +14,7 @@ > > #include > > #include > > #include > > +#include > > Why do you need kernel.h in here? I initially thought it was > for panic(), but, later I found panic() is already in use in this file. > > Isn't kernel.h being included transitively? Right, I removed it in v2, thanks. > > #include > > #include > > #include > > @@ -32,23 +33,26 @@ 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 void __init init_irq_scs(void) > > { > > int cpu; > > + void *s; > > > > if (!scs_is_enabled()) > > return; > > > > - for_each_possible_cpu(cpu) > > - per_cpu(irq_shadow_call_stack_ptr, cpu) = > > - scs_alloc(early_cpu_to_node(cpu)); > > + for_each_possible_cpu(cpu) { > > + s = scs_alloc(early_cpu_to_node(cpu)); > > + if (!s) > > + panic("irq: Failed to allocate shadow call stack\n"); > > + per_cpu(irq_shadow_call_stack_ptr, cpu) = s; > > + } > > } > > Reading RISC-V code, it seems it has the same problem. Is it worth fixing also? > > static void init_irq_scs(void) > { > int cpu; > > if (!scs_is_enabled()) > return; > > for_each_possible_cpu(cpu) > per_cpu(irq_shadow_call_stack_ptr, cpu) = > scs_alloc(cpu_to_node(cpu)); > } Yes, thanks for the check. > > Other than these nits, feel free to add: > > Reviewed-by: Breno Leitao Thank you. I sent v2: [PATCH v2] arm64: panic from init_IRQ if IRQ handler stacks cannot be allocated To cover init_irq_stacks as well. Best regards, Osama