From patchwork Tue Nov 7 15:05:57 2017 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: 118186 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp636753edm; Tue, 7 Nov 2017 07:10:27 -0800 (PST) X-Google-Smtp-Source: ABhQp+RyP/3km+wJ/qTQz6DcHdxGVBSeqFQgDF0w27i/e9gUk+aOI0o0THldSc52SIStkijDIFcr X-Received: by 10.13.225.145 with SMTP id k139mr12470247ywe.483.1510067426930; Tue, 07 Nov 2017 07:10:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510067426; cv=none; d=google.com; s=arc-20160816; b=zYpAEqsyLpPtwg05b2sLvWeRNH5+OLdJv9z9TQNSiK4xTiy/Nq7aWi4xAkkfY2oErJ LWiWJVyvPY+baSfg8jdP1YuKXVIOVP7XrVQRu+x2SiT6fAYH24Lvx9lpBfxdbEiYFdfC /HVnRNQsUEhSIFe3GVT4FHcyKoVgsuC24dwN4xuj69i196/zsAc/osYTHJC2XAR65cO4 ACfA5k7ka8wTaHBzeIf4BRH7axfhOVlS52tZFY+wlS+8adU9F778uDGMmovPEmgA1OTJ FCMPJ2vENbOBLltR4mnVQjk6a+xdXNnfGQtBD1uBHuVEUycF3MjG9ljNmve6FQ4v6G3a TlBw== 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=Xj0UFbzpuaqTimkoIVxuJ9PFirQ2UgIpgeXk++kf+lg=; b=szPXRdRaf4wkLIFuuopFOHCIo0Pw2SuPuQvEZ0a9xvKfJIRO0M4ik/gwIJN0ZFPheE /+6ZiHiZismwkm6xLpPy00OXUi6/W8r8xwlaZZSGAeOgWeQVsXex/Rtf3glO/Ev2HBWy 9ivocWGsvi4FDfxrd5Vi6dS2NmkirxRJ0/2unaLGpJFtqwaF8gwgoeD73Th5qiApOPW8 GV0nig7ywyRx0y+IH0+4EdwzLyUm1UEEOtdPI4+JjdvojPPS+alUsWWrko3NQ8GwVIzR caNggV8iAi3bF14tP050vrXhzpYL3ihEGKZP3uxFAaGPHA3F78eFFjC7uayt9nXVM8XP 8FOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=a2EUCCN/; 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 14si312163ywh.544.2017.11.07.07.10.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 07 Nov 2017 07:10:26 -0800 (PST) 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=a2EUCCN/; 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]:53866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC5WE-0000K7-7g for patch@linaro.org; Tue, 07 Nov 2017 10:10:26 -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) 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-Received: by 10.28.190.12 with SMTP id o12mr1839271wmf.4.1510067182561; Tue, 07 Nov 2017 07:06:22 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , Dave.Martin@arm.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- risu_reginfo_aarch64.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ risu_reginfo_aarch64.h | 8 ++++++ 2 files changed, 82 insertions(+) -- 2.14.2 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 #include "risu.h" #include "risu_reginfo_aarch64.h" +#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[] = { + {"test-sve", no_argument, &test_sve, 1}, + {0, 0, 0, 0} +}; + +void *arch_long_opts = &extra_opts[0]; +char *arch_extra_help = " --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 = false; + + while (!found) { + switch (ctx->magic) + { + case SVE_MAGIC: + found = 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", __func__, ctx->size); + return; + default: + ctx = (struct _aarch64_ctx *)((void *)ctx + ctx->size); + break; + } + + } + + sve = (struct sve_context *) ctx; + ri->vl = sve->vl; + vq = sve_vq_from_vl(sve->vl); /* number of quads for whole vl */ + + /* Copy ZREG's one at a time */ + for (r = 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 = 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 /* 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)); @@ -59,6 +126,13 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) for (i = 0; i < 32; i++) { ri->vregs[i] = fp->vregs[i]; } + +#ifdef SVE_MAGIC + if (test_sve) { + ctx = (struct _aarch64_ctx *) &uc->uc_mcontext.__reserved[0]; + reginfo_copy_sve(ri, ctx); + } +#endif }; /* 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 }; #endif /* RISU_REGINFO_AARCH64_H */