From patchwork Fri May 22 02:34:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187134 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2106785ilb; Thu, 21 May 2020 19:44:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZxqFKCino2uHQvf5BxhAanassvfH6dPy4vwu8lcR05MBko494jw3tjWfa/nyarCh3Js6V X-Received: by 2002:ac8:6118:: with SMTP id a24mr13807716qtm.30.1590115482318; Thu, 21 May 2020 19:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590115482; cv=none; d=google.com; s=arc-20160816; b=Donw1A1X8MmBLmhXmIP4Tuf39MiR+0IHOT530ha1uS5IUF16gQDUj2zayCsULX07bi o63z6bzkrmaE2l5XoHzUimvHQf/kHbtVnikfJX2xKlHWZxJXLU/healNSK+zLrSvNCar Jyy6lOJ1Qy1f4jEiCSHuwGZFk4RiAnecAjWDJA2VMhi9UwIUqwYyZkObX544qSaFSwGp d5ueTlsPxxpa2dEqKuynQons2z8/x/37tNzkuvnDgQ0lSQTgn6PcYXaU9wljH59qVCol dnNANzHqCs9I9kQGNL/wd257XKmV5ktm2p2kVtUCXYlhdKYzzdSwwGeZ2eI053XzoyL+ UQ1g== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=yWhTT6Tler29jJNVR4Zy3JBAxKgKpOlXGq4NgNVQoXk=; b=o5FDYbWZkHaKCqy9EzQf8vhuRnge92qP2vqpYFSfPmL6dgar0VoIfENxLvT+vkJ7f/ FzS/SZv7cJ8rR0roFUG1P6vBKIQCe69mYcee9q6jV928jfXoJMkHD4JL5Xutrp1jgF+i sHqQiwDTEUkjrj+yZg4LF92v1x8UmfgXnKJEr6kZsg7baAoDownKBQRrhPz2m59UL6il iv26LAMe0zwsH2g5i5OKyvhFYKD+CvUt8YsCd+0Dyq3277zKP32ah7YfphHWfgGWWv8b v6NhhkmtwQA32C8ChCvJO7FT3YXgNWCki9ZHktf0EMqD9Q2HK1i9sn5UlzBGvnBE+3RY WXew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jbQNc8jm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i17si10359qtp.102.2020.05.21.19.44.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 May 2020 19:44:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jbQNc8jm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbxft-0008Vz-SB for patch@linaro.org; Thu, 21 May 2020 22:44:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbxWg-00033N-KL for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:10 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:53751) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbxWf-00058i-CG for qemu-devel@nongnu.org; Thu, 21 May 2020 22:35:10 -0400 Received: by mail-pj1-x102c.google.com with SMTP id ci21so4301989pjb.3 for ; Thu, 21 May 2020 19:35:08 -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=yWhTT6Tler29jJNVR4Zy3JBAxKgKpOlXGq4NgNVQoXk=; b=jbQNc8jmS6QsogwRXB6jiRqzwhYNSaoVNMotTMIk4pxg0AowvCR/GNpofFlPtGCkGh LEoC/59q5a2k8KPNdmnH4sQGCAz1ZqxutLuhGO2BWecKWos7Nhiw2yOIdu9UxkXEbK8F RqC1QtFoRzaQJf1KHI/WM7ixkP0zKXp12OYBEjdFyPYTjRjEQcYd3Dlo8X4jeMLyAi9s 3NNBA/vP3QO/FitdSI/VkIAp8Njgn0DHkd2F64Adl1FViF93J7T+pcfnK63ZNWTNhC7y lSgQxJYYvDLjxLTVYuQa2XHOlwKvKTFCWb6NULs6tORLJj9faa5dkrJ9kbv58kXAQV5K F1bw== 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=yWhTT6Tler29jJNVR4Zy3JBAxKgKpOlXGq4NgNVQoXk=; b=pEf+HjaqmGjfnMzjCZkXGhh/QnJT9c9WXKru+C0cHP+vWn2uMT3Q5oQD0IhZeye1tG fLRq23QtM6Acf4do9YSUx6PsNHTEM3rv1acwf0ypHoue2stfN4E4+yEBuldsMpvp2N7R beDvq+IZzQrNYB9XRLUYU5XZZ4CyePS60U9FaKogh7plu6lAB4gUcxW5kbsLZAk2dTwp CPrhsaiS7czuMtuJ9gMALJ/n0ZTCybsLoOg1kO1ikSLcpBZZkrAgpJfYtrj8Nisi41GR ydOmHSCdDB3R5of+gOxbabNvdjEf7Rjf2fnP1A5Z7VN2KsDdxs+67emdLCP7gu5lZLwy I/mg== X-Gm-Message-State: AOAM531ffd0fvJjElrJECf6w73nxV1hrusZ3uHz0g0VX5b8r7AqHTKOi TX3Fp/ae50jYJEkVnrtCtN1fm9Kij90= X-Received: by 2002:a17:90a:17ed:: with SMTP id q100mr1677697pja.80.1590114907295; 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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 19:35:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 20/25] aarch64: Use arch_init to configure sve Date: Thu, 21 May 2020 19:34:35 -0700 Message-Id: <20200522023440.26261-21-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 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Adjust some of the aarch64 code to look at the reginfo struct instead of looking at test_sve, so that we do not need to pass the --test-sve option in order to dump sve trace files. Signed-off-by: Richard Henderson --- risu.h | 1 + risu.c | 3 +++ risu_reginfo_aarch64.c | 55 +++++++++++++++++++++++++++--------------- risu_reginfo_arm.c | 4 +++ risu_reginfo_i386.c | 4 +++ risu_reginfo_m68k.c | 4 +++ risu_reginfo_ppc64.c | 4 +++ 7 files changed, 55 insertions(+), 20 deletions(-) -- 2.20.1 Reviewed-by: Alex Bennée diff --git a/risu.h b/risu.h index 3cad3d5..bdb70c1 100644 --- a/risu.h +++ b/risu.h @@ -23,6 +23,7 @@ extern const struct option * const arch_long_opts; extern const char * const arch_extra_help; void process_arch_opt(int opt, const char *arg); +void arch_init(void); #define FIRST_ARCH_OPT 0x100 /* GCC computed include to pull in the correct risu_reginfo_*.h for diff --git a/risu.c b/risu.c index a70b778..1c096a8 100644 --- a/risu.c +++ b/risu.c @@ -617,6 +617,9 @@ int main(int argc, char **argv) load_image(imgfile); + /* E.g. select requested SVE vector length. */ + arch_init(); + if (ismaster) { return master(); } else { diff --git a/risu_reginfo_aarch64.c b/risu_reginfo_aarch64.c index a1020ac..fb8e11a 100644 --- a/risu_reginfo_aarch64.c +++ b/risu_reginfo_aarch64.c @@ -44,8 +44,6 @@ const char * const arch_extra_help void process_arch_opt(int opt, const char *arg) { #ifdef SVE_MAGIC - long want, got; - assert(opt == FIRST_ARCH_OPT); test_sve = strtol(arg, 0, 10); @@ -53,22 +51,37 @@ void process_arch_opt(int opt, const char *arg) fprintf(stderr, "Invalid value for VQ (1-%d)\n", SVE_VQ_MAX); exit(EXIT_FAILURE); } - want = sve_vl_from_vq(test_sve); - got = prctl(PR_SVE_SET_VL, want); - if (want != got) { - if (got < 0) { - perror("prctl PR_SVE_SET_VL"); - } else { - fprintf(stderr, "Unsupported value for VQ (%d != %d)\n", - test_sve, (int)sve_vq_from_vl(got)); - } - exit(EXIT_FAILURE); - } #else abort(); #endif } +void arch_init(void) +{ +#ifdef SVE_MAGIC + long want, got1, got2; + + if (test_sve == 0) { + return; + } + + want = sve_vl_from_vq(test_sve); + asm(".arch_extension sve\n\trdvl %0, #1" : "=r"(got1)); + if (want != got1) { + got2 = prctl(PR_SVE_SET_VL, want); + if (want != got2) { + if (got2 < 0) { + perror("prctl PR_SVE_SET_VL"); + got2 = got1; + } + fprintf(stderr, "Unsupported value for VQ (%d != %d)\n", + test_sve, (int)sve_vq_from_vl(got1)); + exit(EXIT_FAILURE); + } + } +#endif +} + int reginfo_size(struct reginfo *ri) { #ifdef SVE_MAGIC @@ -170,6 +183,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) if (sve->head.size < SVE_SIG_CONTEXT_SIZE(vq)) { if (sve->head.size == sizeof(*sve)) { /* SVE state is empty -- not an error. */ + goto do_simd; } else { fprintf(stderr, "risu_reginfo_aarch64: " "failed to get complete SVE state\n"); @@ -182,6 +196,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc) SVE_SIG_CONTEXT_SIZE(vq) - SVE_SIG_REGS_OFFSET); return; } + do_simd: #endif /* SVE_MAGIC */ for (i = 0; i < 32; i++) { @@ -260,8 +275,9 @@ int reginfo_dump(struct reginfo *ri, FILE * f) fprintf(f, " fpcr : %08x\n", ri->fpcr); #ifdef SVE_MAGIC - if (test_sve) { - int q, vq = test_sve; + if (ri->sve_vl) { + int vq = sve_vq_from_vl(ri->sve_vl); + int q; fprintf(f, " vl : %d\n", ri->sve_vl); @@ -339,13 +355,12 @@ int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) } #ifdef SVE_MAGIC - if (test_sve) { + if (m->sve_vl != a->sve_vl) { + fprintf(f, " vl : %d vs %d\n", m->sve_vl, a->sve_vl); + } + if (m->sve_vl) { 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++) { uint64_t *zm = reginfo_zreg(m, vq, i); uint64_t *za = reginfo_zreg(a, vq, i); diff --git a/risu_reginfo_arm.c b/risu_reginfo_arm.c index 47c52e8..202120b 100644 --- a/risu_reginfo_arm.c +++ b/risu_reginfo_arm.c @@ -36,6 +36,10 @@ void process_arch_opt(int opt, const char *arg) abort(); } +void arch_init(void) +{ +} + int reginfo_size(struct reginfo *ri) { return sizeof(*ri); diff --git a/risu_reginfo_i386.c b/risu_reginfo_i386.c index 50505ab..e9730be 100644 --- a/risu_reginfo_i386.c +++ b/risu_reginfo_i386.c @@ -74,6 +74,10 @@ void process_arch_opt(int opt, const char *arg) } } +void arch_init(void) +{ +} + int reginfo_size(struct reginfo *ri) { return sizeof(*ri); diff --git a/risu_reginfo_m68k.c b/risu_reginfo_m68k.c index 4eb30cd..4c25e77 100644 --- a/risu_reginfo_m68k.c +++ b/risu_reginfo_m68k.c @@ -23,6 +23,10 @@ void process_arch_opt(int opt, const char *arg) abort(); } +void arch_init(void) +{ +} + int reginfo_size(struct reginfo *ri) { return sizeof(*ri); diff --git a/risu_reginfo_ppc64.c b/risu_reginfo_ppc64.c index 39e8f1c..c80e387 100644 --- a/risu_reginfo_ppc64.c +++ b/risu_reginfo_ppc64.c @@ -32,6 +32,10 @@ void process_arch_opt(int opt, const char *arg) abort(); } +void arch_init(void) +{ +} + int reginfo_size(struct reginfo *ri) { return sizeof(*ri);