Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1397869rwd; Tue, 13 Jun 2023 08:37:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7wdg/TNO0BTPILKQgH+uwBydGSA0hioLP8P+Dq4PL6Ifn3uNT25PZo+/G1EcW0hE39qXEZ X-Received: by 2002:a17:902:ec8f:b0:1b2:450f:99e with SMTP id x15-20020a170902ec8f00b001b2450f099emr10786578plg.46.1686670629235; Tue, 13 Jun 2023 08:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686670629; cv=none; d=google.com; s=arc-20160816; b=BaEedF1Grhdse1p4UjFhW1xlin/h2OC3TptgT2HaoW3m7/xJQVKSLDxGPAsHxILyqG kmil7wA9+u7WKzamdwGLF6evNr8A8vxAu3fGdV1a+HDuLuDgiEZ8Fv8NsZ0KMZ2jCkgk nR1Vdvz15B94nwIKqLkdqVUZLODVHHgm/6TGj80W+Q8/0yBpi9QO7wrg3q9W5UL4MEDN oPOB+XFpGYvseg78otWjbBMIWBUJUSLLNg1pWMzOSWUMAEmh3Kc/TQ2WuOkR1IVx2eBG 2vTcE64AVQMw/B3tBrwYD22hkgWSNmE7L/W18qvFRQIvGgDMoATW3xaychigiD1QO9Zx cLLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=AnhxWHtXEyNZmsMq1a78yiJQIOltqX0j8xXjJK3c7qY=; b=CK74wBUxj6GQb2ac2WEXskZg1o6AeRkfzXp5xODjdRBboDgr0clDP6X/24gFgHzVYn CGSEDRWrmWQeflSG4ln/3wbneALbadgcAUhm8OHJy31i9lM3ga+jQz5HR7eaf8CcQqt0 lnnbC/oOulGMoTAAhrujAnlyKVZAbuZlkbO/HKIeefzlXaIaKvlElB8yIqy+YAg6QBEa ZOCyx1LXmArc36WxdF0yn2ddIlJWMSlQXs+WJ2eRQQjf/fBznbFDBQP/q2qErHogCL// TYTCFyhptOW+3QBOM3nlXwOZblMqMlMQOANmgypABqDzHHKq12ogdO3W8HHZXiJynLgb +Dew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JhbB4c1X; 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 c4-20020a170903234400b001a64fa4eb27si9703261plh.230.2023.06.13.08.36.57; Tue, 13 Jun 2023 08:37:09 -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=JhbB4c1X; 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 S242599AbjFMPWP (ORCPT + 99 others); Tue, 13 Jun 2023 11:22:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234367AbjFMPWN (ORCPT ); Tue, 13 Jun 2023 11:22:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC490171F; Tue, 13 Jun 2023 08:22:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C353F63781; Tue, 13 Jun 2023 15:22:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33181C433F2; Tue, 13 Jun 2023 15:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686669731; bh=A//ADTpJNEvj5sg5K/oNCTDrlTuwFx3q2DsloGFiOhY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=JhbB4c1XT5azVk1QDRETMtpcAshUJGmCBa0jLgc29MOBWoZSdAe6g/KwPt9MAeZl2 x2tXkatNcYYbkN8oGbfXCLejrQIR6un1w/r7YtbFTKhDiJubIL/+MMUZo+S4GkGUVB dNgZLoM8cyA/ACEbVfENqpElTZ2V8kZBZyXUwlsfaQlGcCGvxQMojxOqwJGhK5cTlE 2sfqBtsQJ4oQDW2V6plElkq0mj2tO0QhqcxbLBqAT6tMQ7+M738X4T+2h+hcgHM7X8 EGWMp3nSjflU8bwiVrB7EXo1OXiFM5ewysMB2lhx7KsPbuD47R4t6NLFjJ1GThBhRL 73egeATN3Z5jQ== Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-5149c51fd5bso9487978a12.0; Tue, 13 Jun 2023 08:22:11 -0700 (PDT) X-Gm-Message-State: AC+VfDzhYylAGmDE9PyUnr/cxRQMWcXYbjwNB/rQYIlgipv7B5CtQOM0 5550LOsTkfbse0ZvlndQKZbartu0r6EKyv+eEdA= X-Received: by 2002:aa7:c50e:0:b0:516:7f02:92c0 with SMTP id o14-20020aa7c50e000000b005167f0292c0mr8125021edq.39.1686669729363; Tue, 13 Jun 2023 08:22:09 -0700 (PDT) MIME-Version: 1.0 References: <20230529084600.2878130-1-guoren@kernel.org> <20230529084600.2878130-2-guoren@kernel.org> In-Reply-To: From: Guo Ren Date: Tue, 13 Jun 2023 23:21:57 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH -next V12 1/3] riscv: stack: Support HAVE_IRQ_EXIT_ON_IRQ_STACK To: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= Cc: arnd@arndb.de, palmer@rivosinc.com, conor.dooley@microchip.com, heiko@sntech.de, jszhang@kernel.org, bjorn@kernel.org, greentime.hu@sifive.com, vincent.chen@sifive.com, andy.chiu@sifive.com, paul.walmsley@sifive.com, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Guo Ren Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Tue, Jun 13, 2023 at 9:01=E2=80=AFPM Cl=C3=A9ment L=C3=A9ger wrote: > > > > On 29/05/2023 10:45, guoren@kernel.org wrote: > > From: Guo Ren > > > > Add independent irq stacks for percpu to prevent kernel stack overflows= . > > It is also compatible with VMAP_STACK by arch_alloc_vmap_stack. > > > > Tested-by: Jisheng Zhang > > Signed-off-by: Guo Ren > > Signed-off-by: Guo Ren > > Cc: Conor Dooley > > --- > > arch/riscv/Kconfig | 7 ++++++ > > arch/riscv/include/asm/irq_stack.h | 32 +++++++++++++++++++++++++ > > arch/riscv/include/asm/thread_info.h | 2 ++ > > arch/riscv/kernel/irq.c | 33 ++++++++++++++++++++++++++ > > arch/riscv/kernel/traps.c | 35 ++++++++++++++++++++++++++-= - > > 5 files changed, 107 insertions(+), 2 deletions(-) > > create mode 100644 arch/riscv/include/asm/irq_stack.h > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > > index fa256f2e23c1..44b4c9690f94 100644 > > --- a/arch/riscv/Kconfig > > +++ b/arch/riscv/Kconfig > > @@ -588,6 +588,13 @@ config FPU > > > > If you don't know what to do here, say Y. > > > > +config IRQ_STACKS > > + bool "Independent irq stacks" if EXPERT > > + default y > > + select HAVE_IRQ_EXIT_ON_IRQ_STACK > > + help > > + Add independent irq stacks for percpu to prevent kernel stack o= verflows. > > + > > endmenu # "Platform type" > > > > menu "Kernel features" > > diff --git a/arch/riscv/include/asm/irq_stack.h b/arch/riscv/include/as= m/irq_stack.h > > new file mode 100644 > > index 000000000000..b0dcee9a3fa2 > > --- /dev/null > > +++ b/arch/riscv/include/asm/irq_stack.h > > @@ -0,0 +1,32 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > + > > +#ifndef _ASM_RISCV_IRQ_STACK_H > > +#define _ASM_RISCV_IRQ_STACK_H > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +DECLARE_PER_CPU(ulong *, irq_stack_ptr); > > + > > +#ifdef CONFIG_VMAP_STACK > > +/* > > + * To ensure that VMAP'd stack overflow detection works correctly, all= VMAP'd > > + * stacks need to have the same alignment. > > + */ > > +static inline unsigned long *arch_alloc_vmap_stack(size_t stack_size, = int node) > > +{ > > + void *p; > > + > > + BUILD_BUG_ON(!IS_ENABLED(CONFIG_VMAP_STACK)); > > Hi Guo, > > Since this function is already guarded with #ifdef CONFIG_VMAP_STACK, I > guess this BUILD_BUG_ON() is unnecessary). Yes, my carelessness. I would remove it in the next version. > > Cl=C3=A9ment -- Best Regards Guo Ren