Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp516184pxx; Thu, 29 Oct 2020 08:01:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweN2cEcyQlrwQ35Rfqo4nz98Tc6Bg02oLupicAXjUhRkCkJq0U7Yi9ehnwqtAJ+ZnH95iO X-Received: by 2002:a1c:7214:: with SMTP id n20mr219494wmc.93.1603983668965; Thu, 29 Oct 2020 08:01:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603983668; cv=none; d=google.com; s=arc-20160816; b=VJyoSA5Fb6FrMW38I79kovF4zxTitJ6JfnlNRAHGH39DqsrTCdsTXNQOH12OWEPGF+ m5CXiTo75z+vH+k7dcAnxyH/Bvx4rObH2xzdGNJihDxa4slV0oogFS0kWxGPfnEKaUWf XrspRgJCVnbq+xacjMQEPCr2/eY66MMoUtM4CHib02qTW238SWnC4Kxh1he///MreqdN 9qScn9/BKfiTDPLi2FTDlPMKhViMVTpvVEztlQ7X735UF67DAd9ej0bcmGYb2F5ev3x6 H0fL9GypSlIeHfmCzGTwj9ILBQxtqF+BOAypjXNSAURcqxRM2KIH1rVyzBcnBWLzxM5k CDOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=4e2yfnMR++56KFut6kOLfTQarMmYrpZq1CE3qMECL4w=; b=VgpoX5F+cBHUGOV+//VmHMvw4qWaKcc/F9sU/vj6eY+hZxmwhJdDXsiFngAJuTnupJ 9n7OAcVTxsR7wh5XckWSIIIDbAaJnemM+elnId5EXknUCLFfzabZlPu6bZhZ8yXKgK4B aCNh0XYqQL0mGCe8NyQ5z9S/wGw7TFV2bosjcAFCQnb5TfxcABDjNJrm4BIkVp0e+XFQ 54TfxsziGx4BkEy3w6pj/L++L+G199HedrRM0WGJRvhpx133cTwLUFSe4tPiMBin5Qft K8i2hDUHXE306SHb8/y85blUfRScH9cdUIxcPhUEg5Sb67G3ZW0JemUYUaCFAkMyn87a PL4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XJjksHkY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si2272371edq.98.2020.10.29.08.00.45; Thu, 29 Oct 2020 08:01:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XJjksHkY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727980AbgJ2O6o (ORCPT + 99 others); Thu, 29 Oct 2020 10:58:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727853AbgJ2O6o (ORCPT ); Thu, 29 Oct 2020 10:58:44 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01056C0613CF for ; Thu, 29 Oct 2020 07:58:44 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id 1so1422651ple.2 for ; Thu, 29 Oct 2020 07:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4e2yfnMR++56KFut6kOLfTQarMmYrpZq1CE3qMECL4w=; b=XJjksHkYjikof0fGwOzB1QkkJRMDBaLHRUDrY80u2Tk8IH/yUVD8vNqh+AAMwDF9St knzq2LyaXm7qnqr2hVVDAp2Az6bDj4MxRUVPgtflqKHXkEYzXfRMiY2a1MGIZvHh2fgM dWU3O5F/Sb8Mz1QDYYtzqaJvWY3YNDrAYvBDZg/CQNOnsqkfV/7ZMC/6TdLDkeI4bAG0 Psyg8AsSTJxuh4yaYGnKqrIpwZaek1nTr4aViON9Mwrh8pCSKF763tbtlsfCwuBAPc9Z Mr26xOICSLDIEjReczhTA53I9mWmGajpJ4R12nCyfQocQ0/HLlCN45+LwZuU0xwJNzMj iSGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4e2yfnMR++56KFut6kOLfTQarMmYrpZq1CE3qMECL4w=; b=Q4i95gs9IV64+XAvbRV5g433kLKjoi6ZJv9SeqYQj0IFcq1szKdOKj/6HHEm0G3XmV +AULkDduVGKxuURCjDqbWh7NOR9tP1EcVbHJGIPEhNApVbIJzl3T7wr/YRRV1Wqo2EqV fBzwKIY5PLiSec2jov+eeyEvZAqa24qcdrTwloQ0VmhL6FBOdchflc/jcsVTZFrHonkx Cx2wmqDkU0vrHen4iOPG82lDFNG9KAXv5BS1m3Wc4O5wv/8Sww6N3P2KYty08oWBGq7O kEuVUSMsTdwdphzxbd8SKfZH8ne8HUUK4oFPFVCy/AtefZZKEh2mrwJqFNr+W5BimPdm lRWA== X-Gm-Message-State: AOAM53198/Ky48P4rZfWt5sSHZkNPCGQsQPmWznI6zrmG8sm2txUOIQR HsMLVJeQKKNBz014k4lDrh6//w== X-Received: by 2002:a17:902:9042:b029:d5:eef1:c9c8 with SMTP id w2-20020a1709029042b02900d5eef1c9c8mr4826847plz.0.1603983523466; Thu, 29 Oct 2020 07:58:43 -0700 (PDT) Received: from localhost.localdomain ([117.252.71.231]) by smtp.gmail.com with ESMTPSA id j11sm3085082pfc.64.2020.10.29.07.58.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Oct 2020 07:58:42 -0700 (PDT) From: Sumit Garg To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, tglx@linutronix.de, jason@lakedaemon.net, linux@armlinux.org.uk, tsbogend@alpha.franken.de, mpe@ellerman.id.au, davem@davemloft.net, mingo@redhat.com, bp@alien8.de, x86@kernel.org, mark.rutland@arm.com, julien.thierry.kdev@gmail.com, dianders@chromium.org, daniel.thompson@linaro.org, jason.wessel@windriver.com, msys.mizuma@gmail.com, ito-yuichi@fujitsu.com, kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH v6 4/7] nmi: backtrace: Allow runtime arch specific override Date: Thu, 29 Oct 2020 20:26:24 +0530 Message-Id: <1603983387-8738-5-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1603983387-8738-1-git-send-email-sumit.garg@linaro.org> References: <1603983387-8738-1-git-send-email-sumit.garg@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a boolean return to arch_trigger_cpumask_backtrace() to support a use-case where a particular architecture detects at runtime if it supports NMI backtrace or it would like to fallback to default implementation using SMP cross-calls. Currently such an architecture example is arm64 supporting pseudo NMIs feature which is only available on platforms which have support for GICv3 or later version. Signed-off-by: Sumit Garg --- arch/arm/include/asm/irq.h | 2 +- arch/arm/kernel/smp.c | 3 ++- arch/mips/include/asm/irq.h | 2 +- arch/mips/kernel/process.c | 3 ++- arch/powerpc/include/asm/nmi.h | 2 +- arch/powerpc/kernel/stacktrace.c | 3 ++- arch/sparc/include/asm/irq_64.h | 2 +- arch/sparc/kernel/process_64.c | 4 +++- arch/x86/include/asm/irq.h | 2 +- arch/x86/kernel/apic/hw_nmi.c | 3 ++- include/linux/nmi.h | 12 ++++-------- 11 files changed, 20 insertions(+), 18 deletions(-) diff --git a/arch/arm/include/asm/irq.h b/arch/arm/include/asm/irq.h index 46d4114..54b0180 100644 --- a/arch/arm/include/asm/irq.h +++ b/arch/arm/include/asm/irq.h @@ -31,7 +31,7 @@ void handle_IRQ(unsigned int, struct pt_regs *); void init_IRQ(void); #ifdef CONFIG_SMP -extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask, +extern bool arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self); #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace #endif diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 48099c6e..bb20a43 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -856,7 +856,8 @@ static void raise_nmi(cpumask_t *mask) __ipi_send_mask(ipi_desc[IPI_CPU_BACKTRACE], mask); } -void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) +bool arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) { nmi_trigger_cpumask_backtrace(mask, exclude_self, raise_nmi); + return true; } diff --git a/arch/mips/include/asm/irq.h b/arch/mips/include/asm/irq.h index c5d3517..34f3b42 100644 --- a/arch/mips/include/asm/irq.h +++ b/arch/mips/include/asm/irq.h @@ -78,7 +78,7 @@ extern int cp0_fdc_irq; extern int get_c0_fdc_int(void); -void arch_trigger_cpumask_backtrace(const struct cpumask *mask, +bool arch_trigger_cpumask_backtrace(const struct cpumask *mask, bool exclude_self); #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index 75ebd8d..d19e672 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -735,9 +735,10 @@ static void raise_backtrace(cpumask_t *mask) } } -void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) +bool arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) { nmi_trigger_cpumask_backtrace(mask, exclude_self, raise_backtrace); + return true; } int mips_get_process_fp_mode(struct task_struct *task) diff --git a/arch/powerpc/include/asm/nmi.h b/arch/powerpc/include/asm/nmi.h index 84b4cfe..a5eb3e2 100644 --- a/arch/powerpc/include/asm/nmi.h +++ b/arch/powerpc/include/asm/nmi.h @@ -9,7 +9,7 @@ static inline void arch_touch_nmi_watchdog(void) {} #endif #if defined(CONFIG_NMI_IPI) && defined(CONFIG_STACKTRACE) -extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask, +extern bool arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self); #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace #endif diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c index b644065..22b112a 100644 --- a/arch/powerpc/kernel/stacktrace.c +++ b/arch/powerpc/kernel/stacktrace.c @@ -264,8 +264,9 @@ static void raise_backtrace_ipi(cpumask_t *mask) } } -void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) +bool arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) { nmi_trigger_cpumask_backtrace(mask, exclude_self, raise_backtrace_ipi); + return true; } #endif /* defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_NMI_IPI) */ diff --git a/arch/sparc/include/asm/irq_64.h b/arch/sparc/include/asm/irq_64.h index 4d748e9..35c01ff 100644 --- a/arch/sparc/include/asm/irq_64.h +++ b/arch/sparc/include/asm/irq_64.h @@ -87,7 +87,7 @@ static inline unsigned long get_softint(void) return retval; } -void arch_trigger_cpumask_backtrace(const struct cpumask *mask, +bool arch_trigger_cpumask_backtrace(const struct cpumask *mask, bool exclude_self); #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c index a75093b..9182001 100644 --- a/arch/sparc/kernel/process_64.c +++ b/arch/sparc/kernel/process_64.c @@ -248,7 +248,7 @@ static void __global_reg_poll(struct global_reg_snapshot *gp) } } -void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) +bool arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) { struct thread_info *tp = current_thread_info(); struct pt_regs *regs = get_irq_regs(); @@ -303,6 +303,8 @@ void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) memset(global_cpu_snapshot, 0, sizeof(global_cpu_snapshot)); spin_unlock_irqrestore(&global_cpu_snapshot_lock, flags); + + return true; } #ifdef CONFIG_MAGIC_SYSRQ diff --git a/arch/x86/include/asm/irq.h b/arch/x86/include/asm/irq.h index 528c8a7..b7668e0 100644 --- a/arch/x86/include/asm/irq.h +++ b/arch/x86/include/asm/irq.h @@ -47,7 +47,7 @@ extern void init_ISA_irqs(void); extern void __init init_IRQ(void); #ifdef CONFIG_X86_LOCAL_APIC -void arch_trigger_cpumask_backtrace(const struct cpumask *mask, +bool arch_trigger_cpumask_backtrace(const struct cpumask *mask, bool exclude_self); #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace diff --git a/arch/x86/kernel/apic/hw_nmi.c b/arch/x86/kernel/apic/hw_nmi.c index 34a992e..e7dcd28 100644 --- a/arch/x86/kernel/apic/hw_nmi.c +++ b/arch/x86/kernel/apic/hw_nmi.c @@ -34,10 +34,11 @@ static void nmi_raise_cpu_backtrace(cpumask_t *mask) apic->send_IPI_mask(mask, NMI_VECTOR); } -void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) +bool arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) { nmi_trigger_cpumask_backtrace(mask, exclude_self, nmi_raise_cpu_backtrace); + return true; } static int nmi_cpu_backtrace_handler(unsigned int cmd, struct pt_regs *regs) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 750c7f3..cedbfc1 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -143,26 +143,22 @@ static inline void touch_nmi_watchdog(void) #ifdef arch_trigger_cpumask_backtrace static inline bool trigger_all_cpu_backtrace(void) { - arch_trigger_cpumask_backtrace(cpu_online_mask, false); - return true; + return arch_trigger_cpumask_backtrace(cpu_online_mask, false); } static inline bool trigger_allbutself_cpu_backtrace(void) { - arch_trigger_cpumask_backtrace(cpu_online_mask, true); - return true; + return arch_trigger_cpumask_backtrace(cpu_online_mask, true); } static inline bool trigger_cpumask_backtrace(struct cpumask *mask) { - arch_trigger_cpumask_backtrace(mask, false); - return true; + return arch_trigger_cpumask_backtrace(mask, false); } static inline bool trigger_single_cpu_backtrace(int cpu) { - arch_trigger_cpumask_backtrace(cpumask_of(cpu), false); - return true; + return arch_trigger_cpumask_backtrace(cpumask_of(cpu), false); } /* generic implementation */ -- 2.7.4