From patchwork Sun Mar 26 15:55:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 9645061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E41AB601D7 for ; Sun, 26 Mar 2017 15:57:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C765120564 for ; Sun, 26 Mar 2017 15:57:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9A51200DF; Sun, 26 Mar 2017 15:57:17 +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=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 41605200DF for ; Sun, 26 Mar 2017 15:57:16 +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: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:In-Reply-To: References:List-Owner; bh=yjJ2yklxXNKXlE1iHll83J3TakJbCFrkFRwCH8hPaEQ=; b=h9r fAKNq/e6RBYPkpz3nDonVv6w6W160ulxUYFdHI22r/ok2kyJbP6cpH8qEvcYy5ZjAAii5u/jF3YsL 2MyBQTJF97qycxXP3B6WFVnhy805bh3OM3VuTBlkQQl1s8sVFtN4urYyKcIcJMCbfzf4skTzNlgKR yLP+T8N2Gn0XHYIsRY9nYTeXrqox1MrXPRjkMMKc74viX/yZd3sM5Q0ADEMcVAe/s+zkWFMdVRQcL L9VhpslpCfFVJ8aWWTcOeP7S4jKLG9UJOUgIfKqbQbHs9et/JvKfE2QEHQpJpR9NbYCo0OMV2CKTI FH1o7NoZhyctPXCNAK9JoafiAiARO7w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1csAXa-0006k4-Jq; Sun, 26 Mar 2017 15:57:14 +0000 Received: from mail-wr0-f193.google.com ([209.85.128.193]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1csAXW-0006i8-O0 for linux-arm-kernel@lists.infradead.org; Sun, 26 Mar 2017 15:57:12 +0000 Received: by mail-wr0-f193.google.com with SMTP id 20so5944815wrx.0 for ; Sun, 26 Mar 2017 08:56:49 -0700 (PDT) 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; bh=uXq3CtXZrQJiVz5ExJgK9B2YCyi0yLPAH98qqR8QIAY=; b=rTo+GOPf6dAbgjiomQn1nT8ljiA4CKvzTbwTY/mEkciVhZmFKA+zU8GrNSTdomkXEh QjgTtdwQ7aHotpvjdKkerV+U346ILjRqAHI7sJ81ygKVYkgjTDpR9L3b/e1gTCCKtbPv nPBN+VI/iZs0POvVv8dfwbX9rLgWGZdH5Ghxxx31ZtnS+e6kQ3vcMmqJmjNmJJgJvMgR I8miPRsvNOnEVe52B7lshkZALWKbkc4KRTpRQ03djzLRRm57k1F+1tkQmPrtOUPjlY6M jHTvlBUaUDUbXtxtSeFPE5N6x3pHUsbpNtgdFRGZLAR2Q7FEak5lxh23qYkys01J05Hs NfVw== X-Gm-Message-State: AFeK/H2uyUMRpS6YzBXZrCYO+v9uBNejhm7A+VqQanY9sxpe5A6CwXFVDMqZohOn8cDAnQ== X-Received: by 10.223.175.202 with SMTP id y10mr6104997wrd.77.1490543806829; Sun, 26 Mar 2017 08:56:46 -0700 (PDT) Received: from localhost.localdomain (cpc91312-watf11-2-0-cust1112.15-2.cable.virginm.net. [82.14.76.89]) by smtp.gmail.com with ESMTPSA id g78sm11308107wrd.11.2017.03.26.08.56.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Mar 2017 08:56:45 -0700 (PDT) From: Abel Vesa To: nicstange@gmail.com, rabin@rab.in, keescook@chromium.org Subject: [RESEND] arm: ftrace: fix dynamic ftrace with DEBUG_RODATA and !FRAME_POINTER Date: Sun, 26 Mar 2017 16:55:49 +0100 Message-Id: <1490543749-20376-1-git-send-email-abelvesa@linux.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170326_085710_945094_722A6D97 X-CRM114-Status: UNSURE ( 9.53 ) X-CRM114-Notice: Please train this message. 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-kernel@vger.kernel.org, Steven Rostedt , Russell King , Abel Vesa , Ingo Molnar , linux-arm-kernel@lists.infradead.org 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 The support for dynamic ftrace with CONFIG_DEBUG_RODATA involves overriding the weak arch_ftrace_update_code() with a variant which makes the kernel text writable around the patching. This override was however added under the CONFIG_OLD_MCOUNT ifdef, and CONFIG_OLD_MCOUNT is only enabled if frame pointers are enabled. This leads to non-functional dynamic ftrace (ftrace triggers a WARN_ON()) when CONFIG_DEBUG_RODATA is enabled and CONFIG_FRAME_POINTER is not. Move the override out of that ifdef and into the CONFIG_DYNAMIC_FTRACE ifdef where it belongs. Fixes: 80d6b0c2eed2a ("ARM: mm: allow text and rodata sections to be read-only") Suggested-by: Nicolai Stange Suggested-by: Rabin Vincent Signed-off-by: Abel Vesa Acked-by: Rabin Vincent --- arch/arm/kernel/ftrace.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c index 3f17594..414e60e 100644 --- a/arch/arm/kernel/ftrace.c +++ b/arch/arm/kernel/ftrace.c @@ -29,11 +29,6 @@ #endif #ifdef CONFIG_DYNAMIC_FTRACE -#ifdef CONFIG_OLD_MCOUNT -#define OLD_MCOUNT_ADDR ((unsigned long) mcount) -#define OLD_FTRACE_ADDR ((unsigned long) ftrace_caller_old) - -#define OLD_NOP 0xe1a00000 /* mov r0, r0 */ static int __ftrace_modify_code(void *data) { @@ -51,6 +46,12 @@ void arch_ftrace_update_code(int command) stop_machine(__ftrace_modify_code, &command, NULL); } +#ifdef CONFIG_OLD_MCOUNT +#define OLD_MCOUNT_ADDR ((unsigned long) mcount) +#define OLD_FTRACE_ADDR ((unsigned long) ftrace_caller_old) + +#define OLD_NOP 0xe1a00000 /* mov r0, r0 */ + static unsigned long ftrace_nop_replace(struct dyn_ftrace *rec) { return rec->arch.old_mcount ? OLD_NOP : NOP;