From patchwork Tue Mar 29 15:49:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1610698 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=o4IU8Xwa; 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 4KSYtM4l12z9sFk for ; Wed, 30 Mar 2022 02:50:19 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KSYtM3gtSz2xvF for ; Wed, 30 Mar 2022 02:50:19 +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=o4IU8Xwa; 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::433; helo=mail-pf1-x433.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=o4IU8Xwa; dkim-atps=neutral Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) (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 4KSYtK2qMzz2xy3 for ; Wed, 30 Mar 2022 02:50:17 +1100 (AEDT) Received: by mail-pf1-x433.google.com with SMTP id u22so16253658pfg.6 for ; Tue, 29 Mar 2022 08:50:17 -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=BcwkrbrP7TqExCViK0h3asOLLgzPtX/+16heB40BBkQ=; b=o4IU8Xwa1dwH/ObXBONcx0ilRg/n3UlnlHL74T1AHE4nDpbk4je8KAnTUysQABU6GH 9vhiwRFuJyK2ppctXi1i74xbenr6FBxtP+/zJgRGNdZxPsTkaNj809gZGG8Kj51ChuOY IwYMujSl88tl7trBupMqXbgqCEksN6GpKTUsVarQ08yw3n4sbQNUqGfAfvOrXFC+pPfF JMIIelemdqlXbdTiHpSqpf2OT4m4IhXpFXtoQFV8d8DlS/PHzjhopG0XuBPD00Padack S8/qpNR3Bv34OVz1o3uRPXKXW0zxdSxaeW1wl1N3V4eTi0cgdLq5jd6vKURf7GBVE1OQ l0Lg== 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=BcwkrbrP7TqExCViK0h3asOLLgzPtX/+16heB40BBkQ=; b=G+zsK5Si6qkdq5IAB1EY5CleyVSO87qKJkSJp447tuq4X5nV8Q4pueYIlFd2rkBHYS +K87RkRmqFcbbh9T8KfnLa7sKZNc2WrA1lhBxSjKsNSXrOX2s351DQgCe+dCrErDRu3I oF4kzBqLXDaZU0h4QzW1R/GOBDAVDBCjZCBp/4k8z/6FHVpJhRPbDkqxt9BzNJxcQfii mM1f0M9JmwUzX1SxVeZNjeKDv4kbvR2V3d0fc/HdVCQ4ihwxujU4gfqAm55TEdsGE+TH 6Dm3Qxt+LBjdAsnWtwVAKDn98BXFxiYv5QVsv2UQU74/5lE14GK+1TlGBTO5GzzYWDgA MHoA== X-Gm-Message-State: AOAM5311AmsIsbjKGMADr9FarGpBwxBwfJ2TZz4CXT6NOknP1oxJgDb8 c7EtYfZ8TIWhtcGFAlznipel19IY31g= X-Google-Smtp-Source: ABdhPJzhsbTQFSUtb6b3ledWamJWbcKg5SzJaweH2WXUiSSpI7PQgNDBOFc7lYYOt+H30PXpQpZJ2Q== X-Received: by 2002:a63:5024:0:b0:380:83f7:1603 with SMTP id e36-20020a635024000000b0038083f71603mr2394681pgb.289.1648569014731; Tue, 29 Mar 2022 08:50:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Mar 2022 08:50:14 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Wed, 30 Mar 2022 01:49:09 +1000 Message-Id: <20220329154931.493851-17-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 16/38] libpdbg: Remove enable_attn target command 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" enable_attn is only used by gdbserver and it can be implemented with existing target register access. Move it to gdbserver. Signed-off-by: Nicholas Piggin --- libpdbg/hwunit.h | 1 - libpdbg/p8chip.c | 31 ------------------------------- src/pdbgproxy.c | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/libpdbg/hwunit.h b/libpdbg/hwunit.h index 4662aec..2ce41db 100644 --- a/libpdbg/hwunit.h +++ b/libpdbg/hwunit.h @@ -155,7 +155,6 @@ struct thread { int (*ram_setup)(struct thread *); int (*ram_instruction)(struct thread *, uint64_t opcode, uint64_t *scratch); int (*ram_destroy)(struct thread *); - int (*enable_attn)(struct thread *); int (*getmem)(struct thread *, uint64_t, uint64_t *); int (*getregs)(struct thread *, struct thread_regs *regs); diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index 92e18cc..5b2a90a 100644 --- a/libpdbg/p8chip.c +++ b/libpdbg/p8chip.c @@ -611,36 +611,6 @@ static int p8_get_hid0(struct pdbg_target *chip, uint64_t *value) return 0; } -static int p8_put_hid0(struct pdbg_target *chip, uint64_t value) -{ - CHECK_ERR(pib_write(chip, HID0_REG, value)); - return 0; -} - -static int p8_enable_attn(struct thread *thread) -{ - struct pdbg_target *core; - uint64_t hid0; - - core = pdbg_target_require_parent("core", &thread->target); - - /* Need to enable the attn instruction in HID0 */ - if (p8_get_hid0(core, &hid0)) { - PR_ERROR("Unable to get HID0\n"); - return 1; - } - PR_INFO("HID0 was 0x%"PRIx64 " \n", hid0); - - hid0 |= EN_ATTN; - - PR_INFO("writing 0x%"PRIx64 " to HID0\n", hid0); - if (p8_put_hid0(core, hid0)) { - PR_ERROR("Unable to set HID0\n"); - return 1; - } - return 0; -} - static struct thread p8_thread = { .target = { .name = "POWER8 Thread", @@ -657,7 +627,6 @@ static struct thread p8_thread = { .ram_setup = p8_ram_setup, .ram_instruction = p8_ram_instruction, .ram_destroy = p8_ram_destroy, - .enable_attn = p8_enable_attn, .getmem = ram_getmem, .getregs = ram_getregs, .getgpr = ram_getgpr, diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index dfd00a9..3e27644 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -24,6 +24,7 @@ #include "optcmd.h" #include "debug.h" #include "path.h" +#include "sprs.h" #ifndef DISABLE_GDBSERVER @@ -101,6 +102,35 @@ static void detach(uint64_t *stack, void *priv) send_response(fd, OK); } +#define POWER8_HID_ENABLE_ATTN PPC_BIT(31) + +static int set_attn(bool enable) +{ + uint64_t hid; + + if (thread_getspr(thread_target, SPR_HID, &hid)) + return -1; + + if (pdbg_target_compatible(thread_target, "ibm,power8-thread")) { + if (enable) { + if (hid & POWER8_HID_ENABLE_ATTN) + return 0; + hid |= POWER8_HID_ENABLE_ATTN; + } else { + if (!(hid & POWER8_HID_ENABLE_ATTN)) + return 0; + hid &= ~POWER8_HID_ENABLE_ATTN; + } + } else { + return -1; + } + + if (thread_putspr(thread_target, SPR_HID, hid)) + return -1; + + return 0; +} + /* 32 registers represented as 16 char hex numbers with null-termination */ #define REG_DATA_SIZE (32*16+1) static void get_gprs(uint64_t *stack, void *priv) @@ -255,7 +285,6 @@ static void put_mem(uint64_t *stack, void *priv) uint8_t attn_opcode[] = {0x00, 0x00, 0x02, 0x00}; uint8_t gdb_break_opcode[] = {0x7d, 0x82, 0x10, 0x08}; int err = 0; - struct thread *thread = target_to_thread(thread_target); if (littleendian) { attn_opcode[1] = 0x02; @@ -285,8 +314,10 @@ static void put_mem(uint64_t *stack, void *priv) data = attn_opcode; /* Need to enable the attn instruction in HID0 */ - if (thread->enable_attn(thread)) + if (set_attn(true)) { + err = 2; goto out; + } } if (mem_write(adu_target, addr, data, len, 0, false)) {