From patchwork Thu Mar 3 20:59:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 547826 Delivered-To: patch@linaro.org Received: by 2002:ac0:f585:0:0:0:0:0 with SMTP id s5csp985246imq; Thu, 3 Mar 2022 13:13:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWCmwAhE2TSQnm9ge4KawRUEbqZDnDGogMbf+zmsDjl8hj9cI+JBNdo8Ir30ekSaDvpox0 X-Received: by 2002:a81:5791:0:b0:2dc:4a64:56f4 with SMTP id l139-20020a815791000000b002dc4a6456f4mr3245970ywb.286.1646341997122; Thu, 03 Mar 2022 13:13:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646341997; cv=none; d=google.com; s=arc-20160816; b=CDmI28urQQTS7nD8AvIleTw+rEVtS5qLI04S3uvBiH9Do/StPbsoqQi558YZq3WpLZ nGYhxssQZQJmzzATrvfIxvtl9TmY8o270HnMcJSPkhBPYNpnx3LgOJJLqGrdhAihBsoA EZiNCOTjrlPTS3zWUvew6TpEwQFXums3Rm+DmdTzTo7YmyGrEZ04/wj5GNnsYXB7hGqY 04CYF/JF6+z0MHSTR6oYpl/dxzhifEim1BFFeIRWnFUmtOsMa6oXzX5ybuu8X5jMNkBW ybhmZnSi6QsI6Tm/rZNTUvRB2nPlo0mGkFfQi8WM07ak6ynFtRv1gCJU/WATQU8YTulw iiPQ== 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=Q4ztDzPr5E6ml7W6Zmqb62vg4iAy99rspvKuLZXH7gY=; b=IATvxQEkwaqa2llK2tEZ89y0K7BYL16heyOKAgujiaR0K6Btligh5gzXg1olcB04+v hJI60Dbn2ory2iKXvQca2sdNz3/Lw7HKmIbVz6h783MLmU4OW5qB0nWoztjz4Q1SDgtX xN7OjpKWyBHaY6Egc59tfYNnRVpptMkhLXwcvejfGDbR3BRLZdJ4Mhhkr9snPBjkxqvp UbwxnieTujocUhIlsc53z5NFv/8IsjVGn8/P/dxkLu0KEp98KB27zCN4gDIAZznarkhr eKpD/c9kQ7b6XCR0N4pjikS4Si+jJM+jBBvR7+9I7o846wkj34j2SbpSZF/eu5ojmjyY QeVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lXv6R6s9; 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 a2-20020a5b0002000000b006243fbdeb32si2343473ybp.697.2022.03.03.13.13.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Mar 2022 13:13:17 -0800 (PST) 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=lXv6R6s9; 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]:60518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPslA-0004pe-Ir for patch@linaro.org; Thu, 03 Mar 2022 16:13:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPsYJ-0005aB-N9 for qemu-devel@nongnu.org; Thu, 03 Mar 2022 15:59:59 -0500 Received: from [2607:f8b0:4864:20::52e] (port=36454 helo=mail-pg1-x52e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPsYI-00043Z-24 for qemu-devel@nongnu.org; Thu, 03 Mar 2022 15:59:59 -0500 Received: by mail-pg1-x52e.google.com with SMTP id t14so5754676pgr.3 for ; Thu, 03 Mar 2022 12:59:57 -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=Q4ztDzPr5E6ml7W6Zmqb62vg4iAy99rspvKuLZXH7gY=; b=lXv6R6s9FVr3Vzx4dG71l6RYx/ozvMjnKMPBptQXtrY5xpsX4S1ImzIYJCfFNbDuPN SIMyBK8Yrgt/xCQxD+I65/ovIyJBIUt2o7wh0qHeGwGJPAtv2BxkJd3MbtU6uQqW8ADT dQepGFHdrj9tgs82FxwdTQVKy/IhUT5BGqFTnpA5x+ohTl257wy2jF1SFvssicE75fpV HYpVYHC3SPgYbKeAnn0s5FoCh5pdUTdQnhwm2fR7kvFA1RyMJ8igFjg/i6/ZAN8Z+Nqw +42plp7rn+OG4/bYWzF0RVYV1zzGLbJkwlPvQPBjMC3VkJ1Y9G3fNYzYkr7398pF3W68 uesg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q4ztDzPr5E6ml7W6Zmqb62vg4iAy99rspvKuLZXH7gY=; b=4nikkzyXk97zI1iaRh1VOVA5zI7+sMyVJuwBIr1ea5bRFDvCy3xUrqXj1ozXyMgfTZ +0TdAsdPIxUWqEeaDSzRLjEiI6T6WkFrZCVwFxXQFdhGN/7AO/k4cd+3HCm5/2j1xcnh 9wtJHMoeM9uunAazWpy8DFP9xDhlfcj5zomjWkYqkJaRcAPmWgsqmwnYt4bq7cr+NSrv tr1KCCba5FKJmkFCVbLHl5BOo25Wz5yj3fWIkcZUrsJFhZw1xCNBj5kbGJNz2kpjU5bN 8M/bmIj2iQkUxzv+wuZDphUbWW7TDeKnLjq7+PvNbx/diI/QsmwDWHYYTHcB4N7BHvUd ujXQ== X-Gm-Message-State: AOAM532o2anANEVlcanAgs+mng+MNCduZdXbeOafooE7vSKoq3MNlOgO MXZldc13msFMGT75mPC08Z4uAdc8kXsDMA== X-Received: by 2002:a63:be0e:0:b0:363:e0be:613f with SMTP id l14-20020a63be0e000000b00363e0be613fmr31423896pgf.448.1646341196809; Thu, 03 Mar 2022 12:59:56 -0800 (PST) Received: from localhost.localdomain (2603-800c-1201-c600-119c-490c-a4ee-08e8.res6.spectrum.com. [2603:800c:1201:c600:119c:490c:a4ee:8e8]) by smtp.gmail.com with ESMTPSA id t8-20020a6549c8000000b00372eb3a7fb3sm2729934pgs.92.2022.03.03.12.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 12:59:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 06/30] tcg/i386: Detect AVX512 Date: Thu, 3 Mar 2022 10:59:20 -1000 Message-Id: <20220303205944.469445-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303205944.469445-1-richard.henderson@linaro.org> References: <20220303205944.469445-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::52e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There are some operation sizes in some subsets of AVX512 that are missing from previous iterations of AVX. Detect them. Tested-by: Alex Bennée Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/qemu/cpuid.h | 20 +++++++++++++++++--- tcg/i386/tcg-target.h | 4 ++++ tcg/i386/tcg-target.c.inc | 24 ++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/include/qemu/cpuid.h b/include/qemu/cpuid.h index 09fc245b91..7adb12d320 100644 --- a/include/qemu/cpuid.h +++ b/include/qemu/cpuid.h @@ -45,12 +45,26 @@ #ifndef bit_AVX2 #define bit_AVX2 (1 << 5) #endif -#ifndef bit_AVX512F -#define bit_AVX512F (1 << 16) -#endif #ifndef bit_BMI2 #define bit_BMI2 (1 << 8) #endif +#ifndef bit_AVX512F +#define bit_AVX512F (1 << 16) +#endif +#ifndef bit_AVX512DQ +#define bit_AVX512DQ (1 << 17) +#endif +#ifndef bit_AVX512BW +#define bit_AVX512BW (1 << 30) +#endif +#ifndef bit_AVX512VL +#define bit_AVX512VL (1u << 31) +#endif + +/* Leaf 7, %ecx */ +#ifndef bit_AVX512VBMI2 +#define bit_AVX512VBMI2 (1 << 6) +#endif /* Leaf 0x80000001, %ecx */ #ifndef bit_LZCNT diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index ecd0fa6e05..79af353860 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -103,6 +103,10 @@ extern bool have_bmi1; extern bool have_popcnt; extern bool have_avx1; extern bool have_avx2; +extern bool have_avx512bw; +extern bool have_avx512dq; +extern bool have_avx512vbmi2; +extern bool have_avx512vl; extern bool have_movbe; /* optional instructions */ diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index faa15eecab..7516be5d5f 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -171,6 +171,10 @@ bool have_bmi1; bool have_popcnt; bool have_avx1; bool have_avx2; +bool have_avx512bw; +bool have_avx512dq; +bool have_avx512vbmi2; +bool have_avx512vl; bool have_movbe; #ifdef CONFIG_CPUID_H @@ -3839,12 +3843,12 @@ static void tcg_out_nop_fill(tcg_insn_unit *p, int count) static void tcg_target_init(TCGContext *s) { #ifdef CONFIG_CPUID_H - unsigned a, b, c, d, b7 = 0; + unsigned a, b, c, d, b7 = 0, c7 = 0; unsigned max = __get_cpuid_max(0, 0); if (max >= 7) { /* BMI1 is available on AMD Piledriver and Intel Haswell CPUs. */ - __cpuid_count(7, 0, a, b7, c, d); + __cpuid_count(7, 0, a, b7, c7, d); have_bmi1 = (b7 & bit_BMI) != 0; have_bmi2 = (b7 & bit_BMI2) != 0; } @@ -3874,6 +3878,22 @@ static void tcg_target_init(TCGContext *s) if ((xcrl & 6) == 6) { have_avx1 = (c & bit_AVX) != 0; have_avx2 = (b7 & bit_AVX2) != 0; + + /* + * There are interesting instructions in AVX512, so long + * as we have AVX512VL, which indicates support for EVEX + * on sizes smaller than 512 bits. We are required to + * check that OPMASK and all extended ZMM state are enabled + * even if we're not using them -- the insns will fault. + */ + if ((xcrl & 0xe0) == 0xe0 + && (b7 & bit_AVX512F) + && (b7 & bit_AVX512VL)) { + have_avx512vl = true; + have_avx512bw = (b7 & bit_AVX512BW) != 0; + have_avx512dq = (b7 & bit_AVX512DQ) != 0; + have_avx512vbmi2 = (c7 & bit_AVX512VBMI2) != 0; + } } } }