From patchwork Wed Feb 25 11:46:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 5879331 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 D7C329F691 for ; Wed, 25 Feb 2015 11:50:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 62C8A20373 for ; Wed, 25 Feb 2015 11:50:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5644020353 for ; Wed, 25 Feb 2015 11:50:26 +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 1YQaRs-0002Iu-4E; Wed, 25 Feb 2015 11:48:16 +0000 Received: from szxga01-in.huawei.com ([119.145.14.64]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YQaRm-0002Bq-F7; Wed, 25 Feb 2015 11:48:11 +0000 Received: from 172.24.2.119 (EHLO szxeml427-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CJX00185; Wed, 25 Feb 2015 19:47:07 +0800 (CST) Received: from [127.0.0.1] (10.111.69.129) by szxeml427-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.3.158.1; Wed, 25 Feb 2015 19:46:55 +0800 Message-ID: <54EDB629.4020908@huawei.com> Date: Wed, 25 Feb 2015 19:46:49 +0800 From: Wang Nan User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: Masami Hiramatsu Subject: Re: [RFC PATCH v3 00/26] Early kprobe: enable kprobes at very early booting stage. References: <1423805941-61407-1-git-send-email-wangnan0@huawei.com> <54E6B139.20909@hitachi.com> <54EDADD6.5070404@huawei.com> In-Reply-To: <54EDADD6.5070404@huawei.com> X-Originating-IP: [10.111.69.129] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150225_034810_872915_17CC7148 X-CRM114-Status: GOOD ( 10.49 ) X-Spam-Score: -2.3 (--) Cc: tixy@linaro.org, mark.rutland@arm.com, peterz@infradead.org, catalin.marinas@arm.com, dave.hansen@linux.intel.com, linux-kernel@vger.kernel.org, yalin.wang2010@gmail.com, JBeulich@suse.com, hpa@zytor.com, jkenisto@us.ibm.com, keescook@chromium.org, prarit@redhat.com, linux@arm.linux.org.uk, nico@linaro.org, stefani@seibold.net, x86@kernel.org, anil.s.keshavamurthy@intel.com, mingo@redhat.com, dave.long@linaro.org, Yalin.Wang@sonymobile.com, rusty@rustcorp.com.au, rostedt@goodmis.org, fabf@skynet.be, anton@samba.org, "yrl.pp-manager.tt@hitachi.com" , tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, ananth@in.ibm.com, oleg@redhat.com, luto@amacapital.net, lizefan@huawei.com, hannes@cmpxchg.org, akpm@linux-foundation.org, davem@davemloft.net X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 On 2015/2/25 19:11, Wang Nan wrote: > On 2015/2/20 11:59, Masami Hiramatsu wrote: >> Hi, >> >> Sorry for replying late. >> >> (2015/02/13 14:39), Wang Nan wrote: >>> I fell very sorry for people who reviewed my v2 patch series yesterday >>> at https://lkml.org/lkml/2015/2/12/234 because I didn't provide enough >>> information in commit log. This v3 patch series add those missing >>> commit messages. There are also 2 small fix based on v2: >>> >>> 1. Fixes ftrace_sort_mcount_area. Original patch doesn't work for module. >>> 2. Wraps setting of kprobes_initialized in stop_machine() context. >> >> From the viewpoint of the maintenance, it seems over-engineered and >> not general implementation. Please reconsider just initializing breakpoint >> handler in earlier stage. Since those exceptions may happen anywhere, >> those trap handlers setup very early stage. E.g. on x86, setup_arch() >> setup early_trap_init() at beginning. So we just need to initialize >> kprobes earlier. > > I tried as your suggestion. For x86, int3 handler doesn't work correctly until > trap_init(). I don't have enough time to look into this problem today (and I don't > familiar with x86 architecture). Could you please have a look on it? > > Thank you. > Hi Masami, Sorry for the noise. I have futher information may be useful. I initialize kprobe and probed an instruction with int3 between setup_arch() and trap_init(). It doesn't work at first. By dumping __log_buf[] I fount it reports NULL pointer panic. With some random test I found following patch, which makes it works (looks like) correctly. However I think there must be some reason to set dpl to '3' instead of '0' (set_mni_gate use 0 as dpl). Do you have any suggestion on it? Thank you. ------------- The patch --------------- diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 9d2073e..ac29277 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -925,9 +925,9 @@ dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code) /* Set of traps needed for early debugging. */ void __init early_trap_init(void) { - set_intr_gate_ist(X86_TRAP_DB, &debug, DEBUG_STACK); + set_intr_gate_ist(X86_TRAP_DB, &debug, 0); /* int3 can be called from all */ - set_system_intr_gate_ist(X86_TRAP_BP, &int3, DEBUG_STACK); + set_intr_gate_ist(X86_TRAP_BP, &int3, 0); #ifdef CONFIG_X86_32 set_intr_gate(X86_TRAP_PF, page_fault); #endif