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: 10646863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8971917D4 for ; Thu, 18 Oct 2018 08:24:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 785F128827 for ; Thu, 18 Oct 2018 08:24:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CB5728834; Thu, 18 Oct 2018 08:24:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5DBCF28827 for ; Thu, 18 Oct 2018 08:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=Idv8hhlNM/G8vB6msH4pK59ycWOBQJ35GOtweUhP/uY=; b=oMhctC0LrAGq9ZsTe/35QH3VFc U7ygRGhXypqAl9PMyhrcE5d73IXEO07Tcngmq/uIkfqJR8jgr6zxQbbZiZhinkNOnrQVYEjNRcs6n ZXs1HJ9muS0HOxJS+BDlIrcpJ9MJfRYWas8HpQBEk4F5dA28NCAf5GLhZR9RjWDxu5H5nvbr90twc BTF9Wf0XL9V8ADN4uuyWDHwf1Gr0uQUOB+q1M13KTKa80iEy8S8Dl2kLQYcmuWgf2lH5n+iJcGnUM EDPZf0sQUuI8OZ2xS+FvGoa+D5n31UXtGkXTVYc//cBKCi+mIftmPzUItpZI0L5shQ+Fy2RSBshcM o1FvR13Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gD3bo-0005jf-94; Thu, 18 Oct 2018 08:24:44 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gD3bk-0005iM-Jq for linux-arm-kernel@lists.infradead.org; Thu, 18 Oct 2018 08:24:42 +0000 Received: by mail-pg1-x543.google.com with SMTP id c10-v6so13851822pgq.4 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=BfUEB/lBNHw7ckuipGZd5VIO54wWa0+o0BucN9DhIzmjAi9WiE2pP3T9RsE40aILuN PvMf9oBJ2wtjIx3Exu+3F4cOfocQY1BPxMpBLWTZfS9FSYXu/krnI48P/gbw2ivd2MyV aku1sBOhBOqnDdEr81oxCDmkAH5o5rJuZCaWqk44ROVxWdSz8LMTiL5jAVFHZdHQdaC5 1pAQCh1dUG0rrYuwPF1swBM5r/0GMtPkOli+PsfC1NCiRGJ4yVwkpHzaUEruAnh8tSQD fTNfVv4KDfK4FT4xlcgItGscy+v8psxeuQPEum2qAUdN7ze0ReA2XzTQPet7gHyaP99M 7pKw== X-Gm-Message-State: ABuFfogoWMQAp0SQZdzCGH4ekfPdprzS9JIAg/wA386d+EH59tSezL8U oahWgl8IcqmvfBOIrQGUyya9Ig== X-Google-Smtp-Source: ACcGV62CQ1AfBglm9yOGYNwyeFh8efoO20DS0F1pM1Wet8/f2Et28cNa5aKh2SEt9mjaWRRfZv4COA== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181018_012440_673782_900FD1B1 X-CRM114-Status: GOOD ( 18.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Chunyan Zhang , linux-kernel@vger.kernel.org, Arnd Bergmann MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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)