From patchwork Fri Jan 10 03:40:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1220770 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47v80F0Yh0z9sRK for ; Fri, 10 Jan 2020 14:41:01 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47v80D4vLxzDqbv for ; Fri, 10 Jan 2020 14:41:00 +1100 (AEDT) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (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 47v8013YJ7zDqbW for ; Fri, 10 Jan 2020 14:40:49 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 47v80111MDz9sR4; Fri, 10 Jan 2020 14:40:49 +1100 (AEDT) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Fri, 10 Jan 2020 14:40:43 +1100 Message-Id: <20200110034043.27936-1-alistair@popple.id.au> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Pdbg] [PATCH] libpdbg.c: Fix address translation 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: , Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" If a target provides a translation callback it's expected that the callback will return the absolute bus address to be used for the access. However the caller of this callback was continuing to apply translations to this absoulte address resulting in incorrect translations in some cases. Instead short-circuit the translation process. Signed-off-by: Alistair Popple Reviewed-by: Amitay Isaacs --- libpdbg/target.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libpdbg/target.c b/libpdbg/target.c index dcbee2f..46004ef 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -19,12 +19,16 @@ struct list_head target_classes = LIST_HEAD_INIT(target_classes); static struct pdbg_target *get_class_target_addr(struct pdbg_target *target, const char *name, uint64_t *addr) { /* Check class */ + pdbg_log(PDBG_DEBUG, "Target addr 0x%" PRIx64, *addr); while (strcmp(target->class, name)) { - - if (target->translate) + if (target->translate) { *addr = target->translate(target, *addr); - else + target = target_parent(name, target, false); + assert(target); + break; + } else { *addr += pdbg_target_address(target, NULL); + } /* Keep walking the tree translating addresses */ target = get_parent(target, false); @@ -34,6 +38,7 @@ static struct pdbg_target *get_class_target_addr(struct pdbg_target *target, con assert(target != pdbg_target_root()); } + pdbg_log(PDBG_DEBUG, " -> 0x%" PRIx64 "\n", *addr); return target; }