From patchwork Thu Mar 8 16:41:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10268407 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 63898602C8 for ; Thu, 8 Mar 2018 16:43:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51A5926E76 for ; Thu, 8 Mar 2018 16:43:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46A3A285F2; Thu, 8 Mar 2018 16:43:58 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 B867B26E76 for ; Thu, 8 Mar 2018 16:43:57 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: References:In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AUcuNJOa9/fOvByF/j7Z5bppcsrX77fxBgtvup2vOh4=; b=toQYYTA0Rd66l3 T7I5ucAqkMza8x/Qc6DtXoz4jB5DxOGPbFn9eR9obBN6m9N4LfmtzTvLqbLlrDZgLV1SLVEWR1PdT 11e6vF6FWoy2COikx/IS6hu4A0MLox9m0pA96e+IyuOiAa4OtxBxDbnSEoYtD/lQtdcKIPxmHYBo4 8VE7tzBXddnbv/NWV/7B1FT2owwfEMlrT1QhYsH+7JTZyi2J6BGhVxuLlM8TXXtQDK7nJZosIFxd0 Qy4gena67Ag5mu5xY9nH1LazdYGI943qFzZ27nkO3WhHAEwUuqm7tsM6Cfb/2byeBZkSawchq6gDy NPGDusdtbjid0SWH9P6w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1etydx-0002G2-6e; Thu, 08 Mar 2018 16:43:49 +0000 Received: from mail-vk0-x244.google.com ([2607:f8b0:400c:c05::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1etycT-0001T8-0J for linux-arm-kernel@lists.infradead.org; Thu, 08 Mar 2018 16:42:22 +0000 Received: by mail-vk0-x244.google.com with SMTP id y127so199598vky.9 for ; Thu, 08 Mar 2018 08:42:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=5yKbqPRAOtX0DLGOAuIM7pFcIf2WHV44xGeVDjpxPpQ=; b=dQi9a5hj/05TQ2y+AXyy4hYwKuZWVEDJ4LuTjDUm/q95a3HTt0pTEJkUtS+9ftYgWt E79HnSNxBJ3N6l6DAdQIqDcLRHSXh5agEvinLFAImqB7O7KMVMAvmbLomWErUcIQd9Le 2nhP3cgIlan9khNjRopmx/IvudmKJDalTFqMoiI+XErBTQjIWfO4ZIBD8dia5gkqmmnG AYv6lFydyMVAmP9EtaAyJ+odc0e0bWf61rYIZL5elxAR/nNAlM0EaXLgQtfA0RPCqbjD p+e9CfTkE25JdNriWk2xfQG/DXIevzQQmQpqqogKzugmGgg1QuTIX4hwU8k8DiX3Q9kH YbLg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=5yKbqPRAOtX0DLGOAuIM7pFcIf2WHV44xGeVDjpxPpQ=; b=Cq9oJWEIDNLKOtejp8dIPLNNe9i8uzWJ3cnC3nnpzKdPRhKMhxB25+qrP+SC82opxI M2RXfQ/HRuLCHkaad7Bpca2K9r3+wLdIpgNx5PDFUj2yWHFj3kvx1ALAy5foyJuYHZ4K uGhU5IXPPr+CA/d2SPBpp0N3E/fH00WimfQX8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=5yKbqPRAOtX0DLGOAuIM7pFcIf2WHV44xGeVDjpxPpQ=; b=PWXZOqNjUFwJWP5w5oi516Io9tUZJgjjezdDhkSkB1AcwzOZaJLKe0A9veOUOou9yl NGhdT5f4NXi2ILI4qJ/WLdxhTMrgNl8CKw/xb99/qQjTsrmThfsmzQ9M8zC8parkbxKm 6RLoMOkJB+XbBC4e3+OPIrzSngvnc9FbiQu35tmybpmKnIaKFNH8PufwtgiqLUVqC6Yt +r0d8YZap4PIs34AXy8PJE0KWjBsNUZ604vmfIQO3CyLxSkj5F5Yv7eentjqq8fQy5G/ vQSNMDs+luxB5eOS6QOrygXyGUrdaQKHesthHdQfE17Esi0ciJpzlOAajBwfIvnH2hLB Tpng== X-Gm-Message-State: APf1xPDDFKmOfIdZW40Ef2ePkvLKK/5pCtTJ6aRIlchtNXtzdtYcxx72 +zKpohsheUMw+9DRxKqIHsm0Vd7R7u/Ko3a0u5MiVA== X-Google-Smtp-Source: AG47ELvQ3TkqhmzX0jERQvBUu02wjQP6ugvw2+OGuEi6WePxzoIRvpg7I58qrQnlplQwtl4jdafiHsI28JW12xO9gZo= X-Received: by 10.31.160.81 with SMTP id j78mr18799190vke.139.1520527319964; Thu, 08 Mar 2018 08:41:59 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.254.65 with HTTP; Thu, 8 Mar 2018 08:41:59 -0800 (PST) In-Reply-To: <382abcdd-5264-0c0c-282f-d1f52ecff8e3@linaro.org> References: <20180305234309.233226-1-dianders@chromium.org> <382abcdd-5264-0c0c-282f-d1f52ecff8e3@linaro.org> From: Doug Anderson Date: Thu, 8 Mar 2018 08:41:59 -0800 X-Google-Sender-Auth: SLORXc4tvcBvG-kReuCATlW0wK0 Message-ID: Subject: Re: [PATCH v2] arm64/debug: Fix registers on sleeping tasks To: Daniel Thompson X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180308_084219_964800_17954EE9 X-CRM114-Status: GOOD ( 17.97 ) 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: Mark Rutland , Catalin Marinas , Brian Norris , Will Deacon , LKML , evgreen@chromium.org, swboyd@chromium.org, Linux ARM 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 Hi, On Thu, Mar 8, 2018 at 8:19 AM, Daniel Thompson wrote: > On 05/03/18 23:43, Douglas Anderson wrote: >> >> This is the equivalent of commit 001bf455d206 ("ARM: 8428/1: kgdb: Fix >> registers on sleeping tasks") but for arm64. Nuff said. >> >> ...well, perhaps I could also add that task_pt_regs are userspace >> registers and that's not what kgdb is supposed to be reporting. We're >> supposed to be reporting kernel registers. >> >> Signed-off-by: Douglas Anderson > > > I hacked together a (still very immature) kgdb test suite[1] around the turn > of the year. Whilst its not quite solid enough for me to recommend others > deploy it except out of curiosity... so I haven't yet started yelling about > test suite failures except in the privacy of my own head. > > However I can confirm that this patch fixes one of the test suite failures I > haven't had time to blame allocate yet! > > So... > Tested-by: Daniel Thompson Thanks for your testing! ...I'll have to check out your test suite soon. > BTW is this something that should Cc: stable? It wouldn't hurt if this made it back to stable on a best-effort approach. The problem has been there since the beginning, so it's not like it's fixing a regression that cropped up in a specific version. ...but it does fix a bug, so probably Cc stable makes sense. I guess I'd leave it up to the maintainer that applies the patch? -Doug

On Thu, Mar 8, 2018 at 8:19 AM, Daniel Thompson <daniel.thompson@linaro.org> wrote:
On 05/03/18 23:43, Douglas Anderson wrote:
This is the equivalent of commit 001bf455d206 ("ARM: 8428/1: kgdb: Fix
registers on sleeping tasks") but for arm64.  Nuff said.

...well, perhaps I could also add that task_pt_regs are userspace
registers and that's not what kgdb is supposed to be reporting.  We're
supposed to be reporting kernel registers.

Signed-off-by: Douglas Anderson <dianders@chromium.org>

I hacked together a (still very immature) kgdb test suite[1] around the turn of the year. Whilst its not quite solid enough for me to recommend others deploy it except out of curiosity... so I haven't yet started yelling about test suite failures except in the privacy of my own head.

However I can confirm that this patch fixes one of the test suite failures I haven't had time to blame allocate yet!

So...
Tested-by: Daniel Thompson <daniel.thompson@linaro.org>

BTW is this something that should Cc: stable?


Daniel.

[1] https://github.com/daniel-thompson/kgdbtest



---

Changes in v2:
- Init cpu_context in one line
- Explain that task_pt_regs are userspace

  arch/arm64/kernel/kgdb.c | 21 ++++++++++++++++-----
  1 file changed, 16 insertions(+), 5 deletions(-)

+       gdb_regs[31] = cpu_context->sp;
+       gdb_regs[32] = cpu_context->pc;
  }
    void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc)



diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c
index 2122cd187f19..a20de58061a8 100644
--- a/arch/arm64/kernel/kgdb.c
+++ b/arch/arm64/kernel/kgdb.c
@@ -138,14 +138,25 @@ int dbg_set_reg(int regno, void *mem, struct pt_regs *regs)
  void
  sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *task)
  {
-       struct pt_regs *thread_regs;
+       struct cpu_context *cpu_context = &task->thread.cpu_context;
        /* Initialize to zero */
        memset((char *)gdb_regs, 0, NUMREGBYTES);
-       thread_regs = task_pt_regs(task);
-       memcpy((void *)gdb_regs, (void *)thread_regs->regs, GP_REG_BYTES);
-       /* Special case for PSTATE (check comments in asm/kgdb.h for details) */
-       dbg_get_reg(33, gdb_regs + GP_REG_BYTES, thread_regs);
+
+       gdb_regs[19] = cpu_context->x19;
+       gdb_regs[20] = cpu_context->x20;
+       gdb_regs[21] = cpu_context->x21;
+       gdb_regs[22] = cpu_context->x22;
+       gdb_regs[23] = cpu_context->x23;
+       gdb_regs[24] = cpu_context->x24;
+       gdb_regs[25] = cpu_context->x25;
+       gdb_regs[26] = cpu_context->x26;
+       gdb_regs[27] = cpu_context->x27;
+       gdb_regs[28] = cpu_context->x28;
+       gdb_regs[29] = cpu_context->fp;
+