From patchwork Wed Sep 30 18:23:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 54338 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id E6E0523009 for ; Wed, 30 Sep 2015 18:40:03 +0000 (UTC) Received: by labjc2 with SMTP id jc2sf18268167lab.1 for ; Wed, 30 Sep 2015 11:40:02 -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=C9EnRVwj3E+slCCHpv+Vr/i965uDhTB3LkLX+kTeobM=; b=NsZQggG3hesMaEETBhcQZ2ky7R+6gDju1hxe30fbtHvG9SPZUjr4Mm0PvyN+L27/A8 s237slgGNP0cx2CkkcmCr5Vf6HYBhznhqQo8hN5RadOqTR5N8fmbDqfyI4b59xDky/8n yODuZ2uCaDUgOTfCl+Ud6U93sH+OLkzuYHWDeVDcvEuKP8Yhak144FW1jfCl5rdri/Dg nOYaP3yXM3peIY/8Oohem7Gkitvw4EJ45ZuMPNcu8p0EwgiGfiV8haq/srwkWevIZxsu u0IAeV/IZ6wq1vkFszl/gT4vjlWTHNBgenWp1pTVU57EY36J306cjEhco+DTQMLt86PB 9dUw== X-Gm-Message-State: ALoCoQkEhS1NyfFRf0zIagrd2m8iP/3KJxIsYJDxmRkz8C/AJoYIDajPNVHRrlrTICBVNj7AkLzb X-Received: by 10.112.190.65 with SMTP id go1mr811080lbc.9.1443638402205; Wed, 30 Sep 2015 11:40:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.163.194 with SMTP id m185ls64870lfe.66.gmail; Wed, 30 Sep 2015 11:40:02 -0700 (PDT) X-Received: by 10.112.16.199 with SMTP id i7mr1554292lbd.105.1443638402000; Wed, 30 Sep 2015 11:40:02 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id ad7si835890lbc.116.2015.09.30.11.40.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Sep 2015 11:40:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by laclj5 with SMTP id lj5so57193622lac.3 for ; Wed, 30 Sep 2015 11:40:01 -0700 (PDT) X-Received: by 10.152.26.41 with SMTP id i9mr1612119lag.36.1443638401646; Wed, 30 Sep 2015 11:40:01 -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 w3csp129755lbq; Wed, 30 Sep 2015 11:40:00 -0700 (PDT) X-Received: by 10.107.155.78 with SMTP id d75mr7691888ioe.44.1443638400013; Wed, 30 Sep 2015 11:40:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n40si1743198ioi.161.2015.09.30.11.39.59; Wed, 30 Sep 2015 11:39:59 -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 S933127AbbI3Sj5 (ORCPT + 30 others); Wed, 30 Sep 2015 14:39:57 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:35360 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932495AbbI3Sjz (ORCPT ); Wed, 30 Sep 2015 14:39:55 -0400 Received: by pacfv12 with SMTP id fv12so49104627pac.2 for ; Wed, 30 Sep 2015 11:39:54 -0700 (PDT) X-Received: by 10.67.4.9 with SMTP id ca9mr6620491pad.90.1443638394872; Wed, 30 Sep 2015 11:39:54 -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 dk2sm2026065pbd.57.2015.09.30.11.39.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Sep 2015 11:39:54 -0700 (PDT) From: Yang Shi To: rostedt@goodmis.org, bigeasy@linutronix.de, catalin.marinas@arm.com, will.deacon@arm.com, dave.long@linaro.org Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, yang.shi@linaro.org Subject: [PATCH] arm64: convert patch_lock to raw lock Date: Wed, 30 Sep 2015 11:23:12 -0700 Message-Id: <1443637392-6679-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.53 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 loc kto 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 --- 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; }