From patchwork Tue Mar 29 15:49:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1610701 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=YUhYOrqp; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (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 4KSYtT5Fnyz9sFk for ; Wed, 30 Mar 2022 02:50:25 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KSYtT44zCz2xvv for ; Wed, 30 Mar 2022 02:50:25 +1100 (AEDT) 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=YUhYOrqp; 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::530; helo=mail-pg1-x530.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=YUhYOrqp; dkim-atps=neutral Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) (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 4KSYtR1XwBz2yJ9 for ; Wed, 30 Mar 2022 02:50:23 +1100 (AEDT) Received: by mail-pg1-x530.google.com with SMTP id k14so15207341pga.0 for ; Tue, 29 Mar 2022 08:50:23 -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=Chwc6sjTUvNe4ItNCrKZA6/Xah3CQDXFtfN02z2EHaY=; b=YUhYOrqpLCPLPeJZ91TJQxYuYvjBEjh99b9+rZ+OJKwsN6rUQFLa6fMHlxKSNBPGTU KjflryThnx1e9TUT2XSIjVYo5sZlFQmL7yrW55MYULZYN6wrb9ZfbT+LX10O6VgbzwYb QEGjK461w7QKyPKyoN3BYJW9T5MkzbNsxaEV1zkRU1s/EnL1FMtGwAfdoAyvxMUqFamy /sZ0ljtxBaE4p0ti2kECYmKi87gkR5Y3dejnV8z1A34BtKpIeYC5X3V6QRNMe6cDALef EKhlGebvn3P92WWYlpdqLaYVYd2D0fCV7HWCG/QPFLR9OZbbWpjQgjEvYnCFXPDkSbRn +Qbg== 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=Chwc6sjTUvNe4ItNCrKZA6/Xah3CQDXFtfN02z2EHaY=; b=tPnTxSpzR/5H5cDn3l32UdRI7mmNyMprlj+WqsbW/XrAC9h2C7/F3NII9Mn4e3AS2X WXmbiyeSY2aCgqJIbMW6fmfiS6fOba/f/aqtdm7qgE7lPjFJbxbPZmiCzyUfeuZU6V6s jai7MZ6Ua7yRw+R6P78SXXpPjzhH5q104wRhN6HRnhBt23ExzDfuFp23it0HNDwzOvhi pBuwgt7RRRTO/CdjJfMqWdQXocfPQEP/rxWUH+jEO8nwFr4Ka/vPcVdxAYJzYilV9kAC 18XrguQJpk0+ao4x1MLAMW0XtxutoeD3Dy4fk6tpuBb/Rx/wFbGs7Wc4I6qBzCzksd35 DCQA== X-Gm-Message-State: AOAM533l6RAyuFsvDU0KxVcI9xu9agmic3/b8evKLk39zPGOW4rKwfjA Vd2V/xD/eiW47ZmSNqK61+OLg41Q6M0= X-Google-Smtp-Source: ABdhPJxJgIfHerk2ooDVUjFmXgpiXc+zEqPCiktPBMWdx6Vrt4XIvh2UcMd4See+4tj0KrjIFF6g0w== X-Received: by 2002:a63:d149:0:b0:384:b288:8704 with SMTP id c9-20020a63d149000000b00384b2888704mr2416211pgj.112.1648569020717; Tue, 29 Mar 2022 08:50:20 -0700 (PDT) Received: from bobo.ibm.com (58-6-255-110.tpgi.com.au. [58.6.255.110]) by smtp.gmail.com with ESMTPSA id s35-20020a056a001c6300b004fb20b5d6c1sm14163564pfw.40.2022.03.29.08.50.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Mar 2022 08:50:20 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Wed, 30 Mar 2022 01:49:12 +1000 Message-Id: <20220329154931.493851-20-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220329154931.493851-1-npiggin@gmail.com> References: <20220329154931.493851-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 19/38] 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 --- README.md | 14 +++++++++++--- src/pdbgproxy.c | 29 +++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index be26dc1..5c5c05d 100644 --- a/README.md +++ b/README.md @@ -527,8 +527,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: @@ -540,7 +541,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: @@ -559,6 +560,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 c7cab28..b3bf5bd 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) {