From patchwork Thu Nov 12 09:50:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 7600621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4AC759F1D3 for ; Thu, 12 Nov 2015 09:52:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 665B920772 for ; Thu, 12 Nov 2015 09:52:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 729D92075F for ; Thu, 12 Nov 2015 09:52:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZwoWk-0004S0-U4; Thu, 12 Nov 2015 09:50:46 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZwoWh-0004DL-F9 for linux-arm-kernel@lists.infradead.org; Thu, 12 Nov 2015 09:50:44 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 391DE140936; Thu, 12 Nov 2015 09:50:22 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 29F5B140958; Thu, 12 Nov 2015 09:50:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: sboyd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id C2117140955; Thu, 12 Nov 2015 09:50:21 +0000 (UTC) Date: Thu, 12 Nov 2015 01:50:20 -0800 From: Stephen Boyd To: Ard Biesheuvel Subject: pj4 -marm breaks thumb ftrace Message-ID: <20151112095020.GB15032@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151112_015043_546090_06FF0B4A X-CRM114-Status: GOOD ( 15.46 ) X-Spam-Score: -2.9 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Olof Johansson , Russell King , linux-arm-kernel@lists.infradead.org, Nicolas Pitre 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 When I boot up a thumb2 multi-v7 kernel with ftrace enabled I get this ftrace bug splat. WARNING: CPU: 0 PID: 0 at kernel/trace/ftrace.c:1979 ftrace_bug+0x115/0x1bc() Modules linked in: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.3.0-10337-g3ea2911b81d3-dirty #129 Hardware name: Qualcomm (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x11/0x14) [] (show_stack) from [] (dump_stack+0x57/0x6c) [] (dump_stack) from [] (warn_slowpath_common+0x57/0x88) [] (warn_slowpath_common) from [] (warn_slowpath_null+0x17/0x1c) [] (warn_slowpath_null) from [] (ftrace_bug+0x115/0x1bc) [] (ftrace_bug) from [] (ftrace_process_locs+0x1d7/0x3e4) [] (ftrace_process_locs) from [] (ftrace_init+0x49/0xb0) [] (ftrace_init) from [] (start_kernel+0x26f/0x2d8) [] (start_kernel) from [<0020807f>] (0x20807f) ---[ end trace cb88537fdc8fa200 ]--- ftrace failed to modify [] iwmmxt_do+0x8/0x3c actual: dc:f8:ff:fa ftrace record flags: 0 (0) expected tramp: c030c565 I suspect this is caused by commit 13d1b9575ac2 (ARM: 8221/1: PJ4: allow building in Thumb-2 mode, 2014-11-25) which adds an -marm flag to the compilation of arch/arm/kernel/pj4-cp0.c. When ftrace tries to replace the instruction in ftrace_make_nop() -> ftrace_modify_code(), it gets confused because it checks to make sure the instruction it's replacing is actually a branch to mcount with a thumb encoding. But given that the branch is done in arm instead of thumb it doesn't see the instruction it's looking for and bails out with this bug. Should we mark this whole file as notrace? That at least seems to fix the problem for me. I imagine we could make things more complicated and try to figure out if the branch is either arm or thumb and replace it with the appropriate nop or interworking branch to ftrace code, but do we really care? Here's the simple patch. -----8<---- diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index af9e59bf3831..f65daa440610 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -73,6 +73,7 @@ obj-$(CONFIG_IWMMXT) += iwmmxt.o obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o obj-$(CONFIG_HW_PERF_EVENTS) += perf_event_xscale.o perf_event_v6.o \ perf_event_v7.o +CFLAGS_REMOVE_pj4-cp0.o = -pg CFLAGS_pj4-cp0.o := -marm AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt obj-$(CONFIG_ARM_CPU_TOPOLOGY) += topology.o