From patchwork Fri Sep 7 06:40:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967212 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 42679m57r3z9sBJ for ; Fri, 7 Sep 2018 16:40:44 +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="MSc2Y4gj"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42679m2lRjzF3Sb for ; Fri, 7 Sep 2018 16:40:44 +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="MSc2Y4gj"; 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=209.85.214.195; helo=mail-pl1-f195.google.com; envelope-from=rashmica.g@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="MSc2Y4gj"; dkim-atps=neutral Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) (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 42679h5CHYzF3SK for ; Fri, 7 Sep 2018 16:40:40 +1000 (AEST) Received: by mail-pl1-f195.google.com with SMTP id b30-v6so3850966pla.0 for ; Thu, 06 Sep 2018 23:40:40 -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:in-reply-to:references; bh=eg2+mbVW0ch8IxRHjmwb1eIZsiPD2UPJTnvOAff8mro=; b=MSc2Y4gjEGDbWXQqr5xA+jcDiqvvx9mog08Djz7a9sAUTlhcT8NlVqMrYOWcIzki+r 6EB4eCKMVNr1YA+KFI24QQIFiPAl4O5mHNfiGN7YwvbBddVMkV8awUAcgkrLZm4XzjIZ JuWvtpiJdywA7Y5RXAkGZy0yUnHFzQTMew92Q2iddTFmaOhoDPSZ31BGw+mQ6UA5jTOq QxyMB55rLidrqMCGVC1O/yTSsjSxMsqLs9nDU4AVqwXxw1vV30n9I08y3q+0AM8sKDi4 7KC0XdFaQbbdqngcgOeHScWvfEsoGWpJHaoJfjkosrdGKKaENp9mvvIqMDPmRada1XxI gQMg== 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:in-reply-to :references; bh=eg2+mbVW0ch8IxRHjmwb1eIZsiPD2UPJTnvOAff8mro=; b=fLDJUjCInW0bQHwExJEYaIi6kjfCvACVX95++0jBrs8iPjj7rpLHny9RWOenE3aiXV nFsSY7ViCBRUTT85xfLZBQDSEDpzO3Oyu9uw9HBpEEeFfjUVStEV6y/xYmqOuS4flNPQ 28l0rIeYmAGy43IzRJygh/xcTruQYhgAB4bn8kk2TaI/OrMkTWsO+K7mO401Fb/rFbHB VOU6aQjc2P6D9ozy29XX7m25bIZ+B412FzWeko5kbyFK+4GpBYWTjrCdiw87pPIoCecM ZBFjgfWj23SUjKpUQ9iVf+oKXYPIx6Vp6B71brQ6cCRU2bkpfr7kaOSqn7eIJCz707U+ l73Q== X-Gm-Message-State: APzg51DCo5XGwxgL76BCJwuJcybLhufdD1LFIHF6QvFvLmv+MTRzKnLL 2CSI+uS4EPdNFthJwPGA1Q2usyD1uiU= X-Google-Smtp-Source: ANB0Vda1ZgiYkTSz1su74K/mbweRGle3kJpXciM18DiJcG5Z3eia1Bnqu+xU11grIYOMfO0K98AGjg== X-Received: by 2002:a17:902:722:: with SMTP id 31-v6mr6373802pli.207.1536302438388; Thu, 06 Sep 2018 23:40:38 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.40.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:40:37 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:00 +1000 Message-Id: <20180907064015.1058-2-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 01/16] libpdbg: Release adu lock when erroring out 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- libpdbg/adu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libpdbg/adu.c b/libpdbg/adu.c index 4f2949f..27049b7 100644 --- a/libpdbg/adu.c +++ b/libpdbg/adu.c @@ -277,6 +277,7 @@ retry: else { PR_ERROR("Unable to read memory. " \ "ALTD_STATUS_REG = 0x%016" PRIx64 "\n", val); + adu_unlock(adu); return -1; } } From patchwork Fri Sep 7 06:40:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967214 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 4267B31CcFz9sBJ for ; Fri, 7 Sep 2018 16:40:59 +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="KOo9NF2D"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267B26CwqzF3Sd for ; Fri, 7 Sep 2018 16:40:58 +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="KOo9NF2D"; 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=209.85.215.178; helo=mail-pg1-f178.google.com; envelope-from=rashmica.g@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="KOo9NF2D"; dkim-atps=neutral Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 42679y5yLxzF3SN for ; Fri, 7 Sep 2018 16:40:54 +1000 (AEST) Received: by mail-pg1-f178.google.com with SMTP id x26-v6so6478093pge.12 for ; Thu, 06 Sep 2018 23:40:54 -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:in-reply-to:references; bh=c3LfDcAOKahkHzN5UfQ8CSD/XyNvt9gW+aoR5oppW+g=; b=KOo9NF2DmtgTSuB4fxPbQJOLQjHa2IH1C556vGTmm89DKpCQg9h/eR9RST/vEpACs1 GaWlRSlxESrBxo8FhwCQUtfiobnUsSX6hWFS772cEJWK6ocK5qLTLEqK8Aj0OR8aFcRn Ob+wLehQgUfABOHD9PHyyRGAQOBvywgONCvkXiX3HndAajlve18BMS3wGw6zzPMUCX2P JzRdAgVQoDDu514+MbrdmvpgdYUkE7WW9FmR0DwHhSkSIRg+qxxXNqSrD6ZgsmJmTsVc py+/3WHVgFeuL9GyqVrYp8KhiIyNhfPbRoNNS66UTLNoHYP1AIfcyoDNuQJBiIBVkbB8 6i6w== 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:in-reply-to :references; bh=c3LfDcAOKahkHzN5UfQ8CSD/XyNvt9gW+aoR5oppW+g=; b=DNhNTwz7QadGOVsw6Op2HURs3szDYuH3V+wFYFxGjvDGGZpbrIrt21Lf24TON31qMb ViV10SoKBMZWKC92IXA9hUzr4lRi57JUdCvhPRA9adlu2pENTCvPIjMxIYzVygE+BQjX w55i2/nuzbvT8JxBpIs+98Se/o9t/0u1dOSLrAum/xnHJv4XbeozM5wpFcmY8Kfy9K2m /rOesPLiaF+wZQiZFG7cqqQlRup+gVtKYaNh97OrVDBTlDNHL9yWcoGxIdDexJEmdPnP +aG7y263q/aSGZ7YNQzbXomD+DxWqVb/0eBw1H/J5HapQDii9OTxB7SswmLDeiJ3lPsw Ekhg== X-Gm-Message-State: APzg51DKavzsx3yGfijl0gxd4R+Puuo+HOdSOOCjiAba5m6SgHc63GGM mslrOpltpbj2AO2PBy+guene3lmiSdY= X-Google-Smtp-Source: ANB0Vdaa4KRZJOKOJd5yYheBQM77qe/D1WLIOWRl1YKpscUAWw/HWaaEv3P+VQRCpUpMAxHJsXxiMw== X-Received: by 2002:a62:438f:: with SMTP id l15-v6mr7068066pfi.196.1536302452860; Thu, 06 Sep 2018 23:40:52 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.40.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:40:52 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:01 +1000 Message-Id: <20180907064015.1058-3-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 02/16] pdbg: Fix function call for putnia command 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- src/reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reg.c b/src/reg.c index aa77a8a..c63f6da 100644 --- a/src/reg.c +++ b/src/reg.c @@ -116,7 +116,7 @@ OPTCMD_DEFINE_CMD(getnia, getnia); static int putnia(uint64_t nia) { uint64_t reg = REG_NIA; - return for_each_target("thread", getprocreg, ®, &nia); + return for_each_target("thread", putprocreg, ®, &nia); } OPTCMD_DEFINE_CMD_WITH_ARGS(putnia, putnia, (DATA)); From patchwork Fri Sep 7 06:40:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967215 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 4267BB3GzFz9sBJ for ; Fri, 7 Sep 2018 16:41:06 +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="tYgac/5B"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267BB0kNyzF3SR for ; Fri, 7 Sep 2018 16:41:06 +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="tYgac/5B"; 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=209.85.214.176; helo=mail-pl1-f176.google.com; envelope-from=rashmica.g@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="tYgac/5B"; dkim-atps=neutral Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 4267B137rTzF3SN for ; Fri, 7 Sep 2018 16:40:57 +1000 (AEST) Received: by mail-pl1-f176.google.com with SMTP id f1-v6so6133446plt.4 for ; Thu, 06 Sep 2018 23:40:57 -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:in-reply-to:references; bh=eRjNLdpug2qunr2gOzXBwNeAXD29v55+TfYcYT1Hfgg=; b=tYgac/5BY5t+WKfoezQJgeeH1Y3lHu+pvgluTNzRsClVODeraMSdWlXVkhV4ZCL/D3 RC/AmY7ULWYcVVuh3QDaRTzOrSKA2xm4DlafxV308J4B3hWSMwhl2tWAprJK7iqjC+mk VxxTxipiN1q5o82OL7MKeBoMh9pxIwcg2YnTDO+r94NeSqwQt+0/Agw2HPut3qTUR5yB 6WNCDwwTB/qzIqYEDvNVoWDPhLslnXUEoJWHpwOpOZsjeagRTjePIp2JjhkncYqMMWJ5 VX/ZbPW38Lbp5SIQxOlw6MkEwPrb+tc1YXqCsUfPwkY15qUDkFejpFYZUAKtt9vG/eic BpQw== 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:in-reply-to :references; bh=eRjNLdpug2qunr2gOzXBwNeAXD29v55+TfYcYT1Hfgg=; b=HO37hZrfV7ebYqgi0YofQfFwIpmBNDlcaxN/cAeoCUfrptnKKxDXYzLxp9QudHP6Mi 1DaBhOGnN5uao3DHQsICpEPTAavdP/NTqn7ReZEswB46czV6rRrt3vB9R+0VSNo5kv9h BRxrMf/qGvdyKdaNiiJhzCGBkBsdBTDM+6DDp4jCE0VdTGAks24xMB8Pr1BqA2RFA6hy uzkaHcGNOvzlD130Bn3oDBT8NcvRdpGZXy1LJMmwfo4ILw/1Zr7sQkuwQJAd+K0BVmgO q88laAtTkw1oUwLbJzxTkeLyTgyFBWquLZ8N4I6I6E/7nszLFIOZu0fMBRbRuYeCwjoF uROQ== X-Gm-Message-State: APzg51Bdyja6ljjRvl1LVryhlYRryyT0emumnWlbll4mvwC9ydK0Yoox M6NygdusYF2L+2L4XJ21hzAaBRFTbPY= X-Google-Smtp-Source: ANB0VdaNbUexmpYXQfBuAhh6m2zFYt1apYl+CSSZLtpfKJxElnRZ18WlB4lbEgkHRECGbyDbiV/08g== X-Received: by 2002:a17:902:b28:: with SMTP id 37-v6mr1587772plq.337.1536302455283; Thu, 06 Sep 2018 23:40:55 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.40.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:40:54 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:02 +1000 Message-Id: <20180907064015.1058-4-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 03/16] libpdbg: Print the name of the instruction when erroring 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- libpdbg/chip.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 80a2261..1c5080e 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -29,7 +29,7 @@ static uint64_t mfspr(uint64_t reg, uint64_t spr) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mfspr\n"); return MFSPR_OPCODE | (reg << 21) | ((spr & 0x1f) << 16) | ((spr & 0x3e0) << 6); } @@ -37,7 +37,7 @@ static uint64_t mfspr(uint64_t reg, uint64_t spr) static uint64_t mtspr(uint64_t spr, uint64_t reg) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mtspr\n"); return MTSPR_OPCODE | (reg << 21) | ((spr & 0x1f) << 16) | ((spr & 0x3e0) << 6); } @@ -45,9 +45,9 @@ static uint64_t mtspr(uint64_t spr, uint64_t reg) static uint64_t mfocrf(uint64_t reg, uint64_t cr) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mfocrf\n"); if (cr > 7) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid CR field specified\n"); return MFOCRF_OPCODE | (reg << 21) | (1U << (12 + cr)); } @@ -55,7 +55,7 @@ static uint64_t mfocrf(uint64_t reg, uint64_t cr) static uint64_t mfnia(uint64_t reg) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mfnia\n"); return MFNIA_OPCODE | (reg << 21); } @@ -63,7 +63,7 @@ static uint64_t mfnia(uint64_t reg) static uint64_t mtnia(uint64_t reg) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mtnia\n"); return MTNIA_OPCODE | (reg << 21); } @@ -71,7 +71,7 @@ static uint64_t mtnia(uint64_t reg) static uint64_t mfmsr(uint64_t reg) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mfmsr\n"); return MFMSR_OPCODE | (reg << 21); } @@ -79,7 +79,7 @@ static uint64_t mfmsr(uint64_t reg) static uint64_t mtmsr(uint64_t reg) { if (reg > 31) - PR_ERROR("Invalid register specified\n"); + PR_ERROR("Invalid register specified for mtmsr\n"); return MTMSR_OPCODE | (reg << 21); } From patchwork Fri Sep 7 06:40:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967216 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 4267BF6CBKz9s4Z for ; Fri, 7 Sep 2018 16:41:09 +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="Q03+didK"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267BF3LtyzF3Sb for ; Fri, 7 Sep 2018 16:41:09 +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="Q03+didK"; 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=209.85.210.176; helo=mail-pf1-f176.google.com; envelope-from=rashmica.g@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="Q03+didK"; dkim-atps=neutral Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 4267B36vtGzF3Sf for ; Fri, 7 Sep 2018 16:40:59 +1000 (AEST) Received: by mail-pf1-f176.google.com with SMTP id l9-v6so6523087pff.9 for ; Thu, 06 Sep 2018 23:40:59 -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:in-reply-to:references; bh=mPn9JMcr+4YlqANWvJNT/bUvdbMvr5qFcFBkg9VYCVY=; b=Q03+didK47XTSb18u2NkKKYQ0zULV6Tn7qPCkvgkp+wO2/ehKUaoSZwFJgHKOcv07U oTzvt29eaZUJb+FguE/s7OxysgZarAFBPNQZ3xCAImCX7whP33bHPlAaXA8z+ogSBDup AT5BEIR0w20hffRHVkXiu1BWHDsKOXqBw9tCa8qsQLHsxyV9/uh/rRRUvJTKJT1attYO 6tZp8aQz2yTPMsWqCFCusSun176A6au+4Z6mLOFCrS6aTOKpZDZGe2rDGRMaCHZUOw64 82TmI18yGF7kKLd3bAv3l45BxzO+lr9stFf9GcBntBj1ctFWugAPyCP/cTJP/yKDbZY/ vrfA== 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:in-reply-to :references; bh=mPn9JMcr+4YlqANWvJNT/bUvdbMvr5qFcFBkg9VYCVY=; b=ssG1GIqyFsfyWT+DR09nMKLjCbPSJ43W9VY46BKC1P9V5AM/agbB9GiWCdFJ3fl6+n p3IdIjHiuY1pINp+zSd/ifGN5vh0R6Vklu8m1WfDp75kxnam5k3hJ+/etv8ZJ86pykU2 fF6pf6XUmlbgmS6YFexdZohOoxI+bPsDx+KkToAxjM5J84rbBkzFCruY6HazdelCUF4N +ipCPVRK/+ahpMaXKvWNf7NOZgHWOZ2r+JpXQvoBCP1STG9BywdwHWkuu6oOhH3JP//u leS1aO6gWW33K0UxYM97TCCnHuCQmywqU6Q2isSnyrTpW1veqVAcf8dZHVu2Luqmyqhz AQyA== X-Gm-Message-State: APzg51C/4nhwbNnXXcq4bF9v6XhWiy3+T372V8wLK0gJtcZJ6LH1/jEe Fr1C5j2zmHWUWc+F3ZQcWSTYHgim8A8= X-Google-Smtp-Source: ANB0Vda/4kArPLe3oby/UDYeAOZIsu8Cbh5wXaVukQb/Zsgi43XMwyg5nQAbupMhAbwIKYo3Prl0BQ== X-Received: by 2002:a65:49cc:: with SMTP id t12-v6mr6678731pgs.27.1536302457614; Thu, 06 Sep 2018 23:40:57 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.40.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:40:57 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:03 +1000 Message-Id: <20180907064015.1058-5-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 04/16] libpdbg: Remove unused error code 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" --- libpdbg/operations.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/libpdbg/operations.h b/libpdbg/operations.h index 52bfe7e..722b53a 100644 --- a/libpdbg/operations.h +++ b/libpdbg/operations.h @@ -20,9 +20,6 @@ #include "target.h" #include "debug.h" -/* Error codes */ -#define EFSI 1 - #define PRINT_ERR PR_DEBUG("failed\n"); #define CHECK_ERR(x) do { \ if (x) { \ From patchwork Fri Sep 7 06:40:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967217 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 4267BJ5RBPz9s4Z for ; Fri, 7 Sep 2018 16:41:12 +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="LJEqg9QK"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267BJ3TWjzF3Sc for ; Fri, 7 Sep 2018 16:41:12 +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="LJEqg9QK"; 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=209.85.215.176; helo=mail-pg1-f176.google.com; envelope-from=rashmica.g@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="LJEqg9QK"; dkim-atps=neutral Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 4267B635vNzF3SR for ; Fri, 7 Sep 2018 16:41:02 +1000 (AEST) Received: by mail-pg1-f176.google.com with SMTP id x26-v6so6478260pge.12 for ; Thu, 06 Sep 2018 23:41:02 -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:in-reply-to:references; bh=7MwA6agLgjK11S8EHY0d+LMkJOYa4wbpoOUop05RR0M=; b=LJEqg9QKUlFcprBL/1eBPwHzLFi0fqpKvv5RYY9AutrW+ROyBUeztCxAVyHd9P8+nu Y/wKoZB7DGJ3DY0GL4XT52RDJOs3tKGn/sXkQs6yIcAPeWGJRJONUENsuT1U/zUs7ze+ KVwY67RpF7usXaS3mFJ8uWWkxdheEnxp0/ME4kNW/nwg6YnK9K5Z9P3sbQ81Aa5G5Msz rLCTwQc84tATM1m5iZohJv0kJpeqk8qS3esFOYQp8gEtwp0ZpN8CurueP2advTUERsk2 8TW6Lc+qLZAUX8EMa7rke232q1dw6DOg1TVa2oFfZEqrDE+o3OEaheKVVGzrJhqo2w2M Y/SA== 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:in-reply-to :references; bh=7MwA6agLgjK11S8EHY0d+LMkJOYa4wbpoOUop05RR0M=; b=pQ+fLxj3kEuGqANpdhdGSLFo1+U2m/AtdCNxkbOwojOpDmxhQkpi+vqn+XU8K1fIq+ v28CHbWhnQ/oH+sNf3TgH3fwiqkDkZa6MwaeMrUjI0ACntciOXONcDoGj+XIrC8rK2ky W3x4XV5b5bv1NRMaX1jBsqwnaJZQFEfaBWKPKClwsV7+hB0+Yxoa2nIJ2ZFkh81dixbh g26TCI116YO47fpKEGs3/yb/3Rz3N/x+SXMoC94G3CZsl7yui1c0dvDzyDcIUMRsbSLo cXovTu6rJY2//M5F1to+lgE4tceZnogYRGDYuF3lFkc1ff/bB7IVdREtoatKrKf9ly7v nGrw== X-Gm-Message-State: APzg51DgjW+qCu+1ACn921v9zrxkn2A1Dj2os6speQT0CRXpwUWmlUfK Q+ho7rXSL28zNJJP8hRe23s9nGHWA1k= X-Google-Smtp-Source: ANB0VdYJoCUU6JfShJnPnEd9yKlm14zTUNJKxqz3hzRGMpjRZ9KUwRLE9gyKdivJzxDdusAi0L9VVg== X-Received: by 2002:a63:221b:: with SMTP id i27-v6mr6501735pgi.212.1536302460001; Thu, 06 Sep 2018 23:41:00 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.40.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:40:59 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:04 +1000 Message-Id: <20180907064015.1058-6-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 05/16] libpdbg: Check if scom controllers are exposed 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" If CONFIG_SCOM_DEBUGFS is not set in the running kernel then the scom controllers are not exposed and so using getscom won't work. Add check for /sys/kernel/debug/powerpc/scom to give a more useful error message. Signed-off-by: Rashmica Gupta --- libpdbg/host.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libpdbg/host.c b/libpdbg/host.c index 483e048..eb627be 100644 --- a/libpdbg/host.c +++ b/libpdbg/host.c @@ -95,7 +95,15 @@ static int host_pib_probe(struct pdbg_target *target) if (chip_id == -1) goto out; - if (asprintf(&access_fn, "%s/%08x/access", XSCOM_BASE_PATH, chip_id) < 0) + /* This check should probably be done earlier */ + if (access(XSCOM_BASE_PATH, F_OK) == -1) + { + PR_ERROR("Can not access %s. ", XSCOM_BASE_PATH); + PR_ERROR("Is CONFIG_SCOM_DEBUGFS set? "); + PR_ERROR("You may need to re-run the command as root.\n"); + } + + if (asprintf(&access_fn, "%s/%08d/access", XSCOM_BASE_PATH, chip_id) < 0) goto out; *fd = open(access_fn, O_RDWR); From patchwork Fri Sep 7 06:40:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967218 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 4267BM26H6z9s4Z for ; Fri, 7 Sep 2018 16:41:15 +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="qy+zyDs9"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267BM01WhzF3Sk for ; Fri, 7 Sep 2018 16:41:15 +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="qy+zyDs9"; 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=209.85.215.196; helo=mail-pg1-f196.google.com; envelope-from=rashmica.g@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="qy+zyDs9"; dkim-atps=neutral Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) (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 4267B8619nzF3ST for ; Fri, 7 Sep 2018 16:41:04 +1000 (AEST) Received: by mail-pg1-f196.google.com with SMTP id v66-v6so6473818pgb.10 for ; Thu, 06 Sep 2018 23:41:04 -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:in-reply-to:references; bh=oOBeKWKKgZYl/nVuhuLUWeF3PyDl1aFvFuJnsHThD20=; b=qy+zyDs9hECVtnRotC8+nvUr7IsEwCFqUxNjV7mRdgRuUyNaF+CHcFE4hnjDM3wul4 r0TuUIHB2INJJ+A3KApyLh9CQPhIE2Y7v1CdfxapudfXnXH5k21lB8Dhfq3Q30GMyH/l gDq0l9guB7XGk9p6KUn9f/w+uBqWh25mLieM/WWTShU0Zd4KrmpqpJKaEz8p58bYUXFu cYHjqBBbIz4nEg9/bjKvLaKCS/inHHDMEH19gmd3If1fAoGGR8NCV2PvX3kpxh2y3eX5 bzWQSKHq6ooK3uWxeKNk/DdoTolEfJ1SREanukTq4ceE5KuPVA48MEnMEKUmaEDHzzGC CJ+Q== 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:in-reply-to :references; bh=oOBeKWKKgZYl/nVuhuLUWeF3PyDl1aFvFuJnsHThD20=; b=dWb8uTixROlXZaqYrGNG9zAJvx09kpUZHxkrltMzWlI0l0Ka49Imkzwxo4gZlxwrlJ iDQU6QA2Aeq6eMe/33ZZlYAAQqrYnUENHgLlVfhgW6y7H81TuVnkTjk38XqrKIFjYUy3 vTD4zC9JRbYpHycmSP86srll6lnQjLW2dnmCRN2JZnyHPnryH8pQnxPqj36EqZnqeL7V 76cEf6UC2VAodUDWerseNp2YhNfnzk6NnePgMha1k3pRzkmWKUuI8lFljakhMxi2kfo8 crOJvBjUHX1MrMpD+Uu4g80zsSfaDE6ZADaRtSJze+wPhgv1GWqnRQiEm5JKBhSwsBll 7WGA== X-Gm-Message-State: APzg51A2LOw7X9A1iiiSSpW/PY0+tx3OxXnlNWm1EXsEUiJ4dXdZRIg+ ihXJ9ikaPQUSgqVZXiCihR6hdEab178= X-Google-Smtp-Source: ANB0Vdb1EB/H+Bqavzxju3kjDXFV9NqieTo9EoKo0AUHNv2EtXSY3VlEx6/hfoHueIUTiVsTwgCRMA== X-Received: by 2002:a63:c544:: with SMTP id g4-v6mr6786343pgd.113.1536302462545; Thu, 06 Sep 2018 23:41:02 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.41.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:41:02 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:05 +1000 Message-Id: <20180907064015.1058-7-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 06/16] libpdbg: Add in getxer and putxer functions 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- libpdbg/chip.c | 40 ++++++++++++++++++------ libpdbg/chip.h | 24 +++++++++++++++ libpdbg/libpdbg.h | 4 ++- libpdbg/operations.h | 3 +- libpdbg/p8chip.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ libpdbg/p9chip.c | 31 +++++++++++++++++-- libpdbg/target.h | 2 ++ 7 files changed, 177 insertions(+), 13 deletions(-) create mode 100644 libpdbg/chip.h diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 1c5080e..01c9b58 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -26,7 +26,7 @@ #include "bitutils.h" #include "debug.h" -static uint64_t mfspr(uint64_t reg, uint64_t spr) +uint64_t mfspr(uint64_t reg, uint64_t spr) { if (reg > 31) PR_ERROR("Invalid register specified for mfspr\n"); @@ -34,7 +34,7 @@ static uint64_t mfspr(uint64_t reg, uint64_t spr) return MFSPR_OPCODE | (reg << 21) | ((spr & 0x1f) << 16) | ((spr & 0x3e0) << 6); } -static uint64_t mtspr(uint64_t spr, uint64_t reg) +uint64_t mtspr(uint64_t spr, uint64_t reg) { if (reg > 31) PR_ERROR("Invalid register specified for mtspr\n"); @@ -148,7 +148,7 @@ int ram_sreset_thread(struct pdbg_target *thread_target) * data. Note that only register r0 is saved and restored so opcodes * must not touch other registers. */ -static int ram_instructions(struct pdbg_target *thread_target, uint64_t *opcodes, +int ram_instructions(struct pdbg_target *thread_target, uint64_t *opcodes, uint64_t *results, int len, unsigned int lpar) { uint64_t opcode = 0, r0 = 0, r1 = 0, scratch = 0; @@ -168,6 +168,7 @@ static int ram_instructions(struct pdbg_target *thread_target, uint64_t *opcodes /* RAM instructions */ for (i = -2; i < len + 2; i++) { if (i == -2) + /* Save r1 (assumes opcodes don't touch other registers) */ opcode = mtspr(277, 1); else if (i == -1) /* Save r0 (assumes opcodes don't touch other registers) */ @@ -309,6 +310,31 @@ int ram_getmem(struct pdbg_target *thread, uint64_t addr, uint64_t *value) return 0; } +int ram_getxer(struct pdbg_target *thread_target, uint64_t *value) +{ + + struct thread *thread; + + assert(!strcmp(thread_target->class, "thread")); + thread = target_to_thread(thread_target); + + CHECK_ERR(thread->ram_getxer(thread_target, value)); + + return 0; +} + +int ram_putxer(struct pdbg_target *thread_target, uint64_t value) +{ + struct thread *thread; + + assert(!strcmp(thread_target->class, "thread")); + thread = target_to_thread(thread_target); + + CHECK_ERR(thread->ram_putxer(thread_target, value)); + + return 0; +} + /* * Read the given ring from the given chiplet. Result must be large enough to hold ring_len bits. */ @@ -368,12 +394,8 @@ int ram_state_thread(struct pdbg_target *thread, struct thread_regs *regs) } printf("CR : 0x%08" PRIx32 "\n", regs->cr); -#if 0 - /* TODO: Disabling because reading SPR 0x1 reliably checkstops a P8 */ - ram_getspr(thread, 0x1, &value); - regs->xer = value; - printf("XER : 0x%08" PRIx32 "\n", regs->xer); -#endif + ram_getxer(thread, ®s->xer); + printf("XER : 0x%08" PRIx64 "\n", regs->xer); printf("GPRS :\n"); for (i = 0; i < 32; i++) { diff --git a/libpdbg/chip.h b/libpdbg/chip.h new file mode 100644 index 0000000..52f3486 --- /dev/null +++ b/libpdbg/chip.h @@ -0,0 +1,24 @@ +/* Copyright 2018 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __LIBPDBG_CHIP_H +#define __LIBPDBG_CHIP_H + +uint64_t mfspr(uint64_t reg, uint64_t spr) __attribute__ ((visibility("hidden"))); +uint64_t mtspr(uint64_t spr, uint64_t reg) __attribute__ ((visibility("hidden"))); +int ram_instructions(struct pdbg_target *thread_target, uint64_t *opcodes, + uint64_t *results, int len, unsigned int lpar) __attribute__ + ((visibility("hidden"))); +#endif diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 1008e6a..68d158c 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -107,7 +107,7 @@ struct thread_regs { uint64_t ctr; uint64_t tar; uint32_t cr; - uint32_t xer; + uint64_t xer; uint64_t gprs[32]; uint64_t lpcr; @@ -150,6 +150,8 @@ int ram_stop_thread(struct pdbg_target *target); int ram_sreset_thread(struct pdbg_target *target); int ram_state_thread(struct pdbg_target *target, struct thread_regs *regs); struct thread_state thread_status(struct pdbg_target *target); +int ram_getxer(struct pdbg_target *thread, uint64_t *value); +int ram_putxer(struct pdbg_target *thread, uint64_t value); int getring(struct pdbg_target *chiplet_target, uint64_t ring_addr, uint64_t ring_len, uint32_t result[]); enum pdbg_sleep_state {PDBG_THREAD_STATE_RUN, PDBG_THREAD_STATE_DOZE, diff --git a/libpdbg/operations.h b/libpdbg/operations.h index 722b53a..971a3f6 100644 --- a/libpdbg/operations.h +++ b/libpdbg/operations.h @@ -64,9 +64,10 @@ #define MFOCRF_OPCODE 0x7c100026UL #define MFSPR_MASK (MFSPR_OPCODE | ((0x1f) << 16) | ((0x3e0) << 6)) #define MFXER_OPCODE (MFSPR_OPCODE | ((1 & 0x1f) << 16) | ((1 & 0x3e0) << 6)) +#define MTXER_OPCODE (MTSPR_OPCODE | ((1 & 0x1f) << 16) | ((1 & 0x3e0) << 6)) #define LD_OPCODE 0xe8000000UL -#define MFSPR_SPR(opcode) (((opcode >> 16) & 0x1f) | ((opcode >> 6) & 0x3e0)) +#define MXSPR_SPR(opcode) (((opcode >> 16) & 0x1f) | ((opcode >> 6) & 0x3e0)) /* GDB server functionality */ int gdbserver_start(uint16_t port); diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index cb5a46b..89ecfd6 100644 --- a/libpdbg/p8chip.c +++ b/libpdbg/p8chip.c @@ -83,9 +83,61 @@ #define EX_PM_GP0_REG 0xf0100 #define SPECIAL_WKUP_DONE PPC_BIT(31) +/* p8 specific opcodes for instruction ramming*/ +#define MTXERF0_OPCODE 0x00000008UL +#define MTXERF1_OPCODE 0x00000108UL +#define MTXERF2_OPCODE 0x00000208UL +#define MTXERF3_OPCODE 0x00000308UL +#define MFXERF0_OPCODE 0x00000010UL +#define MFXERF1_OPCODE 0x00000110UL +#define MFXERF2_OPCODE 0x00000210UL +#define MFXERF3_OPCODE 0x00000310UL + /* How long (in us) to wait for a special wakeup to complete */ #define SPECIAL_WKUP_TIMEOUT 10 +#include "chip.h" + +static uint64_t mfxerf(uint64_t reg, uint64_t field) +{ + if (reg > 31) + PR_ERROR("Invalid register specified for mfxerf\n"); + + switch (field) { + case 0: + return MFXERF0_OPCODE | (reg << 21); + case 1: + return MFXERF1_OPCODE | (reg << 21); + case 2: + return MFXERF2_OPCODE | (reg << 21); + case 3: + return MFXERF3_OPCODE | (reg << 21); + default: + PR_ERROR("Invalid XER field specified\n"); + } + return 0; +} + +static uint64_t mtxerf(uint64_t reg, uint64_t field) +{ + if (reg > 31) + PR_ERROR("Invalid register specified for mtxerf\n"); + + switch (field) { + case 0: + return MTXERF0_OPCODE | (reg << 21); + case 1: + return MTXERF1_OPCODE | (reg << 21); + case 2: + return MTXERF2_OPCODE | (reg << 21); + case 3: + return MTXERF3_OPCODE | (reg << 21); + default: + PR_ERROR("Invalid XER field specified\n"); + } + return 0; +} + static int assert_special_wakeup(struct core *chip) { int i = 0; @@ -386,6 +438,38 @@ static int p8_ram_destroy(struct thread *thread) return 0; } +static int p8_ram_getxer(struct pdbg_target *thread, uint64_t *value) +{ + uint64_t opcodes[] = {mfxerf(0, 0), mtspr(277, 0), mfxerf(0, 1), + mtspr(277, 0), mfxerf(0, 2), mtspr(277, 0), + mfxerf(0, 3), mtspr(277, 0)}; + uint64_t results[] = {0, 0, 0, 0, 0, 0, 0, 0}; + + /* On POWER8 we can't get xer with getspr. We seem to only be able to + * get and set IBM bits 32-34 and 44-56. + */ + PR_WARNING("Can only get/set IBM bits 32-34 and 44-56 of the XER register\n"); + + + CHECK_ERR(ram_instructions(thread, opcodes, results, ARRAY_SIZE(opcodes), 0)); + + *value = results[1] | results[3] | results[5] | results[7]; + return 0; +} + +static int p8_ram_putxer(struct pdbg_target *thread, uint64_t value) +{ + uint64_t fields[] = {value, value, value, value, 0}; + uint64_t opcodes[] = {mfspr(0, 277), mtxerf(0, 0), mtxerf(0, 1), mtxerf(0, 2), mtxerf(0, 3)}; + + /* We seem to only be able to get and set IBM bits 32-34 and 44-56.*/ + PR_WARNING("Can only set IBM bits 32-34 and 44-56 of the XER register\n"); + + CHECK_ERR(ram_instructions(thread, opcodes, fields, ARRAY_SIZE(opcodes), 0)); + + return 0; +} + /* * Initialise all viable threads for ramming on the given core. */ @@ -413,6 +497,8 @@ static struct thread p8_thread = { .ram_setup = p8_ram_setup, .ram_instruction = p8_ram_instruction, .ram_destroy = p8_ram_destroy, + .ram_getxer = p8_ram_getxer, + .ram_putxer = p8_ram_putxer, }; DECLARE_HW_UNIT(p8_thread); diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c index 189d80a..f126968 100644 --- a/libpdbg/p9chip.c +++ b/libpdbg/p9chip.c @@ -292,7 +292,6 @@ static int __p9_ram_instruction(struct thread *thread, uint64_t opcode, uint64_t switch(opcode & OPCODE_MASK) { case MTNIA_OPCODE: predecode = 8; - /* Not currently supported as we can only MTNIA from LR */ PR_ERROR("MTNIA is not currently supported\n"); break; @@ -307,7 +306,18 @@ static int __p9_ram_instruction(struct thread *thread, uint64_t opcode, uint64_t break; case MFSPR_OPCODE: - switch(MFSPR_SPR(opcode)) { + switch(MXSPR_SPR(opcode)) { + case 1: /* XER */ + predecode = 4; + break; + default: + predecode = 0; + break; + } + break; + + case MTSPR_OPCODE: + switch(MXSPR_SPR(opcode)) { case 1: /* XER */ predecode = 4; break; @@ -395,6 +405,21 @@ static int p9_ram_destroy(struct thread *thread) return 0; } +static int p9_ram_getxer(struct pdbg_target *thread, uint64_t *value) +{ + CHECK_ERR(ram_getspr(thread, 1, value)); + + return 0; +} + +static int p9_ram_putxer(struct pdbg_target *thread, uint64_t value) +{ + CHECK_ERR(ram_putspr(thread, 1, value)); + + return 0; + +} + static struct thread p9_thread = { .target = { .name = "POWER9 Thread", @@ -410,6 +435,8 @@ static struct thread p9_thread = { .ram_setup = p9_ram_setup, .ram_instruction = p9_ram_instruction, .ram_destroy = p9_ram_destroy, + .ram_getxer = p9_ram_getxer, + .ram_putxer = p9_ram_putxer, }; DECLARE_HW_UNIT(p9_thread); diff --git a/libpdbg/target.h b/libpdbg/target.h index 9f055ac..8bad405 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -153,6 +153,8 @@ struct thread { int (*ram_setup)(struct thread *); int (*ram_instruction)(struct thread *, uint64_t opcode, uint64_t *scratch); int (*ram_destroy)(struct thread *); + int (*ram_getxer)(struct pdbg_target *, uint64_t *value); + int (*ram_putxer)(struct pdbg_target *, uint64_t value); }; #define target_to_thread(x) container_of(x, struct thread, target) From patchwork Fri Sep 7 06:40:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967219 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 4267BQ0R0Pz9s4Z for ; Fri, 7 Sep 2018 16:41: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="Ip04NfYM"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267BP599KzF3Sb for ; Fri, 7 Sep 2018 16:41:17 +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="Ip04NfYM"; 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=209.85.215.180; helo=mail-pg1-f180.google.com; envelope-from=rashmica.g@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="Ip04NfYM"; dkim-atps=neutral Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (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 4267BC0rPMzF3SN for ; Fri, 7 Sep 2018 16:41:06 +1000 (AEST) Received: by mail-pg1-f180.google.com with SMTP id r1-v6so6476743pgp.11 for ; Thu, 06 Sep 2018 23:41:06 -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:in-reply-to:references; bh=NYoNGQrw8poaIEHIHdsZGx4adncnFONY4UoK/FwDBLQ=; b=Ip04NfYMZyPDUYT+6GZjWBCdelDNmy3HzZ4JMz4MBVXF7uZYKHwuMM1RmmhmMWlu5y AneTa0J5l1ERAJzrECxsmhR1kDSUQ+e89RLknOJqnRmjl9Yh5ePaaWpgDYOxc9jrVsjO Pyu4BY96WyP9ZxovlmhN74A1UD2TabJy5W+yxSlV3nG/ZFpnVdttctvDpbCZYq9NZ5SA ybwprugJKk060azR4kyYhXz84QZfJHOs16W3VD0MpEwHpBfplZIjJT9c1/1gwzqaLCqm hpGY20y+2C8fAzy967Swvck78t6AzHdVVT2bsSCrbF3E8CUrxbkbHfrJ1Y7PoJaoUOXO 8rxw== 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:in-reply-to :references; bh=NYoNGQrw8poaIEHIHdsZGx4adncnFONY4UoK/FwDBLQ=; b=DfDNfZBztQgPw/Z9+zGRHDsjb4L7b96/ntoq6gzuWDXupBmJArYhv8j0VK5RpZCcaK FMhqzYt6+d38fP+sJO43pR69HEVAR6X3Z7dGmnxWvxdzdNSdhKx7ZSQs1NY2X6qZy46q LVP7EthYSIAEnJ0OasbPthn4hpAKaq7qC3l7ulS/yw85abWN/PT0TI9/D+x3Bk7I8DwT VlCjpIfo5QZ9aIJzVQ4xx6gEn1yT0Za0U9cKWG/I4m6LZAFH5ZIkIVkGdJkrEpD+zDL7 7GcjZ4wANHiYU6edbGrw7v+TLZwPHDsWQdFH4WzZrEI5kK/i4wQRabSrFZba7Xg2Rx8A OLsA== X-Gm-Message-State: APzg51B3YvsPkPVFD4Yk3PbVMOKDMzh3e1WU3pDGmfwvF2lRYdeLv2rF 53Fk6sG5+o53VyNqiRjtHWJ5fMc1dng= X-Google-Smtp-Source: ANB0VdZQsKrmmJLNHq30bUG+bjQ7S40m9SjFKkka9e3r3Z4ruuvb6GvJpxS69dd8vDewKkBg3K8Sww== X-Received: by 2002:a62:205d:: with SMTP id g90-v6mr6998901pfg.253.1536302464927; Thu, 06 Sep 2018 23:41:04 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.41.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:41:04 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:06 +1000 Message-Id: <20180907064015.1058-8-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 07/16] pdbg: Add getxer & putxer commands 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- src/main.c | 6 ++++-- src/reg.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 099b2e5..ea025a6 100644 --- a/src/main.c +++ b/src/main.c @@ -87,7 +87,7 @@ extern struct optcmd_cmd optcmd_getnia, optcmd_putnia, optcmd_getmsr, optcmd_putmsr, optcmd_getring, optcmd_start, optcmd_stop, optcmd_step, optcmd_threadstatus, optcmd_sreset, optcmd_regs, optcmd_probe, - optcmd_getmem, optcmd_putmem; + optcmd_getmem, optcmd_putmem, optcmd_getxer, optcmd_putxer; static struct optcmd_cmd *cmds[] = { &optcmd_getscom, &optcmd_putscom, &optcmd_getcfam, &optcmd_putcfam, @@ -95,7 +95,7 @@ static struct optcmd_cmd *cmds[] = { &optcmd_getnia, &optcmd_putnia, &optcmd_getmsr, &optcmd_putmsr, &optcmd_getring, &optcmd_start, &optcmd_stop, &optcmd_step, &optcmd_threadstatus, &optcmd_sreset, &optcmd_regs, &optcmd_probe, - &optcmd_getmem, &optcmd_putmem, + &optcmd_getmem, &optcmd_putmem, &optcmd_getxer, &optcmd_putxer, }; /* Purely for printing usage text. We could integrate printing argument and flag @@ -115,6 +115,8 @@ static struct action actions[] = { { "putspr", " ", "Write Special Purpose Register (SPR)" }, { "getmsr", "", "Get Machine State Register (MSR)" }, { "putmsr", "", "Write Machine State Register (MSR)" }, + { "getxer", "", "Get Fixed Point Exception Register (XER)" }, + { "putxer", "", "Write Fixed Point Exception Register (XER)" }, { "getring", " ", "Read a ring. Length must be correct" }, { "start", "", "Start thread" }, { "step", "", "Set a thread instructions" }, diff --git a/src/reg.c b/src/reg.c index c63f6da..3864316 100644 --- a/src/reg.c +++ b/src/reg.c @@ -24,6 +24,7 @@ #include "main.h" #include "optcmd.h" +#define REG_XER -4 #define REG_MEM -3 #define REG_MSR -2 #define REG_NIA -1 @@ -42,6 +43,8 @@ static void print_proc_reg(struct pdbg_target *target, uint64_t reg, uint64_t va printf("msr: "); else if (reg == REG_NIA) printf("nia: "); + else if (reg == REG_XER) + printf("xer: "); else if (reg > REG_R31) printf("spr%03" PRIu64 ": ", reg - REG_R31); else if (reg >= 0 && reg <= 31) @@ -63,6 +66,8 @@ static int putprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg, rc = ram_putmsr(target, *value); else if (*reg == REG_NIA) rc = ram_putnia(target, *value); + else if (*reg == REG_XER) + rc = ram_putxer(target, *value); else if (*reg > REG_R31) rc = ram_putspr(target, *reg - REG_R31, *value); else if (*reg >= 0 && *reg <= 31) @@ -82,6 +87,8 @@ static int getprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg, rc = ram_getmsr(target, &value); else if (*reg == REG_NIA) rc = ram_getnia(target, &value); + else if (*reg == REG_XER) + rc = ram_getxer(target, &value); else if (*reg > REG_R31) rc = ram_getspr(target, *reg - REG_R31, &value); else if (*reg >= 0 && *reg <= 31) @@ -147,3 +154,18 @@ static int putmsr(uint64_t data) return for_each_target("thread", putprocreg, ®, &data); } OPTCMD_DEFINE_CMD_WITH_ARGS(putmsr, putmsr, (DATA)); + +static int getxer(void) +{ + uint64_t reg = REG_XER; + return for_each_target("thread", getprocreg, ®, NULL); +} +OPTCMD_DEFINE_CMD(getxer, getxer); + +static int putxer(uint64_t data) +{ + uint64_t reg = REG_XER; + uint64_t d = data; + return for_each_target("thread", putprocreg, ®, &d); +} +OPTCMD_DEFINE_CMD_WITH_ARGS(putxer, putxer, (DATA)); From patchwork Fri Sep 7 06:40:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967220 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 4267BT0lLnz9sBJ for ; Fri, 7 Sep 2018 16:41:21 +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="k2sKtpW/"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267BS5kmxzF3SZ for ; Fri, 7 Sep 2018 16:41:20 +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="k2sKtpW/"; 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=209.85.210.171; helo=mail-pf1-f171.google.com; envelope-from=rashmica.g@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="k2sKtpW/"; dkim-atps=neutral Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 4267BF47qTzF3ST for ; Fri, 7 Sep 2018 16:41:09 +1000 (AEST) Received: by mail-pf1-f171.google.com with SMTP id s13-v6so6523494pfi.7 for ; Thu, 06 Sep 2018 23:41:09 -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:in-reply-to:references; bh=8AJEbq49hPFShF9KyjSC3eE4VPiDyErB5df6RZuLk8k=; b=k2sKtpW/RrXo3PRwMSy/l3hKX/kzI4pQ87nU0+fMRo+6hmPD2sNA2h8W8Xe24A2ZWq P2gRsIuLvg986fcNmhmugh1aWVNHMi92AJHMmnD7YoriOGOF/xfJ0PjN1cY9BPFFjxWQ g7WwzQwW2Ct4pcrbphZO9TY0fj3zXwAnkLlQqMDVL11bn8hhJcmCahPx9Kg5QiCmvbnt wqxlrLI3pGnIETZ8hIlzyLd8jQlidJqhuL8sycZOuWdZ5/wbTTZhdgwynAOF76ASu3IC ZHhvxGXS1OaBctVsDc6BQkXBuKaQp5osyypPKh1A6SaKg1gAWe3sWcEaDWb/fgvFLQWB o/Iw== 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:in-reply-to :references; bh=8AJEbq49hPFShF9KyjSC3eE4VPiDyErB5df6RZuLk8k=; b=q4e5wtpyu5QAtpJxpgucQ/vA0APocmShBIXSd2m+ZScTqc7KJJ1aG7K0PCGtS7v8hh Vjsw31KpdzXqbqlGIk3cFSDjzu2yw0mkIambL3eHCbLMIRwWCs7VDFQyIvIor3t0GvrJ AxcCBtqcRhdeK4HOl2rq6jq0f4yfVJu9UwsfosfwKHnVLTupCcDJ8KpRDFOERHYcV8iq UwNhvilhvQf1scYt/nUbv9xuJpqDmfRCnJOMxYqn5zIghAUuhR2TtMCBtwOJTezmjlb+ 2HBKv/G+/AYWg9uxnvSctGWJfMxNmKAVB41NFFJymF1rfqbbLwfCbFQjAcgKvq20MgNp LvOA== X-Gm-Message-State: APzg51BtlRI1w+ARhv+JZW67yWV6upEHDO4tPbvOUdI/H0/rH/WMPw7/ I188mPUL4/KbovZbqV2BSl3Ljy2NQAg= X-Google-Smtp-Source: ANB0Vda42i3wU4vVRnlvS4Ns6GPhVO+4x8CONMA7au94GXO/inaBI0w2pkx7ESH2VnN0cORYSdzNHg== X-Received: by 2002:a63:6b03:: with SMTP id g3-v6mr6673887pgc.57.1536302467301; Thu, 06 Sep 2018 23:41:07 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.41.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:41:06 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:07 +1000 Message-Id: <20180907064015.1058-9-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 08/16] libpdbg: Make getcr actually get all of the Condition Register 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- libpdbg/chip.c | 27 +++++++++++++++++---------- libpdbg/libpdbg.h | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 01c9b58..31c8c80 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -281,13 +281,25 @@ int ram_getmsr(struct pdbg_target *thread, uint64_t *value) return 0; } -int ram_getcr(struct pdbg_target *thread, int cr, uint64_t *value) +int ram_getcr(struct pdbg_target *thread, uint32_t *value) { - uint64_t opcodes[] = {mfocrf(0, cr), mtspr(277, 0)}; - uint64_t results[] = {0, 0}; + + uint64_t opcodes[] = {mfocrf(0, 0), mtspr(277, 0), mfocrf(0, 1), mtspr(277, 0), + mfocrf(0, 2), mtspr(277, 0), mfocrf(0, 3), mtspr(277, 0), + mfocrf(0, 4), mtspr(277, 0), mfocrf(0, 5), mtspr(277, 0), + mfocrf(0, 6), mtspr(277, 0), mfocrf(0, 7), mtspr(277, 0)}; + uint64_t results[16] = {0}; + uint32_t cr_field, cr = 0; + int i; CHECK_ERR(ram_instructions(thread, opcodes, results, ARRAY_SIZE(opcodes), 0)); - *value = results[1]; + for (i = 1; i < 16; i += 2) { + cr_field = results[i]; + /* We are not guaranteed that the other bits will be zeroed out */ + cr |= cr_field & (0xf << 2*(i-1)); + } + + *value = cr; return 0; } @@ -386,12 +398,7 @@ int ram_state_thread(struct pdbg_target *thread, struct thread_regs *regs) ram_getspr(thread, 815, ®s->tar); printf("TAR : 0x%016" PRIx64 "\n", regs->tar); - regs->cr = 0; - for (i = 0; i < 8; i++) { - uint64_t cr = 0; - ram_getcr(thread, i, &cr); - regs->cr |= cr; - } + ram_getcr(thread, ®s->cr); printf("CR : 0x%08" PRIx32 "\n", regs->cr); ram_getxer(thread, ®s->xer); diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 68d158c..9c29ecc 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -141,6 +141,7 @@ int ram_putnia(struct pdbg_target *target, uint64_t val); int ram_putspr(struct pdbg_target *target, int spr, uint64_t val); int ram_putgpr(struct pdbg_target *target, int spr, uint64_t val); int ram_getmsr(struct pdbg_target *target, uint64_t *val); +int ram_getcr(struct pdbg_target *thread, uint32_t *value); int ram_getnia(struct pdbg_target *target, uint64_t *val); int ram_getspr(struct pdbg_target *target, int spr, uint64_t *val); int ram_getgpr(struct pdbg_target *target, int gpr, uint64_t *val); From patchwork Fri Sep 7 06:40:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967221 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 4267BW59jkz9s4Z for ; Fri, 7 Sep 2018 16:41:23 +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="X0hE9Ai0"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267BW3JJHzF3Sj for ; Fri, 7 Sep 2018 16:41:23 +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="X0hE9Ai0"; 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=209.85.210.193; helo=mail-pf1-f193.google.com; envelope-from=rashmica.g@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="X0hE9Ai0"; dkim-atps=neutral Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (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 4267BH4H85zF3Sj for ; Fri, 7 Sep 2018 16:41:11 +1000 (AEST) Received: by mail-pf1-f193.google.com with SMTP id i26-v6so6514195pfo.12 for ; Thu, 06 Sep 2018 23:41: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:in-reply-to:references; bh=rK22zkDxXNmVYUMC2dq8xtcZua9AuvNXzoveRF7MRhI=; b=X0hE9Ai0yhuC8Ce3ApE2VFQIVHqvLtMp0aqyVPLlFzgMPvocx7w0KYYvJZTmeIBRNw v44spgSGHE1l+FcsGZQDhFgbXOXxtuEk5KaZMgHQR+J0QHNqkRuODw+Xp7biblOlmqIc JneWKxRrHRGIZM7fMNf8YN1aV7x2AyQopONK7UkmfwS6czJV+ZlUPdpHoY84pt378adD JdYpDzSVqWJtMTvoxzWd+vL5sLi9YmAEJZY5PFASDB/FjC2pxBts0lKb5av3foYzHuB0 13ut+S+aMrlBJbpSc+CoYcBSBsrUXHb0vQhgl7xXKT/nke2lckvf5XMX4DPwUesfuAst 29Kg== 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:in-reply-to :references; bh=rK22zkDxXNmVYUMC2dq8xtcZua9AuvNXzoveRF7MRhI=; b=oDHd5gP/eyg9n5RtjpSgli8DS2DNHtuEVi6cqrtpKotAGVjdoRO8h3t2VGak2yfX3X 96xxMhV+d24NCAebtQwqH8GwyEL8H3O93aJIeudDUBzmXgSNJES7R1/KXee4agDobgJu pp8N9BWbgy9I0NGtdoGE1D0MV04b4R8/WcNGwqdUy/EoRs5EBQGXRnAlS9fbBAES8aGC 2jBKHHA+9+u4IHiIX7HHgxKmyezJCzf9K057YCSMVhqVGkkw+3cQuXIwdZEGem46Pqwn U1u5FdigHJxHk9VmIwTFIGXlCRjoUZJxPm8BxcCe0SVF/Fvh5Ha8ISdvZpEfKEpYG043 lwAg== X-Gm-Message-State: APzg51AnfoeJwd6xgsvQooFmbMV7KzM4EMuDjxPpQ8eanigYZc+/4Lhj s4UFUCuKwaWS5Upr1JBnOWa8pRLWRM0= X-Google-Smtp-Source: ANB0VdanR86FE/6j1Lkss7PCs0hYhAhZUk5pG7B3fFt1qn6w+kU93ZxEUjZ9KF16AND26aZ4DMRwPQ== X-Received: by 2002:a63:2acc:: with SMTP id q195-v6mr6548151pgq.291.1536302469703; Thu, 06 Sep 2018 23:41:09 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.41.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:41:09 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:08 +1000 Message-Id: <20180907064015.1058-10-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 09/16] libpdbg: Add in mtocrf and putcr function 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- libpdbg/chip.c | 26 ++++++++++++++++++++++++++ libpdbg/libpdbg.h | 1 + libpdbg/operations.h | 1 + 3 files changed, 28 insertions(+) diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 31c8c80..7a93ab6 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -52,6 +52,20 @@ static uint64_t mfocrf(uint64_t reg, uint64_t cr) return MFOCRF_OPCODE | (reg << 21) | (1U << (12 + cr)); } +static uint64_t mtocrf(uint64_t cr, uint64_t reg) +{ + if (reg > 31) { + PR_ERROR("Invalid register specified for mfocrf\n"); + exit(1); + } + if (cr > 7) { + PR_ERROR("Invalid CR field specified\n"); + exit(1); + } + + return MTOCRF_OPCODE | (reg << 21) | (1U << (12 + cr)); +} + static uint64_t mfnia(uint64_t reg) { if (reg > 31) @@ -303,6 +317,18 @@ int ram_getcr(struct pdbg_target *thread, uint32_t *value) return 0; } +int ram_putcr(struct pdbg_target *thread, uint32_t value) +{ + uint64_t opcodes[] = {mfspr(0, 277), mtocrf(0, 0), mtocrf(1, 0), + mtocrf(2, 0), mtocrf(3, 0), mtocrf(4, 0), + mtocrf(5, 0), mtocrf(6, 0), mtocrf(7, 0)}; + uint64_t results[] = {value}; + + CHECK_ERR(ram_instructions(thread, opcodes, results, ARRAY_SIZE(opcodes), 0)); + + return 0; +} + int ram_putmsr(struct pdbg_target *thread, uint64_t value) { uint64_t opcodes[] = {mfspr(0, 277), mtmsr(0)}; diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 9c29ecc..8bf7042 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -142,6 +142,7 @@ int ram_putspr(struct pdbg_target *target, int spr, uint64_t val); int ram_putgpr(struct pdbg_target *target, int spr, uint64_t val); int ram_getmsr(struct pdbg_target *target, uint64_t *val); int ram_getcr(struct pdbg_target *thread, uint32_t *value); +int ram_putcr(struct pdbg_target *thread, uint32_t value); int ram_getnia(struct pdbg_target *target, uint64_t *val); int ram_getspr(struct pdbg_target *target, int spr, uint64_t *val); int ram_getgpr(struct pdbg_target *target, int gpr, uint64_t *val); diff --git a/libpdbg/operations.h b/libpdbg/operations.h index 971a3f6..93e5df5 100644 --- a/libpdbg/operations.h +++ b/libpdbg/operations.h @@ -62,6 +62,7 @@ #define MFSPR_OPCODE 0x7c0002a6UL #define MTSPR_OPCODE 0x7c0003a6UL #define MFOCRF_OPCODE 0x7c100026UL +#define MTOCRF_OPCODE 0x7C100120UL #define MFSPR_MASK (MFSPR_OPCODE | ((0x1f) << 16) | ((0x3e0) << 6)) #define MFXER_OPCODE (MFSPR_OPCODE | ((1 & 0x1f) << 16) | ((1 & 0x3e0) << 6)) #define MTXER_OPCODE (MTSPR_OPCODE | ((1 & 0x1f) << 16) | ((1 & 0x3e0) << 6)) From patchwork Fri Sep 7 06:40:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967222 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 4267BZ2YXsz9s4Z for ; Fri, 7 Sep 2018 16:41:26 +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="IcpCRCQm"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267BZ0tsQzF3SN for ; Fri, 7 Sep 2018 16:41:26 +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="IcpCRCQm"; 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=209.85.214.170; helo=mail-pl1-f170.google.com; envelope-from=rashmica.g@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="IcpCRCQm"; dkim-atps=neutral Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 4267BL24DPzF3Sk for ; Fri, 7 Sep 2018 16:41:14 +1000 (AEST) Received: by mail-pl1-f170.google.com with SMTP id h3-v6so2775915plh.10 for ; Thu, 06 Sep 2018 23:41:14 -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:in-reply-to:references; bh=icJ3pXs50N0FNgCgsbAqzn5SzgJgeqGTcCbXJdFEoZg=; b=IcpCRCQmuqKGGAI0Rw/I74Qb7Db6ApkBVm9nZm9PHTwP2P9SWAA2tBKSIUYGdMmNNt 8aikjsfBsY0vDIGmxOkpN44KtDuX7+Lqob3aTRpn+l49SjZmA/M3nu2HF+gXPqFMJDaB fjiiwhomvnNcR8Sqz7uM5eJUHsrlJt+sHVfGAsHljWN2HFKNKS8XAWH+wR9WBSrRs/hp dm/z1Ljh/QJ2vbOcMY+OUWmlB8Mi7OnRoKSTUHnPIsFdVObtrx8vZj4HMEZ5GKowvb8X c2dj5/0lS8La9LLray0D+mbJYlPt/GENE4YmiRBr1favwUBaVtfUP+3x7N8PehivBHEo L0UA== 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:in-reply-to :references; bh=icJ3pXs50N0FNgCgsbAqzn5SzgJgeqGTcCbXJdFEoZg=; b=WCLkLP0qc2RMwBmXUQwfUVtYLdAv90BWvcyqzlAAB3E8vnUvWLCxZQ8gbWs7Htv4jk a3QCkVxTYGDRpVYyrEvzhwY56h1r56ieSLdkQngNmh/9SeqFMgTJJOvBuHb5SuIMaKKn P8QNJVxyqp+lZmUWLwT2rrdBvsBs6YhAuGTiB8SVTbsGxdr0Z+cQKrA4JTWAziQrPzDe +7FmIugwVhhk5bylwUsvSUgfjiFBVGUENtPHVOOrdUNyyb6zKvW0d/6eRFM2lFfzGK/S xl3X4yqD3riiKbZ3gVh7Vd5BE9WkcNkk6EzsvMjBbtO3BIDi3Gm4GMxKA07P5A/cO/PP +kNQ== X-Gm-Message-State: APzg51CQ0RawLxbbMM60OwarW9a7xYvAQn4edAKSKlZSPDIVEwUa4XGA 8ypokCSVUDdiBljutoByQwLuYzvWdbM= X-Google-Smtp-Source: ANB0VdawqnVpVkd0yPHIjWxjB7f1N9VvlZcWuYkObI1ILX8V+URq06TT1mTUAt5+UkLrHn6k+CpRXQ== X-Received: by 2002:a17:902:4403:: with SMTP id k3-v6mr6397101pld.243.1536302472134; Thu, 06 Sep 2018 23:41:12 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.41.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:41:11 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:09 +1000 Message-Id: <20180907064015.1058-11-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 10/16] pdbg: Add getcr and putcr options 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- src/main.c | 6 +++++- src/reg.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index ea025a6..883e892 100644 --- a/src/main.c +++ b/src/main.c @@ -87,7 +87,8 @@ extern struct optcmd_cmd optcmd_getnia, optcmd_putnia, optcmd_getmsr, optcmd_putmsr, optcmd_getring, optcmd_start, optcmd_stop, optcmd_step, optcmd_threadstatus, optcmd_sreset, optcmd_regs, optcmd_probe, - optcmd_getmem, optcmd_putmem, optcmd_getxer, optcmd_putxer; + optcmd_getmem, optcmd_putmem, optcmd_getxer, optcmd_putxer, + optcmd_getcr, optcmd_putcr; static struct optcmd_cmd *cmds[] = { &optcmd_getscom, &optcmd_putscom, &optcmd_getcfam, &optcmd_putcfam, @@ -96,6 +97,7 @@ static struct optcmd_cmd *cmds[] = { &optcmd_getring, &optcmd_start, &optcmd_stop, &optcmd_step, &optcmd_threadstatus, &optcmd_sreset, &optcmd_regs, &optcmd_probe, &optcmd_getmem, &optcmd_putmem, &optcmd_getxer, &optcmd_putxer, + &optcmd_getcr, &optcmd_putcr, }; /* Purely for printing usage text. We could integrate printing argument and flag @@ -115,6 +117,8 @@ static struct action actions[] = { { "putspr", " ", "Write Special Purpose Register (SPR)" }, { "getmsr", "", "Get Machine State Register (MSR)" }, { "putmsr", "", "Write Machine State Register (MSR)" }, + { "getcr", "", "Get Condition Register (CR)" }, + { "putcr", "", "Write Condition Register (CR)" }, { "getxer", "", "Get Fixed Point Exception Register (XER)" }, { "putxer", "", "Write Fixed Point Exception Register (XER)" }, { "getring", " ", "Read a ring. Length must be correct" }, diff --git a/src/reg.c b/src/reg.c index 3864316..fcf6f4c 100644 --- a/src/reg.c +++ b/src/reg.c @@ -24,6 +24,7 @@ #include "main.h" #include "optcmd.h" +#define REG_CR -5 #define REG_XER -4 #define REG_MEM -3 #define REG_MSR -2 @@ -45,6 +46,8 @@ static void print_proc_reg(struct pdbg_target *target, uint64_t reg, uint64_t va printf("nia: "); else if (reg == REG_XER) printf("xer: "); + else if (reg == REG_CR) + printf("cr: "); else if (reg > REG_R31) printf("spr%03" PRIu64 ": ", reg - REG_R31); else if (reg >= 0 && reg <= 31) @@ -68,6 +71,8 @@ static int putprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg, rc = ram_putnia(target, *value); else if (*reg == REG_XER) rc = ram_putxer(target, *value); + else if (*reg == REG_CR) + rc = ram_putcr(target, *value); else if (*reg > REG_R31) rc = ram_putspr(target, *reg - REG_R31, *value); else if (*reg >= 0 && *reg <= 31) @@ -89,6 +94,8 @@ static int getprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg, rc = ram_getnia(target, &value); else if (*reg == REG_XER) rc = ram_getxer(target, &value); + else if (*reg == REG_CR) + rc = ram_getcr(target, (uint32_t *)&value); else if (*reg > REG_R31) rc = ram_getspr(target, *reg - REG_R31, &value); else if (*reg >= 0 && *reg <= 31) @@ -169,3 +176,18 @@ static int putxer(uint64_t data) return for_each_target("thread", putprocreg, ®, &d); } OPTCMD_DEFINE_CMD_WITH_ARGS(putxer, putxer, (DATA)); + +static int getcr(void) +{ + uint64_t cr = REG_CR; + return for_each_target("thread", getprocreg, &cr, NULL); +} +OPTCMD_DEFINE_CMD(getcr, getcr); + +static int putcr(uint32_t data) +{ + uint64_t cr = REG_CR; + uint64_t d = data; + return for_each_target("thread", putprocreg, &cr, &d); +} +OPTCMD_DEFINE_CMD_WITH_ARGS(putcr, putcr, (DATA32)); From patchwork Fri Sep 7 06:40:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967223 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 4267Bh2kRQz9sCD for ; Fri, 7 Sep 2018 16:41:32 +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="Rtvkc4Ue"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267Bg2Xs3zF3Sc for ; Fri, 7 Sep 2018 16:41:31 +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="Rtvkc4Ue"; 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=209.85.214.178; helo=mail-pl1-f178.google.com; envelope-from=rashmica.g@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="Rtvkc4Ue"; dkim-atps=neutral Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 4267BN5NjxzF3Sh for ; Fri, 7 Sep 2018 16:41:16 +1000 (AEST) Received: by mail-pl1-f178.google.com with SMTP id g2-v6so5175210plo.2 for ; Thu, 06 Sep 2018 23:41:16 -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:in-reply-to:references; bh=NrJEwkdu2XaewiiEXe6Dzlw2dXnsvYp40QLfkK5/1l4=; b=Rtvkc4Ue/1lSMO0osnru+Z/GopAi8tClSmByXqx27L5I8hG5AKrrgVe4Jn34n0zK69 8W+TIAcjsklFL0dYvNvFl4EAYF3FH2kN/4iN3mOEerBtM3LSp3lDpl+GE+Z+kvXTMYqf e0KBpL0Xt0Sw4SLj2T6APtR++n3den7M2cpYST0keHtPyanyLfUBnuP/JUdE1VeXbpKX +f73aj9cG2yHU5QBrIUBA5NKSPHnUgIPxZPuhY13Ad7h1VYCUNvrWCCBMjUCJhaanWHe 5u7vZaDIZPLXLTbLZjkyx8WQjjJY5/79IdcnZxgq9V1C1eZHXTG3wr1+3+hQ3seSJzHA QGiQ== 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:in-reply-to :references; bh=NrJEwkdu2XaewiiEXe6Dzlw2dXnsvYp40QLfkK5/1l4=; b=mpJAUQnAHqyCdKY9CZZWEuDiWKS0kx9SS0o084uPZOAUbi0PIWBcJmMy2MJDJ4AJXT F7JRph5v5yTdoeseEQClh1kyxBJ6ubsUON/KrpZQg/ACxJ5D7UkZ+4O+5IQqUd6WKotI l+t+etdgX8FC+II0zP0HPpEYf7MfWD/ZQguIv5zmgBRCfTfUmw/tyGhwvlnKMtGQpbeG nGKB5XK1WFU3JighXPHw5yd22hC0lTIcBmKR0UqugHZ/ejaM/rTL6F7Z7EbDPgFy+yhN jxPcWMUcPeMhEqYzG9J6fEEBzdTk/OlUmAJyB+ksErfvC1oiDSfwn+qr9Iu7a+0wSHsB RCkQ== X-Gm-Message-State: APzg51ApqD36N3tStot95k3XviPZuuJTQYXwxF6W1AIN8Ph5Pwn6e8vB aAC3x9NbctMlgSdHOd1qA1jkJ3qx1o4= X-Google-Smtp-Source: ANB0VdZMKi/UEyusuVux1WGZmhBdOqvXQHbQjGBip4JLkjs1QKQwyT/jHerdBRsEZS1eNjgE1TYyMw== X-Received: by 2002:a17:902:47c2:: with SMTP id d2-v6mr6536428plh.317.1536302474554; Thu, 06 Sep 2018 23:41:14 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.41.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:41:14 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:10 +1000 Message-Id: <20180907064015.1058-12-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 11/16] pdbg: Add in parser for uint16_t 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- src/parsers.c | 18 ++++++++++++++++++ src/parsers.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/parsers.c b/src/parsers.c index 6cbe06d..868c383 100644 --- a/src/parsers.c +++ b/src/parsers.c @@ -37,6 +37,24 @@ uint32_t *parse_number32(const char *argv) return n; } +uint16_t *parse_number16(const char *argv) +{ + unsigned long long tmp; + uint16_t *n = malloc(sizeof(*n)); + char *endptr; + + if (!argv) + return NULL; + + errno = 0; + tmp = strtoul(argv, &endptr, 0); + if (errno || *endptr != '\0' || tmp > UINT16_MAX) + return NULL; + + *n = tmp; + return n; +} + /* Parse a GPR number, returning an error if it's greater than 32 */ int *parse_gpr(const char *argv) { diff --git a/src/parsers.h b/src/parsers.h index b5f23cf..935c242 100644 --- a/src/parsers.h +++ b/src/parsers.h @@ -8,12 +8,14 @@ #define ADDRESS32 (parse_number32, NULL) #define DATA (parse_number64, NULL) #define DATA32 (parse_number32, NULL) +#define DATA16 (parse_number16, NULL) #define DEFAULT_DATA(default) (parse_number64, default) #define GPR (parse_gpr, NULL) #define SPR (parse_spr, NULL) uint64_t *parse_number64(const char *argv); uint32_t *parse_number32(const char *argv); +uint16_t *parse_number16(const char *argv); int *parse_gpr(const char *argv); int *parse_spr(const char *argv); bool *parse_flag_noarg(const char *argv); From patchwork Fri Sep 7 06:40:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967225 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 4267Bp56r2z9sBJ for ; Fri, 7 Sep 2018 16:41:38 +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="Ja+PMupm"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267Bp2YTqzF3SW for ; Fri, 7 Sep 2018 16:41:38 +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="Ja+PMupm"; 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=209.85.215.180; helo=mail-pg1-f180.google.com; envelope-from=rashmica.g@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="Ja+PMupm"; dkim-atps=neutral Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (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 4267BQ4WB3zF3Sh for ; Fri, 7 Sep 2018 16:41:18 +1000 (AEST) Received: by mail-pg1-f180.google.com with SMTP id s7-v6so6507212pgc.0 for ; Thu, 06 Sep 2018 23:41:18 -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:in-reply-to:references; bh=Yj2CJv4PWueqyvXH1GRb3wfH66Ch/jam4mCS2lGSZvE=; b=Ja+PMupmxP1bOmn7f4C8mwlfY6t1+kEyGvp9d+f1N5gCRDDPMiXwbJRkxImJJp8sBH DJ0Ca3wxamRvJjLElyWkhK4iUNhqfOMFKav0zHXM3aLVopVo6etdLxrgrmmLCBqk5SQk w5Vf0jQW+O3rBW6Uq0F6ZDvk2AsVtEBT8q4ynmzGW7v7en5K4BtZkjqBD3rJ/30naLyj 2YXIxitJqZJHiBEHKMTakKHAjcDf3zWZlhXUasURCc/GbhyGhB0vI65vbblk3Thk41bB YyvUvSQ7j9hJqzZBhalIL3Q2XdH4cVUw9yMcgL+xZrmfp0ZeFZSCyTyut3jB6N+LHUTj YsHg== 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:in-reply-to :references; bh=Yj2CJv4PWueqyvXH1GRb3wfH66Ch/jam4mCS2lGSZvE=; b=FvbncpNYjeXLo2GdxsSTpouAUGnhlK2d+5zUIDjYGcOY7KBfHWLTnI2os8j9XxRHKe A+8PUcfPvhQoISyrRvGmCECtwf2w9GfJ+037aORMMqvjAFfm3HEgbgmz+FUOEEj//Sbx QM9kk1HmpB0x+f9VCMGtiiwDJkk7fX21/OmLYERArNZ/9Hxt1dB/winLJBR/IP+QDpib CSdpjZAoyWlYujITY6Ca4Uu7dkbv2Sgr8ef8G0fmZR4tqk/Osiad2CoaWT0SSsHf3qjD 38/LV2X+/sXeZEq+knIHyBqY3wJXPNqeruCMDSoszrJLa53O0v4EoH654oce571oU5xB h1NA== X-Gm-Message-State: APzg51DdS8Qt/3ay4m/nfJHOlvJ8mafwg06Pg6eIRcEE4hUe+T8roIlm Bd5nLD7ivOswXN4jPaZcL/4CLTftLMI= X-Google-Smtp-Source: ANB0VdbBcN2WDewvKsIyRFLgiHcoU/WGPf6hKIMDkibv9qeegF9fltq/ofooYNvkhq3VN+qx2mbneA== X-Received: by 2002:a62:5882:: with SMTP id m124-v6mr6885773pfb.249.1536302476941; Thu, 06 Sep 2018 23:41:16 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.41.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:41:16 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:11 +1000 Message-Id: <20180907064015.1058-13-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 12/16] libpdbg: Add in enable_attn function for p8 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- libpdbg/p8chip.c | 41 +++++++++++++++++++++++++++++++++++++++++ libpdbg/target.h | 1 + 2 files changed, 42 insertions(+) diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index 89ecfd6..2f1d599 100644 --- a/libpdbg/p8chip.c +++ b/libpdbg/p8chip.c @@ -82,6 +82,8 @@ #define FSP_SPECIAL_WAKEUP PPC_BIT(0) #define EX_PM_GP0_REG 0xf0100 #define SPECIAL_WKUP_DONE PPC_BIT(31) +#define HID0_REG 0x1329c +#define EN_ATTN PPC_BIT(31) /* p8 specific opcodes for instruction ramming*/ #define MTXERF0_OPCODE 0x00000008UL @@ -483,6 +485,44 @@ static int p8_thread_probe(struct pdbg_target *target) return 0; } +static int p8_get_hid0(struct pdbg_target *chip, uint64_t *value) +{ + CHECK_ERR(pib_read(chip, HID0_REG, 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 pdbg_target *target) +{ + struct pdbg_target *core; + uint64_t hid0; + + core = pdbg_target_parent("core", target); + if (core == NULL) + { + PR_ERROR("CORE NOT FOUND\n"); + return 1; + } + + /* Need to enable the attn instruction in HID0 */ + if (p8_get_hid0(core, &hid0)) { + PR_ERROR("Unable to get HID0\n"); + return 1; + } + hid0 |= EN_ATTN; + + 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", @@ -499,6 +539,7 @@ static struct thread p8_thread = { .ram_destroy = p8_ram_destroy, .ram_getxer = p8_ram_getxer, .ram_putxer = p8_ram_putxer, + .enable_attn = p8_enable_attn, }; DECLARE_HW_UNIT(p8_thread); diff --git a/libpdbg/target.h b/libpdbg/target.h index 8bad405..c8da048 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -155,6 +155,7 @@ struct thread { int (*ram_destroy)(struct thread *); int (*ram_getxer)(struct pdbg_target *, uint64_t *value); int (*ram_putxer)(struct pdbg_target *, uint64_t value); + int (*enable_attn)(struct pdbg_target *); }; #define target_to_thread(x) container_of(x, struct thread, target) From patchwork Fri Sep 7 06:40:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967226 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 4267Bs1yhYz9sBJ for ; Fri, 7 Sep 2018 16:41:41 +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="VNvWEli2"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267Br6rqZzF3Sc for ; Fri, 7 Sep 2018 16:41:40 +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="VNvWEli2"; 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=209.85.210.196; helo=mail-pf1-f196.google.com; envelope-from=rashmica.g@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="VNvWEli2"; dkim-atps=neutral Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) (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 4267BV038czF3Sh for ; Fri, 7 Sep 2018 16:41:21 +1000 (AEST) Received: by mail-pf1-f196.google.com with SMTP id b11-v6so6534497pfo.3 for ; Thu, 06 Sep 2018 23:41:21 -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:in-reply-to:references; bh=7/98//w0dD4SRhp6YcNj5P68jdmZoNMKqC62UpjbVIo=; b=VNvWEli2yNsjtorlUm+XTjesolmPjfTjRt+tkNDaVqgBoUqA5QbNlFMJ9nLZIT+WYi GC0l8Ta3XyydsGhp3f/helhZ6YUqC7nuGbE11VRAH0cfXrD1JDGPF4lW5CkXgvcOFHvI zyXBgqLVN18knaPEVI238fcyqi9uWPG/l56ZIGNP5ahvi+nILR70kmxBpu6E6QqyhPMV Tt7NmSXSmsFPkwSGFC1iajeZFybBXrUXj5qNJc6UspwvsMiiEkRP4fv2UC+Y6Xmw9DKu N17RgC+7umyWEoXWsD4jdDDS+P1BM6DdFAltyzmmio+G3KNDGnMq+gvNKEaj8LPxCjT4 BuUA== 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:in-reply-to :references; bh=7/98//w0dD4SRhp6YcNj5P68jdmZoNMKqC62UpjbVIo=; b=BDdZzfaKKxTD/X6joLxGx2+ST7NbSqm2PGjvXOsvdVkx6aguppDuoIbvqpts3D2LtD QHHOPUdO7FJo9GXn25N9NY4PJPRC2deiPhH7wycmCtVjYxyWVC4I/sjLDM2wlm43W3T4 +/XY/v4WuDE6C/KSHZalgAulhTz/NIgF3rxh9VtmnipmiWd6D7JK4zPnZ7Uerwy8xAwN IRILRp0VS5Kzkq8Q2ZKJUf1wo4SF6A3b5kYewMnOiZ6EjnTbn5XxgLdPfMQO6ffY+Gib 4D3/++pd1pqLCAsTCh+U2dcJ/CdhUpjhYGoj/n3C7g0GenTNCwvLZQKP1mDKSfbVz3/b +qAw== X-Gm-Message-State: APzg51DFU8aUDa0Z/lDYT7gvLkoNcFL/3ungd0uas2I29D5NnEevtDnr KaN2FkDL6ujIRg9L2UGR0EP1UBpEr1c= X-Google-Smtp-Source: ANB0VdYzRlO4QuMS3hfUc47t6dVNUHWIpPTdOAzGu0PawAu9fyGODHj7jRiYAz5zeLd9nq1UCBr2tQ== X-Received: by 2002:a62:2a48:: with SMTP id q69-v6mr6960250pfq.86.1536302479717; Thu, 06 Sep 2018 23:41:19 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.41.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:41:19 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:12 +1000 Message-Id: <20180907064015.1058-14-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 13/16] pdbg/gdbserver: Add in basic skeleton for a gdbserver on p8 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" From: Alistair Popple I have changed a few bits here and there but this patch is largely authored by Alistair Popple. Signed-off-by: Rashmica Gupta --- .gitignore | 1 + Makefile.am | 13 +- configure.ac | 3 + libpdbg/libpdbg.h | 1 + libpdbg/operations.h | 3 - libpdbg/target.h | 1 + src/gdb_parser.rl | 146 ++++++++++++++ src/main.c | 6 +- src/pdbgproxy.c | 540 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/pdbgproxy.h | 13 ++ 10 files changed, 720 insertions(+), 7 deletions(-) create mode 100644 src/gdb_parser.rl create mode 100644 src/pdbgproxy.c create mode 100644 src/pdbgproxy.h diff --git a/.gitignore b/.gitignore index c25b053..79f1ef9 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ optcmd_test *.trs *.log test-driver +src/gdb_parser.c diff --git a/Makefile.am b/Makefile.am index 88aabe9..98f42b5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -83,7 +83,9 @@ pdbg_SOURCES = \ src/optcmd.h \ src/options.h \ src/parsers.h \ - src/progress.h + src/progress.h \ + src/pdbgproxy.c \ + src/gdb_parser.c src/main.c: $(DT_headers) @@ -193,6 +195,10 @@ GEN_V = $(GEN_V_$(V)) GEN_V_ = $(GEN_V_$(AM_DEFAULT_VERBOSITY)) GEN_V_0 = @echo " GEN " $@; +RAGEL_V = $(RAGEL_V_$(V)) +RAGEL_V_ = $(RAGEL_V_$(AM_DEFAULT_VERBOSITY)) +RAGEL_V_0 = @echo " RAGEL " $@; + %.dts: %.dts.m4 $(M4_V)$(M4) -I$(dir $<) $< | $(DTC) -I dts -O dts > $@ @@ -213,4 +219,7 @@ p9z-fsi.dts: p9z-fsi.dts.m4 p9-fsi.dtsi %.dtb.o: %.dtb $(AM_V_CC)$(CC) -c $(srcdir)/template.S -DSYMBOL_PREFIX=$(shell echo $@ | tr '.-' '_') -DFILENAME=\"$<\" -o $@ -MOSTLYCLEANFILES = *.dtb *.dts *.dt.h p9-fsi.dtsi +%.c: %.rl + $(RAGEL_V)$(RAGEL) -o $@ $< + +MOSTLYCLEANFILES = *.dtb *.dts *.dt.h p9-fsi.dtsi src/gdb_parser.c diff --git a/configure.ac b/configure.ac index e48e80f..3486969 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,9 @@ if test x"$ac_cv_path_DTC" = x ; then fi AC_SUBST([DTC]) +AC_PATH_PROG([RAGEL], [ragel]) +AC_SUBST([RAGEL]) + AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile]) diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 8bf7042..c802020 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -137,6 +137,7 @@ struct thread_regs { }; int ram_putmsr(struct pdbg_target *target, uint64_t val); +int ram_getmem(struct pdbg_target *thread, uint64_t addr, uint64_t *value); int ram_putnia(struct pdbg_target *target, uint64_t val); int ram_putspr(struct pdbg_target *target, int spr, uint64_t val); int ram_putgpr(struct pdbg_target *target, int spr, uint64_t val); diff --git a/libpdbg/operations.h b/libpdbg/operations.h index 93e5df5..96a7c01 100644 --- a/libpdbg/operations.h +++ b/libpdbg/operations.h @@ -70,9 +70,6 @@ #define MXSPR_SPR(opcode) (((opcode >> 16) & 0x1f) | ((opcode >> 6) & 0x3e0)) -/* GDB server functionality */ -int gdbserver_start(uint16_t port); - enum fsi_system_type {FSI_SYSTEM_P8, FSI_SYSTEM_P9W, FSI_SYSTEM_P9R, FSI_SYSTEM_P9Z}; enum chip_type get_chip_type(uint64_t chip_id); diff --git a/libpdbg/target.h b/libpdbg/target.h index c8da048..d1a6aec 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -165,4 +165,5 @@ struct chiplet { int (*getring)(struct chiplet *, uint64_t, int64_t, uint32_t[]); }; #define target_to_chiplet(x) container_of(x, struct chiplet, target) + #endif diff --git a/src/gdb_parser.rl b/src/gdb_parser.rl new file mode 100644 index 0000000..6259b96 --- /dev/null +++ b/src/gdb_parser.rl @@ -0,0 +1,146 @@ +#include +#include +#include +#include + +#include "src/pdbgproxy.h" + +%%{ + machine gdb; + + action reset { + cmd = 0; + rsp = NULL; + data = stack; + memset(stack, 0, sizeof(stack)); + crc = 0; + } + + action crc { + crc += *p; + } + + action push { + data++; + assert(data < &stack[10]); + } + + action hex_digit { + *data *= 16; + + if (*p >= '0' && *p <= '9') + *data += *p - '0'; + else if (*p >= 'a' && *p <= 'f') + *data += *p - 'a' + 10; + else if (*p >= 'A' && *p <= 'F') + *data += *p - 'A' + 10; + } + + action end { + /* *data should point to the CRC */ + if (crc != *data) { + printf("CRC error\n"); + send_nack(priv); + } else { + printf("Cmd %d\n", cmd); + send_ack(priv); + + /* Push the response onto the stack */ + if (rsp) + *data = (uintptr_t)rsp; + else + *data = 0; + + command_callbacks[cmd](stack, priv); + } + } + + get_mem = ('m' @{cmd = GET_MEM;} + xdigit+ $hex_digit %push + ',' + xdigit+ $hex_digit %push); + + put_mem = ('M' any* @{cmd = PUT_MEM;} + xdigit+ $hex_digit %push + ',' + xdigit+ $hex_digit %push + ':' + xdigit+ $hex_digit %push); + + get_gprs = ('g' @{cmd = GET_GPRS;}); + + get_spr = ('p' @{cmd = GET_SPR;} + xdigit+ $hex_digit %push); + + stop_reason = ('?' @{cmd = STOP_REASON;}); + + set_thread = ('H' any* @{cmd = SET_THREAD;}); + + disconnect = ('D' @{cmd = DISCONNECT;} + xdigit+ $hex_digit %push); + + # TODO: We don't actually listen to what's supported + q_attached = ('qAttached:' xdigit* @{rsp = "1";}); + q_C = ('qC' @{rsp = "QC1";}); + q_supported = ('qSupported:' any* @{rsp = "multiprocess+;vContSupported+";}); + qf_threadinfo = ('qfThreadInfo' @{rsp = "m1l";}); + + # vCont packet parsing + v_contq = ('vCont?' @{rsp = "vCont;c;C;s;S";}); + v_contc = ('vCont;c' any* @{cmd = V_CONTC;}); + v_conts = ('vCont;s' any* @{cmd = V_CONTS;}); + + interrupt = (3 @{command_callbacks[INTERRUPT](stack, priv);}); + + commands = (get_mem | get_gprs | get_spr | stop_reason | set_thread | + q_attached | q_C | q_supported | qf_threadinfo | q_C | + v_contq | v_contc | v_conts | put_mem | disconnect ); + + cmd = ((commands & ^'#'*) | ^'#'*) $crc + ('#' xdigit{2} $hex_digit @end); + + # We ignore ACK/NACK for the moment + ack = ('+'); + nack = ('-'); + + main := (( ^('$' | interrupt)*('$' | interrupt) @reset) (cmd | ack | nack))*; + +}%% + +static enum gdb_command cmd = NONE; +static uint64_t stack[10], *data = stack; +static char *rsp; +static uint8_t crc; +static int cs; + +command_cb *command_callbacks; + +%%write data; + +void parser_init(command_cb *callbacks) +{ + %%write init; + + command_callbacks = callbacks; +} + +int parse_buffer(char *buf, size_t len, void *priv) +{ + char *p = buf; + char *pe = p + len + 1; + + %%write exec; + + return 0; +} + +#if 0 +int main(int argc, char **argv) +{ + parser_init(NULL); + + if (argc > 1) + parse_buffer(argv[1], strlen(argv[1]), NULL); + return 0; +} +#endif diff --git a/src/main.c b/src/main.c index 883e892..e9a7856 100644 --- a/src/main.c +++ b/src/main.c @@ -38,6 +38,7 @@ #include "options.h" #include "optcmd.h" #include "progress.h" +#include "pdbgproxy.h" #define PR_ERROR(x, args...) \ pdbg_log(PDBG_ERROR, x, ##args) @@ -88,7 +89,7 @@ extern struct optcmd_cmd optcmd_getring, optcmd_start, optcmd_stop, optcmd_step, optcmd_threadstatus, optcmd_sreset, optcmd_regs, optcmd_probe, optcmd_getmem, optcmd_putmem, optcmd_getxer, optcmd_putxer, - optcmd_getcr, optcmd_putcr; + optcmd_getcr, optcmd_putcr, optcmd_gdbserver; static struct optcmd_cmd *cmds[] = { &optcmd_getscom, &optcmd_putscom, &optcmd_getcfam, &optcmd_putcfam, @@ -97,7 +98,7 @@ static struct optcmd_cmd *cmds[] = { &optcmd_getring, &optcmd_start, &optcmd_stop, &optcmd_step, &optcmd_threadstatus, &optcmd_sreset, &optcmd_regs, &optcmd_probe, &optcmd_getmem, &optcmd_putmem, &optcmd_getxer, &optcmd_putxer, - &optcmd_getcr, &optcmd_putcr, + &optcmd_getcr, &optcmd_putcr, &optcmd_gdbserver, }; /* Purely for printing usage text. We could integrate printing argument and flag @@ -136,6 +137,7 @@ static struct action actions[] = { { "threadstatus", "", "Print the status of a thread" }, { "sreset", "", "Reset" }, { "regs", "", "State" }, + { "gdbserver", "", "Start a gdb server" }, }; static void print_usage(char *pname) diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c new file mode 100644 index 0000000..6689e14 --- /dev/null +++ b/src/pdbgproxy.c @@ -0,0 +1,540 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "pdbgproxy.h" +#include "main.h" +#include "optcmd.h" +#include "debug.h" +#include "chip.h" + +/* Maximum packet size */ +#define BUFFER_SIZE 8192 + +/* GDB packets */ +#define STR(e) "e" +#define ACK "+" +#define NACK "-" +#define OK "OK" +#define TRAP "S05" +#define ERROR(e) "E"STR(e) + +static struct pdbg_target *thread_target = NULL; +static struct timeval timeout; +static int poll_interval = 100; +static int fd = -1; +enum client_state {IDLE, WAIT_FOR_START, SIGNAL_WAIT}; +static enum client_state state = IDLE; + +static void destroy_client(int dead_fd); + +static uint8_t gdbcrc(char *data) +{ + uint8_t crc = 0; + int i; + + for (i = 0; i < strlen(data); i++) + crc += data[i]; + + return crc; +} + +static void send_response(int fd, char *response) +{ + int len; + char *result; + + len = asprintf(&result, "$%s#%02x", response, gdbcrc(response)); + PR_INFO("Send: %s\n", result); + send(fd, result, len, 0); + free(result); +} + +void send_nack(void *priv) +{ + PR_INFO("Send: -\n"); + send(fd, NACK, 1, 0); +} + +void send_ack(void *priv) +{ + PR_INFO("Send: +\n"); + send(fd, ACK, 1, 0); +} + +static void set_thread(uint64_t *stack, void *priv) +{ + send_response(fd, OK); +} + +static void stop_reason(uint64_t *stack, void *priv) +{ + send_response(fd, TRAP); +} + +static void disconnect(uint64_t *stack, void *priv) +{ + PR_INFO("Terminating connection with client. pid %16" PRIi64 "\n", stack[0]); + send_response(fd, OK); +} + +/* 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) +{ + char data[REG_DATA_SIZE] = ""; + uint64_t regs[32] = {0}; + uint64_t opcodes[32] = {0}; + int i; + + for (i = 0; i < 32; i++) { + opcodes[i] = mtspr(277, i); + } + + if(ram_instructions(thread_target, opcodes, regs, ARRAY_SIZE(opcodes), 0)) + PR_ERROR("Error reading gprs\n"); + + for (i = 0; i < 32; i++) { + PR_INFO("r%d = 0x%016" PRIx64 "\n", i, regs[i]); + snprintf(data + i*16, 17, "%016" PRIx64 , __builtin_bswap64(regs[i])); + } + + send_response(fd, data); +} + +static void get_spr(uint64_t *stack, void *priv) +{ + char data[REG_DATA_SIZE]; + uint64_t value; + + switch (stack[0]) { + case 0x40: + /* Get PC/NIA */ + if (ram_getnia(thread_target, &value)) + PR_ERROR("Error reading NIA\n"); + snprintf(data, REG_DATA_SIZE, "%016" PRIx64 , __builtin_bswap64(value)); + send_response(fd, data); + break; + + case 0x41: + /* Get MSR */ + if (ram_getmsr(thread_target, &value)) + PR_ERROR("Error reading MSR\n"); + snprintf(data, REG_DATA_SIZE, "%016" PRIx64 , __builtin_bswap64(value)); + send_response(fd, data); + break; + + case 0x42: + /* Get CR */ + if (ram_getcr(thread_target, (uint32_t *)&value)) + PR_ERROR("Error reading CR \n"); + snprintf(data, REG_DATA_SIZE, "%016" PRIx64 , __builtin_bswap64(value)); + send_response(fd, data); + break; + + case 0x43: + /* Get LR */ + if (ram_getspr(thread_target, 8, &value)) + PR_ERROR("Error reading LR\n"); + snprintf(data, REG_DATA_SIZE, "%016" PRIx64 , __builtin_bswap64(value)); + send_response(fd, data); + break; + + case 0x44: + /* Get CTR */ + if (ram_getspr(thread_target, 9, &value)) + PR_ERROR("Error reading CTR\n"); + snprintf(data, REG_DATA_SIZE, "%016" PRIx64 , __builtin_bswap64(value)); + send_response(fd, data); + break; + + case 0x45: + /* We can't get the whole XER register in RAM mode as part of it + * is in latches that we need to stop the clocks to get. Probably + * not helpful to only return part of a register in a debugger so + * return unavailable. */ + // TODO p8 only + send_response(fd, "xxxxxxxxxxxxxxxx"); + break; + + default: + send_response(fd, "xxxxxxxxxxxxxxxx"); + break; + } +} + +#define MAX_DATA 0x1000 + +/* Returns a real address to use with adu_getmem or -1UL if we + * couldn't determine a real address. At the moment we only deal with + * kernel linear mapping but in future we could walk that page + * tables. */ +static uint64_t get_addr(uint64_t addr) +{ + if (GETFIELD(PPC_BITMASK(0, 3), addr) == 0xc) + /* Assume all 0xc... addresses are part of the linux linear map */ + addr &= ~PPC_BITMASK(0, 1); + else + addr = -1UL; + + return addr; +} + +static void get_mem(uint64_t *stack, void *priv) +{ + struct pdbg_target *adu; + uint64_t addr, len, linear_map; + int i, err = 0; + uint64_t data[MAX_DATA/sizeof(uint64_t)]; + char result[2*MAX_DATA]; + + /* stack[0] is the address and stack[1] is the length */ + addr = stack[0]; + len = stack[1]; + + pdbg_for_each_class_target("adu", adu) { + if (pdbg_target_probe(adu) == PDBG_TARGET_ENABLED) + break; + } + + if (adu == NULL) { + PR_ERROR("ADU NOT FOUND\n"); + err=3; + goto out; + } + + if (len > MAX_DATA) { + PR_INFO("Too much memory requested, truncating\n"); + len = MAX_DATA; + } + + if (!addr) { + err = 2; + goto out; + } + + linear_map = get_addr(addr); + if (linear_map != -1UL) { + if (adu_getmem(adu, addr, (uint8_t *) data, len)) { + PR_ERROR("Unable to read memory\n"); + err = 1; + } + } else { + /* Virtual address */ + for (i = 0; i < len; i += sizeof(uint64_t)) { + if (ram_getmem(thread_target, addr, &data[i/sizeof(uint64_t)])) { + PR_ERROR("Fault reading memory\n"); + err = 2; + break; + } + } + } + +out: + if (!err) + for (i = 0; i < len; i ++) { + sprintf(&result[i*2], "%02x", *(((uint8_t *) data) + i)); + } + else + sprintf(result, "E%02x", err); + + send_response(fd, result); +} + +static void put_mem(uint64_t *stack, void *priv) +{ + struct pdbg_target *adu; + uint64_t addr, len; + uint8_t *data; + uint8_t attn_opcode[] = {0x00, 0x02, 0x00, 0x00}; + int err = 0; + struct thread *thread = target_to_thread(thread_target); + + addr = stack[0]; + len = stack[1]; + data = (uint8_t *) &stack[2]; + + pdbg_for_each_class_target("adu", adu) { + if (pdbg_target_probe(adu) == PDBG_TARGET_ENABLED) + break; + } + + if (adu == NULL) { + PR_ERROR("ADU NOT FOUND\n"); + err=3; + goto out; + } + + addr = get_addr(addr); + if (addr == -1UL) { + PR_ERROR("TODO: No virtual address support for putmem\n"); + err = 1; + goto out; + } + + PR_INFO("put_mem 0x%016" PRIx64 " = 0x%016" PRIx64 "\n", addr, stack[2]); + + if (len == 4 && stack[2] == 0x0810827d) { + /* According to linux-ppc-low.c gdb only uses this + * op-code for sw break points so we replace it with + * the correct attn opcode which is what we need for + * breakpoints. + * + * TODO: Upstream a patch to gdb so that it uses the + * right opcode for baremetal debug. */ + PR_INFO("Breakpoint opcode detected, replacing with attn\n"); + data = attn_opcode; + + /* Need to enable the attn instruction in HID0 */ + if (thread->enable_attn(thread_target)) + goto out; + } else + stack[2] = __builtin_bswap64(stack[2]) >> 32; + + if (adu_putmem(adu, addr, data, len)) { + PR_ERROR("Unable to write memory\n"); + err = 3; + } + +out: + if (err) + send_response(fd, ERROR(EPERM)); + else + send_response(fd, OK); +} + +static void v_conts(uint64_t *stack, void *priv) +{ + ram_step_thread(thread_target, 1); + send_response(fd, TRAP); +} + +#define VCONT_POLL_DELAY 100000 +static void v_contc(uint64_t *stack, void *priv) +{ + ram_start_thread(thread_target); + state = WAIT_FOR_START; + poll_interval = 1; +} + +static void interrupt(uint64_t *stack, void *priv) +{ + PR_INFO("Interrupt\n"); + ram_stop_thread(thread_target); + send_response(fd, TRAP); + + return; +} + +static void poll(void) +{ + uint64_t nia; + struct thread_state status; + + thread_target->probe(thread_target); + status = thread_status(thread_target); + + switch (state) { + case IDLE: + break; + + case WAIT_FOR_START: + /* Make sure thread is started */ + if (!(status.quiesced)) { + state = SIGNAL_WAIT; + return; + } + break; + + case SIGNAL_WAIT: + if (!(status.quiesced)) + break; + + state = IDLE; + poll_interval = VCONT_POLL_DELAY; + if (!(status.active)) { + PR_ERROR("Thread inactive after trap\n"); + send_response(fd, ERROR(EPERM)); + return; + } + + /* Restore NIA */ + if (ram_getnia(thread_target, &nia)) + PR_ERROR("Error during getnia\n"); + if (ram_putnia(thread_target, nia - 4)) + PR_ERROR("Error during putnia\n"); + send_response(fd, TRAP); + break; + } +} + +static void cmd_default(uint64_t *stack, void *priv) +{ + uintptr_t tmp = stack[0]; + if (stack[0]) { + send_response(fd, (char *) tmp); + } else + send_response(fd, ""); +} + +static void create_client(int new_fd) +{ + PR_INFO("Client connected\n"); + fd = new_fd; +} + +static void destroy_client(int dead_fd) +{ + PR_INFO("Client disconnected\n"); + close(dead_fd); + fd = -1; +} + +static int read_from_client(int fd) +{ + char buffer[BUFFER_SIZE + 1]; + int nbytes; + + nbytes = read(fd, buffer, sizeof(buffer)); + if (nbytes < 0) { + perror(__FUNCTION__); + return -1; + } else if (nbytes == 0) { + PR_INFO("0 bytes\n"); + return -1; + } else { + buffer[nbytes] = '\0'; + PR_INFO("%x\n", buffer[0]); + PR_INFO("Recv: %s\n", buffer); + parse_buffer(buffer, nbytes, &fd); + } + + return 0; +} + +command_cb callbacks[LAST_CMD + 1] = { + cmd_default, + get_gprs, + get_spr, + get_mem, + stop_reason, + set_thread, + v_contc, + v_conts, + put_mem, + interrupt, + disconnect, + NULL}; + +int gdbserver_start(struct pdbg_target *target, uint16_t port) +{ + int sock, i; + struct sockaddr_in name; + fd_set active_fd_set, read_fd_set; + + parser_init(callbacks); + thread_target = target; + + sock = socket(PF_INET, SOCK_STREAM, 0); + if (sock < 0) { + perror(__FUNCTION__); + return -1; + } + + name.sin_family = AF_INET; + name.sin_port = htons(port); + name.sin_addr.s_addr = htonl(INADDR_ANY); + if (bind(sock, (struct sockaddr *) &name, sizeof(name)) < 0) { + perror(__FUNCTION__); + return -1; + } + + if (listen(sock, 1) < 0) { + perror(__FUNCTION__); + return -1; + } + + FD_ZERO(&active_fd_set); + FD_SET(sock, &active_fd_set); + + while (1) { + read_fd_set = active_fd_set; + timeout.tv_sec = 0; + timeout.tv_usec = poll_interval; + if (select(FD_SETSIZE, &read_fd_set, NULL, NULL, &timeout) < 0) { + perror(__FUNCTION__); + return -1; + } + + for (i = 0; i < FD_SETSIZE; i++) { + if (FD_ISSET(i, &read_fd_set)) { + if (i == sock) { + int new; + new = accept(sock, NULL, NULL); + if (new < 0) { + perror(__FUNCTION__); + return -1; + } + + if (fd > 0) + /* It only makes sense to accept a single client */ + close(new); + else { + create_client(new); + FD_SET(new, &active_fd_set); + } + } else { + if (read_from_client(i) < 0) { + destroy_client(i); + FD_CLR(i, &active_fd_set); + } + } + } + } + + poll(); + } + + return 1; +} + + +static int gdbserver(uint16_t port) +{ + struct pdbg_target *target = NULL; + + for_each_class_target("thread", target) { + if (!target_selected(target)) + continue; + if (pdbg_target_probe(target) == PDBG_TARGET_ENABLED) + break; + } + if (!target->class) + return -1; + assert(!strcmp(target->class, "thread")); + // Temporary until I can get this working a bit smoother on p9 + if (strcmp(target->compatible, "ibm,power8-thread")) { + PR_ERROR("GDBSERVER is only tested on POWER8\n"); + return -1; + } + gdbserver_start(target, port); + return 0; +} +OPTCMD_DEFINE_CMD_WITH_ARGS(gdbserver, gdbserver, (DATA16)); diff --git a/src/pdbgproxy.h b/src/pdbgproxy.h new file mode 100644 index 0000000..1fe67f2 --- /dev/null +++ b/src/pdbgproxy.h @@ -0,0 +1,13 @@ +#ifndef __PDBGPROXY_H +#define __PDBGPROXY_H + +enum gdb_command {NONE, GET_GPRS, GET_SPR, GET_MEM, + STOP_REASON, SET_THREAD, V_CONTC, V_CONTS, + PUT_MEM, INTERRUPT, DISCONNECT, LAST_CMD}; +typedef void (*command_cb)(uint64_t *stack, void *priv); + +void parser_init(command_cb *callbacks); +int parse_buffer(char *buf, size_t len, void *priv); +void send_nack(void *priv); +void send_ack(void *priv); +#endif From patchwork Fri Sep 7 06:40:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967227 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 4267Bw3MJRz9s4Z for ; Fri, 7 Sep 2018 16:41:44 +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="PB3wl4Xx"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267Bw0wxyzF3Sg for ; Fri, 7 Sep 2018 16:41:44 +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="PB3wl4Xx"; 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=209.85.210.182; helo=mail-pf1-f182.google.com; envelope-from=rashmica.g@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="PB3wl4Xx"; dkim-atps=neutral Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 4267BX4fhMzF3SW for ; Fri, 7 Sep 2018 16:41:24 +1000 (AEST) Received: by mail-pf1-f182.google.com with SMTP id p12-v6so6532161pfh.2 for ; Thu, 06 Sep 2018 23:41:24 -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:in-reply-to:references; bh=sW17/29hGJ5JQxyzp8KAOYHLEskmiyYHRaZcgxznB54=; b=PB3wl4XxPDvcXf2o6xwl6rmy9+Xn9yTGLCJpsFeXniz9kyDygoItdnTjRqnCp0h7Y3 bR0OTbN57/2czHJomlEup9O5NqDmydFEzeZwaA8vfv0LWVHjcp3aMJ55J9SJu2JULDHi iuWL6albGA5+p8BjZDDPnWD1tyi08oQYpZY8CbuVdI+RNS5TscFjLcLldJK4seMexP19 rIq77hMtDJV2yi4BB/B74xQKohyW2wMyFGoQdnx8aN07JjuakQKwr6rjFO1qFqWTArEx kJtKLaK6G92Ee/+XoIyrdx0KttegWDAhD+1PIqEMHp7ZSDjPY9k0/N1rII//m0H8WyEU DpHg== 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:in-reply-to :references; bh=sW17/29hGJ5JQxyzp8KAOYHLEskmiyYHRaZcgxznB54=; b=jqk1atYK/XkJfeKayBl7ibtdUknYiCiirMEbF85yJaS7hGAwsiNLRlVDVLhgYAlRw3 lokxwjuqEVHpPoS8qmw5q8BEfSlc0UMNACi1Pfq1BB1vWCLiMbDZ15WeSc4UQTU1dd5v 9NYwllNlSebfLQeHXxbD5CgoHRNNLTi2Wt7+yXk5m7TcLP3tJA0XJxzfX1R7CLKaZtzc wn+mdbhc9mG7oat8Xst4BpY/5UV3qr2j2YI8peNvNHO1QDtyyRmwpKPAA7T3EVX8JLGW 2w9foFM3VyyJU+za+QM+Nox2FHaESWj2PthylpWvRQcBfnzOj3vpw9vhZamuzSx6PJIW f09A== X-Gm-Message-State: APzg51BtRed9T9CcX8WxJ+jJsqwTRb8gR+NAz8701uHSJY0O/SwbPgws E1cO11yWeOtH2jYHFXidEj3S/fdvgFA= X-Google-Smtp-Source: ANB0Vdb0XF3Ipb6YWVwy7OBAzVekI5BDbTlxpJJiF+6bReBQLzrzAj96BmpVwJ3YxLJS4pHJi+azRQ== X-Received: by 2002:a62:2119:: with SMTP id h25-v6mr7031639pfh.112.1536302482243; Thu, 06 Sep 2018 23:41:22 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.41.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:41:21 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:13 +1000 Message-Id: <20180907064015.1058-15-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 14/16] pdbg/gdbserver: Make ragel optional 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" From: Alistair Popple Add in the generated c file so if the build system doesn't have ragel gdbserver can still be built. Signed-off-by: Rashmica Gupta --- Makefile.am | 6 + configure.ac | 1 + src/gdb_parser_precompile.c | 410 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+) create mode 100644 src/gdb_parser_precompile.c diff --git a/Makefile.am b/Makefile.am index 98f42b5..a476b87 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,6 +65,12 @@ DT_headers = $(DT:.dts=.dt.h) optcmd_test_SOURCES = src/optcmd.c src/parsers.c src/tests/optcmd_test.c optcmd_test_CFLAGS = -Wall -g +if HAVE_RAGEL +extra_sources = src/gdb_parser.c +else +extra_sources = src/gdb_parser_precompile.c +endif + pdbg_SOURCES = \ src/main.c \ src/cfam.c \ diff --git a/configure.ac b/configure.ac index 3486969..7cfd2ea 100644 --- a/configure.ac +++ b/configure.ac @@ -19,6 +19,7 @@ AC_SUBST([DTC]) AC_PATH_PROG([RAGEL], [ragel]) AC_SUBST([RAGEL]) +AM_CONDITIONAL([HAVE_RAGEL], [test x"$ac_cv_path_RAGEL" != "x"]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([config.h]) diff --git a/src/gdb_parser_precompile.c b/src/gdb_parser_precompile.c new file mode 100644 index 0000000..715cdd7 --- /dev/null +++ b/src/gdb_parser_precompile.c @@ -0,0 +1,410 @@ + +#line 1 "src/gdb_parser.rl" +#include +#include +#include +#include + +#include "pdbgproxy.h" + + +#line 105 "src/gdb_parser.rl" + + +static enum gdb_command cmd = NONE; +static uint64_t stack[10], *data = stack; +static char *rsp; +static uint8_t crc; +static int cs; + +command_cb *command_callbacks; + + +#line 24 "src/gdb_parser.c" +static const char _gdb_actions[] = { + 0, 1, 0, 1, 1, 1, 2, 1, + 3, 2, 1, 0, 2, 2, 1, 2, + 3, 1, 2, 3, 4, 2, 5, 1, + 2, 6, 1, 2, 7, 1, 2, 8, + 1, 2, 9, 1, 2, 10, 1, 2, + 11, 1, 2, 12, 1, 2, 13, 1, + 2, 14, 1, 2, 15, 1, 2, 16, + 1, 2, 17, 1, 2, 18, 0, 3, + 1, 18, 0, 3, 6, 2, 1, 3, + 6, 3, 1 +}; + +static const char _gdb_key_offsets[] = { + 0, 0, 2, 13, 14, 20, 26, 29, + 37, 45, 46, 53, 61, 68, 77, 84, + 92, 99, 107, 114, 121, 126, 128, 130, + 132, 134, 136, 138, 140, 142, 149, 151, + 153, 155, 157, 159, 161, 163, 165, 167, + 168, 170, 172, 174, 176, 178, 180, 182, + 184, 186, 188, 190, 192, 194, 196, 199, + 202, 203, 204, 206 +}; + +static const char _gdb_trans_keys[] = { + 3, 36, 35, 43, 45, 63, 72, 77, + 103, 109, 112, 113, 118, 35, 48, 57, + 65, 70, 97, 102, 48, 57, 65, 70, + 97, 102, 3, 35, 36, 3, 36, 48, + 57, 65, 70, 97, 102, 3, 36, 48, + 57, 65, 70, 97, 102, 35, 35, 48, + 57, 65, 70, 97, 102, 35, 44, 48, + 57, 65, 70, 97, 102, 35, 48, 57, + 65, 70, 97, 102, 35, 44, 58, 48, + 57, 65, 70, 97, 102, 35, 48, 57, + 65, 70, 97, 102, 35, 44, 48, 57, + 65, 70, 97, 102, 35, 48, 57, 65, + 70, 97, 102, 35, 44, 48, 57, 65, + 70, 97, 102, 35, 48, 57, 65, 70, + 97, 102, 35, 48, 57, 65, 70, 97, + 102, 35, 65, 67, 83, 102, 35, 116, + 35, 116, 35, 97, 35, 99, 35, 104, + 35, 101, 35, 100, 35, 58, 35, 48, + 57, 65, 70, 97, 102, 35, 117, 35, + 112, 35, 112, 35, 111, 35, 114, 35, + 116, 35, 101, 35, 100, 35, 58, 35, + 35, 84, 35, 104, 35, 114, 35, 101, + 35, 97, 35, 100, 35, 73, 35, 110, + 35, 102, 35, 111, 35, 67, 35, 111, + 35, 110, 35, 116, 35, 59, 63, 35, + 99, 115, 35, 35, 3, 36, 3, 35, + 36, 0 +}; + +static const char _gdb_single_lengths[] = { + 0, 2, 11, 1, 0, 0, 3, 2, + 2, 1, 1, 2, 1, 3, 1, 2, + 1, 2, 1, 1, 5, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 1, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 3, 3, + 1, 1, 2, 3 +}; + +static const char _gdb_range_lengths[] = { + 0, 0, 0, 0, 3, 3, 0, 3, + 3, 0, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 3, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; + +static const short _gdb_index_offsets[] = { + 0, 0, 3, 15, 17, 21, 25, 29, + 35, 41, 43, 48, 54, 59, 66, 71, + 77, 82, 88, 93, 98, 104, 107, 110, + 113, 116, 119, 122, 125, 128, 133, 136, + 139, 142, 145, 148, 151, 154, 157, 160, + 162, 165, 168, 171, 174, 177, 180, 183, + 186, 189, 192, 195, 198, 201, 204, 208, + 212, 214, 216, 219 +}; + +static const char _gdb_indicies[] = { + 1, 2, 0, 4, 5, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 3, 4, + 3, 14, 14, 14, 15, 16, 16, 16, + 15, 18, 19, 20, 17, 1, 2, 21, + 21, 21, 0, 1, 2, 16, 16, 16, + 0, 4, 22, 4, 24, 24, 24, 23, + 4, 25, 24, 24, 24, 23, 4, 26, + 26, 26, 23, 4, 25, 27, 26, 26, + 26, 23, 4, 28, 28, 28, 23, 29, + 25, 28, 28, 28, 23, 4, 30, 30, + 30, 3, 4, 31, 30, 30, 30, 3, + 4, 32, 32, 32, 3, 29, 32, 32, + 32, 3, 4, 33, 34, 35, 36, 3, + 4, 37, 3, 4, 38, 3, 4, 39, + 3, 4, 40, 3, 4, 41, 3, 4, + 42, 3, 4, 43, 3, 4, 44, 3, + 4, 45, 45, 45, 3, 4, 46, 3, + 4, 47, 3, 4, 48, 3, 4, 49, + 3, 4, 50, 3, 4, 51, 3, 4, + 52, 3, 4, 53, 3, 4, 54, 3, + 4, 55, 4, 56, 3, 4, 57, 3, + 4, 58, 3, 4, 59, 3, 4, 60, + 3, 4, 61, 3, 4, 62, 3, 4, + 63, 3, 4, 64, 3, 4, 65, 3, + 4, 66, 3, 4, 67, 3, 4, 68, + 3, 4, 69, 3, 4, 70, 71, 3, + 4, 72, 73, 3, 4, 74, 4, 75, + 1, 2, 0, 18, 19, 20, 17, 0 +}; + +static const char _gdb_trans_targs[] = { + 1, 2, 2, 3, 4, 59, 3, 9, + 10, 3, 16, 18, 20, 50, 5, 0, + 58, 6, 2, 7, 2, 8, 9, 10, + 11, 12, 13, 14, 15, 4, 17, 18, + 19, 21, 3, 30, 40, 22, 23, 24, + 25, 26, 27, 28, 29, 29, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 39, + 41, 42, 43, 44, 45, 46, 47, 48, + 49, 3, 51, 52, 53, 54, 55, 3, + 56, 57, 56, 57 +}; + +static const char _gdb_trans_actions[] = { + 0, 60, 1, 3, 0, 3, 33, 3, + 3, 27, 21, 30, 3, 3, 7, 0, + 18, 3, 63, 0, 9, 7, 36, 24, + 71, 67, 71, 67, 71, 5, 15, 12, + 15, 3, 42, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 39, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 45, + 3, 3, 3, 3, 3, 3, 3, 3, + 3, 48, 3, 3, 3, 3, 3, 51, + 3, 3, 54, 57 +}; + +static const int gdb_start = 58; +static const int gdb_first_final = 58; +static const int gdb_error = 0; + +static const int gdb_en_main = 58; + + +#line 116 "src/gdb_parser.rl" + +void parser_init(command_cb *callbacks) +{ + +#line 181 "src/gdb_parser.c" + { + cs = gdb_start; + } + +#line 120 "src/gdb_parser.rl" + + command_callbacks = callbacks; +} + +int parse_buffer(char *buf, size_t len, void *priv) +{ + char *p = buf; + char *pe = p + len + 1; + + +#line 197 "src/gdb_parser.c" + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _gdb_trans_keys + _gdb_key_offsets[cs]; + _trans = _gdb_index_offsets[cs]; + + _klen = _gdb_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (unsigned int)(_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _gdb_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += (unsigned int)((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _gdb_indicies[_trans]; + cs = _gdb_trans_targs[_trans]; + + if ( _gdb_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _gdb_actions + _gdb_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +#line 11 "src/gdb_parser.rl" + { + cmd = 0; + rsp = NULL; + data = stack; + memset(stack, 0, sizeof(stack)); + crc = 0; + } + break; + case 1: +#line 19 "src/gdb_parser.rl" + { + crc += *p; + } + break; + case 2: +#line 23 "src/gdb_parser.rl" + { + data++; + assert(data < &stack[10]); + } + break; + case 3: +#line 28 "src/gdb_parser.rl" + { + *data *= 16; + + if (*p >= '0' && *p <= '9') + *data += *p - '0'; + else if (*p >= 'a' && *p <= 'f') + *data += *p - 'a' + 10; + else if (*p >= 'A' && *p <= 'F') + *data += *p - 'A' + 10; + } + break; + case 4: +#line 39 "src/gdb_parser.rl" + { + /* *data should point to the CRC */ + if (crc != *data) { + printf("CRC error\n"); + send_nack(priv); + } else { + printf("Cmd %d\n", cmd); + send_ack(priv); + + /* Push the response onto the stack */ + if (rsp) + *data = (uintptr_t)rsp; + else + *data = 0; + + command_callbacks[cmd](stack, priv); + } + } + break; + case 5: +#line 58 "src/gdb_parser.rl" + {cmd = GET_MEM;} + break; + case 6: +#line 63 "src/gdb_parser.rl" + {cmd = PUT_MEM;} + break; + case 7: +#line 70 "src/gdb_parser.rl" + {cmd = GET_GPRS;} + break; + case 8: +#line 72 "src/gdb_parser.rl" + {cmd = GET_SPR;} + break; + case 9: +#line 75 "src/gdb_parser.rl" + {cmd = STOP_REASON;} + break; + case 10: +#line 77 "src/gdb_parser.rl" + {cmd = SET_THREAD;} + break; + case 11: +#line 80 "src/gdb_parser.rl" + {rsp = "1";} + break; + case 12: +#line 81 "src/gdb_parser.rl" + {rsp = "QC1";} + break; + case 13: +#line 82 "src/gdb_parser.rl" + {rsp = "multiprocess+;vContSupported+";} + break; + case 14: +#line 83 "src/gdb_parser.rl" + {rsp = "m1l";} + break; + case 15: +#line 86 "src/gdb_parser.rl" + {rsp = "vCont;c;C;s;S";} + break; + case 16: +#line 87 "src/gdb_parser.rl" + {cmd = V_CONTC;} + break; + case 17: +#line 88 "src/gdb_parser.rl" + {cmd = V_CONTS;} + break; + case 18: +#line 90 "src/gdb_parser.rl" + {command_callbacks[INTERRUPT](stack, priv);} + break; +#line 384 "src/gdb_parser.c" + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +#line 130 "src/gdb_parser.rl" + + return 0; +} + +#if 0 +int main(int argc, char **argv) +{ + parser_init(NULL); + + if (argc > 1) + parse_buffer(argv[1], strlen(argv[1]), NULL); + return 0; +} +#endif From patchwork Fri Sep 7 06:40:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967228 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 4267Bz0C3Xz9sBJ for ; Fri, 7 Sep 2018 16:41:47 +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="TMawXJa1"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267By4sTwzF3SN for ; Fri, 7 Sep 2018 16:41:46 +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="TMawXJa1"; 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=209.85.215.177; helo=mail-pg1-f177.google.com; envelope-from=rashmica.g@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="TMawXJa1"; dkim-atps=neutral Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (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 4267BZ4T4XzF3Sd for ; Fri, 7 Sep 2018 16:41:26 +1000 (AEST) Received: by mail-pg1-f177.google.com with SMTP id y4-v6so6480248pgp.9 for ; Thu, 06 Sep 2018 23:41:26 -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:in-reply-to:references; bh=fLVyrnHmT+aMSiaQW3tz9YJzMmb52+lJ9sYZ9Lauysc=; b=TMawXJa1P+REnOF6Cntu139+P6MW4VAMsWl/FX62ut4i7yJwF4BRI+R3N97CcLtSmt 5tI9uhGbAuoV0Qdx+hyvcXsIIrZr5Jthm5BXTUdXDTtbDpBTJGCb8RIOFm+yoT77WX9a 9qI1sKwbrHlcnmzsfttjO7YkSWLf9WH50EZCXNR0bsvUFSXH1MPq9gpGjpDrcpapTS6w RHk8dLZL25E/60WOMANJormEExxlGgfQfQ/ORrUe39xfiD4LT/A5JCM9afmXJJqyJ0VJ pyEdmf3T87Q5ciMKOpC0zc27gWKr3vF/qsc04lVxzN78F01ND9PXdwQ+DGL/DsDEkDF+ QlZw== 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:in-reply-to :references; bh=fLVyrnHmT+aMSiaQW3tz9YJzMmb52+lJ9sYZ9Lauysc=; b=dUJOBAZ/YNqPayser/nJ9FzSNPExHu8Omt01UB8RAXpQv6hqnXO5JeOQ5RGMi27yUh CVJFO4cAYuyBU2s+lAUK9NMwC+AMbLRvx2NUS5qshcrbG9rP7z+GpHTvIwgviiJAnNdt u4+isUMJAGMJwF96e5kl6Hlg7EAEslAgULErmNx5+smoEGGER8IVITjrElslpN/q6qco Mn4ARhBry9cGx+ejYZBfZ1LnKKHBI/BysNcaZkdLMXqc7WQKOvxsvtbEbALuYkf45ls2 8PPN6ePjYMl+yJqo0LMn5G+LbZDCarryON6f9oyXsJ7pCGQmWNBBn3RTPgw3ChvgclyV vgpg== X-Gm-Message-State: APzg51ChIq0j54HaaEcVcuJg9KX24CJ1bvDYFKPzgvktuV5mB6OoTVQx qGiVjN5pf6ECTOKWe3UzP/aooPEkOu4= X-Google-Smtp-Source: ANB0Vda3iFEPYVn/Ar0TM3bP3K7eFDNgFE/NXWmh1dNSi573kt1uctbBgyTuBXzJhxXfFevu2umJMQ== X-Received: by 2002:a62:c98e:: with SMTP id l14-v6mr6886357pfk.10.1536302484751; Thu, 06 Sep 2018 23:41:24 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.41.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:41:24 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:14 +1000 Message-Id: <20180907064015.1058-16-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 15/16] pdbg/gdbserver: Make gdbserver optional 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- Makefile.am | 21 +++++++++++---------- configure.ac | 6 ++++++ src/pdbgproxy.c | 3 ++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index a476b87..581419c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -84,14 +84,17 @@ pdbg_SOURCES = \ src/parsers.c \ src/optcmd.c \ src/options_@ARCH@.c \ - src/htm.h \ - src/main.h \ - src/optcmd.h \ - src/options.h \ - src/parsers.h \ - src/progress.h \ - src/pdbgproxy.c \ - src/gdb_parser.c + src/pdbgproxy.c + +pdbg_CFLAGS = -I$(top_srcdir)/libpdbg -Wall -Werror -DGIT_SHA1=\"${GIT_SHA1}\" \ + $(ARCH_FLAGS) + +if GDBSERVER +pdbg_SOURCES += \ + $(extra_sources) +else +pdbg_CFLAGS += -DDISABLE_GDBSERVER +endif src/main.c: $(DT_headers) @@ -99,8 +102,6 @@ pdbg_LDADD = $(DT_objects) libpdbg.la libfdt.la libccan.a \ -L.libs -lrt pdbg_LDFLAGS = -Wl,--whole-archive,-lpdbg,--no-whole-archive -pdbg_CFLAGS = -I$(top_srcdir)/libpdbg -Wall -Werror -DGIT_SHA1=\"${GIT_SHA1}\" \ - $(ARCH_FLAGS) lib_LTLIBRARIES = libpdbg.la libfdt.la diff --git a/configure.ac b/configure.ac index 7cfd2ea..24440ac 100644 --- a/configure.ac +++ b/configure.ac @@ -36,4 +36,10 @@ AC_SUBST([ARCH]) AM_CONDITIONAL([TARGET_ARM], [test x"$ARCH" = "xarm"]) AM_CONDITIONAL([TARGET_PPC], [test x"$ARCH" = "xppc"]) +AC_ARG_ENABLE(gdbserver, +AC_HELP_STRING([--disable-gdbserver], [disables building the gdbserver]), +want_gdbserver=false, +want_gdbserver=true) +AM_CONDITIONAL([GDBSERVER], [test x$want_gdbserver = xtrue]) + AC_OUTPUT diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index 6689e14..8e91770 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -36,6 +36,7 @@ #define TRAP "S05" #define ERROR(e) "E"STR(e) +#ifndef DISABLE_GDBSERVER static struct pdbg_target *thread_target = NULL; static struct timeval timeout; static int poll_interval = 100; @@ -514,7 +515,7 @@ int gdbserver_start(struct pdbg_target *target, uint16_t port) return 1; } - +#endif static int gdbserver(uint16_t port) { From patchwork Fri Sep 7 06:40:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 967229 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 4267C13yBbz9s4Z for ; Fri, 7 Sep 2018 16:41:49 +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="slC1nJ0R"; dkim-atps=neutral Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4267C122xhzF3Sg for ; Fri, 7 Sep 2018 16:41:49 +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="slC1nJ0R"; 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=209.85.210.196; helo=mail-pf1-f196.google.com; envelope-from=rashmica.g@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="slC1nJ0R"; dkim-atps=neutral Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) (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 4267Bc5xfnzF3ST for ; Fri, 7 Sep 2018 16:41:28 +1000 (AEST) Received: by mail-pf1-f196.google.com with SMTP id j26-v6so6522105pfi.10 for ; Thu, 06 Sep 2018 23:41:28 -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:in-reply-to:references; bh=xZjNRCDcQXklAz8+IMOOIGVH7F5zdmpuGp8/KKvQEAE=; b=slC1nJ0RKhUHS4PN51YrFjdZdfdFVIcObrFW8iLfrI85rA73sCZ2iyuGq8s86sinxv x/C13vuXNCjyRAb/by8Yjx5VT3g29wcbk6y0YuJQ/4PrKall7mjcztvRXruHBzfk2Re4 TuMGvctVxMQgiUzCetqianUK39eqpBjq6Mc624WYLjINPNpxMt2BrauBPHk0wsWQj73M b9czLHZC50QabKTB+Koohy7FbwN1GpNpeZkOyWf/Fi99cAuGoKvzPd0r0Gsv9j705VD+ fU2bqWy8FnfQRj+Xraxd8iNvvthGBX+MXtZC8GVe65aRwY9t+QHJGcrp14tUGjw3AH4s pR+Q== 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:in-reply-to :references; bh=xZjNRCDcQXklAz8+IMOOIGVH7F5zdmpuGp8/KKvQEAE=; b=kYaCDXFybHsMn4Fe3+G5HYxV/SD2FqeKHd2ma/qzWseLLDZptCndYpHtfuvN80QooF TYvu3O6+bFjiJvoC7oe2gXRdLcFXPeZ5fq/L7ywv5wrkELZih0bCyIBk1pvPaSsDL+hc pUnTKswDrMFuVWfVM4R/DEXikS0YaQ52MyJ/R46043YhhKoInWxfhr0paTX2cCZlVYeW FMwwCpF4pjeoARPeqbc5PZTVxaTYfYCXzNQofnEOY1fnyGgOw51J8/Ql5pT/0Z+fXvpC u2qGf/Dvstc650hUmejpkmSK6ZewdU1MmBdwa64fqG6Bi16hxpTVV5vOzKq5ImEPdQ1K ClJw== X-Gm-Message-State: APzg51BR97/UMClgM9+HAWTPFDsSTsGGsRwXXo21IIox/tbXO0u0iifH WejXRKieFUpfluy9hIS8DTqDSF+B5N0= X-Google-Smtp-Source: ANB0VdYHuf5XN4GQ45V3UoDrjhklnEbdsAZvLpvnwdzEzY53G2XNs1Y3Sea7cgh8FIyxDEB1kMB4Vg== X-Received: by 2002:a63:f:: with SMTP id 15-v6mr6750602pga.430.1536302487126; Thu, 06 Sep 2018 23:41:27 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y69-v6sm14958108pfd.36.2018.09.06.23.41.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 23:41:26 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 7 Sep 2018 16:40:15 +1000 Message-Id: <20180907064015.1058-17-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180907064015.1058-1-rashmica.g@gmail.com> References: <20180907064015.1058-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH v2 16/16] README: Add some gdbserver info 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 878e6d3..dcbbbe3 100644 --- a/README.md +++ b/README.md @@ -365,3 +365,29 @@ There are also low level htm commands which can also be used: - `stop` will still stop the trace and de-configure the hardware. - `dump` will dump the trace to a file. +### GDBSERVER +At the moment gdbserver is only supported on P8 while the cores are in the +kernel. + +To run a gdbserver on a P8 machine from a BMC running openbmc: + +Stop all the cores of the host +$ ./pdbg -d p8 -a stop + +Run gdbserver on thread 0 of core 11, accessible through port 44 +$ ./pdbg -d p8 -p0 -c11 -t0 gdbserver 44 + +On your local machine: +$ gdb +(gdb) set architecture powerpc:common64 +(gdb) target remote palm5-bmc:44 + +Debugging info: +(gdb) set debug remote 10 + + +Notes: +1. DON'T RUN PDBG OVER FSI WHILE HOSTBOOT IS RUNNING. Weird things seem to +happen. +2. If you want to view the kernel call trace then run gdb on the vmlinux that +the host is running (the kernel needs to be compiled with debug symbols).