From patchwork Wed Jan 22 04:31:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijay Kilari X-Patchwork-Id: 3521791 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D1C5FC02DC for ; Wed, 22 Jan 2014 04:32:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E712F20122 for ; Wed, 22 Jan 2014 04:32:31 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 672102011E for ; Wed, 22 Jan 2014 04:32:30 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W5pUG-0002Hw-Iy; Wed, 22 Jan 2014 04:32:24 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W5pUE-0003TC-3O; Wed, 22 Jan 2014 04:32:22 +0000 Received: from mail-ig0-f174.google.com ([209.85.213.174]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W5pUB-0003Sp-0n for linux-arm-kernel@lists.infradead.org; Wed, 22 Jan 2014 04:32:19 +0000 Received: by mail-ig0-f174.google.com with SMTP id hl1so12870479igb.1 for ; Tue, 21 Jan 2014 20:31:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=CYpHnSTtY1CwklaE7CkVtYZPuvRzLZkkN4KbotxYPfs=; b=uTvnLp8RAvE6nJ66tU0P1I2kExq0xEQCBUrcuzwwMyavqWRqWXZ/m5fm6EG+NPSu2e 6vJpcXOyRbfj+XotOZNQRfMgKHHBSpKHgYcvLzBHpgqT7UApsjeSzkbFP4yqwEP9RfTs 61xC2eoiclrkNFRoUUtPg1ulAvNfY3mePcQaR/ODJfOjfRvQTE6T7G/HJMTFUxJp3W/S fPQfl7SeJvh+jipC12nCEm4oD2BNKMwV9Cl/pdPHgETNlKNt7ChrTgTMcBOnhh8sgTO4 GPF9JVZtVHK9cfh0K3Dj9O3MH8/m8ohnqThx+FPS0DlrMw5tHf91re3qbasxyshlLXss VZBQ== MIME-Version: 1.0 X-Received: by 10.50.72.36 with SMTP id a4mr21867591igv.40.1390365113839; Tue, 21 Jan 2014 20:31:53 -0800 (PST) Received: by 10.64.14.240 with HTTP; Tue, 21 Jan 2014 20:31:53 -0800 (PST) In-Reply-To: <20140121183604.GQ30706@mudshark.cambridge.arm.com> References: <1387453851-19341-1-git-send-email-vijay.kilari@gmail.com> <20140116134550.GA7496@arm.com> <20140120102302.GC16496@mudshark.cambridge.arm.com> <20140121183604.GQ30706@mudshark.cambridge.arm.com> Date: Wed, 22 Jan 2014 10:01:53 +0530 Message-ID: Subject: Re: [PATCH v6 0/3] AArch64: KGDB support From: Vijay Kilari To: Will Deacon X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140121_233219_121098_D3269FA3 X-CRM114-Status: GOOD ( 23.52 ) X-Spam-Score: -2.7 (--) Cc: Mark Rutland , "linaro-kernel@lists.linaro.org" , "linux@arm.linux.org.uk" , Prasun Kapoor , Catalin Marinas , Vijaya Kumar K , Sandeepa Prabhu , "jason.wessel@windriver.com" , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Wed, Jan 22, 2014 at 12:06 AM, Will Deacon wrote: > On Tue, Jan 21, 2014 at 02:10:14PM +0000, Vijay Kilari wrote: >> Hi Will, > > Hello Vijay, > >> On Mon, Jan 20, 2014 at 3:53 PM, Will Deacon wrote: >> > Well, the warnings are one thing but the 100 miles of backtrace output that >> > appear on every boot (and I think end in an oops) are probably more >> > important to fix. Please enable CONFIG_KGDB_TESTS and >> > CONFIG_KGDB_TESTS_ON_BOOT and take a look. >> > >> >> I could manage to run KGDB boot tests if I run from sysfs after complete boot >> >> echo V1F1000 > /sys/module/kgdbts/parameters/kgdbts >> >> Here the value of PSTATE is 80000145, which means PSTATE.D is unmasked >> hence it works fine. >> >> If I run during boot by enabling CONFIG_KGDB_TESTS_ON_BOOT, >> the step debug test fail because value of PSTATE is 80000345. >> If I force PSTATE.D to 0, it works fine >> >> In debug_monitors.c file, only PSTATE.SS & MDSCR.KDE/MDE is managed >> but not PSTATE.D >> >> Can you please let me know if where PSTATE.D is managed in arm64? > > That's a good point: I think we wait until our first exception before they > are unmasked. Perhaps we should: > > (1) Move local_dbg_{save,restore} from debug-monitors.h into irqflags.h > (2) Add local_dbg_enable/local_dbg_disable macros > (3) Add a call to local_dbg_enable in the clear_os_lock function after the > isb(). > > Does that work for you? Yes, only after first exception occurs the PSTATE.D is unmasked. I have patched (temp) as below and now KGDB boot tests pass boot test: [32927.161317] msgmni has been set to 1870 [32927.212747] alg: No test for stdrng (krng) [32927.213953] Key type asymmetric registered [32927.214899] Asymmetric key parser 'x509' registered [32927.220029] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253) [32927.225824] io scheduler noop registered [32927.226764] io scheduler deadline registered [32927.230714] io scheduler cfq registered (default) [32927.237895] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled [32927.266066] kgdb: Registered I/O driver kgdbts. [32927.266419] kgdb: Waiting for connection from remote gdb... [32927.268598] kgdbts:RUN plant and detach test [32927.270683] kgdbts:RUN sw breakpoint test [32927.287659] kgdbts:RUN bad memory access test [32927.290322] kgdbts:RUN singlestep test 1000 iterations [32927.330342] kgdbts:RUN singlestep [0/1000] [32931.286356] kgdbts:RUN singlestep [100/1000] [32935.242536] kgdbts:RUN singlestep [200/1000] [32939.205392] kgdbts:RUN singlestep [300/1000] [32943.169522] kgdbts:RUN singlestep [400/1000] [32947.231868] kgdbts:RUN singlestep [500/1000] [32951.188008] kgdbts:RUN singlestep [600/1000] [32955.332243] kgdbts:RUN singlestep [700/1000] [32959.467109] kgdbts:RUN singlestep [800/1000] [32963.430888] kgdbts:RUN singlestep [900/1000] [32967.346992] kgdbts:RUN do_fork for 100 breakpoints kgdb test using sysfs: ~ # echo V1F1000 > /sys/module/kgdbts/parameters/kgdbts [33231.554237] kgdb: Registered I/O driver kgdbts. [33231.554677] kgdbts:RUN plant and detach test [33231.557072] kgdbts:RUN sw breakpoint test [33231.576980] kgdbts:RUN bad memory access test [33231.580022] kgdbts:RUN singlestep test 1000 iterations [33231.627056] kgdbts:RUN singlestep [0/1000] [33235.954027] kgdbts:RUN singlestep [100/1000] [33240.429086] kgdbts:RUN singlestep [200/1000] [33244.687118] kgdbts:RUN singlestep [300/1000] [33248.945191] kgdbts:RUN singlestep [400/1000] [33253.203751] kgdbts:RUN singlestep [500/1000] [33257.462019] kgdbts:RUN singlestep [600/1000] [33261.817809] kgdbts:RUN singlestep [700/1000] [33266.081268] kgdbts:RUN singlestep [800/1000] [33270.339813] kgdbts:RUN singlestep [900/1000] [33274.712404] kgdbts:RUN do_fork for 1000 breakpoints ~ # This works for me. Should I patch it or will you send a patch for this? PS: cc to mailing list missed > > Will diff --git a/arch/arm64/include/asm/debug-monitors.h b/arch/arm64/include/asm/debug-monitors.h index aff3a76..ea2bc46 100644 --- a/arch/arm64/include/asm/debug-monitors.h +++ b/arch/arm64/include/asm/debug-monitors.h @@ -64,6 +111,24 @@ struct task_struct; #define DBG_ARCH_ID_RESERVED 0 /* In case of ptrace ABI updates. */ +#define local_dbg_enable() \ + do { \ + asm volatile( \ + "msr daifclr, #9 // arch_local_irq_disable" \ + : \ + : \ + : "memory"); \ + } while (0) + +#define local_dbg_disable() \ + do { \ + asm volatile( \ + "msr daifset, #9 // arch_local_irq_disable" \ + : \ + : \ + : "memory"); \ + } while (0) + struct step_hook { struct list_head node; int (*fn)(struct pt_regs *regs, unsigned int insn, unsigned long addr); diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c index f8b90c0..d0e55f7 100644 --- a/arch/arm64/kernel/debug-monitors.c +++ b/arch/arm64/kernel/debug-monitors.c @@ -139,6 +142,7 @@ static void clear_os_lock(void *unused) { asm volatile("msr oslar_el1, %0" : : "r" (0)); isb(); + local_dbg_enable(); }