From patchwork Mon May 9 17:39:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 9048681 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AAD68BF29F for ; Mon, 9 May 2016 17:41:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A99B120114 for ; Mon, 9 May 2016 17:41:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B918920103 for ; Mon, 9 May 2016 17:41:42 +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 1azpA7-000813-3j; Mon, 09 May 2016 17:40:07 +0000 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1azpA3-000762-Rm for linux-arm-kernel@lists.infradead.org; Mon, 09 May 2016 17:40:04 +0000 Received: by mail-wm0-x236.google.com with SMTP id a17so199956197wme.0 for ; Mon, 09 May 2016 10:39:42 -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; bh=EDUYDt7Gminp0pybeCXe+oCHVHAHjQhIWRYVc7BHsGA=; b=Fywv8uziqKtUhVNoMlLLW+6n/VwLlT5Mr1KCMse2QXLYTx4mrVS5VYpJ6sqv06W/Uo BRPtrmDas1h1oLXn5oOWcD+wV0KDHZX04kk7oMzogNw7y3WGH0p79hFK9wjWUxHBPXT0 SJ2xHSNkMBEgh01TOJcvoYfhTUA4/a+uPo0W0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=EDUYDt7Gminp0pybeCXe+oCHVHAHjQhIWRYVc7BHsGA=; b=giT8BWH9+g6nrS4yvB5iTIk9vDVgDTL6BpuOaiiG3FkQrGd43aDDbcd+hE1hu5p9iz nRkMD5bkVFjT7ShnjxIIzjVAt562nmOiyTpvlidCfS+DzgvVsiwEq5eRWDbDRkmLzeIH hH3jMT772KtMGxopmoCMyP6pDUdHvnHMw4dSzH4Vc0rgBdANxpeO+LjwWGDVSoDyPNHp LcpF+ojpf60vYu5J9TLcDsEm1WfrkIn0qmcbd3xfencI5/HLhxOPG2BzxKTB30tj51GP T5lBCnxhFFGG1X4xZpLDSER3QTGPGxL24ktBsI2qZWOY/I1Z4Z/uRXw3BFPr1lc0FK9I lduQ== X-Gm-Message-State: AOPr4FW504Ptqb37F2CeJ0fJE9VlgQ1qadfmSxLE4O3JgD+TAIbIU0CTELjuRWqq/4uV5B3q X-Received: by 10.194.139.104 with SMTP id qx8mr33745828wjb.14.1462815581612; Mon, 09 May 2016 10:39:41 -0700 (PDT) Received: from wychelm.lan (cpc4-aztw19-0-0-cust71.18-1.cable.virginm.net. [82.33.25.72]) by smtp.gmail.com with ESMTPSA id az2sm32354885wjc.6.2016.05.09.10.39.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 May 2016 10:39:40 -0700 (PDT) From: Daniel Thompson To: Catalin Marinas , Will Deacon Subject: [PATCH] arm64: kgdb: Match pstate size with gdbserver protocol Date: Mon, 9 May 2016 18:39:26 +0100 Message-Id: <1462815566-15086-1-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.5.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160509_104004_065378_BFC25881 X-CRM114-Status: GOOD ( 16.92 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Daniel Thompson , linaro-kernel@lists.linaro.org, patches@linaro.org, Vijaya Kumar K , linux-kernel@vger.kernel.org, Jason Wessel , Dave P Martin , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 Current versions of gdb do not interoperate cleanly with kgdb on arm64 systems because gdb and kgdb do not use the same register description. This patch modifies kgdb to work with recent releases of gdb (>= 7.8.1). Compatibility with gdb (after the patch is applied) is as follows: gdb-7.6 and earlier Ok gdb-7.7 series Works if user provides custom target description gdb-7.8(.0) Works if user provides custom target description gdb-7.8.1 and later Ok When commit 44679a4f142b ("arm64: KGDB: Add step debugging support") was introduced it was paired with a gdb patch that made an incompatible change to the gdbserver protocol. This patch was eventually merged into the gdb sources: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=a4d9ba85ec5597a6a556afe26b712e878374b9dd The change to the protocol was mostly made to simplify big-endian support inside the kernel gdb stub. Unfortunately the gdb project released gdb-7.7.x and gdb-7.8.0 before the protocol incompatibility was identified and reversed: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=bdc144174bcb11e808b4e73089b850cf9620a7ee This leaves us in a position where kgdb still uses the no-longer-used protocol; gdb-7.8.1, which restored the original behaviour,If was released on 2014-10-29. I don't believe it is possible to detect/correct the protocol incompatiblity which means the kernel must take a view about which version of the gdb remote protocol is "correct". This patch takes the view that the original/current version of the protocol is correct and that version found in gdb-7.7.x and gdb-7.8.0 is anomalous. Signed-off-by: Daniel Thompson --- Notes: Vijaya: I really hope I have the history lesson in the commit message correct! I've done a fair bit of archeology to unpick things. arch/arm64/include/asm/kgdb.h | 13 +++++-------- arch/arm64/kernel/kgdb.c | 7 ++++++- 2 files changed, 11 insertions(+), 9 deletions(-) -- 2.5.5 diff --git a/arch/arm64/include/asm/kgdb.h b/arch/arm64/include/asm/kgdb.h index f69f69c8120c..326fa8f44da5 100644 --- a/arch/arm64/include/asm/kgdb.h +++ b/arch/arm64/include/asm/kgdb.h @@ -43,20 +43,17 @@ extern int kgdb_fault_expected; * General purpose regs: * r0-r30: 64 bit * sp,pc : 64 bit - * pstate : 64 bit - * Total: 34 + * pstate : 32 bit + * Total: 33 + 1 * FPU regs: * f0-f31: 128 bit - * Total: 32 - * Extra regs * fpsr & fpcr: 32 bit - * Total: 2 - * + * Total: 32 + 2 */ -#define _GP_REGS 34 +#define _GP_REGS 33 #define _FP_REGS 32 -#define _EXTRA_REGS 2 +#define _EXTRA_REGS 3 /* * general purpose registers size in bytes. * pstate is only 4 bytes. subtract 4 bytes diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c index b67531a13136..ec62a4e3c190 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c @@ -58,7 +58,11 @@ struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = { { "x30", 8, offsetof(struct pt_regs, regs[30])}, { "sp", 8, offsetof(struct pt_regs, sp)}, { "pc", 8, offsetof(struct pt_regs, pc)}, - { "pstate", 8, offsetof(struct pt_regs, pstate)}, + { "pstate", 4, offsetof(struct pt_regs, pstate) +#ifdef CONFIG_CPU_BIG_ENDIAN + + 4 +#endif + }, { "v0", 16, -1 }, { "v1", 16, -1 }, { "v2", 16, -1 }, @@ -128,6 +132,7 @@ sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *task) memset((char *)gdb_regs, 0, NUMREGBYTES); thread_regs = task_pt_regs(task); memcpy((void *)gdb_regs, (void *)thread_regs->regs, GP_REG_BYTES); + dbg_get_reg(33, gdb_regs + GP_REG_BYTES, thread_regs); } void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc)