From patchwork Tue Oct 6 21:12:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 7340161 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 2325A9F1D5 for ; Tue, 6 Oct 2015 21:32:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4EAA820627 for ; Tue, 6 Oct 2015 21:32:19 +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 6817320626 for ; Tue, 6 Oct 2015 21:32:18 +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 1ZjZnz-0008Qy-Vl; Tue, 06 Oct 2015 21:29:51 +0000 Received: from mail-pa0-f52.google.com ([209.85.220.52]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZjZnw-00081c-SR for linux-arm-kernel@lists.infradead.org; Tue, 06 Oct 2015 21:29:49 +0000 Received: by pablk4 with SMTP id lk4so220255864pab.3 for ; Tue, 06 Oct 2015 14:29:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1C+YLrL8v5G3usqcFaxsAnGcHIWoDbKsySrk4XVvQrc=; b=NeuonEJ0uB7eBL5/vX7gXlclHQH7rL+wD3zk1V2yuaKHI4Tchoj5YkamDVIgGxNjN3 hlbeABk0MnQ+EZZYtfVHjnGJvLagTl/nzzCi3ZwyWTATpv1idd7XeS39QVA6G6+X8/kh WdbXR6+9mjx27SA6tZEhRQaFVL3sTHuSVfGwno9l2Tea3T3Qb7k5GiaeGZ1QH8n42+sC dL6SxWjuNdq34faCFPztTVGlC8+1G+5tuyJ5dh+Meq3JMPTTsHeIQTfAbSFKWUD/CGAC /TFnilJwv5+sLFIn9wE9ycpNC+6Hcz6ZuOB9CDnOUa1B/RJl+hbPxEvcix2/e0BBxtaT lQWw== X-Gm-Message-State: ALoCoQlJiIr03Kqaehk/XgLNwmFl5/5t5XC2pqCrDttsGCXkoHM87X+S0hwJDXC5q+gAjok+62rI X-Received: by 10.68.137.161 with SMTP id qj1mr49516008pbb.14.1444166967192; Tue, 06 Oct 2015 14:29:27 -0700 (PDT) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id qd5sm35240884pbc.73.2015.10.06.14.29.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Oct 2015 14:29:26 -0700 (PDT) From: Yang Shi To: rostedt@goodmis.org, catalin.marinas@arm.com, will.deacon@arm.com Subject: [v2 PATCH] arm64: convert patch_lock to raw lock Date: Tue, 6 Oct 2015 14:12:31 -0700 Message-Id: <1444165951-26065-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151006_142948_970231_0274085E X-CRM114-Status: GOOD ( 11.22 ) X-Spam-Score: -2.6 (--) 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: yang.shi@linaro.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rt-users@vger.kernel.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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When running kprobe test on arm64 rt kernel, it reports the below warning: root@qemu7:~# modprobe kprobe_example BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:917 in_atomic(): 0, irqs_disabled(): 128, pid: 484, name: modprobe CPU: 0 PID: 484 Comm: modprobe Not tainted 4.1.6-rt5 #2 Hardware name: linux,dummy-virt (DT) Call trace: [] dump_backtrace+0x0/0x128 [] show_stack+0x20/0x30 [] dump_stack+0x1c/0x28 [] ___might_sleep+0x120/0x198 [] rt_spin_lock+0x28/0x40 [] __aarch64_insn_write+0x28/0x78 [] aarch64_insn_patch_text_nosync+0x18/0x48 [] aarch64_insn_patch_text_cb+0x70/0xa0 [] aarch64_insn_patch_text_sync+0x28/0x48 [] arch_arm_kprobe+0x38/0x48 [] arm_kprobe+0x34/0x50 [] register_kprobe+0x4cc/0x5b8 [] kprobe_init+0x38/0x7c [kprobe_example] [] do_one_initcall+0x90/0x1b0 [] do_init_module+0x6c/0x1cc [] load_module+0x17f8/0x1db0 [] SyS_finit_module+0xb4/0xc8 Convert patch_lock to raw lock to avoid this issue. Although the problem is found on rt kernel, the fix should be applicable to mainline kernel too. Signed-off-by: Yang Shi Acked-by: Steven Rostedt --- v1 -> v2: Add Steven's Acked-by Fix subject (remove unnecessary "make") Fix a typo error in commit log arch/arm64/kernel/insn.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c index f341866..c08b9ad 100644 --- a/arch/arm64/kernel/insn.c +++ b/arch/arm64/kernel/insn.c @@ -85,7 +85,7 @@ bool aarch64_insn_is_branch_imm(u32 insn) aarch64_insn_is_bcond(insn)); } -static DEFINE_SPINLOCK(patch_lock); +static DEFINE_RAW_SPINLOCK(patch_lock); static void __kprobes *patch_map(void *addr, int fixmap) { @@ -131,13 +131,13 @@ static int __kprobes __aarch64_insn_write(void *addr, u32 insn) unsigned long flags = 0; int ret; - spin_lock_irqsave(&patch_lock, flags); + raw_spin_lock_irqsave(&patch_lock, flags); waddr = patch_map(addr, FIX_TEXT_POKE0); ret = probe_kernel_write(waddr, &insn, AARCH64_INSN_SIZE); patch_unmap(FIX_TEXT_POKE0); - spin_unlock_irqrestore(&patch_lock, flags); + raw_spin_unlock_irqrestore(&patch_lock, flags); return ret; }