Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1580415imm; Wed, 26 Sep 2018 22:12:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV60xAsKzsxAynw9ngmCbf1wT8rK6ilSV7NBVOAc4mevZWJjsBMeAaw7Rqz65JNmkcRcoo9mj X-Received: by 2002:a17:902:2e01:: with SMTP id q1-v6mr9085904plb.40.1538025122470; Wed, 26 Sep 2018 22:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538025122; cv=none; d=google.com; s=arc-20160816; b=mPiQUiQhjNHJYbqunDKiwQk0qmeuweM/Tnqy8ibpl9TLylKr4rtCuQ/2AdsYMb40V0 rlPWsZfzXHZlWXmCoL7A6f3NVj6GUtMLKKrZ5Z7B9QuYnn8Y/MLjQQ43FJVLIbM3UlCR El532JkMFfaVdRIN08Q8XE7s8HZykCupaBFii3URGzrtbA/uTmEwXQKgAPuAhlpDmcl5 AZEkf9GiFzZ641J1q/ZuRTMPYyqAureDUGghEvUQ5zcQFdg94Icvh016EriPJRA1mgal 8DVdbevMYJfmSv8B2czMTPWL1XdQIiDaMqj0Fx+FIP7WYNnWXESOQWSAV6XhkTCU9rxS ja4g== 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 x68-v6si96596pfc.205.2018.09.26.22.11.47; Wed, 26 Sep 2018 22:12:02 -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 S1726632AbeI0L0p (ORCPT + 99 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 Content-Type: text/plain 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(-) 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) -- 2.7.4