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: 54564 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id 4F71722F05 for ; Tue, 6 Oct 2015 21:29:34 +0000 (UTC) Received: by laff3 with SMTP id f3sf32833656laf.0 for ; Tue, 06 Oct 2015 14:29:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=2qNhuimx1UMqreZKRLwFSRQAJutX3zlkmw7/Vdu7pRI=; b=Ltz+71/YqLK/sfzngFYcfGTdw6Mm6JW2oyBXucmQPz8DFYqlW+qqDVyRM9//1QGmC5 8/j9JO4yP6cjJSsDqLEhm6chCl7uqm/3vXQfP7XQGp2LoKuk0qgqQ9/N9s4wxUsYgopJ 3/PMFyo4D2AwgNJ2cwJQ7dCN+jCWme7TAwmY4R6u8LxYzUgzgtZ32e8tUEBZkXO0aWz1 d5p4SKQwyPh1uKXJcSiu9Y56BqlpPuBWsVsxLn+F9ZNv8q3Q456HdLYJdrLOp2+XSkw1 zkGY6dobX3rnjtbIDyhxJILf+OghW0s0s1W2SlFW8OQ48AwLM/aQaShhOnS/pVE9Tow8 Efzg== X-Gm-Message-State: ALoCoQmO/4KIkZ4OZDNzhLsLBCmo9azw6BPqejZ66cMLHejPIuTD9gGLKfhVZNkqvyK1LtnZzo3V X-Received: by 10.112.198.33 with SMTP id iz1mr6787190lbc.8.1444166973244; Tue, 06 Oct 2015 14:29:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.169.198 with SMTP id s189ls545283lfe.87.gmail; Tue, 06 Oct 2015 14:29:33 -0700 (PDT) X-Received: by 10.25.80.77 with SMTP id e74mr10210827lfb.11.1444166973014; Tue, 06 Oct 2015 14:29:33 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id x128si22500068lfd.127.2015.10.06.14.29.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Oct 2015 14:29:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lacdq7 with SMTP id dq7so9618776lac.2 for ; Tue, 06 Oct 2015 14:29:32 -0700 (PDT) X-Received: by 10.25.205.198 with SMTP id d189mr10156371lfg.72.1444166972427; Tue, 06 Oct 2015 14:29:32 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2078093lbq; Tue, 6 Oct 2015 14:29:31 -0700 (PDT) X-Received: by 10.50.23.80 with SMTP id k16mr18633386igf.62.1444166971136; Tue, 06 Oct 2015 14:29:31 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si15083172igk.92.2015.10.06.14.29.30; Tue, 06 Oct 2015 14:29:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752754AbbJFV33 (ORCPT + 30 others); Tue, 6 Oct 2015 17:29:29 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:33157 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751829AbbJFV31 (ORCPT ); Tue, 6 Oct 2015 17:29:27 -0400 Received: by pacex6 with SMTP id ex6so221373885pac.0 for ; Tue, 06 Oct 2015 14:29:27 -0700 (PDT) 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 Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: yang.shi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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; }