From patchwork Sat Oct 17 07:06:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 11842643 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38EF561C for ; Sat, 17 Oct 2020 07:07:48 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A3242074A for ; Sat, 17 Oct 2020 07:07:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="D8zAL3pM"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="dpzFjkTt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A3242074A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=XykbAU8HZ7xv26R6BBednPMGfV0fOn/1y01ahJ9kocc=; b=D8zAL3pMQLRerbT9sKVZb9Isq6 E6HmZ7VZaUVzIUJBlmBEj4E/mVEiuq57Wcjlu3VS4IdG/j9XnhRtXNDvXK/tiXGX4jIUvZSWYT2NL G3dfallTQnOUNQ83qOuBR4K7WPzl5E7cREQD0EC5Gmbm427Ghg2lFdHdQbiansgi+AHOHEZpZD5KZ 2tNDiftWwgCwr5YSR+p/hX2ZaXov9gmrfV2p2ra+RfPp4dZKNbvqP3zxXMNQsmMonPP0i/8E3OUZr 1Kr04diALhNhadV+fky0msERb94tnbNZXD4cNKnFBipJVe+WwoQroRB6MrwPKT4joVrgbr9GCFIff qiPBvcKg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kTgJd-0001s3-NK; Sat, 17 Oct 2020 07:07:45 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kTgJa-0001qZ-OG for linux-riscv@lists.infradead.org; Sat, 17 Oct 2020 07:07:43 +0000 Received: from localhost.localdomain (89.208.247.74.16clouds.com [89.208.247.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 68EA720874; Sat, 17 Oct 2020 07:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602918462; bh=srSubu9UNVpIv85z4Sxt3cqVPcjn15nIxX15NjwY84E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dpzFjkTtPL811x+lpJwIUsz4HBERa5sNFmuY6mD2thtXxMi3r8T3moO1ibeuu+MVi U6jaXZnOVX0H/PB3uxz6F/ox3SyXJj59T8oLtGejlZUhLgTBZIDcSzNpOlvY/zMMo/ TqhJRCBZDvgrw+KNV19U4BzBABU96VedjFKxvadk= From: guoren@kernel.org To: palmerdabbelt@google.com, paul.walmsley@sifive.com, mhiramat@kernel.org, alankao@andestech.com, rostedt@goodmis.org Subject: [PATCH v4 9/9] riscv: Fixup lockdep_assert_held(&text_mutex) in patch_insn_write Date: Sat, 17 Oct 2020 07:06:17 +0000 Message-Id: <1602918377-23573-10-git-send-email-guoren@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1602918377-23573-1-git-send-email-guoren@kernel.org> References: <1602918377-23573-1-git-send-email-guoren@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201017_030742_924519_505569BF X-CRM114-Status: GOOD ( 10.34 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [198.145.29.99 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: me@packi.ch, Guo Ren , anup@brainfault.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, guoren@kernel.org, zong.li@sifive.com, greentime.hu@sifive.com, linux-riscv@lists.infradead.org MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org From: Guo Ren It will cause warning messages: echo function_graph > /sys/kernel/debug/tracing/current_tracer [ 47.691397] ------------[ cut here ]------------ [ 47.692899] WARNING: CPU: 0 PID: 11 at arch/riscv/kernel/patch.c:63 patch_insn_write+0x182/0x19a [ 47.694483] Modules linked in: [ 47.695754] CPU: 0 PID: 11 Comm: migration/0 Not tainted 5.9.0-11367-g1054335 #132 [ 47.698228] epc: ffffffe000204530 ra : ffffffe00020452c sp : ffffffe0023ffc20 gp : ffffffe0013e1fe0 tp : ffffffe0023e4e00 t0 : 0000000000000000 [ 47.701872] t1 : 000000000000000e t2 : 000000000000001b s0 : ffffffe0023ffc70 s1 : ffffffe000206850 a0 : 0000000000000000 a1 : ffffffffffffffff [ 47.705550] a2 : 0000000000000000 a3 : ffffffe03af7c5e8 a4 : 0000000000000000 a5 : 0000000000000000 a6 : 0000000000000000 a7 : 00000000150b02d8 [ 47.709159] s2 : 0000000000000008 s3 : 0000000000000858 s4 : ffffffe0023ffc98 s5 : 0000000000000850 s6 : 0000000000000003 s7 : 0000000000000002 [ 47.714135] s8 : 0000000000000004 s9 : 0000000000000001 s10: 0000000000000001 s11: 0000000000000003 t3 : ffffffffffffe000 t4 : 0000000000d86254 [ 47.716574] t5 : 0000000000000005 t6 : 0000000000040000status: 0000000000000100 badaddr: 0000000000000000 cause: 0000000000000003 [ 47.720019] CPU: 0 PID: 11 Comm: migration/0 Not tainted 5.9.0-11367-g1054335 #132 [ 47.722074] Call Trace: [ 47.722561] [] walk_stackframe+0x0/0xc2 [ 47.724608] [] show_stack+0x46/0x52 [ 47.726246] [] dump_stack+0x90/0xb6 [ 47.727672] [] __warn+0x98/0xfa [ 47.729131] [] report_bug+0xaa/0x11e [ 47.730624] [] do_trap_break+0x96/0xfe [ 47.732448] [] ret_from_exception+0x0/0x14 [ 47.734341] [] patch_insn_write+0x17e/0x19a [ 47.737235] irq event stamp: 39 [ 47.738521] hardirqs last enabled at (39): [] _save_context+0xa2/0xe6 [ 47.741055] hardirqs last disabled at (38): [] multi_cpu_stop+0x130/0x166 [ 47.743551] softirqs last enabled at (0): [] copy_process+0x430/0x1316 [ 47.746031] softirqs last disabled at (0): [<0000000000000000>] 0x0 [ 47.748617] ---[ end trace 88a1054faa6524ef ]--- Because the path of stop_machine(__ftrace_modify_code)-> ftrace_modify_all_code->...->patch_insn_write has no pair of lock&unlock text_mutex, so we shouldn't put assert here. Signed-off-by: Guo Ren --- arch/riscv/kernel/patch.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c index 0b55287..2ee5063 100644 --- a/arch/riscv/kernel/patch.c +++ b/arch/riscv/kernel/patch.c @@ -55,13 +55,6 @@ static int patch_insn_write(void *addr, const void *insn, size_t len) bool across_pages = (((uintptr_t) addr & ~PAGE_MASK) + len) > PAGE_SIZE; int ret; - /* - * Before reaching here, it was expected to lock the text_mutex - * already, so we don't need to give another lock here and could - * ensure that it was safe between each cores. - */ - lockdep_assert_held(&text_mutex); - if (across_pages) patch_map(addr + len, FIX_TEXT_POKE1);