From patchwork Tue Oct 3 05:10:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 9981653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 629C260291 for ; Tue, 3 Oct 2017 05:09:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D7E42870E for ; Tue, 3 Oct 2017 05:09:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FCC12871B; Tue, 3 Oct 2017 05:09:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8612B2870E for ; Tue, 3 Oct 2017 05:09:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=H5TegBhsFmRxHFcMxAmhnr5pO+PbzWhnjbfwqyP/M+Y=; b=aaXEPP0u0+ZbWgSVGLaYXNb/Qw uiVEvlTJ3z0RrhZr7TNUwTMa9cnyl8HkUqcYcG0yojkaLeNkl4FzP70NjRUz8W1nKYNbjq1XaTvRf hzALVyobl9mVztyFZrbcUoHGE4E/q3oQQl+ak7XWTUsuJ+NxnLQqYnbJnfd11Y98lXnSTaJdMSdhM 9bnSpPwWYC+07w2QCAbjQHfFjnc2H+E/j8VRKx4x9EQ6KEFlqOe8m5CyMzEUbzGf7nsoJoNT6G57q EOUSLSLCiltMVkjfTPF/6G4Eqc6Lh6YBmRtjgfXR4biTwpjb1bFOGJK98KPUbEFQ4zKV85bW7W/y9 BHoqG6QQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dzFSG-0007tf-90; Tue, 03 Oct 2017 05:09:16 +0000 Received: from mail-pf0-x22b.google.com ([2607:f8b0:400e:c00::22b]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dzFRd-0007UQ-E2 for linux-arm-kernel@lists.infradead.org; Tue, 03 Oct 2017 05:09:04 +0000 Received: by mail-pf0-x22b.google.com with SMTP id n14so2130270pfh.8 for ; Mon, 02 Oct 2017 22:08:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=e4oJGDkED1AnSe6F9X9iHSTPOMExVdrmg0KyFhyiBbo=; b=R8XilI/r/cEgUXx+IY7d8TB67ZckfzJt9fzy5vz+Fa65Lz71B4musLQ2j6BCz3wKyO B6NTUNQeOEZSuBriZnfWAM/UUJvcPm5pwn6R8Wqbeqt1KzrXq/P1Vpf3vUak4vcm5o4Y vokbw7+gaFxSgmfqi2uI8UdPUsmnCiNb/0erM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=e4oJGDkED1AnSe6F9X9iHSTPOMExVdrmg0KyFhyiBbo=; b=DRwJoWdMPk4QflU5EYv8N1RmbwjjrpDHad9AkPqKu4y8iDNNH3FkNEecEo7VY8fdiU dLRNAMHUJz5haphAEoDeaj/k27ITgVB/IgxJA/YwRFAnfSaihGsGxAdKLVjTnkjK4ZD1 acWu8rTB6NzXilWW+Bk5/R9sUTI/ushe9TS0giy7o557GWJOG2dSuRvB2RthScCB9ere MNXuQfl5WavYyPvW+0uO9sXENgwMbOp+DBdtuOPx052x2eU6WTLIbJNmkXWbUU/nENko 3rAHlG7QK7koqRFzuxwPPybyEcCgF+rHBSnjtWBw1O9SVONDIQ+Q24h8vCraetCG4h6l wItg== X-Gm-Message-State: AMCzsaU58JkyQSvo5pORLq8nnQJ+vwww2JiliUmXgwa58F8laxR1pQkK MaAEMomFJxcU2iQweTH8ShkrogbPUgw= X-Google-Smtp-Source: AOwi7QASDXMajsao+OjjkN3ZWXxC++M8vgfutoITd31hQiJm8CkJAEYOhpxvEyHTpUR2utYTbN1mRg== X-Received: by 10.99.116.89 with SMTP id e25mr1502913pgn.316.1507007296517; Mon, 02 Oct 2017 22:08:16 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id e3sm1997702pgq.62.2017.10.02.22.08.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 22:08:15 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, jason.wessel@windriver.com Subject: [PATCH v4 1/3] arm64: kgdb: fix single stepping Date: Tue, 3 Oct 2017 14:10:17 +0900 Message-Id: <20171003051019.29714-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171003051019.29714-1-takahiro.akashi@linaro.org> References: <20171003051019.29714-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171002_220838_009331_6A29DB08 X-CRM114-Status: GOOD ( 12.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kgdb-bugreport@lists.sourceforge.net, linux-arm-kernel@lists.infradead.org, AKASHI Takahiro MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP After entering kgdb mode, the first 'stepi' can succeed, but the following 'stepi' never executes the next instruction. This is because a software step cannot get enabled as the software step bit(SS) in SPSR, which is cleared by the first single stepping, will not be set again for the following 's' commands. Please note that this bit, as well as the software step control bit(SS) in MDSCR, must be set before resuming the execution. If you want to take a single step with interrupts disabled, please try the following gdb macro: ===8<=== define my-si set $instr = *(int *)$pc set $opsr = $cpsr set $cpsr = $cpsr | 0x80 stepi # If interrupt was enabled before stepi, restore the I flag. if !($opsr & 0x80) # msr daifset, if (($instr & 0xfffff0ff) == 0xd50340df) if !($instr & 0x200) set $cpsr = $cpsr & ~0x80 end else # msr daif, if (($instr & 0xffffffe0) == 0xd51b4220) eval "set $val = $x%d", $instr & 0x1f if !($val & 0x80) set $cpsr = $cpsr & ~0x80 end else set $cpsr = $cpsr & ~0x80 end end end end ===>8=== Signed-off-by: AKASHI Takahiro Cc: Catalin Marinas Cc: Will Deacon Cc: Jason Wessel --- arch/arm64/kernel/kgdb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c index 2122cd187f19..8d3ec8cf4ec4 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c @@ -253,6 +253,10 @@ static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr) return DBG_HOOK_ERROR; kgdb_handle_exception(1, SIGTRAP, 0, regs); + + /* rewind a single step */ + regs->pstate |= DBG_SPSR_SS; + return 0; } NOKPROBE_SYMBOL(kgdb_step_brk_fn);