From patchwork Sat Nov 10 10:05:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 995866 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42sXhl5JSlz9s7W for ; Sat, 10 Nov 2018 21:05:43 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jKiuA5EG"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42sXhl064lzF3f8 for ; Sat, 10 Nov 2018 21:05:43 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jKiuA5EG"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::541; helo=mail-pg1-x541.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jKiuA5EG"; dkim-atps=neutral Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42sXhd3mqWzF3dy for ; Sat, 10 Nov 2018 21:05:37 +1100 (AEDT) Received: by mail-pg1-x541.google.com with SMTP id r9-v6so1926360pgv.6 for ; Sat, 10 Nov 2018 02:05:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=TnqPxY+1DkImbuCpdiupyTLYZkAQg8ZmN8RNRxBV7uQ=; b=jKiuA5EGykl8RQpwGGk1hipTZfuY3+1bQWF6rXexnntPLhCKHauiMLUK95110kHspC GT577kFz4yEi/YX8fOAf+X7dqJlC7n+4s4MIdd8ZpYcmHKzzZ5RWxFvSq+yUJM3S59Wg Ib8oetJFZrXiPq2R1LcRB8rnrrqGK+H/w4z7Lr8sGXDBcH4Sw5wLyZajH8xB5vR6gv8F FB76wMo+aPCbNJIIBaQvUOku1Xqm7niOeHs/yTLT3Y4Ahq372ibZC8DRvoywasQZzHel hab0MK2iDFPoaG+ISonArf4rUVELzK+tRvLvxCqljLqGa3ao6wW7KpwxEYsBtNST0JGl H9ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TnqPxY+1DkImbuCpdiupyTLYZkAQg8ZmN8RNRxBV7uQ=; b=Y+w9JPps4jOjghMpJXr24SqVGoN99nlZenebyDqGQ1IEPYkP5qpt48SAPA/VyyqC2S VsxZ06vOGDI+vd7Bg5b433p0bXyM8N/T1uiJ7LggF07qowbkmW16JbgSaWiu5yXszflO EiyUaDwjBo7ADhDnNB3klHRhCGX/KR4bf99Tz1aWgfaKWDe3PTzyK+/n+zDCZvO1muaX M7ba0Ow12zE9gfzSEdSYKEAFFjo9n2UdGu5A5puV9ja9cx8wMDhKCXzpXpvOI7i5Qyks jja/d5PgJcaintv0gHycSygrpHS3Nn653GpzvYVNSTgd0qa7sie5zEgH3TFndn6YgbWo ldFQ== X-Gm-Message-State: AGRZ1gKeIft936Ma8wRt49L9lzCAnAltdW+qZOchey1rxvg39f7uzAa/ P+/kElko/X7IKd38cBotW0DEpEd2 X-Google-Smtp-Source: AJdET5fMRegM/TnyluXmxatNMG/W3KDVVfUL1mRZfh9yEA1Yr+yOLLNorhNJR26XA3ExSxNzicEYmQ== X-Received: by 2002:a62:401:: with SMTP id 1-v6mr12180253pfe.156.1541844334900; Sat, 10 Nov 2018 02:05:34 -0800 (PST) Received: from roar.ibm.com (148.36.194.203.dial.dynamic.acc01-tull-pth.comindico.com.au. [203.194.36.148]) by smtp.gmail.com with ESMTPSA id c127-v6sm10445343pfa.31.2018.11.10.02.05.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Nov 2018 02:05:34 -0800 (PST) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Sat, 10 Nov 2018 20:05:26 +1000 Message-Id: <20181110100526.18403-1-npiggin@gmail.com> X-Mailer: git-send-email 2.18.0 Subject: [Pdbg] [PATCH] libpdbg: Fix rework target addressing 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Commit 936dbdcedb27 ("libpdbg: Rework target addressing") introduced a bug in the target address calculation, using index 1 rather than the intended 0. Fixes: 936dbdcedb27 ("libpdbg: Rework target addressing") Signed-off-by: Nicholas Piggin --- libpdbg/device.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 9557172..f81b1b5 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -626,15 +626,14 @@ uint64_t pdbg_target_address(struct pdbg_target *target, uint64_t *out_size) const struct dt_property *p; u32 na = dt_n_address_cells(target); u32 ns = dt_n_size_cells(target); - u32 pos, n; + u32 n; p = dt_require_property(target, "reg", -1); n = (na + ns) * sizeof(u32); - pos = n; - assert((pos + n) <= p->len); + assert(n <= p->len); if (out_size) - *out_size = dt_get_number(p->prop + pos + na * sizeof(u32), ns); - return dt_get_number(p->prop + pos, na); + *out_size = dt_get_number(p->prop + na * sizeof(u32), ns); + return dt_get_number(p->prop, na); } void pdbg_targets_init(void *fdt)