From patchwork Thu Oct 18 08:23:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 149100 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1676192lji; Thu, 18 Oct 2018 01:24:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV61gsEhiCGU8OYn1bz+HSE5MRxQGdcv1fzU77YImH8W/Vdt1GPmA2Cv6LxHW12SSsWMuBAxo X-Received: by 2002:aa7:8252:: with SMTP id e18-v6mr29819251pfn.164.1539851072305; Thu, 18 Oct 2018 01:24:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539851072; cv=none; d=google.com; s=arc-20160816; b=aE9+OrrvIt1rnq3UueaczjhR9eCGaALzRT45L+hzlEZ4CWEI2MVlGqo1Jg7fixg3nu +uaTLlXc5f8lN/ckC9Nnp+oRuy9g39p500mMOZldgn0KMdCJsNymbiM5RlbplvuNUS4y 4ggAHmV4GEQ4wwDHmCJoCDpuZZ/Ql7DG3DNDNFiwN9CPF7g5/16uGe4H65/ELQ1mCgOU gkH76SQxGVME2sJdysPDtgB/RHvJVtWqGac5f0/QZEZGcbfJbDnyk3hM44b1y7u6bqXj vxb5mcZ4pYW4RdrozuquLOucc9r9+jxiEvbbXloMhJQcKX9KqDbCcd9SXv+n8D7WeF9W RSyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=lQ4qM7GVWLol2Q0OL4g4jfd2pwuqVD0wkT6TvnQ9zEY=; b=0PXiU9oDOKOAMQKOUMBboScu5tvi9m73BOhksV3+1Pmk8gRrZGJSJnhKvtaSJwVjX/ AVfob17x0In+wxsJGy7fIAMeMv44Od0TrKRO+ZyIgn0oAZigvN5L27IwhgVkQXP4xCoW kE6z2kkwUK046zfA1OtEgrhJfRTIxcDOaNBW+HrBaXAtyfmrKTYrnuNhs1QE0YUpyOdQ PsJG1ehtHIDAi4wYYALi4aD/f20C0R5XlX+/88Ml/xKsL31ER5lVFtIDbZ3G604sE6Z5 jkw/shEeKV+Go4/vpPPDkLm63VQQV2APoC2k+1fa233NAmkJcckuv4Z29/NFNEO+a8Xn 52fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YuxunfCa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13-v6si15350966plr.439.2018.10.18.01.24.32; Thu, 18 Oct 2018 01:24:32 -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; dkim=pass header.i=@linaro.org header.s=google header.b=YuxunfCa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727751AbeJRQYV (ORCPT + 32 others); Thu, 18 Oct 2018 12:24:21 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:36453 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726131AbeJRQYV (ORCPT ); Thu, 18 Oct 2018 12:24:21 -0400 Received: by mail-pg1-f193.google.com with SMTP id f18-v6so13861487pgv.3 for ; Thu, 18 Oct 2018 01:24:29 -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=lQ4qM7GVWLol2Q0OL4g4jfd2pwuqVD0wkT6TvnQ9zEY=; b=YuxunfCakbkPChj/mEm6Z3PK98m5UoevAT/QvMtCbQqUB8Rw7pOKlHw4rQtZMDxhNr B/i62CRmyVgi4JxH8YByPhgXH12aQYXOmS4u7FBiObX1BDo4Gst2k4U5syMruhGru5TK q9ipi9ryA9hsmxgjdMVY1VH6Eahk+2mE+AcAQ= 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=lQ4qM7GVWLol2Q0OL4g4jfd2pwuqVD0wkT6TvnQ9zEY=; b=SPa2i5aNNxikZ0nHsWdHz+r5C2dDbpSlRP9RL9ErbFn0OvrJAiTII9cr46L+Tk5KqA PgvXJj0+nsdqy+SwzjoqBq2vHE0eqAnVK4X7LGiIGAdDCpbZzc0x2/bAuCGRreB6w+v5 aWSQMlB3zqAxu0cnzDKYJqJUI5ggeMIqxweOJ1ITbp4NcCGid3BiuM4itvCU71a1cNdc hyG+XEFkQXcn/1HnHlbMuw5xBcMh06o7zjeSFxWr1SXlxL+qhXQmkap2iRrLF1BE5A4j EF54jvH6sFEKYeQvXL4/fl5Uija53B4T2j316cuQqq6dhuJnAJ7zf43sZPjkqv9Bpr+4 fUuw== X-Gm-Message-State: ABuFfoh4sszX4Vf7V03TxCffFfSncLCm60pmD/w0jYJvRYqRX7myqf5C O7BlxXkyMwfjfM+HWTMftx1P9A== X-Received: by 2002:a65:498b:: with SMTP id r11-v6mr27357237pgs.153.1539851069283; Thu, 18 Oct 2018 01:24:29 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id o76-v6sm36743049pfi.162.2018.10.18.01.24.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 01:24:28 -0700 (PDT) From: Chunyan Zhang To: Russell King , Marc Zyngier Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Chunyan Zhang Subject: [PATCH] ARM: prevent tracing IPI_CPU_BACKTRACE Date: Thu, 18 Oct 2018 16:23:59 +0800 Message-Id: <1539851039-15778-1-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538019697-14673-1-git-send-email-chunyan.zhang@unisoc.com> References: <1538019697-14673-1-git-send-email-chunyan.zhang@unisoc.com> 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. Resubmitting 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 that 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..ddd48e2 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)