From patchwork Wed Apr 20 06:49:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1619347 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=RBlokyqh; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KjrtC1dMyz9sG0 for ; Wed, 20 Apr 2022 16:51:15 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KjrtC0w5Vz30Lp for ; Wed, 20 Apr 2022 16:51:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=RBlokyqh; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1033; helo=mail-pj1-x1033.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=RBlokyqh; dkim-atps=neutral Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Kjrt92Mkzz2xnM for ; Wed, 20 Apr 2022 16:51:13 +1000 (AEST) Received: by mail-pj1-x1033.google.com with SMTP id n33-20020a17090a5aa400b001d28f5ee3f9so1140713pji.4 for ; Tue, 19 Apr 2022 23:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dMX5/Hhw3TlInkOe7vN8cVa2yytiaDFCZqvFW/Su0lk=; b=RBlokyqhl4q8tSap694+mULSskCAjA3OoZzuhVeq1spkDfGARr6uWSQ+K+ADu5jZ1y pfAigh2P5MEIBJYoOgQctgogizPKg17ocJnNXCon+G+x8yJWw91azfhWAjNnOULEZ93+ eS5zUpbzefpFDkHGoWoJQCAdpTfY49HrwAPmLWoTveYoVwahJX+lQIY7MCaycfmQsiFh vwQ6g4eZYFFUEPsHXIwuFmOdheWj6mmVkEo43NjSE1z+NSbu6Y0IsdEnf1iunoTnjuv2 5kHucy6iAHrilgIDbvHKpmljSGGg0SQuMASzoRu25ywqoBeuvyJ3fa8PL5r7L/nQWhRW RQ0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dMX5/Hhw3TlInkOe7vN8cVa2yytiaDFCZqvFW/Su0lk=; b=cWI7sMzSuWJ6t0IxIOblYrY5f+61Y0VObWoCNDSk2FIfvkkgSehXX+UceiilwvrWwM 7xftHzYjpyRctc9foOoAyOpqvmR6gUgm8lhpa1EFo7Y92LmcOrehGnM98ScD7KY4o52f Cihlh9CWp6uospqdBL1f3GvPSAm6dqjvKWZCzpoDizfa1YQ6nImL+lYLJJgublHukr5o au8tSjgRu0M/skGsXdQgnSLgNWkBR3rRGAjSi72dkaqp3tKbTvE05Xg/mKxlAl06Jbi2 Kk+G5onbUKCv53lEMX+X971Vr+AtoOZgvaVjFxzH7VEMn/bmeiG995Kp0aYq5bvWfLZV DkZg== X-Gm-Message-State: AOAM530DtKmqBntgkQEBmTjzkZyCWMmw7BJNXTH9fjoZRP6c6l4ijQfB QCEH7ffFv3qVfUtgcOzVtSo7RfYzPEiZCQ== X-Google-Smtp-Source: ABdhPJyt5F5/b6mQi46l1HavLpG2EwlNoytZv0leseGWQPbMli9W1da7na/ZQYt6rP+rijkj1fqpOg== X-Received: by 2002:a17:902:ca04:b0:158:eab9:2676 with SMTP id w4-20020a170902ca0400b00158eab92676mr18102005pld.1.1650437471476; Tue, 19 Apr 2022 23:51:11 -0700 (PDT) Received: from bobo.ozlabs.ibm.com ([203.221.203.144]) by smtp.gmail.com with ESMTPSA id x20-20020aa79574000000b005061f4782c5sm18481235pfq.183.2022.04.19.23.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 23:51:11 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Wed, 20 Apr 2022 16:49:54 +1000 Message-Id: <20220420065013.222816-21-npiggin@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220420065013.222816-1-npiggin@gmail.com> References: <20220420065013.222816-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 20/39] gdbserver: enable POWER9 support X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" POWER9 has a strange problem with attn, but otherwise gdbserver works well. Enable it. Signed-off-by: Nicholas Piggin Reviewed-by: Joel Stanley --- README.md | 14 +++++++++++--- src/pdbgproxy.c | 29 +++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9ece33f9..ba17c613 100644 --- a/README.md +++ b/README.md @@ -534,8 +534,9 @@ There are also low level htm commands which can also be used: - `dump` will dump the trace to a file. ### GDBSERVER -At the moment gdbserver is only supported on P8 while the cores are in the -kernel. +At the moment gdbserver is only supported on P8 and P9. + +Memory access can only be performed on kernel memory. To run a gdbserver on a P8 machine from a BMC running openbmc: @@ -547,7 +548,7 @@ $ ./pdbg -d p8 -p0 -c11 -t0 gdbserver 44 On your local machine: $ gdb -(gdb) set architecture powerpc:common64 +(gdb) set architecture powerpc:common64 (gdb) target remote palm5-bmc:44 Debugging info: @@ -566,6 +567,13 @@ Notes: happen. 2. If you want to view the kernel call trace then run gdb on the vmlinux that the host is running (the kernel needs to be compiled with debug symbols). +3. The kernel HARDLOCKUP watchdog can interact badly with GDBSERVER (and all +pdbg direct controls for that matter). Disabling it before debugging is a +good idea. +4. Idle states have often had problems with pdbg direct controls. If things are +misbehaving, booting Linux with powersave=off is the first thing to try. +5. attn instructions seem to cause host hangs on POWER9. gdb breakpoints should +not be used. ## Submitting patches diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 4c7b4a82..3028d418 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -105,6 +105,9 @@ static void detach(uint64_t *stack, void *priv) #define POWER8_HID_ENABLE_ATTN PPC_BIT(31) +#define POWER9_HID_ENABLE_ATTN PPC_BIT(3) +#define POWER9_HID_FLUSH_ICACHE PPC_BIT(2) + static int set_attn(bool enable) { uint64_t hid; @@ -122,6 +125,17 @@ static int set_attn(bool enable) return 0; hid &= ~POWER8_HID_ENABLE_ATTN; } + } else if (pdbg_target_compatible(thread_target, "ibm,power9-thread")) { + if (enable) { + if (hid & POWER9_HID_ENABLE_ATTN) + return 0; + hid |= POWER9_HID_ENABLE_ATTN; + } else { + if (!(hid & POWER9_HID_ENABLE_ATTN)) + return 0; + hid &= ~POWER9_HID_ENABLE_ATTN; + } + hid |= POWER9_HID_FLUSH_ICACHE; } else { return -1; } @@ -658,13 +672,20 @@ static int gdbserver(uint16_t port) return 0; } - // - // Temporary until I can get this working a bit smoother on p9 - if (!pdbg_target_compatible(thread, "ibm,power8-thread")) { - PR_ERROR("GDBSERVER is only available on POWER8\n"); + if (!pdbg_target_compatible(thread, "ibm,power8-thread") && + !pdbg_target_compatible(thread, "ibm,power9-thread")) { + PR_ERROR("GDBSERVER is only available on POWER8 and POWER9\n"); return -1; } + if (pdbg_target_compatible(thread, "ibm,power9-thread")) { + /* + * XXX: If we advertise no swbreak support on POWER9 does + * that prevent the client using them? + */ + PR_WARNING("Breakpoints may cause host crashes on POWER9 and should not be used\n"); + } + /* Check endianess in MSR */ rc = thread_getmsr(thread, &msr); if (rc) {