From patchwork Thu Sep 27 03:41:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 147668 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1542740lji; Wed, 26 Sep 2018 22:10:26 -0700 (PDT) X-Google-Smtp-Source: ACcGV61XH4+lmo/ricwdaG7v6ANDImZBkz3KE5812theEcBFXlQvqdTCo4MYu07senprZOgfT7sY X-Received: by 2002:a17:902:28a8:: with SMTP id f37-v6mr8926559plb.264.1538025026174; Wed, 26 Sep 2018 22:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538025026; cv=none; d=google.com; s=arc-20160816; b=03qu7IhbjFvLWw15H5kvWEESpyKJd/Ho42Lb9sAECHhO68A2cQ85aBUBjdz/8QUt11 cAh6I5f+d62vHx8b9Nlu9D8KkbUIFWF0JWsU+RFoN7+ggadr5aGHrJG7UAJQc8FICh4W cxTk45oRxyA3ou3kbx4nQ6UY4feTe/JBhG/mDTGgTfRY4yttduN9iIRQcbAu1ZcDihBi QVIiqhq0d/85qOQmYe5bE1qwvNAV0zVyi+ugOY34pKSc+xLzKcllG9pWs5Ev6l2t4jr2 RpJdFxBuecrenkFq7lKLRwfErAyeXTDmGkvy2G7zHV9XLawhhhBp4zRtvNYUFNy1v8Ki vIwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=DZAP4x4u5o1xId6WhKBUHeAq3CBcXvjRpdtaPgqrdfc=; b=vyyxb0hGZkr/lEhmvGGKgGeW3GiApKeLbBombbCPmj/Iep0ocwlJ2w+Zo/45FiGrFh TICQCLfOchCpnsIUgYQcWNIGTwpuq/IXCpfD3zBrxi4AUEg/czSgFXViFCQt2INenHaB jIJ4MMPWQ57HjiC/Tl3V8oU5xNuf2nctQn+OmzYIK28aVtxeSfTnYvDuZZq/LenY7mcd uen/lqXi66fwfhGG6hy48eJ+sXX0Xn6541H88EwWV4PhSlmkNAH9h1n8va2ZPzOvkHKh w3fnaj099glWtz4IQLUr+9kSgCxmkaIxeJVIR1bodeDqkWVRRshEQ3McxKZGiu7Fhn0x WgwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l10-v6si1089781pfe.310.2018.09.26.22.10.25; Wed, 26 Sep 2018 22:10:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726681AbeI0L0p (ORCPT + 32 others); Thu, 27 Sep 2018 07:26:45 -0400 Received: from [222.66.158.132] ([222.66.158.132]:15829 "EHLO SHSQR01.unisoc.com" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726590AbeI0L0p (ORCPT ); Thu, 27 Sep 2018 07:26:45 -0400 X-Greylist: delayed 5124 seconds by postgrey-1.27 at vger.kernel.org; Thu, 27 Sep 2018 07:26:44 EDT Received: from SHSQR01.spreadtrum.com (localhost [127.0.0.2] (may be forged)) by SHSQR01.unisoc.com with ESMTP id w8R3hFVR038733 for ; Thu, 27 Sep 2018 11:43:15 +0800 (CST) (envelope-from Chunyan.Zhang@unisoc.com) Received: from ig2.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by SHSQR01.spreadtrum.com with ESMTP id w8R3dgo4033808 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 27 Sep 2018 11:39:43 +0800 (CST) (envelope-from Chunyan.Zhang@unisoc.com) Received: from localhost (10.0.93.106) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.847.32; Thu, 27 Sep 2018 11:41:39 +0800 From: Chunyan Zhang To: Russell King - ARM Linux , Marc Zyngier , Chunyan Zhang CC: Arnd Bergmann , , , Chunyan Zhang Subject: [RESEND PATCH] ARM: prevent tracing IPI_CPU_BACKTRACE Date: Thu, 27 Sep 2018 11:41:37 +0800 Message-ID: <1538019697-14673-1-git-send-email-chunyan.zhang@unisoc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.0.93.106] X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL: SHSQR01.spreadtrum.com w8R3dgo4033808 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann When function tracing for IPIs is enabled, we get a warning for an overflow of the ipi_types array with the IPI_CPU_BACKTRACE type as triggered by raise_nmi(): arch/arm/kernel/smp.c: In function 'raise_nmi': arch/arm/kernel/smp.c:489:2: error: array subscript is above array bounds [-Werror=array-bounds] trace_ipi_raise(target, ipi_types[ipinr]); This is a correct warning as we actually overflow the array here. This patch raise_nmi() to call __smp_cross_call() instead of smp_cross_call(), to avoid calling into ftrace. For clarification, I'm also adding a two new code comments describing how this one is special. The warning appears to have shown up after patch e7273ff49acf ("ARM: 8488/1: Make IPI_CPU_BACKTRACE a "non-secure" SGI"), which changed the number assignment from '15' to '8', but as far as I can tell has existed since the IPI tracepoints were first introduced. If we decide to backport this patch to stable kernels, we probably need to backport e7273ff49acf as well. Resubmiting this patch is because that I found coverity is complaining the issue this patch fixed, and also I got the traces like below: "ipi_raise: target_mask=00000001 (machine_suspend)" which actually was the TPS of suspend_resume[1] rather than ipi_raise. [1] https://elixir.bootlin.com/linux/latest/source/kernel/power/suspend.c#L80 Signed-off-by: Arnd Bergmann Fixes: e7273ff49acf ("ARM: 8488/1: Make IPI_CPU_BACKTRACE a "non-secure" SGI") Fixes: 365ec7b17327 ("ARM: add IPI tracepoints") # v3.17 Signed-off-by: Chunyan Zhang --- arch/arm/include/asm/hardirq.h | 1 + arch/arm/kernel/smp.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/arch/arm/include/asm/hardirq.h b/arch/arm/include/asm/hardirq.h index cba23ea..7a88f16 100644 --- a/arch/arm/include/asm/hardirq.h +++ b/arch/arm/include/asm/hardirq.h @@ -6,6 +6,7 @@ #include #include +/* number of IPIS _not_ including IPI_CPU_BACKTRACE */ #define NR_IPI 7 typedef struct { diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 0978282..123be77 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -75,6 +75,10 @@ enum ipi_msg_type { IPI_CPU_STOP, IPI_IRQ_WORK, IPI_COMPLETION, + /* + * CPU_BACKTRACE is special and not included in NR_IPI + * or tracable with trace_ipi_* + */ IPI_CPU_BACKTRACE, /* * SGI8-15 can be reserved by secure firmware, and thus may @@ -755,7 +759,7 @@ core_initcall(register_cpufreq_notifier); static void raise_nmi(cpumask_t *mask) { - smp_cross_call(mask, IPI_CPU_BACKTRACE); + _smp_cross_call(mask, IPI_CPU_BACKTRACE); } void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self)