From patchwork Thu Oct 29 14:56:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11866601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85CF4C2D0A3 for ; Thu, 29 Oct 2020 15:01:25 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 089262067C for ; Thu, 29 Oct 2020 15:01:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PoVnLYqN"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VaV6/Go+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 089262067C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vTOM2vflAEbBezEf8zzud1kAoAJHwLtQjhFQp3fIwkU=; b=PoVnLYqNB4R3EXWYTX1xTU07g3 VFLdQ9zTNLY58/bLcBhgWJBfhGzLVjNkrpJq+ehC4YpVKdsS+YHP48NOnRFAP9blIB32IQKUp02qA bAnE4tr+cwciSlLaJCnPt/heJLXZbwq/ucb2ptTByodIBw7BcNLui7ecUvddXkeGX5iJtzNqWzfNN 7vmZPhyHmgpGVfkjjl2jkI8VlxOutyWqJWZdyW8GC+FX9/OIp+dor1wsw5Kvz/ZLar4jEd9Ssqkha xCn2jcQLwVWR/9atFjV0zlx5nOhldY6K0wRaK2yKkc4X1Q2L4MX7FnZKpi2HxR9/m1vkEJhFeSqXA sd81+lVQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY9Ox-0004k8-CC; Thu, 29 Oct 2020 14:59:43 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY9OL-0004UO-I3 for linux-arm-kernel@lists.infradead.org; Thu, 29 Oct 2020 14:59:08 +0000 Received: by mail-pl1-x643.google.com with SMTP id x23so1419986plr.6 for ; Thu, 29 Oct 2020 07:59:05 -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=vRwqyoyBEeMity0cyda+uu/rJEIK2HXvyD5N7tr1KQA=; b=VaV6/Go+khoksNqGfCUHDeBSHVzAJEA+svM5XJTrMpaiwQW5OlTmX/9P+0AhI2Wgrc eaYH6kMXDCKlBsBdwgq0a2AvqpQJFku5TSiBp8O9O1W6GvFJvEqB0WWZiW7gaMNQT2PN JjueUsyk1j1ZDQ4eRWBrzvLUpzbK6D7wXp99Ea6n2DFJoqRpGOqqVsM7B4ahs+rEim/x 7GCHwMuXp3+jVVF5LWSemEJME2d/XEGagujBza5F+oXi2yDsg2/yn7tJa2lMuruEsQyG zzn4vNRJTm1+P8cplXnjZhqwceqWIQYRcmtckz5f8cQH8CuKEpDZGwf2pC+80kwUCRzu /OlA== 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=vRwqyoyBEeMity0cyda+uu/rJEIK2HXvyD5N7tr1KQA=; b=O9Y6rk/TTAk60qziqIVnebZ+zzSsFskPF3u2C1TUMWE/Re7X5IHayG9XK2wSWVIHHj UX5kXGPcvTPWdhlJMIGiUAxammDvLI3HjLzMICtOJlvkvbfeUvwLHC+Yq5GGAU+hR6ui uuwIdWvr47Gq/fMBBQuTcxzySeEoA6LScHakbEA3WE8wvRKtf9zxZ2ZA9lqIqdxe6ghi pftPTD4bYduajf6x3jV/ShpthmWgci+xHfRkgOs6Io1eTybmd3fSW1YVxjy2lATJEyG9 vSPAIa2OIhLhJqX3ftPfeB7te8dJI79r07UbDpvIv4x+cN0dN1iqTQB8Lw/yt+0kxGfJ SSbQ== X-Gm-Message-State: AOAM5303tiBsit200s4aZzFJZMHQGqsS+CV0lrougkVjrgJarltAOjFA GitxkNdl2tIpkF9cBNWzjmUHCg== X-Google-Smtp-Source: ABdhPJyZHAWcF9UXIuaciASbmUM2nhi5xQ3CWgJ6UeAed6E2uiOLILawF0T8+k3uKF2R+aWSxlR5CA== X-Received: by 2002:a17:902:7c86:b029:d5:f680:f756 with SMTP id y6-20020a1709027c86b02900d5f680f756mr4717679pll.39.1603983543591; Thu, 29 Oct 2020 07:59:03 -0700 (PDT) Received: from localhost.localdomain ([117.252.71.231]) by smtp.gmail.com with ESMTPSA id j11sm3085082pfc.64.2020.10.29.07.58.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Oct 2020 07:59:02 -0700 (PDT) From: Sumit Garg To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org Subject: [PATCH v6 6/7] kgdb: roundup: Allow runtime arch specific override Date: Thu, 29 Oct 2020 20:26:26 +0530 Message-Id: <1603983387-8738-7-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201029_105905_842555_3DE47E26 X-CRM114-Status: GOOD ( 20.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, Sumit Garg , daniel.thompson@linaro.org, tsbogend@alpha.franken.de, linux-kernel@vger.kernel.org, jason@lakedaemon.net, ito-yuichi@fujitsu.com, mpe@ellerman.id.au, x86@kernel.org, linux@armlinux.org.uk, dianders@chromium.org, mingo@redhat.com, bp@alien8.de, julien.thierry.kdev@gmail.com, jason.wessel@windriver.com, kgdb-bugreport@lists.sourceforge.net, tglx@linutronix.de, msys.mizuma@gmail.com, davem@davemloft.net, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a new API kgdb_arch_roundup_cpus() for a particular archichecture to override default kgdb roundup and if it detects at runtime to not support NMI roundup then it can fallback to default implementation using async 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/powerpc/kernel/kgdb.c | 3 ++- arch/sparc/kernel/smp_64.c | 3 ++- arch/x86/kernel/kgdb.c | 6 ++++-- include/linux/kgdb.h | 5 +++-- kernel/debug/debug_core.c | 10 +++++++++- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c index 4090802..126575d 100644 --- a/arch/powerpc/kernel/kgdb.c +++ b/arch/powerpc/kernel/kgdb.c @@ -125,9 +125,10 @@ static int kgdb_debugger_ipi(struct pt_regs *regs) } #ifdef CONFIG_SMP -void kgdb_roundup_cpus(void) +bool kgdb_arch_roundup_cpus(void) { smp_send_debugger_break(); + return true; } #endif diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index e38d8bf..c459c83 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c @@ -1014,9 +1014,10 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page) } #ifdef CONFIG_KGDB -void kgdb_roundup_cpus(void) +bool kgdb_arch_roundup_cpus(void) { smp_cross_call(&xcall_kgdb_capture, 0, 0, 0); + return true; } #endif diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c index ff7878d..1b756d9 100644 --- a/arch/x86/kernel/kgdb.c +++ b/arch/x86/kernel/kgdb.c @@ -404,7 +404,8 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs) #ifdef CONFIG_SMP /** - * kgdb_roundup_cpus - Get other CPUs into a holding pattern + * kgdb_arch_roundup_cpus - Get other CPUs into a holding pattern + * in an architectural specific manner * * On SMP systems, we need to get the attention of the other CPUs * and get them be in a known state. This should do what is needed @@ -414,9 +415,10 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs) * * On non-SMP systems, this is not called. */ -void kgdb_roundup_cpus(void) +bool kgdb_arch_roundup_cpus(void) { apic_send_IPI_allbutself(NMI_VECTOR); + return true; } #endif diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h index 0d6cf64..f9db5b8 100644 --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h @@ -200,7 +200,8 @@ kgdb_arch_handle_qxfer_pkt(char *remcom_in_buffer, extern void kgdb_call_nmi_hook(void *ignored); /** - * kgdb_roundup_cpus - Get other CPUs into a holding pattern + * kgdb_arch_roundup_cpus - Get other CPUs into a holding pattern + * in an architectural specific manner * * On SMP systems, we need to get the attention of the other CPUs * and get them into a known state. This should do what is needed @@ -210,7 +211,7 @@ extern void kgdb_call_nmi_hook(void *ignored); * * On non-SMP systems, this is not called. */ -extern void kgdb_roundup_cpus(void); +extern bool kgdb_arch_roundup_cpus(void); /** * kgdb_arch_set_pc - Generic call back to the program counter diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 1e75a89..27e401c 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -241,13 +241,21 @@ void __weak kgdb_call_nmi_hook(void *ignored) } NOKPROBE_SYMBOL(kgdb_call_nmi_hook); -void __weak kgdb_roundup_cpus(void) +bool __weak kgdb_arch_roundup_cpus(void) +{ + return false; +} + +static void kgdb_roundup_cpus(void) { call_single_data_t *csd; int this_cpu = raw_smp_processor_id(); int cpu; int ret; + if (kgdb_arch_roundup_cpus()) + return; + for_each_online_cpu(cpu) { /* No need to roundup ourselves */ if (cpu == this_cpu)