From patchwork Sun Sep 9 06:18:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 967713 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 427Lc66RdFz9s2P for ; Sun, 9 Sep 2018 16:19:18 +1000 (AEST) 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="RvfTGmPT"; 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 427Lc64qzrzF3CM for ; Sun, 9 Sep 2018 16:19:18 +1000 (AEST) 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="RvfTGmPT"; 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="RvfTGmPT"; 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 427Lc14jJWzF31j for ; Sun, 9 Sep 2018 16:19:12 +1000 (AEST) Received: by mail-pg1-x541.google.com with SMTP id 2-v6so8901234pgo.4 for ; Sat, 08 Sep 2018 23:19:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=5Gdp9uzrITS/ApXHnAaWU+j2YGzHLvz9I1fbnIqBX3M=; b=RvfTGmPTEAGmr3iVs90KTqFOn2ziILCjArVSl/NHR9SI8JkHmtdoV+WcYV4NuiNaeP /DoonGBkT3WgW3lvTm1eU+3oYqcBLAkGFkBwgynmAUS+xs0/k1k1zG9U616g+Pw+H9Sx UbUPPmxoLtzj/IHRtBUs8AlSEE7yvBHGLUTgw/OFHOWW/V6LiVqZ9GH3AWv8KhN1ZDOq qKCsTwXGpl4cD8yyeFmKQNW+Xfz0/aD3+wlP5X1uolwpKnm7FuWXfWpv9efqIHpth5HZ 1yXcTPpWjdZdQoKgpgCuNN/aL7k3ZUcGaNjhK1DJVT6OdpDKw922mhxcNNG5dpX65blM VNhA== 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=5Gdp9uzrITS/ApXHnAaWU+j2YGzHLvz9I1fbnIqBX3M=; b=H9KoT+IRYgJKjl5T4J9QvjwfLtVQ0kAeOc+5/tPUppYwax8NxnqZ1u4UL0pFgCwmVi 4eBz06jwWFywt2Ecc5tGgwrXhI15UuK/6Q2bQ/nRn+L90hUv8yeIu+Ss+xSmh78DR9JT /w5eThVVGZhJmIPe/LXJp7IfJoEMg11DyTxMwfTDcxwbj0jk+FW7ir5DDvnOtC3qrPYB +qRI9E5IdvjGeWbUf8Ssl/ipf5MbYIsmbY81vnxBHL0fJe3f+zB0SS9KVgME2ZqmEQJV 6P7BvzqfCD3MAUDGfPkxdiknTxJKJffkHtLZetY45GySLreaTcww6r3zLIV50cpOOIBf ABGw== X-Gm-Message-State: APzg51BBieT4XRiSPleCyq8Qb/AjQD76JFaDjCnuT8gWjNCpiTHlFi3c X3UnW96PBM5dFE7FYrhOvLin4hgC X-Google-Smtp-Source: ANB0VdbzLUGngxtVwny8SkPM1DbhDUbhKpaAR1mKoLUQmxyCdlP/fPrSbrBKkgNAb/jgiZoAeQUVpw== X-Received: by 2002:a62:225d:: with SMTP id i90-v6mr16894829pfi.246.1536473950217; Sat, 08 Sep 2018 23:19:10 -0700 (PDT) Received: from roar.au.ibm.com (115-64-249-220.tpgi.com.au. [115.64.249.220]) by smtp.gmail.com with ESMTPSA id 82-v6sm16921870pfw.159.2018.09.08.23.19.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Sep 2018 23:19:09 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Sun, 9 Sep 2018 16:18:58 +1000 Message-Id: <20180909061859.21445-1-npiggin@gmail.com> X-Mailer: git-send-email 2.18.0 Subject: [Pdbg] [PATCH 1/2] libpdbg/chip: implement putnia with a sequence compatible with P9 X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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" P9 MTNIA uses LR as the source register, so set LR as well as GPR0. This will work on P8 and P9. This is a bit ugly, but it will work until we have general getspr/putspr calls for target backends. Signed-off-by: Nicholas Piggin Tested-by: Rashmica Gupta --- These require Rashmica's "pdbg: Fix function call for putnia command" patch to test properly. libpdbg/chip.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 80a2261..1d41d87 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -145,8 +145,8 @@ int ram_sreset_thread(struct pdbg_target *thread_target) * into *results. *results must point to an array the same size as * *opcodes. Each entry from *results is put into SCR0 prior to * executing an opcode so that it may also be used to pass in - * data. Note that only register r0 is saved and restored so opcodes - * must not touch other registers. + * data. Note that only registers r0 and r1 are saved and restored so + * opcode sequences must preserve other registers. */ static int ram_instructions(struct pdbg_target *thread_target, uint64_t *opcodes, uint64_t *results, int len, unsigned int lpar) @@ -242,10 +242,21 @@ int ram_getnia(struct pdbg_target *thread, uint64_t *value) return 0; } +/* + * P9 must MTNIA from LR, P8 can MTNIA from R0. So we set both LR and R0 + * to value. LR must be saved and restored. + * + * This is a hack and should be made much cleaner once we have target + * specific putspr commands. + */ int ram_putnia(struct pdbg_target *thread, uint64_t value) { - uint64_t opcodes[] = {mfspr(0, 277), mtnia(0)}; - uint64_t results[] = {value, 0}; + uint64_t opcodes[] = { mfspr(1, 8), /* mflr r1 */ + mfspr(0, 277), /* value -> r0 */ + mtspr(8, 0), /* mtlr r0 */ + mtnia(0), + mtspr(8, 1), }; /* mtlr r1 */ + uint64_t results[] = {0, value, 0, 0, 0}; CHECK_ERR(ram_instructions(thread, opcodes, results, ARRAY_SIZE(opcodes), 0)); return 0;