[PATCH OLK-6.6 v4 0/1] stop_machine: mask pseudo nmi before running the callback

*** BLURB HERE *** Wei Li (1): stop_machine: mask pseudo nmi before running the callback arch/arm64/include/asm/arch_gicv3.h | 12 ++++++++++++ kernel/stop_machine.c | 3 +++ 2 files changed, 15 insertions(+) -- 2.34.1

From: Wei Li <liwei391@huawei.com> hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8QBLL ---------------------------------------- Kprobes use 'stop_machine' to modify code which could be ran in the pseudo nmi context at the same time. This patch mask pseudo nmi before running the stop_machine callback to avoid this race condition. Signed-off-by: Wei Li <liwei391@huawei.com> Reviewed-by: Yang Yingliang <yangyingliang@huawei.com> Reviewed-by: Cheng Jian <cj.chengjian@huawei.com> Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com> Signed-off-by: Yuntao Liu <liuyuntao12@huawei.com> --- arch/arm64/include/asm/arch_gicv3.h | 12 ++++++++++++ kernel/stop_machine.c | 3 +++ 2 files changed, 15 insertions(+) diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h index 01281a5336cf..1582900e94f8 100644 --- a/arch/arm64/include/asm/arch_gicv3.h +++ b/arch/arm64/include/asm/arch_gicv3.h @@ -190,6 +190,18 @@ static inline void gic_arch_enable_irqs(void) asm volatile ("msr daifclr, #3" : : : "memory"); } +static inline void gic_arch_disable_irqs(void) +{ + asm volatile ("msr daifset, #3" : : : "memory"); +} + +static inline void gic_arch_restore_irqs(unsigned long flags) +{ + if (gic_supports_nmi()) + asm volatile ("msr daif, %0" : : "r" (flags >> 32) + : "memory"); +} + static inline bool gic_has_relaxed_pmr_sync(void) { return cpus_have_cap(ARM64_HAS_GIC_PRIO_RELAXED_SYNC); diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 9466d61d21c9..320ce5b18511 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c @@ -25,6 +25,7 @@ #ifdef CONFIG_ARM64 #include <linux/arm_sdei.h> +#include <asm/arch_gicv3.h> #endif /* @@ -239,6 +240,7 @@ static int multi_cpu_stop(void *data) local_irq_disable(); hard_irq_disable(); #ifdef CONFIG_ARM64 + gic_arch_disable_irqs(); sdei_mask_local_cpu(); #endif break; @@ -263,6 +265,7 @@ static int multi_cpu_stop(void *data) #ifdef CONFIG_ARM64 sdei_unmask_local_cpu(); + gic_arch_restore_irqs(flags); #endif local_irq_restore(flags); return err; -- 2.34.1

反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/3516 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/2... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/3516 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/2...
participants (2)
-
patchwork bot
-
Yuntao Liu