From patchwork Fri Sep 5 09:47:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 36790 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8EC49202E4 for ; Fri, 5 Sep 2014 09:49:44 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id fp1sf65891685pdb.9 for ; Fri, 05 Sep 2014 02:49:40 -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=5e00179EObXy1FQLw6rbh9licVN8FegBx9JhnVEYnYo=; b=P1QWT+aftWHR32kVS06szMU2ga+fW6lKfLBo2MwkwT9rE7XgrUmppVgxxC186DaZqk PlWvslghkhgu+0eeqFNzI1MwXl5A/xsGuegmxnBYkY7oyM7hYH15JmYB4YOyJ/gVz0bJ S7hEAusKeaM5eGcatUJrUDCdSSPelpdRzowG/dUtSCAUTgylYCef4DX+5mFERAcvc6aD JSj81njK1aqMLAIxoggeDav7fNG6sn1TbBp3kg8UkQlwqLKOj2N25SGqK/L4dvfFoWYa 7EtIB1SALLbdT8IM8Uo4ONE1OW7g4X+/BZjZAztSJvq9JVf84RP3iI0KZU9xFfh6nOmI M7cw== X-Gm-Message-State: ALoCoQlh+H6KuVN8Hx4jiRnDCAIytVr5pe6Nz5Sn+mbSWlTiJpPA+EBiIxkMUx1z0f3ta/tqarv3 X-Received: by 10.66.196.193 with SMTP id io1mr6283725pac.28.1409910580146; Fri, 05 Sep 2014 02:49:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.33.246 with SMTP id j109ls657876qgj.83.gmail; Fri, 05 Sep 2014 02:49:40 -0700 (PDT) X-Received: by 10.221.68.66 with SMTP id xx2mr9314559vcb.1.1409910580002; Fri, 05 Sep 2014 02:49:40 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id bv6si854409vdb.50.2014.09.05.02.49.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 02:49:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id le20so676771vcb.26 for ; Fri, 05 Sep 2014 02:49:39 -0700 (PDT) X-Received: by 10.220.247.3 with SMTP id ma3mr9218186vcb.29.1409910579918; Fri, 05 Sep 2014 02:49:39 -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.221.45.67 with SMTP id uj3csp56779vcb; Fri, 5 Sep 2014 02:49:39 -0700 (PDT) X-Received: by 10.67.3.162 with SMTP id bx2mr18844361pad.57.1409910579070; Fri, 05 Sep 2014 02:49:39 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dd1si2895400pbc.122.2014.09.05.02.49.37 for ; Fri, 05 Sep 2014 02:49:38 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756973AbaIEJsd (ORCPT + 26 others); Fri, 5 Sep 2014 05:48:33 -0400 Received: from mail-ig0-f177.google.com ([209.85.213.177]:48547 "EHLO mail-ig0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756954AbaIEJsa (ORCPT ); Fri, 5 Sep 2014 05:48:30 -0400 Received: by mail-ig0-f177.google.com with SMTP id r10so2881050igi.16 for ; Fri, 05 Sep 2014 02:48:30 -0700 (PDT) X-Received: by 10.70.100.227 with SMTP id fb3mr19366086pdb.137.1409910507042; Fri, 05 Sep 2014 02:48:27 -0700 (PDT) Received: from localhost.localdomain (KD182249094004.au-net.ne.jp. [182.249.94.4]) by mx.google.com with ESMTPSA id uf6sm1414077pac.16.2014.09.05.02.48.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Sep 2014 02:48:26 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Cc: dsaxena@linaro.org, Vijaya.Kumar@caviumnetworks.com, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [RFC] arm64: kgdb: fix single stepping Date: Fri, 5 Sep 2014 18:47:43 +0900 Message-Id: <1409910463-30936-1-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 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: takahiro.akashi@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.220.181 as permitted sender) smtp.mail=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: , I tried to verify kgdb in vanilla kernel on fast model, but it seems that the single stepping with kgdb doesn't work correctly since its first appearance at v3.15. On v3.15, 'stepi' command after breaking the kernel at some breakpoint steps forward to the next instruction, but the succeeding 'stepi' never goes beyond that. On v3.16, 'stepi' moves forward to the second instruction just after call of do_debug_execption() in el1_dbg, and never goes beyond that. This variance of behavior seems to come in with the following patch in v3.16: commit 2a2830703a23 ("arm64: debug: avoid accessing mdscr_el1 on fault paths where possible") I cannot deny the possibility that this migh be a bug of fast model, but this patch works for me better than vanilla, and hopefully will help you see what's happening behind this issue. Signed-off-by: AKASHI Takahiro --- arch/arm64/include/asm/assembler.h | 7 +++++++ arch/arm64/kernel/entry.S | 4 ++-- arch/arm64/kernel/kgdb.c | 15 ++++++--------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 5901480..a345973 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -87,6 +87,13 @@ 9990: .endm + .macro enable_dbg_if_not_stepping, tmp + mrs \tmp, mdscr_el1 + tbnz \tmp, #0, 9990f + enable_dbg +9990: + .endm + /* * Enable both debug exceptions and interrupts. This is likely to be * faster than two daifclr operations, since writes to this register diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index d5eb447..b882f5d 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -325,7 +325,7 @@ el1_dbg: mrs x0, far_el1 mov x2, sp // struct pt_regs bl do_debug_exception - enable_dbg + enable_dbg_if_not_stepping x2 kernel_exit 1 el1_inv: // TODO: add support for undefined instructions in kernel mode @@ -339,7 +339,7 @@ ENDPROC(el1_sync) .align 6 el1_irq: kernel_entry 1 - enable_dbg + enable_dbg_if_not_stepping x2 #ifdef CONFIG_TRACE_IRQFLAGS bl trace_hardirqs_off #endif diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c index 75c9cf1..bbc085f 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c @@ -176,14 +176,6 @@ int kgdb_arch_handle_exception(int exception_vector, int signo, * over and over again. */ kgdb_arch_update_addr(linux_regs, remcom_in_buffer); - atomic_set(&kgdb_cpu_doing_single_step, -1); - kgdb_single_step = 0; - - /* - * Received continue command, disable single step - */ - if (kernel_active_single_step()) - kernel_disable_single_step(); err = 0; break; @@ -198,13 +190,13 @@ int kgdb_arch_handle_exception(int exception_vector, int signo, */ kgdb_arch_update_addr(linux_regs, remcom_in_buffer); atomic_set(&kgdb_cpu_doing_single_step, raw_smp_processor_id()); - kgdb_single_step = 1; /* * Enable single step handling */ if (!kernel_active_single_step()) kernel_enable_single_step(linux_regs); + err = 0; break; default: @@ -229,7 +221,12 @@ static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int esr) static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr) { + kernel_disable_single_step(); + kgdb_handle_exception(1, SIGTRAP, 0, regs); + + atomic_set(&kgdb_cpu_doing_single_step, -1); + return 0; }