From: Pingfan Liu <kernelfans@gmail.com> To: linux-arm-kernel@lists.infradead.org Cc: Pingfan Liu <kernelfans@gmail.com>, Mark Rutland <mark.rutland@arm.com>, "Paul E . McKenney" <paulmck@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>, Thomas Gleixner <tglx@linutronix.de>, Joey Gouly <joey.gouly@arm.com>, Sami Tolvanen <samitolvanen@google.com>, Julien Thierry <julien.thierry@arm.com>, Yuichi Ito <ito-yuichi@fujitsu.com>, rcu@vger.kernel.org Subject: [PATCHv3 2/4] arm64: entry: distinguish pNMI earlier in el0 interrupt Date: Tue, 16 Nov 2021 16:24:48 +0800 [thread overview] Message-ID: <20211116082450.10357-3-kernelfans@gmail.com> (raw) In-Reply-To: <20211116082450.10357-1-kernelfans@gmail.com> For ease of unifying code, it is helpful to lift nmi_{enter,exit}() housekeeping from gic_handle_nmi() to el0_interrupt(). Because gic_handle_nmi() is called by either el1 interrupt or el0, and the housekeeping has already been done in arch level code when el1 interrupt. Note about the original code, which calls enter_from_user_mode() in pNMI context. Although it is weird to call rcu_eqs_exit() in the pseudo NMI context, it has no problem. This is due to the essentiality of pNMI, a higher priority interrupt but not akin to NMI, which allows a break-in at any time. Signed-off-by: Pingfan Liu <kernelfans@gmail.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Paul E. McKenney <paulmck@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Marc Zyngier <maz@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Joey Gouly <joey.gouly@arm.com> Cc: Sami Tolvanen <samitolvanen@google.com> Cc: Julien Thierry <julien.thierry@arm.com> Cc: Yuichi Ito <ito-yuichi@fujitsu.com> Cc: rcu@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- arch/arm64/kernel/entry-common.c | 35 ++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c index 5a1a5dd66d04..afcde43f1b73 100644 --- a/arch/arm64/kernel/entry-common.c +++ b/arch/arm64/kernel/entry-common.c @@ -429,7 +429,7 @@ asmlinkage void noinstr el1h_64_sync_handler(struct pt_regs *regs) } } -static __always_inline void __el1_pnmi(struct pt_regs *regs, +static __always_inline void __pnmi_handler_common(struct pt_regs *regs, void (*handler)(struct pt_regs *)) { arm64_enter_nmi(regs); @@ -437,6 +437,12 @@ static __always_inline void __el1_pnmi(struct pt_regs *regs, arm64_exit_nmi(regs); } +static __always_inline void __el1_pnmi(struct pt_regs *regs, + void (*handler)(struct pt_regs *)) +{ + __pnmi_handler_common(regs, handler); +} + static __always_inline void __el1_irq(struct pt_regs *regs, void (*handler)(struct pt_regs *)) { @@ -673,21 +679,34 @@ asmlinkage void noinstr el0t_64_sync_handler(struct pt_regs *regs) } } -static void noinstr el0_interrupt(struct pt_regs *regs, - void (*handler)(struct pt_regs *)) +static __always_inline void __el0_pnmi(struct pt_regs *regs, + void (*handler)(struct pt_regs *)) +{ + __pnmi_handler_common(regs, handler); +} + +static __always_inline void __el0_irq(struct pt_regs *regs, + void (*handler)(struct pt_regs *)) { enter_from_user_mode(regs); + irq_enter_rcu(); + do_interrupt_handler(regs, handler); + irq_exit_rcu(); + exit_to_user_mode(regs); +} +static void noinstr el0_interrupt(struct pt_regs *regs, + void (*handler)(struct pt_regs *)) +{ write_sysreg(DAIF_PROCCTX_NOIRQ, daif); if (regs->pc & BIT(55)) arm64_apply_bp_hardening(); - irq_enter_rcu(); - do_interrupt_handler(regs, handler); - irq_exit_rcu(); - - exit_to_user_mode(regs); + if (IS_ENABLED(CONFIG_ARM64_PSEUDO_NMI) && is_in_pnmi(regs)) + __el0_pnmi(regs, handler); + else + __el0_irq(regs, handler); } static void noinstr __el0_irq_handler_common(struct pt_regs *regs) -- 2.31.1
WARNING: multiple messages have this Message-ID (diff)
From: Pingfan Liu <kernelfans@gmail.com> To: linux-arm-kernel@lists.infradead.org Cc: Pingfan Liu <kernelfans@gmail.com>, Mark Rutland <mark.rutland@arm.com>, "Paul E . McKenney" <paulmck@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>, Thomas Gleixner <tglx@linutronix.de>, Joey Gouly <joey.gouly@arm.com>, Sami Tolvanen <samitolvanen@google.com>, Julien Thierry <julien.thierry@arm.com>, Yuichi Ito <ito-yuichi@fujitsu.com>, rcu@vger.kernel.org Subject: [PATCHv3 2/4] arm64: entry: distinguish pNMI earlier in el0 interrupt Date: Tue, 16 Nov 2021 16:24:48 +0800 [thread overview] Message-ID: <20211116082450.10357-3-kernelfans@gmail.com> (raw) In-Reply-To: <20211116082450.10357-1-kernelfans@gmail.com> For ease of unifying code, it is helpful to lift nmi_{enter,exit}() housekeeping from gic_handle_nmi() to el0_interrupt(). Because gic_handle_nmi() is called by either el1 interrupt or el0, and the housekeeping has already been done in arch level code when el1 interrupt. Note about the original code, which calls enter_from_user_mode() in pNMI context. Although it is weird to call rcu_eqs_exit() in the pseudo NMI context, it has no problem. This is due to the essentiality of pNMI, a higher priority interrupt but not akin to NMI, which allows a break-in at any time. Signed-off-by: Pingfan Liu <kernelfans@gmail.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Paul E. McKenney <paulmck@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Marc Zyngier <maz@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Joey Gouly <joey.gouly@arm.com> Cc: Sami Tolvanen <samitolvanen@google.com> Cc: Julien Thierry <julien.thierry@arm.com> Cc: Yuichi Ito <ito-yuichi@fujitsu.com> Cc: rcu@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- arch/arm64/kernel/entry-common.c | 35 ++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c index 5a1a5dd66d04..afcde43f1b73 100644 --- a/arch/arm64/kernel/entry-common.c +++ b/arch/arm64/kernel/entry-common.c @@ -429,7 +429,7 @@ asmlinkage void noinstr el1h_64_sync_handler(struct pt_regs *regs) } } -static __always_inline void __el1_pnmi(struct pt_regs *regs, +static __always_inline void __pnmi_handler_common(struct pt_regs *regs, void (*handler)(struct pt_regs *)) { arm64_enter_nmi(regs); @@ -437,6 +437,12 @@ static __always_inline void __el1_pnmi(struct pt_regs *regs, arm64_exit_nmi(regs); } +static __always_inline void __el1_pnmi(struct pt_regs *regs, + void (*handler)(struct pt_regs *)) +{ + __pnmi_handler_common(regs, handler); +} + static __always_inline void __el1_irq(struct pt_regs *regs, void (*handler)(struct pt_regs *)) { @@ -673,21 +679,34 @@ asmlinkage void noinstr el0t_64_sync_handler(struct pt_regs *regs) } } -static void noinstr el0_interrupt(struct pt_regs *regs, - void (*handler)(struct pt_regs *)) +static __always_inline void __el0_pnmi(struct pt_regs *regs, + void (*handler)(struct pt_regs *)) +{ + __pnmi_handler_common(regs, handler); +} + +static __always_inline void __el0_irq(struct pt_regs *regs, + void (*handler)(struct pt_regs *)) { enter_from_user_mode(regs); + irq_enter_rcu(); + do_interrupt_handler(regs, handler); + irq_exit_rcu(); + exit_to_user_mode(regs); +} +static void noinstr el0_interrupt(struct pt_regs *regs, + void (*handler)(struct pt_regs *)) +{ write_sysreg(DAIF_PROCCTX_NOIRQ, daif); if (regs->pc & BIT(55)) arm64_apply_bp_hardening(); - irq_enter_rcu(); - do_interrupt_handler(regs, handler); - irq_exit_rcu(); - - exit_to_user_mode(regs); + if (IS_ENABLED(CONFIG_ARM64_PSEUDO_NMI) && is_in_pnmi(regs)) + __el0_pnmi(regs, handler); + else + __el0_irq(regs, handler); } static void noinstr __el0_irq_handler_common(struct pt_regs *regs) -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-11-16 8:25 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-16 8:24 [PATCHv3 0/4] arm64: Fixes RCU deadlock due to a mistaken Pingfan Liu 2021-11-16 8:24 ` Pingfan Liu 2021-11-16 8:24 ` [PATCHv3 1/4] arm64: entry: judge nmi ealier to avoid deadlock in RCU Pingfan Liu 2021-11-16 8:24 ` Pingfan Liu 2021-11-17 11:38 ` Mark Rutland 2021-11-17 11:38 ` Mark Rutland 2021-11-19 2:01 ` Pingfan Liu 2021-11-19 2:01 ` Pingfan Liu 2021-11-19 14:04 ` Mark Rutland 2021-11-19 14:04 ` Mark Rutland 2021-11-16 8:24 ` Pingfan Liu [this message] 2021-11-16 8:24 ` [PATCHv3 2/4] arm64: entry: distinguish pNMI earlier in el0 interrupt Pingfan Liu 2021-11-16 8:24 ` [PATCHv3 3/4] irqchip: GICv3: expose pNMI discriminator Pingfan Liu 2021-11-16 8:24 ` Pingfan Liu 2021-11-16 9:53 ` Marc Zyngier 2021-11-16 9:53 ` Marc Zyngier 2021-11-17 10:16 ` Pingfan Liu 2021-11-17 10:16 ` Pingfan Liu 2021-11-17 11:01 ` Marc Zyngier 2021-11-17 11:01 ` Marc Zyngier 2021-11-19 2:38 ` Pingfan Liu 2021-11-19 2:38 ` Pingfan Liu 2021-11-16 8:24 ` [PATCHv3 4/4] arm64: entry: remove pNMI judgement in __el1_interrupt() path Pingfan Liu 2021-11-16 8:24 ` Pingfan Liu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211116082450.10357-3-kernelfans@gmail.com \ --to=kernelfans@gmail.com \ --cc=catalin.marinas@arm.com \ --cc=ito-yuichi@fujitsu.com \ --cc=joey.gouly@arm.com \ --cc=julien.thierry@arm.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=mark.rutland@arm.com \ --cc=maz@kernel.org \ --cc=paulmck@kernel.org \ --cc=rcu@vger.kernel.org \ --cc=samitolvanen@google.com \ --cc=tglx@linutronix.de \ --cc=will@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.