From patchwork Tue May 31 09:14:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1637267 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=QCdAl1oo; 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LC67f4TFZz9s1l for ; Tue, 31 May 2022 19:15:26 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4LC67f3ltDz3bkh for ; Tue, 31 May 2022 19:15:26 +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=QCdAl1oo; 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=QCdAl1oo; 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 4LC67b43CMz3bkR for ; Tue, 31 May 2022 19:15:23 +1000 (AEST) Received: by mail-pj1-x1033.google.com with SMTP id gd1so5016109pjb.2 for ; Tue, 31 May 2022 02:15: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=nrkKVwJnggucsiapdQvTK//hRDTW7nWLnJNWxEVw2m0=; b=QCdAl1oo7ECebll+B03Qi6h2nW5ziCJ7pL3vlkfrmvctIuHDdFqkxKZvogcZDuGx0c 43uOIUD2dyHegtuM7rnChoiDdKV+gAD8XH8oF8QBPgY4DiCySN9pzhg/QAzQbaw4vD7V gwKxKDpl0chsn/ZVun3/XybodLcBSzp/v0PCHAnexBaRBIXs9tJGUYNqfqHZc45yDj3G M0HCeT7F3f6Z+NNCzh1L29YV1DtnbTGSyHaJ6Dfr2fXqa5eWmLkYlzZts4T1PihxMeI5 EN3rrA0puGSusDpsvR3G1uEdi03bElcG/t/0CyOFbg4sV0ohdy7Sn0vt+9tpLhxGp9C6 knVQ== 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=nrkKVwJnggucsiapdQvTK//hRDTW7nWLnJNWxEVw2m0=; b=kwPaZ8zqte9cWNdQxekgw0EAT4lVpoBenk/qDsYX/TCHVnt9C0Y61//U9OaWQNMFbV ArvtLVCG0T8jexI7Gr1sRvXtArBE2myO7kCs9HtMS5H+f5MnD+VDolxuMDbiNIDrvsXu XLFyEldjaBLteBgvn+h6fT7bhEtAk7+bdyxDBfcsFWLzEfEtb9G1rq1diZf568iC1Bwd cVRLbEY/vne5dOjss9nxWMmri2HtjZYuPaBVFGHrUwvMHxg3nWUX3yCFxwGAEKynnplJ zoEBu2sJUinfe2faggDlP81xNGH/QgLKaDnYrk2QbOYBFSEwgg/U6OSchQ1I3StTrmQm A64A== X-Gm-Message-State: AOAM530Twwh3GlGtTME0Wgge730Zjq60oPRaZ0y4NStcxZQEYrzbLGtc tRErpLcAKnFTxvYBQXOvo0DfXc1TKBhw8Q== X-Google-Smtp-Source: ABdhPJwqNbv+4b/lRot1XRkWIePCvCKcZclKxbeo0bUkTMw0VTGzuBe9NPu9nKrK0mmyOBq8DNjD4g== X-Received: by 2002:a17:902:d483:b0:163:e9cf:7cef with SMTP id c3-20020a170902d48300b00163e9cf7cefmr7132917plg.82.1653988521055; Tue, 31 May 2022 02:15:21 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (220-245-15-130.tpgi.com.au. [220.245.15.130]) by smtp.gmail.com with ESMTPSA id t10-20020a17090a950a00b001e2ebcce5d5sm1282857pjo.37.2022.05.31.02.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 02:15:20 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Tue, 31 May 2022 19:14:55 +1000 Message-Id: <20220531091457.2208488-9-npiggin@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220531091457.2208488-1-npiggin@gmail.com> References: <20220531091457.2208488-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 08/10] libpdbg: add fused-core thread id 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" libpdbg thread id is in small-core units because pervasive tends to be addressed by small core. However some PC registers contain fused-core thread ID fields, which need fused core indexing. Add thread->fc_id. Signed-off-by: Nicholas Piggin --- libpdbg/hwunit.h | 1 + libpdbg/p10chip.c | 19 +++++++++++++++++++ libpdbg/p8chip.c | 1 + libpdbg/p9chip.c | 18 ++++++++++++++++++ libpdbg/sbefifo.c | 10 ++++++++++ 5 files changed, 49 insertions(+) diff --git a/libpdbg/hwunit.h b/libpdbg/hwunit.h index 4f27e34c..23053b31 100644 --- a/libpdbg/hwunit.h +++ b/libpdbg/hwunit.h @@ -143,6 +143,7 @@ struct thread { struct thread_state status; void *gdbserver_priv; int id; + int fc_id; struct thread_state (*state)(struct thread *); int (*step)(struct thread *, int); int (*start)(struct thread *); diff --git a/libpdbg/p10chip.c b/libpdbg/p10chip.c index fc661d34..c0358ebc 100644 --- a/libpdbg/p10chip.c +++ b/libpdbg/p10chip.c @@ -90,13 +90,32 @@ struct thread_state p10_thread_state(struct thread *thread) return thread_state; } +static uint8_t p10_core_id(struct pdbg_target *core) +{ + return pdbg_target_index(core) & 0xff; +} + static int p10_thread_probe(struct pdbg_target *target) { + struct core *core = target_to_core(pdbg_target_require_parent("core", target)); struct thread *thread = target_to_thread(target); thread->id = pdbg_target_index(target); thread->status = thread->state(thread); + if (core->status.fused_core_mode) { + struct pdbg_target *parent; + uint8_t core_id; + + /* P10 uses core id as core-id */ + parent = pdbg_target_require_parent("core", target); + core_id = p10_core_id(parent); + + thread->fc_id = thread->id * 2 + (core_id % 2); + } else { + thread->fc_id = thread->id; + } + return 0; } diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index 1863af74..798db6c6 100644 --- a/libpdbg/p8chip.c +++ b/libpdbg/p8chip.c @@ -611,6 +611,7 @@ static int p8_thread_probe(struct pdbg_target *target) struct thread *thread = target_to_thread(target); thread->id = (pdbg_target_address(target, NULL) >> 4) & 0xf; + thread->fc_id = thread->id; thread->status = thread->state(thread); return 0; diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c index 1167dac8..28e98762 100644 --- a/libpdbg/p9chip.c +++ b/libpdbg/p9chip.c @@ -111,13 +111,31 @@ struct thread_state p9_thread_state(struct thread *thread) return thread_state; } +static uint8_t p9_core_id(struct pdbg_target *core) +{ + return pdbg_target_index(core) & 0xff; +} + static int p9_thread_probe(struct pdbg_target *target) { + struct core *core = target_to_core(pdbg_target_require_parent("core", target)); struct thread *thread = target_to_thread(target); thread->id = pdbg_target_index(target); thread->status = thread->state(thread); + if (core->status.fused_core_mode) { + struct pdbg_target *parent; + uint8_t core_id; + + parent = pdbg_target_require_parent("core", target); + core_id = p9_core_id(parent); + + thread->fc_id = thread->id * 2 + (core_id % 2); + } else { + thread->fc_id = thread->id; + } + return 0; } diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c index 3be19b80..7a9f614a 100644 --- a/libpdbg/sbefifo.c +++ b/libpdbg/sbefifo.c @@ -375,11 +375,21 @@ static uint8_t sbefifo_core_id(struct sbefifo_context *sctx, struct thread *thre static int sbefifo_thread_probe(struct pdbg_target *target) { + struct pdbg_target *parent = pdbg_target_require_parent("core", target); + struct core *core = target_to_core(parent); struct thread *thread = target_to_thread(target); thread->id = pdbg_target_index(target); thread->status = thread->state(thread); + if (core->status.fused_core_mode) { + uint8_t core_id = pdbg_target_index(parent) & 0xff; + + thread->fc_id = thread->id * 2 + (core_id % 2); + } else { + thread->fc_id = thread->id; + } + return 0; }