From nobody Tue Feb 10 06:58:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1590115161; cv=none; d=zohomail.com; s=zohoarc; b=NFMVKpRUIYW+5qwn4xLUo5ypL9YK2FSQEdieh6Yx1fi5LzdbeEYJMMKGnEQ4tl7n7ozvWWfKr/9WLaHgxBUE2VZhdXzdvVZpFNZCZSScoslSnKpQ6/WFZQgUrCfXDMubYkMZ4pFQk5QzDtyjIEMKRUIhnYwJ/SpxOtU/b/bMYcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590115161; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hhzEI0zY7uuhea/eDo3m8LR1KeJI+fOWQZOyopQnOJc=; b=m6U7ANUr1E3dB8BmNMKKQVWDkokXZQBUrk7BgqFAhNMML+4hZ2lKkZeWU+vhdmGO7QPiYop+MpUSBKZjrq9p3mG1k9luFyS0dlms1+10DSgUizLZsYWxnCkkfq1KVnFjSro0wjfC4l5T/xJsXYwV0su7lmDvS11+7rNscQluHVU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159011516113096.66731687612673; Thu, 21 May 2020 19:39:21 -0700 (PDT) Received: from localhost ([::1]:36674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxah-0004NM-Q0 for importer@patchew.org; Thu, 21 May 2020 22:39:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWf-0002zI-H3 for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:09 -0400 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]:35002) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWd-00058T-W8 for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:09 -0400 Received: by mail-pj1-x1041.google.com with SMTP id 5so4348059pjd.0 for ; Thu, 21 May 2020 19:35:07 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gt10sm5443755pjb.30.2020.05.21.19.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:05 -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=hhzEI0zY7uuhea/eDo3m8LR1KeJI+fOWQZOyopQnOJc=; b=ugYrlGz6ltuiNsbxkqPk9u7b4CZHviOZ4LKmlv//2Vh6NjQcHiyuCLGAlBH5DNp6Fi NF7QciY/bd21G/0PkCIeNnFKldeBJ62KxghAkKOMUjgQLHqPDM4I+PFFli7ap2+M+lHh 1Jsvhv476z9mK8rqQ+frFuTusUi/6abGlEepqWHvZY1ew6fg26sCnfM2M/CMz0Lqi3ia zASSjCqb/gZzggqGfYaH5LGWoPo/EzirIqg62PpAnG9b3eJUDK0cC2Te3mS+jkCaNm8x 8C5MoQmo2tgRDDfwQo2cRMiI1tDW3SNhlKuOfRTokojPZqLiWasdVnEUnBQrNzoCNGcq 2BAQ== 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=hhzEI0zY7uuhea/eDo3m8LR1KeJI+fOWQZOyopQnOJc=; b=Vs0xJcbxELfNol3dtmaYeHn9Va7p5YQp/szhw4+7AUl0i0on0MNaNDXDdgsqnnSJgI 5FtW4ZsQXt5iq2riodxNaFxRtISTh3ofinEAnes7Ek1B2FHD5rV0g5qdPFQHM1BnHVM9 oTdKj8fYdUuIdaUMeOQZx5FWxMnNipq/I8ufduSUNRnQGuxJxv0lYOZd9u4NuebxWCM4 NOtux3sK3WQbAchhNrgBCKjsSa/0Tu+Ehs2HmI9r+Bq8B7q76tEQA8UlA9gQGp1QO1HS +sQfxP8IOmcaO6tJ1yMrJ/mBgJTKW21VKiUUcA8XBg/dv1cqXutpV3p+fbaJQ/5FJZ5D /WCw== X-Gm-Message-State: AOAM530psQ3TUWQ04GIVVIZoJD9KWeo3+sQ0WJP+XP2y+txArdobkvHr TwshWXnOCV/aQVPfI1K+SxW+uiZ8kG4= X-Google-Smtp-Source: ABdhPJzxvN5EpQAD9WlJuDgUhxQH0Mk6eRTTQlxWIj0p/0BiWvEp+tbadZxIQWn6fCImWe4LlFkYTw== X-Received: by 2002:a17:902:dc86:: with SMTP id n6mr12400066pld.17.1590114906123; Thu, 21 May 2020 19:35:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 19/25] aarch64: Reorg sve reginfo to save space Date: Thu, 21 May 2020 19:34:34 -0700 Message-Id: <20200522023440.26261-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522023440.26261-1-richard.henderson@linaro.org> References: <20200522023440.26261-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1041; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1041.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Mirror the signal frame by storing all of the registers as a lump. Use the signal macros to pull out the values. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- risu_reginfo_aarch64.h | 16 +---- risu_reginfo_aarch64.c | 135 +++++++++++++++++++++-------------------- 2 files changed, 73 insertions(+), 78 deletions(-) diff --git a/risu_reginfo_aarch64.h b/risu_reginfo_aarch64.h index c33b86f..01076b4 100644 --- a/risu_reginfo_aarch64.h +++ b/risu_reginfo_aarch64.h @@ -17,20 +17,8 @@ =20 struct simd_reginfo { __uint128_t vregs[32]; - char end[0]; }; =20 -#ifdef SVE_MAGIC -struct sve_reginfo { - /* 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]; - char end[0]; -}; -#endif - /* The kernel headers set this based on future arch extensions. The current arch maximum is 16. Save space below. */ #undef SVE_VQ_MAX @@ -47,11 +35,13 @@ struct reginfo { /* FP/SIMD */ uint32_t fpsr; uint32_t fpcr; + uint32_t sve_vl; =20 union { struct simd_reginfo simd; #ifdef SVE_MAGIC - struct sve_reginfo sve; + char sve[SVE_SIG_CONTEXT_SIZE(16) - SVE_SIG_REGS_OFFSET] + __attribute__((aligned(16))); #endif }; }; diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index 7044648..a1020ac 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -71,15 +71,30 @@ void process_arch_opt(int opt, const char *arg) =20 int reginfo_size(struct reginfo *ri) { - int size =3D offsetof(struct reginfo, simd.end); #ifdef SVE_MAGIC - if (test_sve) { - size =3D offsetof(struct reginfo, sve.end); + if (ri->sve_vl) { + int vq =3D sve_vq_from_vl(ri->sve_vl); + return (offsetof(struct reginfo, sve) + + SVE_SIG_CONTEXT_SIZE(vq) - SVE_SIG_REGS_OFFSET); } #endif - return size; + return offsetof(struct reginfo, simd) + sizeof(ri->simd); } =20 +#ifdef SVE_MAGIC +static uint64_t *reginfo_zreg(struct reginfo *ri, int vq, int i) +{ + return (uint64_t *)(ri->sve + SVE_SIG_ZREG_OFFSET(vq, i) - + SVE_SIG_REGS_OFFSET); +} + +static uint16_t *reginfo_preg(struct reginfo *ri, int vq, int i) +{ + return (uint16_t *)(ri->sve + SVE_SIG_PREG_OFFSET(vq, i) - + SVE_SIG_REGS_OFFSET); +} +#endif + /* reginfo_init: initialize with a ucontext */ void reginfo_init(struct reginfo *ri, ucontext_t *uc) { @@ -152,8 +167,6 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) return; } =20 - ri->sve.vl =3D sve->vl; - if (sve->head.size < SVE_SIG_CONTEXT_SIZE(vq)) { if (sve->head.size =3D=3D sizeof(*sve)) { /* SVE state is empty -- not an error. */ @@ -164,24 +177,9 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) return; } =20 - /* Copy ZREG's one at a time */ - for (i =3D 0; i < SVE_NUM_ZREGS; i++) { - memcpy(&ri->sve.zregs[i], - (void *)sve + SVE_SIG_ZREG_OFFSET(vq, i), - SVE_SIG_ZREG_SIZE(vq)); - } - - /* Copy PREG's one at a time */ - for (i =3D 0; i < SVE_NUM_PREGS; i++) { - memcpy(&ri->sve.pregs[i], - (void *)sve + SVE_SIG_PREG_OFFSET(vq, i), - SVE_SIG_PREG_SIZE(vq)); - } - - /* Finally the FFR */ - memcpy(&ri->sve.ffr, (void *)sve + SVE_SIG_FFR_OFFSET(vq), - SVE_SIG_FFR_SIZE(vq)); - + ri->sve_vl =3D sve->vl; + memcpy(ri->sve, (char *)sve + SVE_SIG_REGS_OFFSET, + SVE_SIG_CONTEXT_SIZE(vq) - SVE_SIG_REGS_OFFSET); return; } #endif /* SVE_MAGIC */ @@ -225,18 +223,20 @@ static void sve_dump_preg_diff(FILE *f, int vq, const= uint16_t *p1, fprintf(f, "\n"); } =20 -static void sve_dump_zreg_diff(FILE *f, int vq, const __uint128_t *z1, - const __uint128_t *z2) +static void sve_dump_zreg_diff(FILE *f, int vq, const uint64_t *za, + const uint64_t *zb) { const char *pad =3D ""; int q; =20 for (q =3D 0; q < vq; ++q) { - if (z1[q] !=3D z2[q]) { + uint64_t za0 =3D za[2 * q], za1 =3D za[2 * q + 1]; + uint64_t zb0 =3D zb[2 * q], zb1 =3D zb[2 * q + 1]; + + if (za0 !=3D zb0 || za1 !=3D zb1) { 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]); + " vs %016" PRIx64 "%016" PRIx64"\n", + pad, q, za1, za0, zb1, zb0); pad =3D " "; } } @@ -263,28 +263,30 @@ int reginfo_dump(struct reginfo *ri, FILE * f) if (test_sve) { int q, vq =3D test_sve; =20 - fprintf(f, " vl : %d\n", ri->sve.vl); + fprintf(f, " vl : %d\n", ri->sve_vl); =20 - for (i =3D 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 (i =3D 0; i < SVE_NUM_ZREGS; i++) { + uint64_t *z =3D reginfo_zreg(ri, vq, i); + + fprintf(f, " Z%-2d q%-2d: %016" PRIx64 "%016" PRIx64 "\n", + i, 0, z[1], z[0]); for (q =3D 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]); + fprintf(f, " q%-2d: %016" PRIx64 "%016" PRIx64 "\n", + q, z[q * 2 + 1], z[q * 2]); } } =20 - for (i =3D 0; i < 16; i++) { - fprintf(f, " P%-2d : ", i); - sve_dump_preg(f, vq, &ri->sve.pregs[i][0]); + for (i =3D 0; i < SVE_NUM_PREGS + 1; i++) { + uint16_t *p =3D reginfo_preg(ri, vq, i); + + if (i =3D=3D SVE_NUM_PREGS) { + fprintf(f, " FFR : "); + } else { + fprintf(f, " P%-2d : ", i); + } + sve_dump_preg(f, vq, p); fprintf(f, "\n"); } - fprintf(f, " FFR : "); - sve_dump_preg(f, vq, &ri->sve.ffr[0]); - fprintf(f, "\n"); - return !ferror(f); } #endif @@ -338,31 +340,34 @@ int reginfo_dump_mismatch(struct reginfo *m, struct r= eginfo *a, FILE * f) =20 #ifdef SVE_MAGIC if (test_sve) { - int vq =3D sve_vq_from_vl(m->sve.vl); + int vq =3D sve_vq_from_vl(m->sve_vl); =20 - if (m->sve.vl !=3D a->sve.vl) { - fprintf(f, " vl : %d vs %d\n", m->sve.vl, a->sve.vl); + if (m->sve_vl !=3D a->sve_vl) { + fprintf(f, " vl : %d vs %d\n", m->sve_vl, a->sve_vl); } =20 for (i =3D 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 =3D 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]); - } + uint64_t *zm =3D reginfo_zreg(m, vq, i); + uint64_t *za =3D reginfo_zreg(a, vq, i); =20 + if (!sve_zreg_is_eq(vq, zm, za)) { + fprintf(f, " Z%-2d ", i); + sve_dump_zreg_diff(f, vq, zm, za); + } + } + for (i =3D 0; i < SVE_NUM_PREGS + 1; i++) { + uint16_t *pm =3D reginfo_preg(m, vq, i); + uint16_t *pa =3D reginfo_preg(a, vq, i); + + if (!sve_preg_is_eq(vq, pm, pa)) { + if (i =3D=3D SVE_NUM_PREGS) { + fprintf(f, " FFR : "); + } else { + fprintf(f, " P%-2d : ", i); + } + sve_dump_preg_diff(f, vq, pm, pa); + } + } return !ferror(f); } #endif --=20 2.20.1