From patchwork Fri Jun 22 14:12:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 139663 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp942636lji; Fri, 22 Jun 2018 07:30:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeKvwIADGFodw6c6e/EqdYqesjc6Ootj3sC5z3KGuF3jN1OUge+6iCTNkpkdpJ9V1OkiHhH X-Received: by 2002:a0c:b34f:: with SMTP id a15-v6mr1626484qvf.116.1529677835428; Fri, 22 Jun 2018 07:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529677835; cv=none; d=google.com; s=arc-20160816; b=nnQ+/OYIBn//vfoER+kzFKt7SHZG8DSO/1FRJMY8rq5JIuZmjw2bsLcwNradjz+TAs yLC/Elhhob7fgpmSQLz31dBrc/8r+ZiMfGEhqvV7Xb5vyHBlM5FOkuLgTAQ1+9ZE/I0v Ufa1hwLkbetTuxwqlJnSe1L9Yl8S6jDtY8R+w2Zm/NpHlqPHbNjsoVD0/z2q9woQg1kO UVdKTDVnfScvBDnlEfDbH2Uwr1JNKuLIZZv/d6U4lShSgzYtvGbX/Kw5D+cECAAixhtT 3baC/IHxfaaMnU2B583JeU/F/SiO3P038pO1zbCK8AlEJvJk9dStucpobo3JZCj2wB/Z zrTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Eo/dpJqkbccungP/oychj/4dCZHJeZ6aJeG80j8fsuM=; b=mDnSipGlM/S4ErkALbGamzaW4O32TwdDtEbkFlppZSTVf+QWNtnOZOfSqMEUjgPMOw 0A1s7ysXZMKzL2sKkgNsuZdojyRfhxEO8M97ny2Bc7NaZ34zPOEmeyQycydRbl0u7pUM E97fHKVoCuiYrErIJnt0uTNCW1g6cwoiKVB8Wf/59hdKlNLzy3+kqbqC2tayv4M3Xehm nKbDkNB5GewvYrEVhe/GFksX2LkKrQyc+5DntQF9AWuq4yT4Hs8NaE1rPZfszYO2yx8j ougHGaiOCsPGs1LfTq40W44mgJeltjv0SPpLD8v5XYM38VF0z+OHkIB6pV70+c/sc4/4 /y5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=B6FaggdH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t69-v6si4152339qki.176.2018.06.22.07.30.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Jun 2018 07:30:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=B6FaggdH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34406 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWN58-0004M9-Gh for patch@linaro.org; Fri, 22 Jun 2018 10:30:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWMwz-0005xY-GF for qemu-devel@nongnu.org; Fri, 22 Jun 2018 10:22:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWMwv-0003Wz-2I for qemu-devel@nongnu.org; Fri, 22 Jun 2018 10:22:09 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:54620) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fWMwu-0003WH-OX for qemu-devel@nongnu.org; Fri, 22 Jun 2018 10:22:04 -0400 Received: by mail-wm0-x236.google.com with SMTP id o13-v6so2421261wmf.4 for ; Fri, 22 Jun 2018 07:22:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Eo/dpJqkbccungP/oychj/4dCZHJeZ6aJeG80j8fsuM=; b=B6FaggdHy1/CcF5Na+l3yY0tX8VcbeuVBYXMMFnozva2c+9kzeAfZ0WDOVcR3P45MY PfYylV0mLGmu9uUO1aAP2Wx0ZH0Oguxp3II4tz1fEm0gGMpeZepV6rQcWWO6eI8hwnKw iyxkIj8qx+ggKgPYOwLmulhqAyasFXFfw61Oo= 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:mime-version:content-transfer-encoding; bh=Eo/dpJqkbccungP/oychj/4dCZHJeZ6aJeG80j8fsuM=; b=o+J7wNWGjcJg+viou4uJR18uIEEd6VYNuxiJKoCIiTe77YBMaCZQ3WpD7ca/F+O03p GFRrpAWPCIFY/WdL9Eluz93d7L6EB0E2jwR/TaLBgdbHPdQvYjGYFlTKO9tITg46qNdQ HCDeLdouh02K8UF4FMYsQs39yLrja/v7KjBo3BgUXB2H6uZwXu5pgWZBS2L7fIpisx6b iHDfkToRz1fIvyKdTpkgS+/iruQ0d5/+sJoEY5Rr7+qqANx2C0R1l49qC5aBCzyzzQIX Fc3LU4w8clxCU23jjcA3pIHmCkq0DmfrOFXZa0aFtF1uy63PN9Hh1DNoDXOhbPqJDw/R OrUg== X-Gm-Message-State: APt69E2hC/NbyXeazJe2D1mxoqOufytXxbXHuyvcqiQ9xDUWWX3DGdMg jYdeow6bwnn9ddh4meJEKGGccg== X-Received: by 2002:a1c:36e0:: with SMTP id y93-v6mr1863668wmh.67.1529677323597; Fri, 22 Jun 2018 07:22:03 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id v15-v6sm6653169wrq.37.2018.06.22.07.22.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Jun 2018 07:22:00 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 4DB983E0CA2; Fri, 22 Jun 2018 15:12:06 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 22 Jun 2018 15:12:03 +0100 Message-Id: <20180622141205.16306-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180622141205.16306-1-alex.bennee@linaro.org> References: <20180622141205.16306-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::236 Subject: [Qemu-devel] [RISU PATCH v4 20/22] risu_reginfo_aarch64: add SVE support to reginfo_dump_mismatch X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, richard.henderson@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We also tweak the justification of the rest of the registers so the : lines up nicely across the register dump and diff dump. Signed-off-by: Alex Bennée --- v2 - include ffr in comparison - mild re-factor of preg cmp/diff v3 - re-factoring v4 - alignment/justification tweaks - merge chunks from the variable VQ patch --- risu_reginfo_aarch64.c | 140 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 124 insertions(+), 16 deletions(-) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 79db5dd..bf98ba1 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "risu.h" #include "risu_reginfo_aarch64.h" @@ -146,12 +147,12 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) } /* Finally the FFR */ - memcpy(&ri->sve.ffr,(void *)sve + SVE_SIG_FFR_OFFSET(vq), + memcpy(&ri->sve.ffr, (void *)sve + SVE_SIG_FFR_OFFSET(vq), SVE_SIG_FFR_SIZE(vq)); return; } -#endif +#endif /* SVE_MAGIC */ for (i = 0; i < 32; i++) { ri->simd.vregs[i] = fp->vregs[i]; @@ -164,6 +165,52 @@ int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2) return memcmp(r1, r2, reginfo_size()) == 0; } +#ifdef SVE_MAGIC +static int sve_zreg_is_eq(int vq, const void *z1, const void *z2) +{ + return memcmp(z1, z2, vq * 16) == 0; +} + +static int sve_preg_is_eq(int vq, const void *p1, const void *p2) +{ + return memcmp(p1, p2, vq * 2) == 0; +} + +static void sve_dump_preg(FILE *f, int vq, const uint16_t *p) +{ + int q; + for (q = vq - 1; q >= 0; q--) { + fprintf(f, "%04x", p[q]); + } +} + +static void sve_dump_preg_diff(FILE *f, int vq, const uint16_t *p1, + const uint16_t *p2) +{ + sve_dump_preg(f, vq, p1); + fprintf(f, " vs "); + sve_dump_preg(f, vq, p2); + fprintf(f, "\n"); +} + +static void sve_dump_zreg_diff(FILE *f, int vq, const __uint128_t *z1, + const __uint128_t *z2) +{ + const char *pad = ""; + int q; + + for (q = 0; q < vq; ++q) { + if (z1[q] != z2[q]) { + fprintf(f, "%sq%-2d: %016" PRIx64 "%016" PRIx64 + " vs %016" PRIx64 "%016" PRIx64"\n", pad, q, + (uint64_t)(z1[q] >> 64), (uint64_t)z1[q], + (uint64_t)(z2[q] >> 64), (uint64_t)z2[q]); + pad = " "; + } + } +} +#endif + /* reginfo_dump: print state to a stream, returns nonzero on success */ int reginfo_dump(struct reginfo *ri, FILE * f) { @@ -171,17 +218,47 @@ int reginfo_dump(struct reginfo *ri, FILE * f) fprintf(f, " faulting insn %08x\n", ri->faulting_insn); for (i = 0; i < 31; i++) { - fprintf(f, " X%-2d : %016" PRIx64 "\n", i, ri->regs[i]); + fprintf(f, " X%-2d : %016" PRIx64 "\n", i, ri->regs[i]); } - fprintf(f, " sp : %016" PRIx64 "\n", ri->sp); - fprintf(f, " pc : %016" PRIx64 "\n", ri->pc); - fprintf(f, " flags : %08x\n", ri->flags); - fprintf(f, " fpsr : %08x\n", ri->fpsr); - fprintf(f, " fpcr : %08x\n", ri->fpcr); + fprintf(f, " sp : %016" PRIx64 "\n", ri->sp); + fprintf(f, " pc : %016" PRIx64 "\n", ri->pc); + fprintf(f, " flags : %08x\n", ri->flags); + fprintf(f, " fpsr : %08x\n", ri->fpsr); + fprintf(f, " fpcr : %08x\n", ri->fpcr); + +#ifdef SVE_MAGIC + if (test_sve) { + int q, vq = test_sve; + + fprintf(f, " vl : %d\n", ri->sve.vl); + + for (i = 0; i < 32; i++) { + fprintf(f, " Z%-2d q%-2d: %016" PRIx64 "%016" PRIx64 "\n", i, 0, + (uint64_t)(ri->sve.zregs[i][0] >> 64), + (uint64_t)ri->sve.zregs[i][0]); + for (q = 1; q < vq; ++q) { + fprintf(f, " q%-2d: %016" PRIx64 "%016" PRIx64 "\n", q, + (uint64_t)(ri->sve.zregs[i][q] >> 64), + (uint64_t)ri->sve.zregs[i][q]); + } + } + + for (i = 0; i < 16; i++) { + fprintf(f, " P%-2d : ", i); + sve_dump_preg(f, vq, &ri->sve.pregs[i][0]); + fprintf(f, "\n"); + } + fprintf(f, " FFR : "); + sve_dump_preg(f, vq, &ri->sve.ffr[0]); + fprintf(f, "\n"); + + return !ferror(f); + } +#endif for (i = 0; i < 32; i++) { - fprintf(f, " V%-2d : %016" PRIx64 "%016" PRIx64 "\n", i, + fprintf(f, " V%-2d : %016" PRIx64 "%016" PRIx64 "\n", i, (uint64_t) (ri->simd.vregs[i] >> 64), (uint64_t) (ri->simd.vregs[i])); } @@ -200,36 +277,67 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) } for (i = 0; i < 31; i++) { if (m->regs[i] != a->regs[i]) { - fprintf(f, " X%-2d : %016" PRIx64 " vs %016" PRIx64 "\n", + fprintf(f, " X%-2d : %016" PRIx64 " vs %016" PRIx64 "\n", i, m->regs[i], a->regs[i]); } } if (m->sp != a->sp) { - fprintf(f, " sp : %016" PRIx64 " vs %016" PRIx64 "\n", + fprintf(f, " sp : %016" PRIx64 " vs %016" PRIx64 "\n", m->sp, a->sp); } if (m->pc != a->pc) { - fprintf(f, " pc : %016" PRIx64 " vs %016" PRIx64 "\n", + fprintf(f, " pc : %016" PRIx64 " vs %016" PRIx64 "\n", m->pc, a->pc); } if (m->flags != a->flags) { - fprintf(f, " flags : %08x vs %08x\n", m->flags, a->flags); + fprintf(f, " flags : %08x vs %08x\n", m->flags, a->flags); } if (m->fpsr != a->fpsr) { - fprintf(f, " fpsr : %08x vs %08x\n", m->fpsr, a->fpsr); + fprintf(f, " fpsr : %08x vs %08x\n", m->fpsr, a->fpsr); } if (m->fpcr != a->fpcr) { - fprintf(f, " fpcr : %08x vs %08x\n", m->fpcr, a->fpcr); + fprintf(f, " fpcr : %08x vs %08x\n", m->fpcr, a->fpcr); } +#ifdef SVE_MAGIC + if (test_sve) { + int vq = sve_vq_from_vl(m->sve.vl); + + if (m->sve.vl != a->sve.vl) { + fprintf(f, " vl : %d vs %d\n", m->sve.vl, a->sve.vl); + } + + for (i = 0; i < SVE_NUM_ZREGS; i++) { + if (!sve_zreg_is_eq(vq, &m->sve.zregs[i], &a->sve.zregs[i])) { + fprintf(f, " Z%-2d ", i); + sve_dump_zreg_diff(f, vq, &m->sve.zregs[i][0], + &a->sve.zregs[i][0]); + } + } + for (i = 0; i < SVE_NUM_PREGS; i++) { + if (!sve_preg_is_eq(vq, &m->sve.pregs[i], &a->sve.pregs[i])) { + fprintf(f, " P%-2d : ", i); + sve_dump_preg_diff(f, vq, &m->sve.pregs[i][0], + &a->sve.pregs[i][0]); + } + } + if (!sve_preg_is_eq(vq, &m->sve.ffr, &a->sve.ffr)) { + fprintf(f, " FFR : "); + sve_dump_preg_diff(f, vq, &m->sve.pregs[i][0], &a->sve.pregs[i][0]); + } + + return !ferror(f); + } +#endif + for (i = 0; i < 32; i++) { if (m->simd.vregs[i] != a->simd.vregs[i]) { - fprintf(f, " V%-2d : " + fprintf(f, " V%-2d : " "%016" PRIx64 "%016" PRIx64 " vs " "%016" PRIx64 "%016" PRIx64 "\n", i, (uint64_t) (m->simd.vregs[i] >> 64),