From nobody Thu Oct 30 08:09:40 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510067516853269.07315898596937; Tue, 7 Nov 2017 07:11:56 -0800 (PST) Received: from localhost ([::1]:53875 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC5Xe-0001Wj-0y for importer@patchew.org; Tue, 07 Nov 2017 10:11:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC5SP-0005vM-Ns for qemu-devel@nongnu.org; Tue, 07 Nov 2017 10:06:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eC5SJ-00009N-RI for qemu-devel@nongnu.org; Tue, 07 Nov 2017 10:06:29 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:56644) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eC5SJ-00008w-Ki for qemu-devel@nongnu.org; Tue, 07 Nov 2017 10:06:23 -0500 Received: by mail-wm0-x241.google.com with SMTP id z3so4534872wme.5 for ; Tue, 07 Nov 2017 07:06:23 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g99sm2879373wrd.72.2017.11.07.07.06.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Nov 2017 07:06:16 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id E90E73E059C; Tue, 7 Nov 2017 15:06:09 +0000 (GMT) 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=Xj0UFbzpuaqTimkoIVxuJ9PFirQ2UgIpgeXk++kf+lg=; b=a2EUCCN/jDFspWViJ/w8K+Sf1KbbNYAuMEfjLpY1zMghtDSxBqXhsEPA8pTWHbOFiV vuCsmVS28FfJKS8zuURSSKeWeHQXbiCTBM5UJfQLHjiMP97v1wXjVdisn43nOmGUhflg EpknebSrzV9fWf/jII4TWfjhdfcq5xlebEt0c= 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=Xj0UFbzpuaqTimkoIVxuJ9PFirQ2UgIpgeXk++kf+lg=; b=EBO7i7YY9Y6Dn9QKxogqZiN9R18L+EehNp1k1DDk/zpCivWvJPOhn8n5dC48+0ZVys r/33uOiTe3H4FPKNxPc2rvW/6HJPl9KlrVsFa/2VBZJ1Um6JhSRaEtBLAtj0amNATWZm FCuNzO+rYOox2icdq5Zp7VMuagASivlwIRyb7vJpE3FyhsQmFS7LzJ/5AmkaAd3x2BlO M1N0NPc/qp0yvWkYQ78Pqwf5kdfAdn0AMdE7pabKsjQ2ftnJZmxPCS21vLZIcJVIchp1 3hMWI4MZq+jwJnOFf1Xtz7bBTbzs7eiErFADy2OX+6tXcoGEi6NbS5+rUZS9oyxliFLl fV/A== X-Gm-Message-State: AJaThX5TFl1H4KyjYM5+Zu9iK0L4Ju7lK7BwOTg93ExdRalH4Zs8aTQY F3l2HQ030V5N8BClZFHoCBOjmg== X-Google-Smtp-Source: ABhQp+RJfLnZn3KTu6b6Z6jKuAoZK6FH+nJIkEsdQ5IoKdyIgwKXWYt3b0ZV0wh8in3pKZQ9msKrjA== X-Received: by 10.28.190.12 with SMTP id o12mr1839271wmf.4.1510067182561; Tue, 07 Nov 2017 07:06:22 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 7 Nov 2017 15:05:57 +0000 Message-Id: <20171107150558.22131-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171107150558.22131-1-alex.bennee@linaro.org> References: <20171107150558.22131-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [RISU PATCH 09/10] risu_reginfo_aarch64: add reginfo_copy_sve 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: qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Dave.Martin@arm.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Add the ability to save SVE registers from the signal context. This is controlled with an optional flag --test-sve. The whole thing is conditionally compiled when SVE support is in the sigcontext headers. Technically SVE registers could be beyond an EXTRA_MAGIC section. I've not seen this on the model so currently we abort() if we encounter the EXTRA_MAGIC section. Signed-off-by: Alex Benn=C3=A9e --- risu_reginfo_aarch64.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ risu_reginfo_aarch64.h | 8 ++++++ 2 files changed, 82 insertions(+) diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 38ad338..7c97790 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -13,12 +13,78 @@ #include #include #include +#include +#include +#include =20 #include "risu.h" #include "risu_reginfo_aarch64.h" =20 +#ifndef SVE_MAGIC void *arch_long_opts; char *arch_extra_help; +#else +/* Should we test SVE register state */ +static int test_sve; +static struct option extra_opts[] =3D { + {"test-sve", no_argument, &test_sve, 1}, + {0, 0, 0, 0} +}; + +void *arch_long_opts =3D &extra_opts[0]; +char *arch_extra_help =3D " --test-sve Compare SVE registers\n"; + +/* Extra SVE copy function, only called with --test-sve */ +static void reginfo_copy_sve(struct reginfo *ri, struct _aarch64_ctx *ctx) +{ + struct sve_context *sve; + int r, vq; + bool found =3D false; + + while (!found) { + switch (ctx->magic) + { + case SVE_MAGIC: + found =3D true; + break; + case EXTRA_MAGIC: + fprintf(stderr, "%s: found EXTRA_MAGIC\n", __func__); + abort(); + case 0: + /* We might not have an SVE context */ + fprintf(stderr, "%s: reached end of ctx, no joy (%d)\n", __fu= nc__, ctx->size); + return; + default: + ctx =3D (struct _aarch64_ctx *)((void *)ctx + ctx->size); + break; + } + + } + + sve =3D (struct sve_context *) ctx; + ri->vl =3D sve->vl; + vq =3D sve_vq_from_vl(sve->vl); /* number of quads for whole vl */ + + /* Copy ZREG's one at a time */ + for (r =3D 0; r < SVE_NUM_ZREGS; r++) { + memcpy(&ri->zregs[r], + (char *)sve + SVE_SIG_ZREG_OFFSET(vq, r), + SVE_SIG_ZREG_SIZE(vq)); + } + + /* Copy PREG's one at a time */ + for (r =3D 0; r < SVE_NUM_PREGS; r++) { + memcpy(&ri->pregs[r], + (char *)sve + SVE_SIG_PREG_OFFSET(vq, r), + SVE_SIG_PREG_SIZE(vq)); + } + + /* Finally the FFR */ + memcpy(&ri->ffr,(char *)sve + SVE_SIG_FFR_OFFSET(vq), + SVE_SIG_FFR_SIZE(vq)); + +} +#endif =20 /* reginfo_init: initialize with a ucontext */ void reginfo_init(struct reginfo *ri, ucontext_t *uc) @@ -26,6 +92,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) int i; struct _aarch64_ctx *ctx; struct fpsimd_context *fp; + /* necessary to be able to compare with memcmp later */ memset(ri, 0, sizeof(*ri)); =20 @@ -59,6 +126,13 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) for (i =3D 0; i < 32; i++) { ri->vregs[i] =3D fp->vregs[i]; } + +#ifdef SVE_MAGIC + if (test_sve) { + ctx =3D (struct _aarch64_ctx *) &uc->uc_mcontext.__reserved[0]; + reginfo_copy_sve(ri, ctx); + } +#endif }; =20 /* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */ diff --git a/risu_reginfo_aarch64.h b/risu_reginfo_aarch64.h index a05fb4e..317383f 100644 --- a/risu_reginfo_aarch64.h +++ b/risu_reginfo_aarch64.h @@ -25,6 +25,14 @@ struct reginfo { uint32_t fpsr; uint32_t fpcr; __uint128_t vregs[32]; + +#ifdef SVE_MAGIC + /* SVE */ + uint16_t vl; /* current VL */ + __uint128_t zregs[SVE_NUM_ZREGS][SVE_VQ_MAX]; + uint16_t pregs[SVE_NUM_PREGS][SVE_VQ_MAX]; + uint16_t ffr[SVE_VQ_MAX]; +#endif }; =20 #endif /* RISU_REGINFO_AARCH64_H */ --=20 2.14.2