From patchwork Fri Jul 8 09:49:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 12910838 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 08687C433EF for ; Fri, 8 Jul 2022 09:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ida0r5AL+DofBuOdbyvaYfCBgSQyeqRipDSHHNdiIfk=; b=pLmvYJqTmoGItz DE9aupa1iEcy/sWa6I4DbRseHWzX7NMUHQP3wcvCREbyS7BuxD4agu799TIplJX106T+NZLpPIgeU PX6fR4ujfSCEYHMOIsWiZXA4jnR8QwQ1ck3Ub6IA2FOKzjl/nWB7cqcxr/df2Knbjxo/3n51WaCBH 10tv7RGQSv+5On2qnaCIm1VpvSCLML2FzPD4gjxsV5sR889WjFjXt/Yab+qTpPHR1xNB2ZMDSqL+t nxW93wMQot6wGip+WcXqvM0/0DzJOh5aHXBF4XKzWRiR5SqxOuTVNdQHlzKfhNHrtTj5nCnS9v/ar sO1n3VuHQJdqh07iZ/xA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9kda-0031j0-Pu; Fri, 08 Jul 2022 09:51:02 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9kcy-0031Pv-55 for linux-arm-kernel@lists.infradead.org; Fri, 08 Jul 2022 09:50:26 +0000 Received: by mail-pl1-x62c.google.com with SMTP id 5so10059323plk.9 for ; Fri, 08 Jul 2022 02:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CInbfRCxTX+lwwkZS0ynkKJhKDRk8XEefCQvvOFfbPc=; b=ClhBVlZfVVoQ+wE0Sn6Rnn1/9c8DzQQe6ttcNMbc2xCavg3qotM59YLWu/VmdcfDjC 2DJ0fsVR6N6KQUBChyvfwf78+eeIySZ3Gd+rrBvOc1Zwpxqk0SPqZuJDlaPMbZ8q2uuv UbHbx3qw3QiWfWMGiH3eUEdJuZjQ1icnwBtF7/+KfuV14dv4X3q8TQRtjMyFxWQ2idjz kUttfKOA/lct8cgjojawMCX32ZbjJsFfkyjnQho4+dLR9Bg9QKmSo7/dilbHTPw9XkVN K3KP3eroLTaBUHozYSNI19itv3VkatfEFZ8jLYOpUSjAluVakIZi3REAXmjCe45f0Mot aULg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CInbfRCxTX+lwwkZS0ynkKJhKDRk8XEefCQvvOFfbPc=; b=BrhVSyMFwMLlyyqlPlwA72ziGM3h3xMD6R3fAenAFUtO34bPtm9ad4o2UFoGjiMtFG Y5Ys4cJCrEohWSnBonQ7Vg44JkjbYzUkxHaKZ/moB5ZeLA3S6i5r4qspJHVR298lFk0S BkAv6mhEdAdPWzzwibhu2cnX1nPfZxVBgUm4ukDxQHtVrA1zkCTLxfEEopswxTGgz32u dj8sLHOAjuV0ddWG5SlBb98Nna7kTeqh6j9PKian7fxQ6lH/o1m5lXpcR37oVwowRx4D yywQth0+cCzamMoY2Z1LTm7458Mn5yZKkZ7ywSGWdSCGI5k2J9ubs67tWCi2iuWonCDd FzlA== X-Gm-Message-State: AJIora+AeeXbD/FsmjXV/2kEyrJ7SxMh6Vwus8UkktmILGJhlti+KW4L iUbRA26HTMKz+lSGDIQ11EpebA== X-Google-Smtp-Source: AGRyM1tG2M7PjSIqi4dbhDxtx2UUOUHT2lI/8aPRs4+wPizXPgf2JHK3Q0g43E1i3OBy9b5r+6gNhA== X-Received: by 2002:a17:902:c992:b0:16b:d8b9:1c5f with SMTP id g18-20020a170902c99200b0016bd8b91c5fmr2786028plc.93.1657273820740; Fri, 08 Jul 2022 02:50:20 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.235]) by smtp.gmail.com with ESMTPSA id c18-20020a621c12000000b0051bbd79fc9csm28551035pfc.57.2022.07.08.02.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 02:50:20 -0700 (PDT) From: Qi Zheng To: arnd@arndb.de, catalin.marinas@arm.com, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Qi Zheng Subject: [PATCH v1 2/2] arm64: support HAVE_IRQ_EXIT_ON_IRQ_STACK Date: Fri, 8 Jul 2022 17:49:50 +0800 Message-Id: <20220708094950.41944-3-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20220708094950.41944-1-zhengqi.arch@bytedance.com> References: <20220708094950.41944-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220708_025024_213133_07579B2D X-CRM114-Status: GOOD ( 14.20 ) 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 Since softirqs are handled on the per-CPU IRQ stack, let's support HAVE_IRQ_EXIT_ON_IRQ_STACK which causes the core code to invoke __do_softirq() directly without going through do_softirq_own_stack(). Signed-off-by: Qi Zheng --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/exception.h | 4 +++- arch/arm64/kernel/entry-common.c | 30 ++++++++++++++++++++---------- arch/arm64/kernel/entry.S | 6 ++++-- arch/arm64/kernel/irq.c | 5 +++-- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index be0a9f0052ee..d2cc7daecce3 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -231,6 +231,7 @@ config ARM64 select TRACE_IRQFLAGS_SUPPORT select TRACE_IRQFLAGS_NMI_SUPPORT select HAVE_SOFTIRQ_ON_OWN_STACK + select HAVE_IRQ_EXIT_ON_IRQ_STACK help ARM 64-bit (AArch64) Linux support. diff --git a/arch/arm64/include/asm/exception.h b/arch/arm64/include/asm/exception.h index d94aecff9690..8bff0aa7ab50 100644 --- a/arch/arm64/include/asm/exception.h +++ b/arch/arm64/include/asm/exception.h @@ -54,7 +54,9 @@ asmlinkage void el0t_32_fiq_handler(struct pt_regs *regs); asmlinkage void el0t_32_error_handler(struct pt_regs *regs); asmlinkage void call_on_irq_stack(struct pt_regs *regs, - void (*func)(struct pt_regs *)); + void (*func)(struct pt_regs *), + void (*do_func)(struct pt_regs *, + void (*)(struct pt_regs *))); asmlinkage void asm_exit_to_user_mode(struct pt_regs *regs); void do_mem_abort(unsigned long far, unsigned long esr, struct pt_regs *regs); diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c index c75ca36b4a49..935d1ab150b5 100644 --- a/arch/arm64/kernel/entry-common.c +++ b/arch/arm64/kernel/entry-common.c @@ -266,14 +266,16 @@ static void __sched arm64_preempt_schedule_irq(void) } static void do_interrupt_handler(struct pt_regs *regs, - void (*handler)(struct pt_regs *)) + void (*handler)(struct pt_regs *), + void (*do_handler)(struct pt_regs *, + void (*)(struct pt_regs *))) { struct pt_regs *old_regs = set_irq_regs(regs); if (on_thread_stack()) - call_on_irq_stack(regs, handler); + call_on_irq_stack(regs, handler, do_handler); else - handler(regs); + do_handler(regs, handler); set_irq_regs(old_regs); } @@ -441,22 +443,32 @@ asmlinkage void noinstr el1h_64_sync_handler(struct pt_regs *regs) } } +static void nmi_handler(struct pt_regs *regs, void (*handler)(struct pt_regs *)) +{ + handler(regs); +} + static __always_inline void __el1_pnmi(struct pt_regs *regs, void (*handler)(struct pt_regs *)) { arm64_enter_nmi(regs); - do_interrupt_handler(regs, handler); + do_interrupt_handler(regs, handler, nmi_handler); arm64_exit_nmi(regs); } +static void irq_handler(struct pt_regs *regs, void (*handler)(struct pt_regs *)) +{ + irq_enter_rcu(); + handler(regs); + irq_exit_rcu(); +} + static __always_inline void __el1_irq(struct pt_regs *regs, void (*handler)(struct pt_regs *)) { enter_from_kernel_mode(regs); - irq_enter_rcu(); - do_interrupt_handler(regs, handler); - irq_exit_rcu(); + do_interrupt_handler(regs, handler, irq_handler); arm64_preempt_schedule_irq(); @@ -699,9 +711,7 @@ static void noinstr el0_interrupt(struct pt_regs *regs, if (regs->pc & BIT(55)) arm64_apply_bp_hardening(); - irq_enter_rcu(); - do_interrupt_handler(regs, handler); - irq_exit_rcu(); + do_interrupt_handler(regs, handler, irq_handler); exit_to_user_mode(regs); } diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 254fe31c03a0..1c351391f6bd 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -867,7 +867,9 @@ NOKPROBE(ret_from_fork) /* * void call_on_irq_stack(struct pt_regs *regs, - * void (*func)(struct pt_regs *)); + * void (*func)(struct pt_regs *) + * void (*do_func)(struct pt_regs *, + * void (*)(struct pt_regs *))); * * Calls func(regs) using this CPU's irq stack and shadow irq stack. */ @@ -886,7 +888,7 @@ SYM_FUNC_START(call_on_irq_stack) /* Move to the new stack and call the function there */ mov sp, x16 - blr x1 + blr x2 /* * Restore the SP from the FP, and restore the FP and LR from the frame diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c index c36ad20a52f3..003db605bc4f 100644 --- a/arch/arm64/kernel/irq.c +++ b/arch/arm64/kernel/irq.c @@ -73,14 +73,15 @@ static void init_irq_stacks(void) #endif #ifndef CONFIG_PREEMPT_RT -static void ____do_softirq(struct pt_regs *regs) +static void ____do_softirq(struct pt_regs *regs, + void (*handler)(struct pt_regs *)) { __do_softirq(); } void do_softirq_own_stack(void) { - call_on_irq_stack(NULL, ____do_softirq); + call_on_irq_stack(NULL, NULL, ____do_softirq); } #endif