From nobody Fri May 17 07:56:01 2024 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=1694796279; cv=none; d=zohomail.com; s=zohoarc; b=OfA2AqPWLXiqB8QTT1UgDmopfvvfFOxMOxiX6sqVuqGhtNvKbAcjab4Ty6TEu9HaOMaFPoOByyHk/Z8j+xYqZbRVeaOZ/TReQW/BPZM5LCenG/PvzbWfbXJUA7lFjETkwnholdbdrmBNIufDPLoJIglph/WRnd5WQhO85O5P+FE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796279; 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=b1NLv1NBVG2fZ70ohDbUJX8NkURlg/p6IknSOTaveXw=; b=nY8lL5EnHAR60vihHfISBp9dIsx1TG51odL0A5yT6Wb4ZUOpdLdf1QmJqaiHDKMUQPZmSOVyx8cjMe40KdRGxni5DLyamjXc66nHgpWbs+ky0dSCZpE16tvQ+BwAzsT8DHlSQJhyPgqSy33PpLAD59Y4Cwgd0r1P24aNhXUO0pU= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796279351343.89094450301195; Fri, 15 Sep 2023 09:44:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBtu-0004QY-6y; Fri, 15 Sep 2023 12:42:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBts-0004Kf-OG for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:36 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBtr-0004sq-4E for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:36 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-68fe39555a0so2117534b3a.3 for ; Fri, 15 Sep 2023 09:42:34 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796153; x=1695400953; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b1NLv1NBVG2fZ70ohDbUJX8NkURlg/p6IknSOTaveXw=; b=T6oMtT9WVYjCicF1ZWc7TNMa6Yn3ik7rnBAsqvlZmPoG7EQKquju2V1NjQdkPvHLws y7wgx5tWN/4J67jjrjYrdDwCXMR03jLNMtzQDQsKlyNz/E5c41ZhdWdrY8uEhEVUr1Iz QZUqJQ+LdEQ3R0BeiNVz0bj9p4Cu/8Voq5WOfskeyZvtJKU4QAJxchTEZH7r6H5PIhbR rCmWfVxWpabXbR+mAzqPq3d/IPK14lPwfWaX9Y9YmQNtedS0HmKM4+OKwvhT2rT10Sva LhpN+hMp3mCl9/+nfeG8RzCPvmPNCwztNN4Bko39Li6K5nW9wN7ozM8AYkPYkaFMQHcT yV0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796153; x=1695400953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b1NLv1NBVG2fZ70ohDbUJX8NkURlg/p6IknSOTaveXw=; b=YfUgnAoK3SZgBk1H6kg3GRkB5LnuoRjykoZbb6nMpnuub2KPzGC9KmSB++uV1Z6udA uaOBQ//jhYsrf/d+yggLPBbYQ9GAixZG5GAB7O6fut1l7ERlccsreZyIWmbgg7sJML4D oHTrpvglXfHY1dI1qAheYlh35oAch9ES1k1ghFPxcWm/G0Sqeo6GfW0zO9DtNTsYwGi5 bMQG0w/9YfC+0yACPLyT/uwG5Dqx2zFApJRuh+oYDgdEDqa0yb8LqfgglwG2Vvw+twO/ dqI15boNiuYyq4i3Q7t4qi00BYuA4s4BxJFCMMDqePAWX3kLdcuLPchW29eO9PDTt+fr GJbA== X-Gm-Message-State: AOJu0YzYB8Dk1q5NXfaFVBHZC7kZpwzEMikayCUuJbXzyERxwro5YwIQ QQdk04x9e2z6IrYqku/dsFI9O54UhYFPLJVhEzI= X-Google-Smtp-Source: AGHT+IE6OenehM6n0Mr2sksr74NaeTtKfpDKQPgcpn2z1PjSrC+FuU4I+EPRRyAK8ACrALpPyxrEhA== X-Received: by 2002:a05:6a00:1996:b0:68f:dfea:9100 with SMTP id d22-20020a056a00199600b0068fdfea9100mr2451745pfl.21.1694796153619; Fri, 15 Sep 2023 09:42:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ard Biesheuvel Subject: [PULL 01/19] crypto: Add generic 8-bit carry-less multiply routines Date: Fri, 15 Sep 2023 09:42:13 -0700 Message-Id: <20230915164231.123580-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796281181100010 Content-Type: text/plain; charset="utf-8" Reviewed-by: Ard Biesheuvel Signed-off-by: Richard Henderson --- include/crypto/clmul.h | 41 +++++++++++++++++++++++++++++ crypto/clmul.c | 60 ++++++++++++++++++++++++++++++++++++++++++ crypto/meson.build | 9 ++++--- 3 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 include/crypto/clmul.h create mode 100644 crypto/clmul.c diff --git a/include/crypto/clmul.h b/include/crypto/clmul.h new file mode 100644 index 0000000000..153b5e3057 --- /dev/null +++ b/include/crypto/clmul.h @@ -0,0 +1,41 @@ +/* + * Carry-less multiply operations. + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (C) 2023 Linaro, Ltd. + */ + +#ifndef CRYPTO_CLMUL_H +#define CRYPTO_CLMUL_H + +/** + * clmul_8x8_low: + * + * Perform eight 8x8->8 carry-less multiplies. + */ +uint64_t clmul_8x8_low(uint64_t, uint64_t); + +/** + * clmul_8x4_even: + * + * Perform four 8x8->16 carry-less multiplies. + * The odd bytes of the inputs are ignored. + */ +uint64_t clmul_8x4_even(uint64_t, uint64_t); + +/** + * clmul_8x4_odd: + * + * Perform four 8x8->16 carry-less multiplies. + * The even bytes of the inputs are ignored. + */ +uint64_t clmul_8x4_odd(uint64_t, uint64_t); + +/** + * clmul_8x4_packed: + * + * Perform four 8x8->16 carry-less multiplies. + */ +uint64_t clmul_8x4_packed(uint32_t, uint32_t); + +#endif /* CRYPTO_CLMUL_H */ diff --git a/crypto/clmul.c b/crypto/clmul.c new file mode 100644 index 0000000000..82d873fee5 --- /dev/null +++ b/crypto/clmul.c @@ -0,0 +1,60 @@ +/* + * Carry-less multiply operations. + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (C) 2023 Linaro, Ltd. + */ + +#include "qemu/osdep.h" +#include "crypto/clmul.h" + +uint64_t clmul_8x8_low(uint64_t n, uint64_t m) +{ + uint64_t r =3D 0; + + for (int i =3D 0; i < 8; ++i) { + uint64_t mask =3D (n & 0x0101010101010101ull) * 0xff; + r ^=3D m & mask; + m =3D (m << 1) & 0xfefefefefefefefeull; + n >>=3D 1; + } + return r; +} + +static uint64_t clmul_8x4_even_int(uint64_t n, uint64_t m) +{ + uint64_t r =3D 0; + + for (int i =3D 0; i < 8; ++i) { + uint64_t mask =3D (n & 0x0001000100010001ull) * 0xffff; + r ^=3D m & mask; + n >>=3D 1; + m <<=3D 1; + } + return r; +} + +uint64_t clmul_8x4_even(uint64_t n, uint64_t m) +{ + n &=3D 0x00ff00ff00ff00ffull; + m &=3D 0x00ff00ff00ff00ffull; + return clmul_8x4_even_int(n, m); +} + +uint64_t clmul_8x4_odd(uint64_t n, uint64_t m) +{ + return clmul_8x4_even(n >> 8, m >> 8); +} + +static uint64_t unpack_8_to_16(uint64_t x) +{ + return (x & 0x000000ff) + | ((x & 0x0000ff00) << 8) + | ((x & 0x00ff0000) << 16) + | ((x & 0xff000000) << 24); +} + +uint64_t clmul_8x4_packed(uint32_t n, uint32_t m) +{ + return clmul_8x4_even_int(unpack_8_to_16(n), unpack_8_to_16(m)); +} diff --git a/crypto/meson.build b/crypto/meson.build index 5f03a30d34..9ac1a89802 100644 --- a/crypto/meson.build +++ b/crypto/meson.build @@ -48,9 +48,12 @@ if have_afalg endif crypto_ss.add(when: gnutls, if_true: files('tls-cipher-suites.c')) =20 -util_ss.add(files('sm4.c')) -util_ss.add(files('aes.c')) -util_ss.add(files('init.c')) +util_ss.add(files( + 'aes.c', + 'clmul.c', + 'init.c', + 'sm4.c', +)) if gnutls.found() util_ss.add(gnutls) endif --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796301; cv=none; d=zohomail.com; s=zohoarc; b=nS/86bSe2PjWWHhoH66/c7nSXb1TyZk/hHUSCPzLF3PwnM2kjexBzhMiRzNizTG+y9ZyvxGy2Z8tCK5NJTLCDkoUpyo858z8AWFfTrKfXQsvmpkKaRyMiMxzyTOqICUNoNphFtHtKUviqIWQxT3VZqj6okUnqFGi3rl+3zOWakI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796301; h=Content-Type: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=0e/zp7VtlxeASFRSSj/wbgTxg8eFq50bfESp96aa+Vg=; b=Q/RiVjZdyr1wKQUtzhZuPJXPPMF3XIRoNpdWRP/oWAiqpdy4K04UaQpKiQMS+YxsZuAc0FUkM4WUX5bM6xWhRbpCfb646mKgDjCUK70GFwpxEnY2ZUHsdVlpIKkFOxYR40Exgf51s3FUTjI2X+bSIiUUPnyI5zTiKndvrTwU+7w= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796301354826.0257090362966; Fri, 15 Sep 2023 09:45:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBtu-0004Qh-Os; Fri, 15 Sep 2023 12:42:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBtt-0004QN-NE for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:37 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBtr-0004sy-OT for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:37 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-68c576d35feso2118524b3a.2 for ; Fri, 15 Sep 2023 09:42:35 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796154; x=1695400954; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0e/zp7VtlxeASFRSSj/wbgTxg8eFq50bfESp96aa+Vg=; b=nznHy4yvS/+/CVlcHBCQyb5mr6F0ku8JnasA+UUo98x21HSqg/W9jsZCh7MEE7PHp8 NyN9Izgff7ny0iE3gJGTSgGR68+IAjZqSkZfImol8nGFwn/GjxixUiMMBwtU5/8jNfmp rTbmS1wYDc60FjPpztvM7wVlqa1z++3sOOGHIBWn0DrernO2u184UImwPCL8EuygJ0zC t8PipW7pI4g6zGb+EV376hDXM+sfPrcBS/9o+9zc2o0pKtX1q8azMEa0aBqAjkmS5YwZ 2KGSZcqunA77sYH7QcK31e4xaFzmZBcO4MgBEaqDbKV6Bbg1TiLSitkgRist93GIHr9/ pPIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796154; x=1695400954; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0e/zp7VtlxeASFRSSj/wbgTxg8eFq50bfESp96aa+Vg=; b=EMYzSdUBlojTW+ku7h+SX69qpSpQP+gE95BIeRYW8YhY+oAR/dkgL5RrGyUeR1BU04 simEcJvdbvD+CQFsiCfdGxiV4V5bGCAsyNcBwT7naURx0jhspyiwPXfYSXin3lS2xqOq wwodlatR5p67sBSDyZypiVVxnrj2OSimbuZoam2UVBbtS7aV+5qGj9NUIW6QI8RvAtbi fzYjwoXanett+tYHRq0y9flZu6ZD23Qbk7/JHVf6mpA0lMKdkZM01crGIwNFshnqOFjg niuNgRGd6/loyXd8vPsTmwhzG/MWP9/2RnNL2/pR5rvz3coKlTwUDUjkueXWP9UKD8uM IXdA== X-Gm-Message-State: AOJu0YxbN3H5axlxfXDCcRHZQ19eInBZ///XyWVtVT+HQiGiG269z6lN u4hIBK1AtdgFI9DfJJkDwfwky2+F7rX6KxSK1l0= X-Google-Smtp-Source: AGHT+IHdxJvFou9raWMLJEcPFd50ZHXagAQ8oABVWgR5VArRaMi7bx12D+hFdWB/oljq+dw//ErzZw== X-Received: by 2002:a05:6a21:2720:b0:157:609f:6012 with SMTP id rm32-20020a056a21272000b00157609f6012mr2153268pzb.61.1694796154461; Fri, 15 Sep 2023 09:42:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 02/19] target/arm: Use clmul_8* routines Date: Fri, 15 Sep 2023 09:42:14 -0700 Message-Id: <20230915164231.123580-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796301681100001 Use generic routines for 8-bit carry-less multiply. Remove our local version of pmull_h. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/arm/tcg/vec_internal.h | 5 ---- target/arm/tcg/mve_helper.c | 8 ++---- target/arm/tcg/vec_helper.c | 53 ++++------------------------------- 3 files changed, 9 insertions(+), 57 deletions(-) diff --git a/target/arm/tcg/vec_internal.h b/target/arm/tcg/vec_internal.h index 1f4ed80ff7..c4afba6d9f 100644 --- a/target/arm/tcg/vec_internal.h +++ b/target/arm/tcg/vec_internal.h @@ -219,11 +219,6 @@ int16_t do_sqrdmlah_h(int16_t, int16_t, int16_t, bool,= bool, uint32_t *); int32_t do_sqrdmlah_s(int32_t, int32_t, int32_t, bool, bool, uint32_t *); int64_t do_sqrdmlah_d(int64_t, int64_t, int64_t, bool, bool); =20 -/* - * 8 x 8 -> 16 vector polynomial multiply where the inputs are - * in the low 8 bits of each 16-bit element -*/ -uint64_t pmull_h(uint64_t op1, uint64_t op2); /* * 16 x 16 -> 32 vector polynomial multiply where the inputs are * in the low 16 bits of each 32-bit element diff --git a/target/arm/tcg/mve_helper.c b/target/arm/tcg/mve_helper.c index 403b345ea3..96ddfb4b3a 100644 --- a/target/arm/tcg/mve_helper.c +++ b/target/arm/tcg/mve_helper.c @@ -26,6 +26,7 @@ #include "exec/exec-all.h" #include "tcg/tcg.h" #include "fpu/softfloat.h" +#include "crypto/clmul.h" =20 static uint16_t mve_eci_mask(CPUARMState *env) { @@ -984,15 +985,12 @@ DO_2OP_L(vmulltuw, 1, 4, uint32_t, 8, uint64_t, DO_MU= L) * Polynomial multiply. We can always do this generating 64 bits * of the result at a time, so we don't need to use DO_2OP_L. */ -#define VMULLPH_MASK 0x00ff00ff00ff00ffULL #define VMULLPW_MASK 0x0000ffff0000ffffULL -#define DO_VMULLPBH(N, M) pmull_h((N) & VMULLPH_MASK, (M) & VMULLPH_MASK) -#define DO_VMULLPTH(N, M) DO_VMULLPBH((N) >> 8, (M) >> 8) #define DO_VMULLPBW(N, M) pmull_w((N) & VMULLPW_MASK, (M) & VMULLPW_MASK) #define DO_VMULLPTW(N, M) DO_VMULLPBW((N) >> 16, (M) >> 16) =20 -DO_2OP(vmullpbh, 8, uint64_t, DO_VMULLPBH) -DO_2OP(vmullpth, 8, uint64_t, DO_VMULLPTH) +DO_2OP(vmullpbh, 8, uint64_t, clmul_8x4_even) +DO_2OP(vmullpth, 8, uint64_t, clmul_8x4_odd) DO_2OP(vmullpbw, 8, uint64_t, DO_VMULLPBW) DO_2OP(vmullptw, 8, uint64_t, DO_VMULLPTW) =20 diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c index 6712a2c790..cd630ff905 100644 --- a/target/arm/tcg/vec_helper.c +++ b/target/arm/tcg/vec_helper.c @@ -23,6 +23,7 @@ #include "tcg/tcg-gvec-desc.h" #include "fpu/softfloat.h" #include "qemu/int128.h" +#include "crypto/clmul.h" #include "vec_internal.h" =20 /* @@ -1986,21 +1987,11 @@ void HELPER(gvec_ushl_h)(void *vd, void *vn, void *= vm, uint32_t desc) */ void HELPER(gvec_pmul_b)(void *vd, void *vn, void *vm, uint32_t desc) { - intptr_t i, j, opr_sz =3D simd_oprsz(desc); + intptr_t i, opr_sz =3D simd_oprsz(desc); uint64_t *d =3D vd, *n =3D vn, *m =3D vm; =20 for (i =3D 0; i < opr_sz / 8; ++i) { - uint64_t nn =3D n[i]; - uint64_t mm =3D m[i]; - uint64_t rr =3D 0; - - for (j =3D 0; j < 8; ++j) { - uint64_t mask =3D (nn & 0x0101010101010101ull) * 0xff; - rr ^=3D mm & mask; - mm =3D (mm << 1) & 0xfefefefefefefefeull; - nn >>=3D 1; - } - d[i] =3D rr; + d[i] =3D clmul_8x8_low(n[i], m[i]); } clear_tail(d, opr_sz, simd_maxsz(desc)); } @@ -2038,22 +2029,6 @@ void HELPER(gvec_pmull_q)(void *vd, void *vn, void *= vm, uint32_t desc) clear_tail(d, opr_sz, simd_maxsz(desc)); } =20 -/* - * 8x8->16 polynomial multiply. - * - * The byte inputs are expanded to (or extracted from) half-words. - * Note that neon and sve2 get the inputs from different positions. - * This allows 4 bytes to be processed in parallel with uint64_t. - */ - -static uint64_t expand_byte_to_half(uint64_t x) -{ - return (x & 0x000000ff) - | ((x & 0x0000ff00) << 8) - | ((x & 0x00ff0000) << 16) - | ((x & 0xff000000) << 24); -} - uint64_t pmull_w(uint64_t op1, uint64_t op2) { uint64_t result =3D 0; @@ -2067,29 +2042,16 @@ uint64_t pmull_w(uint64_t op1, uint64_t op2) return result; } =20 -uint64_t pmull_h(uint64_t op1, uint64_t op2) -{ - uint64_t result =3D 0; - int i; - for (i =3D 0; i < 8; ++i) { - uint64_t mask =3D (op1 & 0x0001000100010001ull) * 0xffff; - result ^=3D op2 & mask; - op1 >>=3D 1; - op2 <<=3D 1; - } - return result; -} - void HELPER(neon_pmull_h)(void *vd, void *vn, void *vm, uint32_t desc) { int hi =3D simd_data(desc); uint64_t *d =3D vd, *n =3D vn, *m =3D vm; uint64_t nn =3D n[hi], mm =3D m[hi]; =20 - d[0] =3D pmull_h(expand_byte_to_half(nn), expand_byte_to_half(mm)); + d[0] =3D clmul_8x4_packed(nn, mm); nn >>=3D 32; mm >>=3D 32; - d[1] =3D pmull_h(expand_byte_to_half(nn), expand_byte_to_half(mm)); + d[1] =3D clmul_8x4_packed(nn, mm); =20 clear_tail(d, 16, simd_maxsz(desc)); } @@ -2102,10 +2064,7 @@ void HELPER(sve2_pmull_h)(void *vd, void *vn, void *= vm, uint32_t desc) uint64_t *d =3D vd, *n =3D vn, *m =3D vm; =20 for (i =3D 0; i < opr_sz / 8; ++i) { - uint64_t nn =3D (n[i] >> shift) & 0x00ff00ff00ff00ffull; - uint64_t mm =3D (m[i] >> shift) & 0x00ff00ff00ff00ffull; - - d[i] =3D pmull_h(nn, mm); + d[i] =3D clmul_8x4_even(n[i] >> shift, m[i] >> shift); } } =20 --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796309; cv=none; d=zohomail.com; s=zohoarc; b=eeojKIiuWQN967CrKPHDM1Vl+7yIeT9xKIZ2Q/XXbWKpA28OQ+Y/KIDzVCjRQ9vkbSuHwXFKga4BdSeG26adfgW2rOB3384XiL5nnt+OhYgQTtHKf8TTA4k9gvgUNaG3YdYS2A5xlDKGmtU21kSgFAsxYMvnRmsaaurwFqSGEq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796309; h=Content-Type: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=q1HqpqG1SCyo6N98nxssbdjX05tzqj9OxhfNx1abB4M=; b=Z4DDubAm3PvDzGuy4lDLG/iCs5lGJF+JiOqm2siSX1Tay88nCqApYv1R0MsFy5V+xu0yK9aOvOAkkmS0CG/bGcyzveFraVFjGacikSBGU/PGtkZXR6w/gcQLqu8cPaWFPudFeDmcgh87+OnIX704MO8wDtekGBjSJdILhfcx3D4= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796309550648.0986188417787; Fri, 15 Sep 2023 09:45:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBtv-0004Rb-Va; Fri, 15 Sep 2023 12:42:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBtu-0004QZ-6p for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:38 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBts-0004t4-KD for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:37 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-68fb2e9ebcdso1944656b3a.2 for ; Fri, 15 Sep 2023 09:42:36 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796155; x=1695400955; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q1HqpqG1SCyo6N98nxssbdjX05tzqj9OxhfNx1abB4M=; b=ZRkTKckmQP4GfMt7g1ytDalJALVslhW/D0RWtSEo92CRpLuuL1T0ginyFTDaeDm7AT GTetWbC6pWl0p7xFPvCnnfTia73g9DNvXzwkfsXtlLU+bOxbJk60dAMY8Aozl0b9+KuI AJ0gJegSjZPnHpzV28HGHxWcELqSJwBqW3q6+eNVQsLDw3ro7ev0oZ6ZcW7OHimVa4d7 GnceHVWYn+FRji96PrbjdF7JS6iivlZ21dmHzQ5cM2+jDryfV9y6oKGqXE41ffAdZJI1 W2UJqrV/3PTpODVFFd6Sx1R7zHkiQFrAKTFzuQmbvt4yh5/FMF32n+vVJ/IAjejwrI1q 1b2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796155; x=1695400955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q1HqpqG1SCyo6N98nxssbdjX05tzqj9OxhfNx1abB4M=; b=THwjpuVFhCu7ILURIDXUv1Jr5sRGU7q8TxdqPKX7yqREFwcS6533o1WhtX5IkohRg0 xn0IqahycIku76PBmkknc0WiTOSo9U8PUmirOmZWVhnnPNdfBK2YaoRHeYpEICYvOFNV 5uxP+MZiGioTr3BLLEbEBEDfid6Cai107/cskwU9VGN0rNENOJQbhaha98lQ6T0gCsqq B7cfmkxRb3SE6PM6aTyIrdkKFjNwDT7pHC0ybgJoanI4Ejmm25lZXqhLrBDKKhpxZACr jN0dQFhVKxVbEx1KioKDUBQZe+U/zKKlGrSsekaLgcjlHTl6FZ2iccl/hrwgr1TMMaDI X8eQ== X-Gm-Message-State: AOJu0Yw2dyS0CamPz8MxiBEABMRgSA82SYETMfc5I99kgTx1/UAeasZj l7Ekt5k6RmEIxtsDgzpbY736JGNnxdzomKh9vmE= X-Google-Smtp-Source: AGHT+IG8W48SftxAwF1XWNJqLqS4l+mZccs5X3qNWRJZbWkdeB1r7PDLnd3P9LbBZSUlgDeLFCAx2Q== X-Received: by 2002:a05:6a20:12c4:b0:159:b45e:1c7d with SMTP id v4-20020a056a2012c400b00159b45e1c7dmr2651096pzg.15.1694796155282; Fri, 15 Sep 2023 09:42:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 03/19] target/s390x: Use clmul_8* routines Date: Fri, 15 Sep 2023 09:42:15 -0700 Message-Id: <20230915164231.123580-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796310868100003 Use generic routines for 8-bit carry-less multiply. Remove our local version of galois_multiply8. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/s390x/tcg/vec_int_helper.c | 32 ++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/target/s390x/tcg/vec_int_helper.c b/target/s390x/tcg/vec_int_h= elper.c index 53ab5c5eb3..edff4d6b2b 100644 --- a/target/s390x/tcg/vec_int_helper.c +++ b/target/s390x/tcg/vec_int_helper.c @@ -14,6 +14,7 @@ #include "vec.h" #include "exec/helper-proto.h" #include "tcg/tcg-gvec-desc.h" +#include "crypto/clmul.h" =20 static bool s390_vec_is_zero(const S390Vector *v) { @@ -179,7 +180,6 @@ static uint##TBITS##_t galois_multiply##BITS(uint##TBIT= S##_t a, \ } = \ return res; = \ } -DEF_GALOIS_MULTIPLY(8, 16) DEF_GALOIS_MULTIPLY(16, 32) DEF_GALOIS_MULTIPLY(32, 64) =20 @@ -203,6 +203,34 @@ static S390Vector galois_multiply64(uint64_t a, uint64= _t b) return res; } =20 +/* + * There is no carry across the two doublewords, so their order does + * not matter. Nor is there partial overlap between registers. + */ +static inline uint64_t do_gfma8(uint64_t n, uint64_t m, uint64_t a) +{ + return clmul_8x4_even(n, m) ^ clmul_8x4_odd(n, m) ^ a; +} + +void HELPER(gvec_vgfm8)(void *v1, const void *v2, const void *v3, uint32_t= d) +{ + uint64_t *q1 =3D v1; + const uint64_t *q2 =3D v2, *q3 =3D v3; + + q1[0] =3D do_gfma8(q2[0], q3[0], 0); + q1[1] =3D do_gfma8(q2[1], q3[1], 0); +} + +void HELPER(gvec_vgfma8)(void *v1, const void *v2, const void *v3, + const void *v4, uint32_t desc) +{ + uint64_t *q1 =3D v1; + const uint64_t *q2 =3D v2, *q3 =3D v3, *q4 =3D v4; + + q1[0] =3D do_gfma8(q2[0], q3[0], q4[0]); + q1[1] =3D do_gfma8(q2[1], q3[1], q4[1]); +} + #define DEF_VGFM(BITS, TBITS) = \ void HELPER(gvec_vgfm##BITS)(void *v1, const void *v2, const void *v3, = \ uint32_t desc) = \ @@ -220,7 +248,6 @@ void HELPER(gvec_vgfm##BITS)(void *v1, const void *v2, = const void *v3, \ s390_vec_write_element##TBITS(v1, i, d); = \ } = \ } -DEF_VGFM(8, 16) DEF_VGFM(16, 32) DEF_VGFM(32, 64) =20 @@ -257,7 +284,6 @@ void HELPER(gvec_vgfma##BITS)(void *v1, const void *v2,= const void *v3, \ s390_vec_write_element##TBITS(v1, i, d); = \ } = \ } -DEF_VGFMA(8, 16) DEF_VGFMA(16, 32) DEF_VGFMA(32, 64) =20 --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796279; cv=none; d=zohomail.com; s=zohoarc; b=f1/kWQvpfmhcnUk+Udy8bKoQ+6quiDaSdl4m+VuMVys1NhYx4nxKguVp2PnLZamSfC1C+T+55IBsgXTzWOce6wb5w4zkYj7NeeCiMJRTu6yCJnHz3ZmGnIavYNKIGLcUp2OtHDXVMUWYO9axIxd6jQflwyF/ZWacOs+PSkkFZNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796279; h=Content-Transfer-Encoding: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=lrofiEdqgOl3RcwS/CbqZ7l9hqJEkeBbwbYNYeWuQXE=; b=HlMPqbc+hG5OP/wE7oUAkqi7SBIVeBHYFucKhtfTyasRq/mgQTwrkvC4jOAt1pIQKyXWjAWp/iIZ5QRy28RZaXAJ5X66/H4YHqTXY3gfwGOdTk7y167XIJu/3y6PdBgbsiee4338+RXGUooqgmSp9Chgo3WpisE2vA+FH/YAkKY= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796279058294.5091739429888; Fri, 15 Sep 2023 09:44:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBtw-0004Rn-HF; Fri, 15 Sep 2023 12:42:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBtv-0004Qq-1t for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:39 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBtt-0004tN-Dc for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:38 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-68fdd6011f2so1946257b3a.3 for ; Fri, 15 Sep 2023 09:42:37 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796156; x=1695400956; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=lrofiEdqgOl3RcwS/CbqZ7l9hqJEkeBbwbYNYeWuQXE=; b=lGpy69nPnY5EoWwgYozfK5+UWIz9Uv4PFm4haZPNsMMa4Gcv5/igRGOTSHZ20hEnnT NgjL/JRyc9n7HRZvVDq8++Tj0hupX1WK2OF81JIeaEr1J1wR5mwvzIlLyCewQI5glnlZ oPZlZo6dBpxvPf9ax/OlWy4W5HlpkfMEW4GgkUBRuWp9OgIffGtOoARyAuOEDpeFV3Bl 94hiAqBFI0gaEpD14CmEyqTvVwF0OqeFfqYM2kDm9asOXWV3NGtwBGXOVhR1UQm754ki MfCH1zIWohV52woEHKw2vWzV5kNn0Q5Atcnp4DfNFpaPJ2+A8iK75s5Vt4tmdYuXAQyv h5Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796156; x=1695400956; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lrofiEdqgOl3RcwS/CbqZ7l9hqJEkeBbwbYNYeWuQXE=; b=Fk+XyPMl1OylBQivnQ/CKJTAEAjB/VldYv8QTmS/K/6QYQDjG7HlXRzIoAOLg8h4hq IuOVBbkxa9tUb5F+bjBv7CZStJ/e+7QNjBCvndcybWa6p38XZcdBCm4PN5r7ZcH9Yv99 c7Tv8X9b5vsDOFUiy1yR1aRJKKOKCpWmwz4IJO0IGFgTW7gkcoLEpKZXZeCjU8mFeIHc XrJ5/mrKmP86rBqlySzfWeM9rVs3EsoCzzKBgkEtUEP26VJaf/rpoY0T7fSdPuKaEFHK P89W1tvWNdGwIAIRp5t0u8KTAx0tb29cggtfLjkV5KddOCCzREuw/eviVmvqKLYGeiim 2NbQ== X-Gm-Message-State: AOJu0Ywi7lxGrZKiE8noefU7DCVMnJmg/TN807soy83x+Sog1Sa3/De+ Sr/i4wRwiUQHEGlLtO6lzXXL4tQ00ERXmLJGVrI= X-Google-Smtp-Source: AGHT+IHUNtQevYdMMGXxCIStrBDWJDfmlUXiEo1WcMOaJ5deo5pdD77J2QaeAgsoiIG9iEqrDLWBRg== X-Received: by 2002:a05:6a00:23c4:b0:68e:29a6:e247 with SMTP id g4-20020a056a0023c400b0068e29a6e247mr2702662pfc.10.1694796156214; Fri, 15 Sep 2023 09:42:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 04/19] target/ppc: Use clmul_8* routines Date: Fri, 15 Sep 2023 09:42:16 -0700 Message-Id: <20230915164231.123580-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796279888100004 Content-Type: text/plain; charset="utf-8" Use generic routines for 8-bit carry-less multiply. Signed-off-by: Richard Henderson --- target/ppc/int_helper.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 96cdb3c7e3..f45b24d321 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -25,6 +25,7 @@ #include "exec/helper-proto.h" #include "crypto/aes.h" #include "crypto/aes-round.h" +#include "crypto/clmul.h" #include "fpu/softfloat.h" #include "qapi/error.h" #include "qemu/guest-random.h" @@ -1424,6 +1425,18 @@ void helper_vbpermq(ppc_avr_t *r, ppc_avr_t *a, ppc_= avr_t *b) #undef VBPERMQ_INDEX #undef VBPERMQ_DW =20 +/* + * There is no carry across the two doublewords, so their order does + * not matter. Nor is there partial overlap between registers. + */ +void helper_vpmsumb(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) +{ + for (int i =3D 0; i < 2; ++i) { + uint64_t aa =3D a->u64[i], bb =3D b->u64[i]; + r->u64[i] =3D clmul_8x4_even(aa, bb) ^ clmul_8x4_odd(aa, bb); + } +} + #define PMSUM(name, srcfld, trgfld, trgtyp) \ void helper_##name(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \ { \ @@ -1444,7 +1457,6 @@ void helper_##name(ppc_avr_t *r, ppc_avr_t *a, ppc_av= r_t *b) \ } \ } =20 -PMSUM(vpmsumb, u8, u16, uint16_t) PMSUM(vpmsumh, u16, u32, uint32_t) PMSUM(vpmsumw, u32, u64, uint64_t) =20 --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796312; cv=none; d=zohomail.com; s=zohoarc; b=IOULeq5hfBMiqpj9dLgCEEdy39CtqZiS02WxK8WCtsnpysG1y4LuMpe68nTZILMsa+sv7H0zyh6yoAL9fOar1mjL0ILZHZfN0KkrlFBrviVVqDCaL5XKaC++DfZrLZtPJRt90QYRtA9IMrVZ7IYSWFySyCBfS36GtDmdJW7vBYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796312; 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=E2sTDZYIaL3GhBPyCh9S4Dw9cyt088qCUZyaRlZTVTE=; b=eCqh4PMIEz159oVLHLwx+KZLrXrDeKdnoXta8IZ8yr9yJa/+s09/50vJISuHFXvzAiJkX5NYiMSSkE7fXhhouQc0EzC6Arupup3piERF/oblFfKz9Irc4zhFmepapxSrnj3s5BTxytS8lWJLVOG+vGyUjIHK8dN9s4AppymMt/c= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796312566981.8929728999684; Fri, 15 Sep 2023 09:45:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBtx-0004SA-E7; Fri, 15 Sep 2023 12:42:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBtv-0004Rc-VE for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:39 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBtu-0004tY-FB for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:39 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68fb2e9ebbfso1947658b3a.2 for ; Fri, 15 Sep 2023 09:42:37 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796157; x=1695400957; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E2sTDZYIaL3GhBPyCh9S4Dw9cyt088qCUZyaRlZTVTE=; b=wVFzv+ax3s0/d6WnXWsYafhnibMfwMFeWc9A2JqVf5eZhr7osijrOSuch2a2Du/uMt QU9adusygMlJMmMVtItEfbRCyLA8/CsWb7EhUiU0kvezLn/Kqtjw88Lx1wuOcipQ3lGr PeyevTDicKHNTr9z2Rqxe0e/pe6S5KXPuMZmV9ZlHqlu2iTH9n0ur4klP4WKDmgFwYOn OX5V3QAr8ypabKLfoHNy18BQptHpmv7hamxhpw6SjEyhxHvmbyyM/2UXFmMz+7e5ddVC R+s5JpBVUrLBqt6s/FM1ANPy+AKmBbIwetQcFA7RCwBeBmDM6ltsO+FoCPQu3jgIyyFs opKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796157; x=1695400957; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E2sTDZYIaL3GhBPyCh9S4Dw9cyt088qCUZyaRlZTVTE=; b=TPpDVP4pjUxMKMsOFvUSv8amnBRyO5qAdA1/JEGPgfs5giJJUIkVIzFHujDvDiJMQ8 VlZrgCd2nUnVOq7cZ51ODlf2q6tge73jw+e9JlN+WJi7cNEMZynMkAJhRXJFheVu2que cxz+/jwItEaoDg8NevljoCzSk+sCVCNzQQ09UfJqMXQipArQTDQZX7g1LXrnAjbr6wCm 9ytoNaQLBOEtBdtIRAkfdZP16yGvyun+sxF1rr8+TjuPU3VXJRBbG1IzbL9+mDCkti+w xvzUXqagbNInEj9alQ5XPB11ij9GFtLH3Dp/i/D1lQnA9WhXZhEBzEy1ebAcJ7x0Feq5 yJgA== X-Gm-Message-State: AOJu0YyvvLZGFCshYLEB/LGuWC/Gfrk7Sugk8ASSSIs0Fv0XqrPNFgdj KBKxtCtkBg2TybjqsxfSoe4ozI+fg5EOM1Yvk2o= X-Google-Smtp-Source: AGHT+IEw2J9+zcg36cIFEvDRv3I8G69EPMo1dclSBwsW13YuRMIEgqI2Hh5tMsDNASFGzIadUPbsPg== X-Received: by 2002:a05:6a00:1acd:b0:68a:604f:420d with SMTP id f13-20020a056a001acd00b0068a604f420dmr2407297pfv.3.1694796157114; Fri, 15 Sep 2023 09:42:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ard Biesheuvel Subject: [PULL 05/19] crypto: Add generic 16-bit carry-less multiply routines Date: Fri, 15 Sep 2023 09:42:17 -0700 Message-Id: <20230915164231.123580-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-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::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796312999100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Ard Biesheuvel Signed-off-by: Richard Henderson --- include/crypto/clmul.h | 16 ++++++++++++++++ crypto/clmul.c | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/crypto/clmul.h b/include/crypto/clmul.h index 153b5e3057..72672b237c 100644 --- a/include/crypto/clmul.h +++ b/include/crypto/clmul.h @@ -38,4 +38,20 @@ uint64_t clmul_8x4_odd(uint64_t, uint64_t); */ uint64_t clmul_8x4_packed(uint32_t, uint32_t); =20 +/** + * clmul_16x2_even: + * + * Perform two 16x16->32 carry-less multiplies. + * The odd words of the inputs are ignored. + */ +uint64_t clmul_16x2_even(uint64_t, uint64_t); + +/** + * clmul_16x2_odd: + * + * Perform two 16x16->32 carry-less multiplies. + * The even words of the inputs are ignored. + */ +uint64_t clmul_16x2_odd(uint64_t, uint64_t); + #endif /* CRYPTO_CLMUL_H */ diff --git a/crypto/clmul.c b/crypto/clmul.c index 82d873fee5..2c87cfbf8a 100644 --- a/crypto/clmul.c +++ b/crypto/clmul.c @@ -58,3 +58,24 @@ uint64_t clmul_8x4_packed(uint32_t n, uint32_t m) { return clmul_8x4_even_int(unpack_8_to_16(n), unpack_8_to_16(m)); } + +uint64_t clmul_16x2_even(uint64_t n, uint64_t m) +{ + uint64_t r =3D 0; + + n &=3D 0x0000ffff0000ffffull; + m &=3D 0x0000ffff0000ffffull; + + for (int i =3D 0; i < 16; ++i) { + uint64_t mask =3D (n & 0x0000000100000001ull) * 0xffffffffull; + r ^=3D m & mask; + n >>=3D 1; + m <<=3D 1; + } + return r; +} + +uint64_t clmul_16x2_odd(uint64_t n, uint64_t m) +{ + return clmul_16x2_even(n >> 16, m >> 16); +} --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796226; cv=none; d=zohomail.com; s=zohoarc; b=FflwIHgoJ91v9JhXIKTVuLUN0WyuziDVvG3WpOCBWJQ60mlY3GIoQuH0mA/7gdgVYAGn7Ksh0YQsyN0RWlMXKVlxoRJDn1Y3W3GIQbrdXGtek+PdI6jOv/JDTaODo5g/fsOO9tNR2x9nJ90PN+xtw1bBorKYckR9w9z8MSc0Uz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796226; h=Content-Type: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=iPO8TcwjCQpKboJkMUgpUg7QTAvab+8lUqTEXa4XMVA=; b=l2rntkhZnwUYQRmmfWVCBzjUiuM0ZSFjsXo8ElD3pBfMfUO3Z+LC5djsPhRgC4/n8GbNnRYsKQLTCnIqOkvoL7NmQGoPstM51rsvtC0vGwaKHWz+jxBlyz/tdWg4RGxDRST/yifYxhiR4TYmZ/YqN+Zp7u+JqavRtZPTu4WvE2E= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796226434364.55041416717154; Fri, 15 Sep 2023 09:43:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBty-0004Sa-LZ; Fri, 15 Sep 2023 12:42:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBtx-0004S2-5G for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:41 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBtv-0004tu-GM for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:40 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-68fc292de9dso1741831b3a.0 for ; Fri, 15 Sep 2023 09:42:39 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796158; x=1695400958; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iPO8TcwjCQpKboJkMUgpUg7QTAvab+8lUqTEXa4XMVA=; b=uszINTY93z64c5xS2WK0WrEVGE6UGrafjRE03mus10CKe7mu7aE2FtW8qKKwJ8yjhO q+TvB/t9QUEC+DNRZbzW75fgRrtGyQeZCgoi+rn/ebq60HqfEuhz2ty7mNLinxx1Owpy Yr9eSV0LFtazxNtdybn/CzpPuandN51xVres2yVRO16HO6bXmfHEdKosVY20VukuL9+s GA+CUjYLfVU6vn3b4TO5v5sbZNCOcVplDuJaN/M0+/eSPIGixRz3taMekBoTb3DAxUIo lbosHRC1LI5O30G/E6gnrVirAiEBt494ub6MroAoro6hQ5sFX5t05oTW52GW5i1CjgJV fz3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796158; x=1695400958; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iPO8TcwjCQpKboJkMUgpUg7QTAvab+8lUqTEXa4XMVA=; b=W2UtM/gjQV7CRNj4/frA98EDp2hEBtGBR08j+R7FusbMOoyLp2YR9KIkK16Hs2byU9 ZKrWrltdiYVePg/JUetTfEzIdsGGBWW6BvA2ZkL6hz+Mc1Iw0pN1kj+CfMHbnuQpc7Wm nAEj7j6+j7yNpljBgIaYGPT1GFNhdPUVpCp87LQF/UlSoZPCBK+7J0D/Br2DL2kaqQjQ n4tTOZXRwDXKU9Wy7Qj13Ejcwu5zFPXWREIG2+XQ8XijK3vK/5kG1hkRGriC6VVvux8Y A5Jk30Bomlav8Ha7VhP84m29BajZzivSWyKeyfDxIW8gGhkS0fl23ZdR5E/MTeXskSgB w5yg== X-Gm-Message-State: AOJu0YwO7P8U1ApgDsTIHGnX7PszDdMrlp7MfkI6cbjiB55URP7Spc/m YDoiv8+xDDOn3nFZhmW4CN6n/N6ykV+xUXcgz5o= X-Google-Smtp-Source: AGHT+IErj3eEBUGFfIiLM+ImYDXNUSvcsf32VZVCBBM2Ae3hO5sMh3f+iXrI34EBL5H7vbLsoMTftw== X-Received: by 2002:a05:6a00:1f97:b0:68f:cbd3:5b01 with SMTP id bg23-20020a056a001f9700b0068fcbd35b01mr5936723pfb.13.1694796158156; Fri, 15 Sep 2023 09:42:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 06/19] target/arm: Use clmul_16* routines Date: Fri, 15 Sep 2023 09:42:18 -0700 Message-Id: <20230915164231.123580-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796228418100005 Use generic routines for 16-bit carry-less multiply. Remove our local version of pmull_w. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/arm/tcg/vec_internal.h | 6 ------ target/arm/tcg/mve_helper.c | 8 ++------ target/arm/tcg/vec_helper.c | 13 ------------- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/target/arm/tcg/vec_internal.h b/target/arm/tcg/vec_internal.h index c4afba6d9f..3ca1b94ccf 100644 --- a/target/arm/tcg/vec_internal.h +++ b/target/arm/tcg/vec_internal.h @@ -219,12 +219,6 @@ int16_t do_sqrdmlah_h(int16_t, int16_t, int16_t, bool,= bool, uint32_t *); int32_t do_sqrdmlah_s(int32_t, int32_t, int32_t, bool, bool, uint32_t *); int64_t do_sqrdmlah_d(int64_t, int64_t, int64_t, bool, bool); =20 -/* - * 16 x 16 -> 32 vector polynomial multiply where the inputs are - * in the low 16 bits of each 32-bit element - */ -uint64_t pmull_w(uint64_t op1, uint64_t op2); - /** * bfdotadd: * @sum: addend diff --git a/target/arm/tcg/mve_helper.c b/target/arm/tcg/mve_helper.c index 96ddfb4b3a..c666a96ba1 100644 --- a/target/arm/tcg/mve_helper.c +++ b/target/arm/tcg/mve_helper.c @@ -985,14 +985,10 @@ DO_2OP_L(vmulltuw, 1, 4, uint32_t, 8, uint64_t, DO_MU= L) * Polynomial multiply. We can always do this generating 64 bits * of the result at a time, so we don't need to use DO_2OP_L. */ -#define VMULLPW_MASK 0x0000ffff0000ffffULL -#define DO_VMULLPBW(N, M) pmull_w((N) & VMULLPW_MASK, (M) & VMULLPW_MASK) -#define DO_VMULLPTW(N, M) DO_VMULLPBW((N) >> 16, (M) >> 16) - DO_2OP(vmullpbh, 8, uint64_t, clmul_8x4_even) DO_2OP(vmullpth, 8, uint64_t, clmul_8x4_odd) -DO_2OP(vmullpbw, 8, uint64_t, DO_VMULLPBW) -DO_2OP(vmullptw, 8, uint64_t, DO_VMULLPTW) +DO_2OP(vmullpbw, 8, uint64_t, clmul_16x2_even) +DO_2OP(vmullptw, 8, uint64_t, clmul_16x2_odd) =20 /* * Because the computation type is at least twice as large as required, diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c index cd630ff905..5def86b573 100644 --- a/target/arm/tcg/vec_helper.c +++ b/target/arm/tcg/vec_helper.c @@ -2029,19 +2029,6 @@ void HELPER(gvec_pmull_q)(void *vd, void *vn, void *= vm, uint32_t desc) clear_tail(d, opr_sz, simd_maxsz(desc)); } =20 -uint64_t pmull_w(uint64_t op1, uint64_t op2) -{ - uint64_t result =3D 0; - int i; - for (i =3D 0; i < 16; ++i) { - uint64_t mask =3D (op1 & 0x0000000100000001ull) * 0xffffffff; - result ^=3D op2 & mask; - op1 >>=3D 1; - op2 <<=3D 1; - } - return result; -} - void HELPER(neon_pmull_h)(void *vd, void *vn, void *vm, uint32_t desc) { int hi =3D simd_data(desc); --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796288; cv=none; d=zohomail.com; s=zohoarc; b=D+Yk26FHDwebJtEoPgo2R7JW7Ncqi+3esJ44BFCzLqZs8I8XwKHIG2mZ05CjtyMN/CJhVSkpo5RzEvgBftHQ+TfO3sTm26YD5xzuiIWO75imtpomB9mW42Bc0ala/Ooh+fqmwusSLrWUyESHfpQuDCkLMdbD9OHZLtP7CpfKUso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796288; h=Content-Type: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=rjJiUhlPai6mmk7xoBYCGw+/59480gYFwt2JNZw/Qk4=; b=cJ6vikOTlwMFnsr/6DctcCmsnqnILR3yoS3H+Gx50up91Ef0bkNbIyUeI6dgcQCpw2rAK3SLMvAcyxy8ODewq1YmzBUL9hjm4+AJENg9IBFs7JitysRJ/1bqPUTpOQSaquvn/mwjslpLT66+zcwuTOpnL0naPvt2jE3TPB8KzSM= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796288618498.51007932190885; Fri, 15 Sep 2023 09:44:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBu0-0004T4-0s; Fri, 15 Sep 2023 12:42:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBty-0004SS-60 for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:42 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBtw-0004uI-I4 for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:41 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-68fc9e0e22eso1947060b3a.1 for ; Fri, 15 Sep 2023 09:42:40 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796159; x=1695400959; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rjJiUhlPai6mmk7xoBYCGw+/59480gYFwt2JNZw/Qk4=; b=HxRuXjvebGnRljb1E0EEDqebZiVoB76kgKh+dr9ErEL7LP1NabrrgxdkVERZESMjJ1 AnSXj5Xe+OY4PcjUdicca3Di1CKR84D/Vp4WgVu3dWkQI7L1b21GPe7WNPqUaosT+J4I TaiE5tduR1AEFE3u4z437PtqBUdpY5MV5B9hbx2Sj9vtevzgNp093GY7HEOtumOjWeZA b3XdagyFxxQTfiF/rU0qWLTxzGO9PbnBPJFkiMTNUVMj4DyE5j/1gm0sjrzC5q3c1ygN rt5FQcPPYVVxWJalDJPYs5lZQWu89jt886g/ZID7Kk6MWbL+z6YEyOIaFULInBCDo5Yq inug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796159; x=1695400959; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rjJiUhlPai6mmk7xoBYCGw+/59480gYFwt2JNZw/Qk4=; b=hPMJ5DVJrzjXDx7VnoGX9IyApUKnE8r9igkmjt4Y2Ew2oxDpH6TqwJe52uHCb0/7+H oSP067DEEmpTlvDMtiM0JHTXBXoxr/03bUdseJKiJQyokzS6YF9Kn0zEXetAWwLPGQul gHgw+z+8/sWEgsz7wcld30cL0328ZSgqAsRK3E3xWbDqJTyx+LCYop21nbR1UN0G8MZl mGP9fhWxZeCJ6WhK5DZ5JIwoX8DOS1eXPaX4I6MzRXP/JEbcUhHWod39deoTWtIYKvEE vrMkYPC2U29CperXNMhWGkdBM9q1FzUcarZDdr9ohAEpZOrtu+dxm+cX7TnyYSswIIMI D3qA== X-Gm-Message-State: AOJu0YzbvjHbxdikhgxriBhsRdVKPxTCHjpFZWmP3PaJo4PFfYGlIHst c4hFX+A5/9Vzkxv43JFXFr1JYOFZt/l3hBC12rA= X-Google-Smtp-Source: AGHT+IG91HnUwpH3wpVpLldVCKAGfaOKsLz/ccS0w30e5LiNsw3IeEQJeWl7EXFy2sV7erkvrUZqkw== X-Received: by 2002:aa7:88d6:0:b0:68e:4653:2a2b with SMTP id k22-20020aa788d6000000b0068e46532a2bmr2610222pff.24.1694796159188; Fri, 15 Sep 2023 09:42:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 07/19] target/s390x: Use clmul_16* routines Date: Fri, 15 Sep 2023 09:42:19 -0700 Message-Id: <20230915164231.123580-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796289301100001 Use generic routines for 16-bit carry-less multiply. Remove our local version of galois_multiply16. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/s390x/tcg/vec_int_helper.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/target/s390x/tcg/vec_int_helper.c b/target/s390x/tcg/vec_int_h= elper.c index edff4d6b2b..11477556e5 100644 --- a/target/s390x/tcg/vec_int_helper.c +++ b/target/s390x/tcg/vec_int_helper.c @@ -180,7 +180,6 @@ static uint##TBITS##_t galois_multiply##BITS(uint##TBIT= S##_t a, \ } = \ return res; = \ } -DEF_GALOIS_MULTIPLY(16, 32) DEF_GALOIS_MULTIPLY(32, 64) =20 static S390Vector galois_multiply64(uint64_t a, uint64_t b) @@ -231,6 +230,30 @@ void HELPER(gvec_vgfma8)(void *v1, const void *v2, con= st void *v3, q1[1] =3D do_gfma8(q2[1], q3[1], q4[1]); } =20 +static inline uint64_t do_gfma16(uint64_t n, uint64_t m, uint64_t a) +{ + return clmul_16x2_even(n, m) ^ clmul_16x2_odd(n, m) ^ a; +} + +void HELPER(gvec_vgfm16)(void *v1, const void *v2, const void *v3, uint32_= t d) +{ + uint64_t *q1 =3D v1; + const uint64_t *q2 =3D v2, *q3 =3D v3; + + q1[0] =3D do_gfma16(q2[0], q3[0], 0); + q1[1] =3D do_gfma16(q2[1], q3[1], 0); +} + +void HELPER(gvec_vgfma16)(void *v1, const void *v2, const void *v3, + const void *v4, uint32_t d) +{ + uint64_t *q1 =3D v1; + const uint64_t *q2 =3D v2, *q3 =3D v3, *q4 =3D v4; + + q1[0] =3D do_gfma16(q2[0], q3[0], q4[0]); + q1[1] =3D do_gfma16(q2[1], q3[1], q4[1]); +} + #define DEF_VGFM(BITS, TBITS) = \ void HELPER(gvec_vgfm##BITS)(void *v1, const void *v2, const void *v3, = \ uint32_t desc) = \ @@ -248,7 +271,6 @@ void HELPER(gvec_vgfm##BITS)(void *v1, const void *v2, = const void *v3, \ s390_vec_write_element##TBITS(v1, i, d); = \ } = \ } -DEF_VGFM(16, 32) DEF_VGFM(32, 64) =20 void HELPER(gvec_vgfm64)(void *v1, const void *v2, const void *v3, @@ -284,7 +306,6 @@ void HELPER(gvec_vgfma##BITS)(void *v1, const void *v2,= const void *v3, \ s390_vec_write_element##TBITS(v1, i, d); = \ } = \ } -DEF_VGFMA(16, 32) DEF_VGFMA(32, 64) =20 void HELPER(gvec_vgfma64)(void *v1, const void *v2, const void *v3, --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796231; cv=none; d=zohomail.com; s=zohoarc; b=MPIVZ2Qt/9eSN+Lj3EqtnSwxIEh8Jy+yKJgCdsXNK/Eq8LVUjOsPa06QyzKeHWLsBd1P9uzP5dFD4GKlhvxdPlIFAGU4Xj7dcmYtjgtld1F9d9iNodULWvd+PfTK0ohqlLv+LcW5myr/FeG6XNLyXnMz6G1A8BlrgMOPryafmmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796231; h=Content-Transfer-Encoding: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=BL7EbX1EMhValKoX7e6yR5u3D5ZsID7pdC/xAbPtSgQ=; b=Ch+urGedWrZAxq/eaLPd68L3dk+HCPszoNMV6TJ4DjwWALaFuunXvF5vW88/RgHx9KqQyMQERBbQTqrAoaiMPFHTo5EAwcgIiphJNMgcOszX69FUsSQva1rWgFjqGoPBvvioQfaXDzoIuqsseLj+tuMATKZOi7F7xUpVAQrvB7E= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16947962316151014.9218022449709; Fri, 15 Sep 2023 09:43:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBu1-0004Th-5l; Fri, 15 Sep 2023 12:42:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBtz-0004Sp-4y for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:43 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBtx-0004uU-HV for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:42 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-68fb98745c1so1949948b3a.1 for ; Fri, 15 Sep 2023 09:42:41 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796160; x=1695400960; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=BL7EbX1EMhValKoX7e6yR5u3D5ZsID7pdC/xAbPtSgQ=; b=ppPnd8PGjQIdN0/Is0+THxhjil2HH8c6Luk9SIlO6X+eo/q9hoiMhRQsyqbYIhSXnr 6tgmm93JxpdwGpztudvJyGWe+Di24IeveBDGgQMU3j8h03XTS6NhOXCUBTXOgVMb3Shp AEkDTMp68v3z/76SXoXkJ7sxTADFJJJkArrU4LigHLxvG4Ts3Y9GigcjEnYfP+LS+v+f Z5RJzQ1RMKRd7Ov3qp/tH+DlLcFg3Ui75UoTsNVxuz0Wa/Pa1qGGZmRNKETITKxYcf11 5F6HeKrplrXOxdH35LdDYeveFKIU4b6OZOPm6FuxMbXGE1puaVZ6jkkcLsWgrb4CdetC 5yjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796160; x=1695400960; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BL7EbX1EMhValKoX7e6yR5u3D5ZsID7pdC/xAbPtSgQ=; b=P1j3qXuPxCIoEOCkhJfWwYiwvITzK3Zw7hoDOfz00rohLrjHKx7Fv2JPXHQ/fRrqoz ihQByZ3GBQNjO2CKf6arYQDYISBYxleDbcUrZE8zXBUsV98EtU7CN1YpAtxQqRfmhNSg tmOybYEmIA0rRK6Z9O/rqNTQWZe+wLI8GwkJydZJfX/S9E7Xty49jbTlC/bASXwPJF6i zaOfK+H0pKjI2Vum7LPxHamL1pP/e6BS3rLT7JJ1Xg8OwmAS+KzIWPGHRqO4RiIwXu57 nLPXw5R5ITqk3BLxvzOk2jd7qsvh/jXhKavJsG9xVXNRXhtHknIC4xAfMJ2fq8L2K3p8 6wfw== X-Gm-Message-State: AOJu0YzAoIg0ZmKD3DrDaVsuD1TuSlSNGOCVhNMYZzIsFOr3qbV6AkZl 7GMkrNEFu5eGNt53NLMvq48MDbaT/HKBxXmjrl0= X-Google-Smtp-Source: AGHT+IFT/yLy3l+yJ84U1C5r4xFGocbBLm1m+fVG633ioNisZ5fX5VaEI48sSi9U7Vm066EMoEfY2Q== X-Received: by 2002:a05:6a00:1409:b0:68f:cd32:c52d with SMTP id l9-20020a056a00140900b0068fcd32c52dmr2328733pfu.14.1694796160177; Fri, 15 Sep 2023 09:42:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 08/19] target/ppc: Use clmul_16* routines Date: Fri, 15 Sep 2023 09:42:20 -0700 Message-Id: <20230915164231.123580-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-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::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796233233100003 Content-Type: text/plain; charset="utf-8" Use generic routines for 16-bit carry-less multiply. Signed-off-by: Richard Henderson --- target/ppc/int_helper.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index f45b24d321..ebb2957fe7 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -1437,6 +1437,14 @@ void helper_vpmsumb(ppc_avr_t *r, ppc_avr_t *a, ppc_= avr_t *b) } } =20 +void helper_vpmsumh(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) +{ + for (int i =3D 0; i < 2; ++i) { + uint64_t aa =3D a->u64[i], bb =3D b->u64[i]; + r->u64[i] =3D clmul_16x2_even(aa, bb) ^ clmul_16x2_odd(aa, bb); + } +} + #define PMSUM(name, srcfld, trgfld, trgtyp) \ void helper_##name(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \ { \ @@ -1457,7 +1465,6 @@ void helper_##name(ppc_avr_t *r, ppc_avr_t *a, ppc_av= r_t *b) \ } \ } =20 -PMSUM(vpmsumh, u16, u32, uint32_t) PMSUM(vpmsumw, u32, u64, uint64_t) =20 void helper_VPMSUMD(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796209; cv=none; d=zohomail.com; s=zohoarc; b=QK/f0B9Yvgn0fufA7zmunAgK3AwUFam663YKwz2iJHtImHPyBSi3R6wfBznDEwLUyy7fc2StsptX77INbcMhQBBHRcz2v5XumpvxZ+Dy63MCNgeY4jOgLz0xomCzhFN2So8pEfq60dOVvxo6nWR4G2n2waowDS/tSwpFHlL7mhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796209; 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=5E1DttN1y2odVDPPAQFBLbvH/8uGREEL7i929ZC+pCE=; b=iQRcgkybcvYyhlYwoQp9L3v+LVITLaKFT/DnUAx8jWmL/Xg2wAdMI3MIPzFf193H+hmU0dJC/mfjBccZtySLPXwMatW72CuVqLGU1+CCKskSKZ23KGOb/HkoETyJg2lDH+BEsOMdtGyrtDcnV615viDRyx3iS8eQ16oyNQwZSTw= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796209965245.37669672505854; Fri, 15 Sep 2023 09:43:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBu2-0004U0-CD; Fri, 15 Sep 2023 12:42:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBu0-0004TK-FR for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:44 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBty-0004ui-Su for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:44 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-68fc292de9dso1741872b3a.0 for ; Fri, 15 Sep 2023 09:42:42 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796161; x=1695400961; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5E1DttN1y2odVDPPAQFBLbvH/8uGREEL7i929ZC+pCE=; b=N9G/t3xKBEped5pkrYdIqSasnkwf5WmyIjE3E3Old1WaCB10uswQmDRGnMACvEMfbw zeYIYs4TjRpCFngTRrkZfpwbiG39/WuPyzGBRdSBdnrpKKnbP8dbTu1zfeNtKVHEm8dv i20op74KqiXebGko1xNgd4RXdIEM2/1exmeYKsCijeVxn3KCh66KdjRLhIEZ5XhhZfI6 ipj7GDddwQlqbJTtnKuX7BJmqfkYw2/kriA0MfvoI4+CTYZytj7N/spPIJ8XA4csE+4Y NZjCPk0MXkECF6BrvTjTj5wXg0wUx6d3gGAOJbC8dGkxCcDeAI+xrJeb/emzvlp50JzU gKZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796161; x=1695400961; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5E1DttN1y2odVDPPAQFBLbvH/8uGREEL7i929ZC+pCE=; b=sn3DgC8Mg1HUUZJ0RLROnV2Hz/xe99mPeNls4K7dCwmjK8UNH7MFHyDuf+0QJXJH+P 4RgJlWwSHaMKFwjCJKfchLfTJoLTkkl4Qm4bb3/j1nPDFfqju5dr4gGgQ4BpjQ6UXyIJ bYJ2qpwmsm2DJ9zuPu1hsMakRxfCr8xLdXOYJV8PgsmbESRMgaCOjiTzXOJvKeaomXaI Z3Jl6rAiNcVtLNINhxlQgkCjzPhfPpbcbJ3ZssV5V8I6D62WPf9yBeNK4t3D63276p0H KvcUA/Fh5wlAKPxdJGs85UrLuEauzGFNTN3SXJWfgk8cKxT8LGVR+Fdm2wlAqH1FW4u8 IN/g== X-Gm-Message-State: AOJu0YxRKI5x/VUy99irEuYnG5FMICu72jiQsmPVeC0G756mUpBEM1hR QBYAwbhGYMFYHqBfdkIKlwNPzRjtDOV1c0x/lTg= X-Google-Smtp-Source: AGHT+IHixqDd8rx6hbpVdg4TgFMQE+WlNFbNlMd8qNm8w0dih1HNOLbi2hUPXPLaEE1Awg0603Ro6g== X-Received: by 2002:a05:6a20:3d26:b0:140:d536:d434 with SMTP id y38-20020a056a203d2600b00140d536d434mr3029428pzi.10.1694796161016; Fri, 15 Sep 2023 09:42:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ard Biesheuvel Subject: [PULL 09/19] crypto: Add generic 32-bit carry-less multiply routines Date: Fri, 15 Sep 2023 09:42:21 -0700 Message-Id: <20230915164231.123580-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-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::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796211248100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Ard Biesheuvel Signed-off-by: Richard Henderson --- include/crypto/clmul.h | 7 +++++++ crypto/clmul.c | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/crypto/clmul.h b/include/crypto/clmul.h index 72672b237c..80de516464 100644 --- a/include/crypto/clmul.h +++ b/include/crypto/clmul.h @@ -54,4 +54,11 @@ uint64_t clmul_16x2_even(uint64_t, uint64_t); */ uint64_t clmul_16x2_odd(uint64_t, uint64_t); =20 +/** + * clmul_32: + * + * Perform a 32x32->64 carry-less multiply. + */ +uint64_t clmul_32(uint32_t, uint32_t); + #endif /* CRYPTO_CLMUL_H */ diff --git a/crypto/clmul.c b/crypto/clmul.c index 2c87cfbf8a..36ada1be9d 100644 --- a/crypto/clmul.c +++ b/crypto/clmul.c @@ -79,3 +79,16 @@ uint64_t clmul_16x2_odd(uint64_t n, uint64_t m) { return clmul_16x2_even(n >> 16, m >> 16); } + +uint64_t clmul_32(uint32_t n, uint32_t m32) +{ + uint64_t r =3D 0; + uint64_t m =3D m32; + + for (int i =3D 0; i < 32; ++i) { + r ^=3D n & 1 ? m : 0; + n >>=3D 1; + m <<=3D 1; + } + return r; +} --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796271; cv=none; d=zohomail.com; s=zohoarc; b=Y1BI4FDjq+vBHVo4Z8hV199vuNS62xWDPKCg4J2xvEBgxT9B4ZCIVJ0O+cylMmq4J1GT/C28LSewzQRWQ8/kg+bCbCVupgv6lktxOgfOXRdnt8lvAfrM35lL8n6ImPVUjjMuPIrx9+uT9YcLNGjLZogJayOaKICFxPmIsXVFpAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796271; h=Content-Type: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=cZrc3DuTynbE6ZobmlduknjscYzm5QXC9S5Fbkh1+j8=; b=aWDzOG+T9d3YRcP4jH/Vrg6gfCFk4smSaH9hxD8J17j0mKLZQzNbff83plxficUMeAzUFCzlv71+c4reAwGmnb4Gf2BS3vqvrMITJ3xh2y55HI5UamAo2QS/05/9QBo+I1nl9mVsZww1scXnBInpPW8AkbObVq2WNToYe8TXwrs= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796270971818.7187627005333; Fri, 15 Sep 2023 09:44:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBu3-0004Um-Ui; Fri, 15 Sep 2023 12:42:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBu0-0004TU-M3 for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:44 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBty-0004v1-UJ for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:44 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68fbb10dea4so1940248b3a.3 for ; Fri, 15 Sep 2023 09:42:42 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796162; x=1695400962; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cZrc3DuTynbE6ZobmlduknjscYzm5QXC9S5Fbkh1+j8=; b=dtxMgAGuXal5R1KvPFIk35pt80vYUhOzF/P7w1dB/KsbfD2v0PZZ6UfVNA1TB5BlR0 odmBokJNaF/6Cf1Nl0tpfQtj9eo9mSKdCLmYcvHH7YfqYTz87h1bMCG/blvSea16rMXh 6acP4cNcBeibPyPfbmegSKyEzFkqqvdDa0uHN5UtgLhCJkEwouEJS7mU9+vzZmSV6gII QiqWIeoASTAev9vmakUtFwyyLRZepUcaOTu2kJwomUOeFOY+LMsxe0EX8c7Dm9D4oZcE o9YqtCKMgcMrems9pFumfv2eWUmHLaDdkRaTN7eUhJAvRL2naE/X4TOgyiKJ+fHDpqMH +nrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796162; x=1695400962; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cZrc3DuTynbE6ZobmlduknjscYzm5QXC9S5Fbkh1+j8=; b=pd09KhZF7/xIPh2cVpKHm9yT1hUOhKTbrPsh1XF0Fb58VoyPbyAhYUlZwBGE3k6Fyz lBCH/+crL5uVLHqO+gdy1qFgseDYGQ2IgALkRAs94aJIVQ+c5cmjxBVvLsrn8+bE9cBF MCHx3u3fsOfsCLFd1XRrcfykvp1yqZKjAzUTccHYT2ZcQHMJgm/qUKfcNNltT9MIVZIT QeddR+vo3VrOKXZjisMP1jSr+7GL4VPUQ7OVp0o5n5zZaE13ezLaFe3IebLvAyZRetFF bWgiWW0MnW+UlVj7KB/CRjxOnwNIr3JFNCNzdhFIFNUwL8ofmC7l0BfPDyJiJLHs5hyA 98LQ== X-Gm-Message-State: AOJu0Yz2/KRXnYXqesKLxweH3IslocDO7dGMWJ8EivB9RtcD1l9TFdIP krNqE+hQqtuIulQzrBw3841sX4yx8Xrknd8WmnY= X-Google-Smtp-Source: AGHT+IGuYu1IqGm41lJzD5WIO5M0KQ/sZbnOJBUWcDznBIkyrKYUexgGn8Bp4PenbsWPPYSfYp/Hgg== X-Received: by 2002:a05:6a20:5489:b0:14d:9938:735f with SMTP id i9-20020a056a20548900b0014d9938735fmr2726889pzk.17.1694796161776; Fri, 15 Sep 2023 09:42:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 10/19] target/arm: Use clmul_32* routines Date: Fri, 15 Sep 2023 09:42:22 -0700 Message-Id: <20230915164231.123580-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796273148100003 Use generic routines for 32-bit carry-less multiply. Remove our local version of pmull_d. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/arm/tcg/vec_helper.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c index 5def86b573..ffb4b44ce4 100644 --- a/target/arm/tcg/vec_helper.c +++ b/target/arm/tcg/vec_helper.c @@ -2055,18 +2055,6 @@ void HELPER(sve2_pmull_h)(void *vd, void *vn, void *= vm, uint32_t desc) } } =20 -static uint64_t pmull_d(uint64_t op1, uint64_t op2) -{ - uint64_t result =3D 0; - int i; - - for (i =3D 0; i < 32; ++i) { - uint64_t mask =3D -((op1 >> i) & 1); - result ^=3D (op2 << i) & mask; - } - return result; -} - void HELPER(sve2_pmull_d)(void *vd, void *vn, void *vm, uint32_t desc) { intptr_t sel =3D H4(simd_data(desc)); @@ -2075,7 +2063,7 @@ void HELPER(sve2_pmull_d)(void *vd, void *vn, void *v= m, uint32_t desc) uint64_t *d =3D vd; =20 for (i =3D 0; i < opr_sz / 8; ++i) { - d[i] =3D pmull_d(n[2 * i + sel], m[2 * i + sel]); + d[i] =3D clmul_32(n[2 * i + sel], m[2 * i + sel]); } } #endif --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796274; cv=none; d=zohomail.com; s=zohoarc; b=Bx0JfeT+y2ZjauS6IxYx4+4w8N7fRKn6axBFf2NEm3TPpllcc9UWw1+tsvSg9OP4ik6cb8FC76RcTb6aBpNcaLvqFQ8VD7OfAQa+UTQQOwheW3lAA6IZ5GDCuksoI2PyhKG0iyqbjoStKjqqjS+2WPncMEutw2oCwZL1mIkO7gA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796274; h=Content-Type: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=W1FQxefxQxkmUZ1SixwcnXZvZP/IO9ZUpCwPt+2NITw=; b=A3We3KSeGBCyfKG5d1IK52k6HiVPsg17xSrgML9nagVWdzWVubKtLwURiEGwIR4wuaGgJ3oABTmZ1gimXamsVbrxg688oKuvCdUX306rabdhMguyB/fjIpncGN4OtBnmb3AfGTp5mpR9mCElgob/d0BtaKUPfb+Jd+CBHgSImgk= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796274573641.1364953921324; Fri, 15 Sep 2023 09:44:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBu5-0004VW-67; Fri, 15 Sep 2023 12:42:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBu2-0004UV-Me for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:46 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBu1-0004w9-1e for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:46 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-68fb79ef55eso2146752b3a.0 for ; Fri, 15 Sep 2023 09:42:44 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796162; x=1695400962; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W1FQxefxQxkmUZ1SixwcnXZvZP/IO9ZUpCwPt+2NITw=; b=PMWdIkfwC61+8PGZrE/P5bWc4p7fH3392/XU18lhRK4xO4P6ZJ2MGYxL6NhdMGKapn /n5KapAX8lF1ZXj9pUDtalmYPELYF/uTSe9P9A9Ju03IU3kWPBZRCEq3LmyFjZxNzASj 33BhVhpXVqtEy1qv/0uVyN6pr5Futzm+Btv7FdLk0OlVFAnUwoCwGYDyvQfo5SyfWXZY C+9N/AD6Rl/qvA00vEqjec4oWEX9DTvWl5YWQYf6Zuv/kPumBy3rJMJL7nenmxu/2EWw ZsmyVSpC/8VKZyQRZ43VSRp1gM8ltvOLseEMu1rrZVJbd/jr4iI9rSfSUGY0BNMuWxnE 3TOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796162; x=1695400962; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W1FQxefxQxkmUZ1SixwcnXZvZP/IO9ZUpCwPt+2NITw=; b=FD9lNuHUPe1AD1JyDQTOQuxTUNFLKkxSUmSQr1hwuLDiSSdTwldoroCbEWLqcDH48l AOymYdDUdqyn3qYLwEVjOgG/JYuCeUS0zNtzEDhrIqRZegj8jjjsABLBi/36RnCrExxh whlhUwb2kT2BvKGCeA5iFo2IQ9ZD7yOgDWQlQ95YOhQsIMwdRk/833QG0316f6L0+Pgp wg7yCsvhzvSudyDlij0A9w1NlH+ljrkj/wDS27R1apY+LLG3lFvtcm3AzI+8Kmt+KPKi 5vVK9JGrtwgXg9GZAa8w6/vlPwQvFQSGYMybTXq9GN2h0eOMGkdyfiyLEJOeej1X0UBJ bX9Q== X-Gm-Message-State: AOJu0YxCpDuI/BpY5eDukG0pgR7qIKu+fE+GtJirFhqUuHwD/wSu9uFr hHJxG7cxtq3RPqBxc0ZTwpyYqSSCY5tNwAI1nB4= X-Google-Smtp-Source: AGHT+IF4t+SsMaogr17mQxO3gCidEyq2/PnZNaR8bNd2IT5rk9gtdTx9TUt3/i6zNZi7fPoxLacnfQ== X-Received: by 2002:a05:6a20:8f01:b0:136:faec:a7dc with SMTP id b1-20020a056a208f0100b00136faeca7dcmr2989402pzk.11.1694796162576; Fri, 15 Sep 2023 09:42:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 11/19] target/s390x: Use clmul_32* routines Date: Fri, 15 Sep 2023 09:42:23 -0700 Message-Id: <20230915164231.123580-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796277235100003 Use generic routines for 32-bit carry-less multiply. Remove our local version of galois_multiply32. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/s390x/tcg/vec_int_helper.c | 75 +++++++++---------------------- 1 file changed, 22 insertions(+), 53 deletions(-) diff --git a/target/s390x/tcg/vec_int_helper.c b/target/s390x/tcg/vec_int_h= elper.c index 11477556e5..ba284b5379 100644 --- a/target/s390x/tcg/vec_int_helper.c +++ b/target/s390x/tcg/vec_int_helper.c @@ -165,22 +165,6 @@ DEF_VCTZ(8) DEF_VCTZ(16) =20 /* like binary multiplication, but XOR instead of addition */ -#define DEF_GALOIS_MULTIPLY(BITS, TBITS) = \ -static uint##TBITS##_t galois_multiply##BITS(uint##TBITS##_t a, = \ - uint##TBITS##_t b) = \ -{ = \ - uint##TBITS##_t res =3D 0; = \ - = \ - while (b) { = \ - if (b & 0x1) { = \ - res =3D res ^ a; = \ - } = \ - a =3D a << 1; = \ - b =3D b >> 1; = \ - } = \ - return res; = \ -} -DEF_GALOIS_MULTIPLY(32, 64) =20 static S390Vector galois_multiply64(uint64_t a, uint64_t b) { @@ -254,24 +238,29 @@ void HELPER(gvec_vgfma16)(void *v1, const void *v2, c= onst void *v3, q1[1] =3D do_gfma16(q2[1], q3[1], q4[1]); } =20 -#define DEF_VGFM(BITS, TBITS) = \ -void HELPER(gvec_vgfm##BITS)(void *v1, const void *v2, const void *v3, = \ - uint32_t desc) = \ -{ = \ - int i; = \ - = \ - for (i =3D 0; i < (128 / TBITS); i++) { = \ - uint##BITS##_t a =3D s390_vec_read_element##BITS(v2, i * 2); = \ - uint##BITS##_t b =3D s390_vec_read_element##BITS(v3, i * 2); = \ - uint##TBITS##_t d =3D galois_multiply##BITS(a, b); = \ - = \ - a =3D s390_vec_read_element##BITS(v2, i * 2 + 1); = \ - b =3D s390_vec_read_element##BITS(v3, i * 2 + 1); = \ - d =3D d ^ galois_multiply32(a, b); = \ - s390_vec_write_element##TBITS(v1, i, d); = \ - } = \ +static inline uint64_t do_gfma32(uint64_t n, uint64_t m, uint64_t a) +{ + return clmul_32(n, m) ^ clmul_32(n >> 32, m >> 32) ^ a; +} + +void HELPER(gvec_vgfm32)(void *v1, const void *v2, const void *v3, uint32_= t d) +{ + uint64_t *q1 =3D v1; + const uint64_t *q2 =3D v2, *q3 =3D v3; + + q1[0] =3D do_gfma32(q2[0], q3[0], 0); + q1[1] =3D do_gfma32(q2[1], q3[1], 0); +} + +void HELPER(gvec_vgfma32)(void *v1, const void *v2, const void *v3, + const void *v4, uint32_t d) +{ + uint64_t *q1 =3D v1; + const uint64_t *q2 =3D v2, *q3 =3D v3, *q4 =3D v4; + + q1[0] =3D do_gfma32(q2[0], q3[0], q4[0]); + q1[1] =3D do_gfma32(q2[1], q3[1], q4[1]); } -DEF_VGFM(32, 64) =20 void HELPER(gvec_vgfm64)(void *v1, const void *v2, const void *v3, uint32_t desc) @@ -288,26 +277,6 @@ void HELPER(gvec_vgfm64)(void *v1, const void *v2, con= st void *v3, s390_vec_xor(v1, &tmp1, &tmp2); } =20 -#define DEF_VGFMA(BITS, TBITS) = \ -void HELPER(gvec_vgfma##BITS)(void *v1, const void *v2, const void *v3, = \ - const void *v4, uint32_t desc) = \ -{ = \ - int i; = \ - = \ - for (i =3D 0; i < (128 / TBITS); i++) { = \ - uint##BITS##_t a =3D s390_vec_read_element##BITS(v2, i * 2); = \ - uint##BITS##_t b =3D s390_vec_read_element##BITS(v3, i * 2); = \ - uint##TBITS##_t d =3D galois_multiply##BITS(a, b); = \ - = \ - a =3D s390_vec_read_element##BITS(v2, i * 2 + 1); = \ - b =3D s390_vec_read_element##BITS(v3, i * 2 + 1); = \ - d =3D d ^ galois_multiply32(a, b); = \ - d =3D d ^ s390_vec_read_element##TBITS(v4, i); = \ - s390_vec_write_element##TBITS(v1, i, d); = \ - } = \ -} -DEF_VGFMA(32, 64) - void HELPER(gvec_vgfma64)(void *v1, const void *v2, const void *v3, const void *v4, uint32_t desc) { --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796279; cv=none; d=zohomail.com; s=zohoarc; b=Q4iCqNfbBT92eY14xzuG+1r9VX95ExMsBg5yQTh1zDialuELWsn7HTpysNhpvXw7p1kl3tZeHCd/MnsVioQzgXNSQN99wavRubHGAIgmD99lldPh3aGYJZ089SyADYCyXjuHQTVg5pNpyDh36kQmYuZ68d3FppRcybgb72MxB9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796279; h=Content-Transfer-Encoding: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=/GHGqee03AmoquehQcXqyFpwhRv/6DB5C+2O1I5qXiA=; b=nHDGAOsnIfnJhaVbdGhsNBJ3QFCZzGAcOEIzuepOADcLUafiDoCmenBtUo1MY3asuTS4q0IFo5if/4KUoPaFnFe75L8tFsvD8yMYpqbauQgZWOEu2XqtJXBFgy5cY1spcDKO53SWkco2t96yZTM7UT/2HDE7vfdqD8vsl/X5U4k= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796279110991.0813122452647; Fri, 15 Sep 2023 09:44:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBu4-0004V3-KV; Fri, 15 Sep 2023 12:42:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBu2-0004UE-GI for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:46 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBu0-0004w4-UF for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:46 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-68fb5bd8f02so2279738b3a.0 for ; Fri, 15 Sep 2023 09:42:44 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796163; x=1695400963; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/GHGqee03AmoquehQcXqyFpwhRv/6DB5C+2O1I5qXiA=; b=hZa36b7cKvfSMEJRbyOnG2C2ZF6k6cSpi8xtFRm53IP+jJoEqNOyjWKfa1YCxB9Iz/ zWJXQ1eyJS0b8OGfOKy+CPsMNf8o3muegyvcG4pfuLzesDrSUfYj/2vNA8ylSaJ1o0Yl CE5wjDbRowYDdBL6jEdW5rbxn2caesLdvXKLM92OXFP5d26H/hrEDYnl6aI2eBAxlHlJ yFj2ddu5sr4v8zqQxprF9VO8ZZr3XaP2ffNqyDI7hKnkSV+X83vwXYFme4l5kWOa+TcO lul8w4fI9/AfHPuzavSGwjw+CKGmBvO6dsqiQ+jl/NRFfCYvH7+noDIVzU56bl73la0r XkZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796163; x=1695400963; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/GHGqee03AmoquehQcXqyFpwhRv/6DB5C+2O1I5qXiA=; b=wx4BJFuA9jb6C2asenurRqDBRJe4qeTcglVDsc+bWdb+0UIi43jzUDaCyYlnuoxM21 bml+Em5UQmR8zHzMPLzNSvLVkUbaTUwnhicM5XrH/sZrLII5U2boW7ouLo0/23JnvlW0 B+hxP0XOH4L0re5n86YXlB5SWW5G7YG1bnzfimd+qrhFqe1g74ztzp2cqMgLzp0VE4v1 aW/84BZiTK4+bkr40ANq2uQezM+tWDFTANcST95M7BATeXh4m3xAHiuL54Fs1mHta3kB sR79D+RxHgItjOFn4luaUFT+5E+Ld29xr6jNBlYGLYYDnDGLtYdnbwGKpw8lYNmVQIju EFQw== X-Gm-Message-State: AOJu0Ywk4I+eucu/jDZparxCCyeQVOO0qlLfFHYo7DrCbQ9BzmPPn6Y+ ZEKNfLDUvTbiMu0F1BYHBVcG1SOSnq/363RWIUI= X-Google-Smtp-Source: AGHT+IEQn93MICRM8J7CzGhVN1HVIAFyYTXg+vwTyBSFGBGKi9JzT7CfVnMaSLZXVO6+EVNhJsEKpw== X-Received: by 2002:a05:6a00:24d2:b0:68f:d35d:2168 with SMTP id d18-20020a056a0024d200b0068fd35d2168mr2393689pfv.0.1694796163459; Fri, 15 Sep 2023 09:42:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 12/19] target/ppc: Use clmul_32* routines Date: Fri, 15 Sep 2023 09:42:24 -0700 Message-Id: <20230915164231.123580-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-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::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796279881100003 Content-Type: text/plain; charset="utf-8" Use generic routines for 32-bit carry-less multiply. Signed-off-by: Richard Henderson --- target/ppc/int_helper.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index ebb2957fe7..1ea42b4ede 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -1445,28 +1445,14 @@ void helper_vpmsumh(ppc_avr_t *r, ppc_avr_t *a, ppc= _avr_t *b) } } =20 -#define PMSUM(name, srcfld, trgfld, trgtyp) \ -void helper_##name(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \ -{ \ - int i, j; \ - trgtyp prod[sizeof(ppc_avr_t) / sizeof(a->srcfld[0])]; \ - \ - VECTOR_FOR_INORDER_I(i, srcfld) { \ - prod[i] =3D 0; \ - for (j =3D 0; j < sizeof(a->srcfld[0]) * 8; j++) { \ - if (a->srcfld[i] & (1ull << j)) { \ - prod[i] ^=3D ((trgtyp)b->srcfld[i] << j); \ - } \ - } \ - } \ - \ - VECTOR_FOR_INORDER_I(i, trgfld) { \ - r->trgfld[i] =3D prod[2 * i] ^ prod[2 * i + 1]; \ - } \ +void helper_vpmsumw(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) +{ + for (int i =3D 0; i < 2; ++i) { + uint64_t aa =3D a->u64[i], bb =3D b->u64[i]; + r->u64[i] =3D clmul_32(aa, bb) ^ clmul_32(aa >> 32, bb >> 32); + } } =20 -PMSUM(vpmsumw, u32, u64, uint64_t) - void helper_VPMSUMD(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) { int i, j; --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796213; cv=none; d=zohomail.com; s=zohoarc; b=aNFEKk75jZDm7JXJePj6rssWEfmrgRDN3JFjPOwNmkhE+apfhRIJLfOTQcw8kUNuv2b4E7hJ4ZuZYVEVtOgo8BH9FT0Idh8j2C+HAiBGMUxL224udA+1LhUwBWHLG8gdiXD4pa29dKsLHYRCwpsMTkleureyUl+1GOEeLChSTQs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796213; 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=SHZnlFNBtvPPOH9mS0fn2N0/KTEtZ6bjCbR6h+ACJf0=; b=diVPgGGEysEOdKjFKuFetLoX0Y9v0YuSKwygpCtkKedmlGY6uBBVF3cFID6w3tdkILO+lyn24UWPd8OArKo2/LlYLUjgnlbqAeBOElQ48ed2CKOD4NN9sz7GtnE06EHR8SC+ac5N4JwYcSQKAyW0elusGbwMft959KaAnD5tcyU= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796213550818.0769617569149; Fri, 15 Sep 2023 09:43:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBu9-0004Xn-Oa; Fri, 15 Sep 2023 12:42:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBu6-0004W6-VG for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:50 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBu1-0004wP-PB for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:50 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-68fb6fd2836so2137923b3a.0 for ; Fri, 15 Sep 2023 09:42:45 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796164; x=1695400964; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SHZnlFNBtvPPOH9mS0fn2N0/KTEtZ6bjCbR6h+ACJf0=; b=jUAadngIND8Ll50rBMZnQfoekaFHNdGIWd02imDcMtbMBtlZInK5HpvUk0QXFdOWRF NEiHvpzmnzCSHk9W/TLELATsK/y4Fpimi/6VdqU+HaVd0p+NZd0a0hD7iGOtD+tIVxVw P9oQWSewjQJ3nfXqBK4N6K/fiQtexkvKwwsQhrzJ2IlwcTOqO4VAg1W/zFSADeFgYCjo /oUiBa5x9I67QFMV9hCt/5ExnJfCDW7IkhC/yNqqT7WLAe15ecKRCHM4fPKzNpgLNZy/ lQCCNBKKvnFc7uivirmu3qEcMe44m7gbwVvGPFNG5AJM3myr9jDRlCfPUtNJdox2pimI UTXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796164; x=1695400964; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SHZnlFNBtvPPOH9mS0fn2N0/KTEtZ6bjCbR6h+ACJf0=; b=onZwj4RgxjwCE2pqrcuJV+LDFhuMj0N3Q/lHfKCb1UrLGG7u98NfLJl8/+//PK7DrV Ktej4pDAosNz8K4qE0aRWHVLgt91sLl5EVJEJpv8i+T2iw74/i4zmjQuHLFNFSljPG+2 6ZtjK+LK0UIiXYYmTFjgZxKZ/MyUpFJmASSXUMdaqEXNrSdKPWIKPRYeaO6ZuvOvgc/Q wngCaoJpMosxkfcQE+acnPnL1FnMch0MEgsUt72toxWBcwgHmtOz8Xoh2hHjZgXF+UPN uAM/v/a2qG39OTG9Ea52z4tHHAKCy9T18NEmcuuIez1MGhaKdMfC4EQcX9mhyc7lrUP9 qQcA== X-Gm-Message-State: AOJu0YwICeFiNuIAyikwGB1FT6ddicMAJGz03BI9SdHWydKm3hnlN8x5 nvdE19N8htETyC7AG4KX5+w9sh+TAQTd7cLERiI= X-Google-Smtp-Source: AGHT+IHt7wLzZhgRaYK8Joixi7UB2RYrXUNM788+zo7vsxWlm4tKCHRjNmn3t+ARaynPINtHb+kRpQ== X-Received: by 2002:a05:6a20:938a:b0:142:952d:3e61 with SMTP id x10-20020a056a20938a00b00142952d3e61mr2657794pzh.7.1694796164263; Fri, 15 Sep 2023 09:42:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ard Biesheuvel Subject: [PULL 13/19] crypto: Add generic 64-bit carry-less multiply routine Date: Fri, 15 Sep 2023 09:42:25 -0700 Message-Id: <20230915164231.123580-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-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::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.google.com 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_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796214936100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Ard Biesheuvel Signed-off-by: Richard Henderson --- host/include/generic/host/crypto/clmul.h | 15 +++++++++++++++ include/crypto/clmul.h | 19 +++++++++++++++++++ crypto/clmul.c | 17 +++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 host/include/generic/host/crypto/clmul.h diff --git a/host/include/generic/host/crypto/clmul.h b/host/include/generi= c/host/crypto/clmul.h new file mode 100644 index 0000000000..915bfb88d3 --- /dev/null +++ b/host/include/generic/host/crypto/clmul.h @@ -0,0 +1,15 @@ +/* + * No host specific carry-less multiply acceleration. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef GENERIC_HOST_CRYPTO_CLMUL_H +#define GENERIC_HOST_CRYPTO_CLMUL_H + +#define HAVE_CLMUL_ACCEL false +#define ATTR_CLMUL_ACCEL + +Int128 clmul_64_accel(uint64_t, uint64_t) + QEMU_ERROR("unsupported accel"); + +#endif /* GENERIC_HOST_CRYPTO_CLMUL_H */ diff --git a/include/crypto/clmul.h b/include/crypto/clmul.h index 80de516464..446931fe05 100644 --- a/include/crypto/clmul.h +++ b/include/crypto/clmul.h @@ -8,6 +8,9 @@ #ifndef CRYPTO_CLMUL_H #define CRYPTO_CLMUL_H =20 +#include "qemu/int128.h" +#include "host/crypto/clmul.h" + /** * clmul_8x8_low: * @@ -61,4 +64,20 @@ uint64_t clmul_16x2_odd(uint64_t, uint64_t); */ uint64_t clmul_32(uint32_t, uint32_t); =20 +/** + * clmul_64: + * + * Perform a 64x64->128 carry-less multiply. + */ +Int128 clmul_64_gen(uint64_t, uint64_t); + +static inline Int128 clmul_64(uint64_t a, uint64_t b) +{ + if (HAVE_CLMUL_ACCEL) { + return clmul_64_accel(a, b); + } else { + return clmul_64_gen(a, b); + } +} + #endif /* CRYPTO_CLMUL_H */ diff --git a/crypto/clmul.c b/crypto/clmul.c index 36ada1be9d..9e3e61a77d 100644 --- a/crypto/clmul.c +++ b/crypto/clmul.c @@ -92,3 +92,20 @@ uint64_t clmul_32(uint32_t n, uint32_t m32) } return r; } + +Int128 clmul_64_gen(uint64_t n, uint64_t m) +{ + uint64_t rl =3D 0, rh =3D 0; + + /* Bit 0 can only influence the low 64-bit result. */ + if (n & 1) { + rl =3D m; + } + + for (int i =3D 1; i < 64; ++i) { + uint64_t mask =3D -((n >> i) & 1); + rl ^=3D (m << i) & mask; + rh ^=3D (m >> (64 - i)) & mask; + } + return int128_make128(rl, rh); +} --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796191; cv=none; d=zohomail.com; s=zohoarc; b=AIX7er4Ck6pTDMkEY8kNm0CT0brAlfRSKiivo5ClD6uC/lYi9LsFciutEEqTtW+Qu9kApV0G/5VJWF+SUw4AfDcw0qdDwtsB8MU996hpLk88WbWFYK8HkNAkF4zHfLue8f1VCxOfCQIGj5r9F10+N+xr89gIsyAlXDKlP7zKg/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796191; h=Content-Type: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=LeRwmoZj3gayyKtebRoC0JW2YuHlKTaNGyIqgqME+tw=; b=BGebh1C5cbPmGd0QskEKEbNzE8Dxn+iEYK2cJcp8d05VTwY9hhAx/E5xQAYbIaQLEZybPUAkqQDm+49oGjnOx+94bBleh3R34mt0I1i/Td0C8cmkj3jd/QoSxHh79+UyQ9cx9+ZaPbaPpRh9f+PXtVhFsbYe2TXpXvYI0AjV0ZI= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796190990378.41013725300616; Fri, 15 Sep 2023 09:43:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBuB-0004YY-CX; Fri, 15 Sep 2023 12:42:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBu7-0004W8-0c for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:52 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBu2-0004wW-6b for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:50 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-68fcb4dc8a9so2247964b3a.2 for ; Fri, 15 Sep 2023 09:42:45 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796165; x=1695400965; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LeRwmoZj3gayyKtebRoC0JW2YuHlKTaNGyIqgqME+tw=; b=MLzuqBHT1waQVa1NmOP9k3UJtevIvMy1oTuSwiUvfGcDmEeoZ9Jb3+fvztG9ofYGsq UAxlC9Ff02l0EfDVaEMMq91hzSnWiRSl8PTwAgzn5StD1egatIJxGD5Mj0ex9m9LidX+ fBHett9ZGt6UtHUeTy4nzZW9r9Km9aQFpr0e12yZGXtyYTE8LNPuevRrDJBupeixOQft sjG21otw/lldKsRfH4Ek+/ZKH+n0gl0qpAtHJf4L4YjtaBPzYpji4IERipln9z1G8yzQ il9Dh46xVgsOeRK9HBh1pwDqjj7KsKsVGMwOQpHk3fCki+XaBRdQ3reKnUzE8prMvZ4I YqQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796165; x=1695400965; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LeRwmoZj3gayyKtebRoC0JW2YuHlKTaNGyIqgqME+tw=; b=Y6jMYPGnlj+6+o8G9CCvO+0ckE8nqrVZIv130nglztMOKhQOWIr/Nj9XMwLhPl6dVb HVbIVQRwXxnJbL0+MgdothUDkFUEEmUnjihT4uuzDANBAumzNe72MXZ3RwhyL76/OlXP EHUgQndeJ6bdcLKas1nSc+DCiHeJl+YdXJmCwmiyA+qo0wtxDLBZoT0h9UQx+mcRPGKL OLZ2qa3l+Si0eJSStAP6j6DqDyHQVjgEVZRIgf6tZhbxdnm2Srt8zAc/8b6WZMiAlleO 5Ln+YWsDUMw74UB2NfWq1S7cEW8eBsMsEWw1fJ7dqb2G6ECwHqOzN00ub6K2nuYD3/sc tfMg== X-Gm-Message-State: AOJu0YxhosdMNcgHQPiEQHtB8/cqutLg1nopQ/FrHhXSsNA5Q6i80VWU jsMEFkhKWzyy6jWHEhZ56NNAxiWFd75JeS9KT3U= X-Google-Smtp-Source: AGHT+IG/76RxcSJfh6KMiNChvxiv/ay/CY11IQ8yRBG57ne/klwl1EgKdpjPcJ2gJQPC01bQF8eHyQ== X-Received: by 2002:a05:6a20:bb02:b0:157:7568:6796 with SMTP id fc2-20020a056a20bb0200b0015775686796mr1890837pzb.60.1694796164956; Fri, 15 Sep 2023 09:42:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 14/19] target/arm: Use clmul_64 Date: Fri, 15 Sep 2023 09:42:26 -0700 Message-Id: <20230915164231.123580-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com 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_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796192973100007 Use generic routine for 64-bit carry-less multiply. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/arm/tcg/vec_helper.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c index ffb4b44ce4..1f93510b85 100644 --- a/target/arm/tcg/vec_helper.c +++ b/target/arm/tcg/vec_helper.c @@ -2003,28 +2003,14 @@ void HELPER(gvec_pmul_b)(void *vd, void *vn, void *= vm, uint32_t desc) */ void HELPER(gvec_pmull_q)(void *vd, void *vn, void *vm, uint32_t desc) { - intptr_t i, j, opr_sz =3D simd_oprsz(desc); + intptr_t i, opr_sz =3D simd_oprsz(desc); intptr_t hi =3D simd_data(desc); uint64_t *d =3D vd, *n =3D vn, *m =3D vm; =20 for (i =3D 0; i < opr_sz / 8; i +=3D 2) { - uint64_t nn =3D n[i + hi]; - uint64_t mm =3D m[i + hi]; - uint64_t rhi =3D 0; - uint64_t rlo =3D 0; - - /* Bit 0 can only influence the low 64-bit result. */ - if (nn & 1) { - rlo =3D mm; - } - - for (j =3D 1; j < 64; ++j) { - uint64_t mask =3D -((nn >> j) & 1); - rlo ^=3D (mm << j) & mask; - rhi ^=3D (mm >> (64 - j)) & mask; - } - d[i] =3D rlo; - d[i + 1] =3D rhi; + Int128 r =3D clmul_64(n[i + hi], m[i + hi]); + d[i] =3D int128_getlo(r); + d[i + 1] =3D int128_gethi(r); } clear_tail(d, opr_sz, simd_maxsz(desc)); } --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796247; cv=none; d=zohomail.com; s=zohoarc; b=Vh+wXkS3s7oCksYMSJPaYeA+PHg+0pJ7Tes7DgAsNUjvqrkHWpHX3n7xaOHwYVaC1mOdDJHuSiNt3qqUT0ana6annHyqkqOIJsqZIHpvVDZlY5GTBsQduIvxkwYPzG+Y8e4SpnkGxKIlQxYSwOQ/TIwXUFqk8Zy94mXqjv0TRQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796247; h=Content-Type: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=b+3/8IiHtNpBs5dwlAlcrSMhCtecqGkkP2HhC4y759E=; b=boHWpThRrBFR31gjAb4SesccczbLg79GMMgHD2aXNbt84ynTAHyoBkk4pByG9/Kbylo9V/BWkcBKygbojDtZKDlQsd72KXKORdd3+cAM3k6T90al0ChRdvTcNNhscz4nXeYClwo+WQgxeUhEm6YNwNMg3Um0/pQWq5ZTW7WtzAg= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796247275995.2713290205268; Fri, 15 Sep 2023 09:44:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBu6-0004Vj-Fs; Fri, 15 Sep 2023 12:42:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBu4-0004VR-VH for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:48 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBu3-0004wm-Cg for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:48 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-68fdd5c1bbbso1722775b3a.1 for ; Fri, 15 Sep 2023 09:42:47 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796166; x=1695400966; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b+3/8IiHtNpBs5dwlAlcrSMhCtecqGkkP2HhC4y759E=; b=TrLqvRrkTYTzuerEopt6OwLgWG+K1+eZXhWlX7gLqT0ERI1lu9nCQOaj/YXeueIbg/ Ndru3nJK8XqtfVgGmoB47DhwhkF6uHcet2JBGtYUhKdtIYBw8Xe7jktUCAFhFzyEEk8Y 8zrzbw6Z0XLZ4hl57B80j+CrYOc/hd/tS5NAyj2roRG2vw+k/c59FwiDadY4pqARujgl VYzwET2qadZlj08pjLDrxZ+rrhF4sU75z3ZMlS9g6n/3BLLrxz9XsImGwuE6suNd1xWx eINCtF1qg6XW/8lx+swIAS1PMdZ+eLGl8G4DONrh6p8b+9MwzVKyi4VG0Lg1cDhkOtVm 1xPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796166; x=1695400966; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b+3/8IiHtNpBs5dwlAlcrSMhCtecqGkkP2HhC4y759E=; b=Ld3tWyey6gp/7jfLZ2cJpnPszToXdUtw3K811gjJiEJHbpo+L+9RclE4RbkfHagTp6 Zjetx3+ICloxh7+nURrIH+h45zEOwqNYwiqp/gync8QvYjePltppANtQLeOfs3fhb+rr smrz5wBrMWK8EufhYs3cGRhBHJtin0V63c7nM4J20bEmKM34rM/BpTTtz7IYw960zMQj dnCKZRU+DUgx+TQINNLDXylm/wIupjUddtvjG+SPSEQInXO75NY/VdSJ3domrVqGp5tk JGArRnx/DRnWAI1vVSzakCW4uxCQc1LiXY8a801nyR5oqEcH9qTS1L2go7XW3y9FLwsP itqg== X-Gm-Message-State: AOJu0YydBY5AlytmRIv3D3ZmbidpwhMv/3F7ywhL+nFPqqAxUIJ7eJy/ DTFd2J4ZX7W0WI36Kll4O+ipLh2quEq1u1OyviA= X-Google-Smtp-Source: AGHT+IG9a5LF1bnb7JgZGyu37DmTsoquDayqpwsPPcJLa+/QfHcqowgeBLyb8bczV4L7DjNxH4mtcQ== X-Received: by 2002:a05:6a20:430d:b0:159:d061:58e9 with SMTP id h13-20020a056a20430d00b00159d06158e9mr7314745pzk.26.1694796165954; Fri, 15 Sep 2023 09:42:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 15/19] target/i386: Use clmul_64 Date: Fri, 15 Sep 2023 09:42:27 -0700 Message-Id: <20230915164231.123580-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796249078100001 Use generic routine for 64-bit carry-less multiply. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/i386/ops_sse.h | 40 +++++++++------------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index a0e425733f..33908c0691 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -20,6 +20,7 @@ =20 #include "crypto/aes.h" #include "crypto/aes-round.h" +#include "crypto/clmul.h" =20 #if SHIFT =3D=3D 0 #define Reg MMXReg @@ -2122,41 +2123,18 @@ target_ulong helper_crc32(uint32_t crc1, target_ulo= ng msg, uint32_t len) =20 #endif =20 -#if SHIFT =3D=3D 1 -static void clmulq(uint64_t *dest_l, uint64_t *dest_h, - uint64_t a, uint64_t b) -{ - uint64_t al, ah, resh, resl; - - ah =3D 0; - al =3D a; - resh =3D resl =3D 0; - - while (b) { - if (b & 1) { - resl ^=3D al; - resh ^=3D ah; - } - ah =3D (ah << 1) | (al >> 63); - al <<=3D 1; - b >>=3D 1; - } - - *dest_l =3D resl; - *dest_h =3D resh; -} -#endif - void glue(helper_pclmulqdq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg = *s, uint32_t ctrl) { - uint64_t a, b; - int i; + int a_idx =3D (ctrl & 1) !=3D 0; + int b_idx =3D (ctrl & 16) !=3D 0; =20 - for (i =3D 0; i < 1 << SHIFT; i +=3D 2) { - a =3D v->Q(((ctrl & 1) !=3D 0) + i); - b =3D s->Q(((ctrl & 16) !=3D 0) + i); - clmulq(&d->Q(i), &d->Q(i + 1), a, b); + for (int i =3D 0; i < SHIFT; i++) { + uint64_t a =3D v->Q(2 * i + a_idx); + uint64_t b =3D s->Q(2 * i + b_idx); + Int128 *r =3D (Int128 *)&d->ZMM_X(i); + + *r =3D clmul_64(a, b); } } =20 --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796191; cv=none; d=zohomail.com; s=zohoarc; b=cQbdTCDUeRzgyxnfvljmrztx+yCqvKUMOgCVq75tohSuIHIWYMZauoZnwkp5a7LQuU+Il/eTZg6my6aBtRtneJrPrwH+U16T7GEiHmEOZfk0ZApAREJ08qwnfJZNpXZK/8Of3KnDu1EwEbyOFVIoT+ZsCkBejMEim3CAH+xMBtI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796191; h=Content-Type: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=mA3cEFgfatbmP6xNVJY+hnrvCkua8Jz5pM6YfngoFhc=; b=SLzcwduf3g/5O88TLp0/6/cz19uEcwH6QUSAD6YFZHiue70LglpOQmpXKaqmr+Zw4mGE3DJvrlG+RR3+DaSlBXYg2W6lPLW7adMEBbyQ94NVRe7Tuwepdgbmr4qQqXwpqjl6/byUhMKp7TIb1dBITPhstsK/eya4roUWIukMD7U= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796191357855.3738594611217; Fri, 15 Sep 2023 09:43:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBu8-0004Wv-Am; Fri, 15 Sep 2023 12:42:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBu6-0004Ve-9A for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:50 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBu4-0004x0-6M for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:49 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-68fb7074348so2162535b3a.2 for ; Fri, 15 Sep 2023 09:42:47 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796167; x=1695400967; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mA3cEFgfatbmP6xNVJY+hnrvCkua8Jz5pM6YfngoFhc=; b=q2jbA0or9bLiKmnvehCglhM+gRZjrwGLNVEhIUfbgtz/gDNGPoEzYzgsqBeEI/B/SS MvWeJ8qjW0on6pyr5Wj43r75WwhbHkbjiibg6zaf3fHS1gho7BCZwVLty4x9RJCbgyw+ 4DlZvq/gHk3lr70QBCsjvgkWFwfb+LZmyKeLzoQEOPSayBpbF1SDojrzgNivuXFbPmMx hLqxFs1t2j2JyT1R6XfzdZP1oTswgI1pj1r2NfYv5aRpl6lRn06vdby5OhSol3uMY/nA nl0K6HO0LCmQbs3IVxDgJXsO6IyXydE2ZmXqpGfeYpcplqlS/kIBPp+tJb8O+sxk/uip C2xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796167; x=1695400967; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mA3cEFgfatbmP6xNVJY+hnrvCkua8Jz5pM6YfngoFhc=; b=eNuCAtjRM1UJLnxQruMn0Fgfsk6WeFwli8Dy60My1cKNa1lcOVVmttrC5NldA0up7a XMveBmo+rRbHWObiGOo5kmMjJgm22LmmCICw+5gUuaCfmD9Oo96jTFMWtWh9i5fNESmp m+Hl7Q7znfiNJmktTCTXBVATWnJQLp4Zmbyql63BPkuogtleXUxXRHJjjH3zpEdWsyuj n4kZdxFBi6DZhuzmfBeX3zudgmUbeiZaQASOXU73HaZ+/iJKdjhlGha7cYTuqkgpN0oq 2ldfkIRLetsIG7fjKFUaW+gTquSLck/3Zeosd5a67QxvO2cYSUNnW+AZP2wDWtXOE8pk fxLA== X-Gm-Message-State: AOJu0YzzKc8pxbk6YwzfypGkAlg87aHvoLZVhw04xfdDWp+X8M/aME5r E4bsiKDZYtV8b6bGx69ble+Fssd/2geFt9qxV8E= X-Google-Smtp-Source: AGHT+IFl6TJZcSBal5yZaoaTLe1xJU+eipZ/bZ0fA/7qmkLlWLniU/zZXosqIXujwh3OlvH5pT//WA== X-Received: by 2002:a05:6a20:1442:b0:14c:a53c:498e with SMTP id a2-20020a056a20144200b0014ca53c498emr2841900pzi.42.1694796166943; Fri, 15 Sep 2023 09:42:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 16/19] target/s390x: Use clmul_64 Date: Fri, 15 Sep 2023 09:42:28 -0700 Message-Id: <20230915164231.123580-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796191764100001 Use the generic routine for 64-bit carry-less multiply. Remove our local version of galois_multiply64. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/s390x/tcg/vec_int_helper.c | 58 +++++++------------------------ 1 file changed, 12 insertions(+), 46 deletions(-) diff --git a/target/s390x/tcg/vec_int_helper.c b/target/s390x/tcg/vec_int_h= elper.c index ba284b5379..b18d8a6d16 100644 --- a/target/s390x/tcg/vec_int_helper.c +++ b/target/s390x/tcg/vec_int_helper.c @@ -21,13 +21,6 @@ static bool s390_vec_is_zero(const S390Vector *v) return !v->doubleword[0] && !v->doubleword[1]; } =20 -static void s390_vec_xor(S390Vector *res, const S390Vector *a, - const S390Vector *b) -{ - res->doubleword[0] =3D a->doubleword[0] ^ b->doubleword[0]; - res->doubleword[1] =3D a->doubleword[1] ^ b->doubleword[1]; -} - static void s390_vec_and(S390Vector *res, const S390Vector *a, const S390Vector *b) { @@ -166,26 +159,6 @@ DEF_VCTZ(16) =20 /* like binary multiplication, but XOR instead of addition */ =20 -static S390Vector galois_multiply64(uint64_t a, uint64_t b) -{ - S390Vector res =3D {}; - S390Vector va =3D { - .doubleword[1] =3D a, - }; - S390Vector vb =3D { - .doubleword[1] =3D b, - }; - - while (!s390_vec_is_zero(&vb)) { - if (vb.doubleword[1] & 0x1) { - s390_vec_xor(&res, &res, &va); - } - s390_vec_shl(&va, &va, 1); - s390_vec_shr(&vb, &vb, 1); - } - return res; -} - /* * There is no carry across the two doublewords, so their order does * not matter. Nor is there partial overlap between registers. @@ -265,32 +238,25 @@ void HELPER(gvec_vgfma32)(void *v1, const void *v2, c= onst void *v3, void HELPER(gvec_vgfm64)(void *v1, const void *v2, const void *v3, uint32_t desc) { - S390Vector tmp1, tmp2; - uint64_t a, b; + uint64_t *q1 =3D v1; + const uint64_t *q2 =3D v2, *q3 =3D v3; + Int128 r; =20 - a =3D s390_vec_read_element64(v2, 0); - b =3D s390_vec_read_element64(v3, 0); - tmp1 =3D galois_multiply64(a, b); - a =3D s390_vec_read_element64(v2, 1); - b =3D s390_vec_read_element64(v3, 1); - tmp2 =3D galois_multiply64(a, b); - s390_vec_xor(v1, &tmp1, &tmp2); + r =3D int128_xor(clmul_64(q2[0], q3[0]), clmul_64(q2[1], q3[1])); + q1[0] =3D int128_gethi(r); + q1[1] =3D int128_getlo(r); } =20 void HELPER(gvec_vgfma64)(void *v1, const void *v2, const void *v3, const void *v4, uint32_t desc) { - S390Vector tmp1, tmp2; - uint64_t a, b; + uint64_t *q1 =3D v1; + const uint64_t *q2 =3D v2, *q3 =3D v3, *q4 =3D v4; + Int128 r; =20 - a =3D s390_vec_read_element64(v2, 0); - b =3D s390_vec_read_element64(v3, 0); - tmp1 =3D galois_multiply64(a, b); - a =3D s390_vec_read_element64(v2, 1); - b =3D s390_vec_read_element64(v3, 1); - tmp2 =3D galois_multiply64(a, b); - s390_vec_xor(&tmp1, &tmp1, &tmp2); - s390_vec_xor(v1, &tmp1, v4); + r =3D int128_xor(clmul_64(q2[0], q3[0]), clmul_64(q2[1], q3[1])); + q1[0] =3D q4[0] ^ int128_gethi(r); + q1[1] =3D q4[1] ^ int128_getlo(r); } =20 #define DEF_VMAL(BITS) = \ --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796262; cv=none; d=zohomail.com; s=zohoarc; b=NUfLw56LtG4SXfH2lYY3qMZHZo6MrdqaaatUPtoih6cykU7XPKNUBNM2r9U09ZMFoqYbIn4tUopLnwJ7m8WpJfQ8Pc+giuYgtExq13sR0FzxNVeSYghApAQFDhu/zh/x/1pRyo/lSU5bLWjkUGwhTlkya5kML9KRKt7V+QP8K/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796262; h=Content-Type: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=2Rw61LzYCVJHqZF5cECHlyAs/184pzzLTdpSydfaqRc=; b=cq76h3nzMdmGLXoHtGrisBBgHGO48+d+4f5tfRxYg5Bgg5+gWHR5Udhv3KJyGKh0w2ZRq6ewDURIqLLXeP5yXQqS8LkhppjJP3tvBbESgXiU/ISL4qj1fm9RO8Kqc92PsTj+TzGUKskOQmNiXe5Mr1F+cTS9O5ykeNlQ/2mKYyk= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796262845559.4337277179299; Fri, 15 Sep 2023 09:44:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBu9-0004XR-4z; Fri, 15 Sep 2023 12:42:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBu6-0004W5-Tc for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:50 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBu5-0004x6-GG for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:50 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-69042d398b1so989433b3a.0 for ; Fri, 15 Sep 2023 09:42:49 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796168; x=1695400968; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2Rw61LzYCVJHqZF5cECHlyAs/184pzzLTdpSydfaqRc=; b=LgM9q1o1ACtTVPeJnffKhNDMZzPVeM1QtgytIyhEsDkoJYB7208bUVxucr9Swpr3hT 1YHNHoiPxLh9ygVjzwzTPxE9J1UTYz6CkUqDlo3zedrSGazRwLcsn7I1xHBpbG/zFY4F Th/Mql75CYayuyQohw5ixcySO2OFoF3zBHtTGMEsDtjOHq/V1SgH9lJVzkymL5bXqwyK FpPbL1z0tlorxnkgHA0oAsDvscWfhtFck7U5CLaRrcv3/tik/HUz5/5XAX0W4VYNr3KT E1d/cgcWbFUCSbh7G1eo8OPku67RQTqlf0r7utDLm4ePX1k4kuGZ6x2PUI8DGKtdgPhp BuBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796168; x=1695400968; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2Rw61LzYCVJHqZF5cECHlyAs/184pzzLTdpSydfaqRc=; b=VnyzUTFItrfU5qqzIcKlQuGP5l/Ebb7os2VI6kNiybJVf+HRRMdnJXrPgSm85BKJ+D mAKAVSD3eBG5Na0e99dSUPG2ax9o5eefsc+xzyX+fcPx3ClusqjLDMV8MApgZbf87Lda l38rNlMWiutGIIqSaxQKhCkHnyPOzZcrEa7001EFuJuqHs3LbbmtKfljYLRl520Mq2tL noImBWR3JaMVoqvkMJTdWp5S6jXatdkp2+hvNC3Z3cfAPirMpR4LXFAUWxfAaSriRQsd nGKeyf50BRP/gvTnOge3pUCO1AwPYYdOkGd2rUhLQCrkNEkyCBAGiGLXTr8DnzQ83s7O kjYg== X-Gm-Message-State: AOJu0YxAaqZQCr+Rg6/iBzXtIIH823UaAvK6kKvEfZKeseJSGm2kjG8g BoJ01UzKa76JqHcheFvsRs11oA/t+1ZhdjTfa94= X-Google-Smtp-Source: AGHT+IFQZYHt8jxpyREB+1wS77kYqEZQXNIAUyBR2IyGppMbui+wOOf4BXf3Nufka1keigJVYr98EQ== X-Received: by 2002:a05:6a21:47cb:b0:153:24c2:c93b with SMTP id as11-20020a056a2147cb00b0015324c2c93bmr2212368pzc.1.1694796167987; Fri, 15 Sep 2023 09:42:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 17/19] target/ppc: Use clmul_64 Date: Fri, 15 Sep 2023 09:42:29 -0700 Message-Id: <20230915164231.123580-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796264217100003 Use generic routine for 64-bit carry-less multiply. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/ppc/int_helper.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 1ea42b4ede..6fd00684a5 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -1455,20 +1455,9 @@ void helper_vpmsumw(ppc_avr_t *r, ppc_avr_t *a, ppc_= avr_t *b) =20 void helper_VPMSUMD(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) { - int i, j; - Int128 tmp, prod[2] =3D {int128_zero(), int128_zero()}; - - for (j =3D 0; j < 64; j++) { - for (i =3D 0; i < ARRAY_SIZE(r->u64); i++) { - if (a->VsrD(i) & (1ull << j)) { - tmp =3D int128_make64(b->VsrD(i)); - tmp =3D int128_lshift(tmp, j); - prod[i] =3D int128_xor(prod[i], tmp); - } - } - } - - r->s128 =3D int128_xor(prod[0], prod[1]); + Int128 e =3D clmul_64(a->u64[0], b->u64[0]); + Int128 o =3D clmul_64(a->u64[1], b->u64[1]); + r->s128 =3D int128_xor(e, o); } =20 #if HOST_BIG_ENDIAN --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796226; cv=none; d=zohomail.com; s=zohoarc; b=QvueNhJW5DxDzkeVRAPjEgwLgNVHtb0nAHJYdUlqbDSWoNTTITcz7Cg09CJIkJXUQtHdi1is6xeDgfI26RhZkWilXV/QGDOsG9d/ZA/Srx5nXN3u04kzQQHEG5JuIpLBPAJ7NrSMpsZsyKM5kOJaLGTLGShRzIurLAYzvfF31pY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796226; 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=+M2eLP1MxR8ITUHAyqevQXr9QFlyFahQKSge9OJBONo=; b=W5G9NkoBZ5a8L/3ni8L9HoIe5/3ecA3ZV9GgqRnH+s8u72bNcq5t83W1lzeonj9MZ0+w2vNSigtwe79lTgXFfhEZQAlHXtbeWE+zlzGFBnRlAJJpTyH3AIhrih/VJUgtJupiz+bNyQPUsKRzNXPFMl+PrV1mV4uI0qVH/WbceIQ= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169479622637015.102980392270979; Fri, 15 Sep 2023 09:43:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBu9-0004Xk-NM; Fri, 15 Sep 2023 12:42:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBu7-0004WU-Pk for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:51 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBu6-0004xJ-67 for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:51 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-68fc1bbc94eso2018006b3a.3 for ; Fri, 15 Sep 2023 09:42:49 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796169; x=1695400969; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+M2eLP1MxR8ITUHAyqevQXr9QFlyFahQKSge9OJBONo=; b=vZjifz+tfhcOdUjJoAeQUXBlEao50fxlO8brSd24jT9+yf80gl59kdpx1PDzd+Pfpo 2PfDPepM9h0WgINr2mpUYc5w61QUV8WkkFuafsXKZtnf7OJck28bKa2K5vZnps9R8H55 tOMgk8u28gHWrMVb7SnbfD81ooIRNVXWoxIm2PaVeEhte48z025PaO3V+4jPjNKM15nr rE6Yv9TdIQ9+AcjMdLUfAlQTzM4h8KybtmZgX9dzxh55UPo+fs3mqJinTlVeLaTSR+gs UD9UxPFx92PBhql/X9dafNuGopCVmI0+slCjBq2SEiCHLxwr4l5r1FgrLyeEuafa4ivJ mq7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796169; x=1695400969; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+M2eLP1MxR8ITUHAyqevQXr9QFlyFahQKSge9OJBONo=; b=uO0PfmSEYPkdb4/N83+OfqLR4nzmcD0Sr2cHA3b8Fkp8am0/yMEp2arZZT1jRHm3Ck a6NfwGO0naLZuZF2t9YxZPp1EiRLJ63EdYUXihs4d8Gb5850dlTFiibjBoILPLBIJuzZ jn+ZiiF14Q1tncrhAynHY4uKTZ+6tYhYCo76W1gbsxBF/2xoHQoAw8Z4uSic5m0M/DzH WURfyysnMS0LhLucOgxWoAtN3oU6MLHzIvZzxBgzV6BQ1LhCN8opf0SDSvD0TsGk0kxl KLNreHNw7psJYj8Vf/LKK6YhjjwvH1H0dwHm4NLXGcuAyxC32TbNfDnh+Xphcsox8WsQ 1yyQ== X-Gm-Message-State: AOJu0YynMDf+Xhf2Xqw2q2kMYwz0dAbluHz3uaEnJWf2XX0ZZ9oK9/ev kBBkB6gWaHqjuAves7WauOENhlkQjaUMWw3aOMs= X-Google-Smtp-Source: AGHT+IHnv95qoNqNd6dMBhTQm4EtFGdgRyz4vUJIsrQQLP4S1JB25heoKGGIUdfItyB6ZHxEYKdKFA== X-Received: by 2002:a05:6a20:12ca:b0:131:a21:9f96 with SMTP id v10-20020a056a2012ca00b001310a219f96mr2914813pzg.6.1694796168907; Fri, 15 Sep 2023 09:42:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ard Biesheuvel Subject: [PULL 18/19] host/include/i386: Implement clmul.h Date: Fri, 15 Sep 2023 09:42:30 -0700 Message-Id: <20230915164231.123580-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-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::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796227104100003 Content-Type: text/plain; charset="utf-8" Detect PCLMUL in cpuinfo; implement the accel hook. Reviewed-by: Ard Biesheuvel Signed-off-by: Richard Henderson --- host/include/i386/host/cpuinfo.h | 1 + host/include/i386/host/crypto/clmul.h | 29 +++++++++++++++++++++++++ host/include/x86_64/host/crypto/clmul.h | 1 + include/qemu/cpuid.h | 3 +++ util/cpuinfo-i386.c | 1 + 5 files changed, 35 insertions(+) create mode 100644 host/include/i386/host/crypto/clmul.h create mode 100644 host/include/x86_64/host/crypto/clmul.h diff --git a/host/include/i386/host/cpuinfo.h b/host/include/i386/host/cpui= nfo.h index 073d0a426f..7ae21568f7 100644 --- a/host/include/i386/host/cpuinfo.h +++ b/host/include/i386/host/cpuinfo.h @@ -27,6 +27,7 @@ #define CPUINFO_ATOMIC_VMOVDQA (1u << 16) #define CPUINFO_ATOMIC_VMOVDQU (1u << 17) #define CPUINFO_AES (1u << 18) +#define CPUINFO_PCLMUL (1u << 19) =20 /* Initialized with a constructor. */ extern unsigned cpuinfo; diff --git a/host/include/i386/host/crypto/clmul.h b/host/include/i386/host= /crypto/clmul.h new file mode 100644 index 0000000000..dc3c814797 --- /dev/null +++ b/host/include/i386/host/crypto/clmul.h @@ -0,0 +1,29 @@ +/* + * x86 specific clmul acceleration. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef X86_HOST_CRYPTO_CLMUL_H +#define X86_HOST_CRYPTO_CLMUL_H + +#include "host/cpuinfo.h" +#include + +#if defined(__PCLMUL__) +# define HAVE_CLMUL_ACCEL true +# define ATTR_CLMUL_ACCEL +#else +# define HAVE_CLMUL_ACCEL likely(cpuinfo & CPUINFO_PCLMUL) +# define ATTR_CLMUL_ACCEL __attribute__((target("pclmul"))) +#endif + +static inline Int128 ATTR_CLMUL_ACCEL +clmul_64_accel(uint64_t n, uint64_t m) +{ + union { __m128i v; Int128 s; } u; + + u.v =3D _mm_clmulepi64_si128(_mm_set_epi64x(0, n), _mm_set_epi64x(0, m= ), 0); + return u.s; +} + +#endif /* X86_HOST_CRYPTO_CLMUL_H */ diff --git a/host/include/x86_64/host/crypto/clmul.h b/host/include/x86_64/= host/crypto/clmul.h new file mode 100644 index 0000000000..f25eced416 --- /dev/null +++ b/host/include/x86_64/host/crypto/clmul.h @@ -0,0 +1 @@ +#include "host/include/i386/host/crypto/clmul.h" diff --git a/include/qemu/cpuid.h b/include/qemu/cpuid.h index 35325f1995..b11161555b 100644 --- a/include/qemu/cpuid.h +++ b/include/qemu/cpuid.h @@ -25,6 +25,9 @@ #endif =20 /* Leaf 1, %ecx */ +#ifndef bit_PCLMUL +#define bit_PCLMUL (1 << 1) +#endif #ifndef bit_SSE4_1 #define bit_SSE4_1 (1 << 19) #endif diff --git a/util/cpuinfo-i386.c b/util/cpuinfo-i386.c index b2ed65bb10..9fddb18303 100644 --- a/util/cpuinfo-i386.c +++ b/util/cpuinfo-i386.c @@ -39,6 +39,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void) info |=3D (c & bit_SSE4_1 ? CPUINFO_SSE4 : 0); info |=3D (c & bit_MOVBE ? CPUINFO_MOVBE : 0); info |=3D (c & bit_POPCNT ? CPUINFO_POPCNT : 0); + info |=3D (c & bit_PCLMUL ? CPUINFO_PCLMUL : 0); =20 /* Our AES support requires PSHUFB as well. */ info |=3D ((c & bit_AES) && (c & bit_SSSE3) ? CPUINFO_AES : 0); --=20 2.34.1 From nobody Fri May 17 07:56:01 2024 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=1694796216; cv=none; d=zohomail.com; s=zohoarc; b=GrPv9JmZ6NQsqxg/w4B/PaOQK0baSeUDkX0Jz5KYE5KR4pH4LCT15tgqg6QJd0ygsAMXoaGTqYkGBSAGLxjIgj3xiZvdt+dZmNzu+b3+AqI/Zz3AeVbJG52mhoLTHQtzMrOsToMW4KZHrqaV3hCcXapVubsUautHYUtMblmAPWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694796216; h=Content-Type: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=26aP/OX6idfw5HUk5RP35KGUcj8QnPWK4lUzZokYGcA=; b=h4Cwo2NpQ5uJ1glK0zuU7czRE3cByC0gPeWap+70TLMZTHqyrcGTse2rBFUzj6LD8ej+1LPCl4q93QnfgmH37lWC/xF9L15ZPF/5Of1V+4Usia9OQZGPpXs5Ol9F3LH0VGTRV/i5BjRH6GOhXSrQ9YXVrY0VFgaXPtSzRwkqw/k= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694796216441293.59527598966633; Fri, 15 Sep 2023 09:43:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhBuB-0004Yc-Rj; Fri, 15 Sep 2023 12:42:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhBu9-0004Xj-Jh for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:53 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhBu8-0004xU-0S for qemu-devel@nongnu.org; Fri, 15 Sep 2023 12:42:53 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-68fb898ab3bso1947820b3a.3 for ; Fri, 15 Sep 2023 09:42:50 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id s187-20020a6377c4000000b00577f55e4a4esm3010087pgc.20.2023.09.15.09.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 09:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694796170; x=1695400970; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=26aP/OX6idfw5HUk5RP35KGUcj8QnPWK4lUzZokYGcA=; b=X9mwh62IZxuK6sgKwMAEMThT2Q2HOdpw6zWO1obfjuriIklwrf6U15lGjRr64hVxzr r0ZeOYuRnt3DN7qpM018Bdoul87RPhTijX6l4KJaWpVjWXQYTMRLyL1UGOSxlSGlD7CV 9tvBoc2UbbBbrbe+SZZE+6d7xn3tZNGtLBJ6+jKfZRJDcBPpRrrnLSM1ICVb9bY67dPx UCJwTIqQE2M7WMD8LGjQEzFFWVTrAi3O/z2IQOwfsgVnyQL6epgptX7ZV+Aer2rQiOp2 eBusDAeRuFNlIU7O8yS6ae1VMUa7hnAnUEsQs7wUWJxMeXr3z7TE/31lSEokKFtZUhXF JxTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694796170; x=1695400970; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=26aP/OX6idfw5HUk5RP35KGUcj8QnPWK4lUzZokYGcA=; b=pgQuNIaKNzaE9pACGRnMuEZih0kRSrV4xm5kdNRx+Oi7nzSX6d7gzs2eNgzPsA0Jly 97IcS3dP5DtUkGs2cn02jJatxHqbmW3H8K2MIR/RGOZNuzWmlxZZ7Pq+sjlsV20etAZY qZx1LocpT2uAQBrFG+AaRezQc6laUYdgS06tgeD1d36D+vTHwvj9WF6XjBKmEgOgJP7q 6075J2pbcAaoVCN5b334FXrEw3WHSMh9LaexWJhzeDEzRovtRTTpFVcIEKz6XzzUS6Hd 1DMJqDW7pBFNB7l8qTneCele3KrH9wQIERujRGls0O1yFLvSW0O5RD42oH6/o4OdgzzE YjCQ== X-Gm-Message-State: AOJu0Yx0jCNEfZWsUOCM4TRWpoz7zLJd4yn68LHP2P4hfL1j7OUXiqem mehcfIAaaV+YfBU+zLCvnyjNCu2A6gLNuBEVo+k= X-Google-Smtp-Source: AGHT+IFIyGfVZHpmydkqY8z+BBWKEBOocy5RDvhZpwqYX5xgKshexysYtC2ut2GielNI94U+UkUGXw== X-Received: by 2002:a05:6a20:1581:b0:148:f16f:113f with SMTP id h1-20020a056a20158100b00148f16f113fmr2735613pzj.12.1694796169829; Fri, 15 Sep 2023 09:42:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ard Biesheuvel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 19/19] host/include/aarch64: Implement clmul.h Date: Fri, 15 Sep 2023 09:42:31 -0700 Message-Id: <20230915164231.123580-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915164231.123580-1-richard.henderson@linaro.org> References: <20230915164231.123580-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1694796216969100007 Detect PMULL in cpuinfo; implement the accel hook. Acked-by: Ard Biesheuvel Tested-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- host/include/aarch64/host/cpuinfo.h | 1 + host/include/aarch64/host/crypto/clmul.h | 41 ++++++++++++++++++++++++ util/cpuinfo-aarch64.c | 4 ++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 host/include/aarch64/host/crypto/clmul.h diff --git a/host/include/aarch64/host/cpuinfo.h b/host/include/aarch64/hos= t/cpuinfo.h index 769626b098..fe8c3b3fd1 100644 --- a/host/include/aarch64/host/cpuinfo.h +++ b/host/include/aarch64/host/cpuinfo.h @@ -10,6 +10,7 @@ #define CPUINFO_LSE (1u << 1) #define CPUINFO_LSE2 (1u << 2) #define CPUINFO_AES (1u << 3) +#define CPUINFO_PMULL (1u << 4) =20 /* Initialized with a constructor. */ extern unsigned cpuinfo; diff --git a/host/include/aarch64/host/crypto/clmul.h b/host/include/aarch6= 4/host/crypto/clmul.h new file mode 100644 index 0000000000..bb516d8b2f --- /dev/null +++ b/host/include/aarch64/host/crypto/clmul.h @@ -0,0 +1,41 @@ +/* + * AArch64 specific clmul acceleration. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef AARCH64_HOST_CRYPTO_CLMUL_H +#define AARCH64_HOST_CRYPTO_CLMUL_H + +#include "host/cpuinfo.h" +#include + +/* + * 64x64->128 pmull is available with FEAT_PMULL. + * Both FEAT_AES and FEAT_PMULL are covered under the same macro. + */ +#ifdef __ARM_FEATURE_AES +# define HAVE_CLMUL_ACCEL true +#else +# define HAVE_CLMUL_ACCEL likely(cpuinfo & CPUINFO_PMULL) +#endif +#if !defined(__ARM_FEATURE_AES) && defined(CONFIG_ARM_AES_BUILTIN) +# define ATTR_CLMUL_ACCEL __attribute__((target("+crypto"))) +#else +# define ATTR_CLMUL_ACCEL +#endif + +static inline Int128 ATTR_CLMUL_ACCEL +clmul_64_accel(uint64_t n, uint64_t m) +{ + union { poly128_t v; Int128 s; } u; + +#ifdef CONFIG_ARM_AES_BUILTIN + u.v =3D vmull_p64((poly64_t)n, (poly64_t)m); +#else + asm(".arch_extension aes\n\t" + "pmull %0.1q, %1.1d, %2.1d" : "=3Dw"(u.v) : "w"(n), "w"(m)); +#endif + return u.s; +} + +#endif /* AARCH64_HOST_CRYPTO_CLMUL_H */ diff --git a/util/cpuinfo-aarch64.c b/util/cpuinfo-aarch64.c index 7d39f47e3b..e0e1fe6071 100644 --- a/util/cpuinfo-aarch64.c +++ b/util/cpuinfo-aarch64.c @@ -56,12 +56,14 @@ unsigned __attribute__((constructor)) cpuinfo_init(void) unsigned long hwcap =3D qemu_getauxval(AT_HWCAP); info |=3D (hwcap & HWCAP_ATOMICS ? CPUINFO_LSE : 0); info |=3D (hwcap & HWCAP_USCAT ? CPUINFO_LSE2 : 0); - info |=3D (hwcap & HWCAP_AES ? CPUINFO_AES: 0); + info |=3D (hwcap & HWCAP_AES ? CPUINFO_AES : 0); + info |=3D (hwcap & HWCAP_PMULL ? CPUINFO_PMULL : 0); #endif #ifdef CONFIG_DARWIN info |=3D sysctl_for_bool("hw.optional.arm.FEAT_LSE") * CPUINFO_LSE; info |=3D sysctl_for_bool("hw.optional.arm.FEAT_LSE2") * CPUINFO_LSE2; info |=3D sysctl_for_bool("hw.optional.arm.FEAT_AES") * CPUINFO_AES; + info |=3D sysctl_for_bool("hw.optional.arm.FEAT_PMULL") * CPUINFO_PMUL= L; #endif =20 cpuinfo =3D info; --=20 2.34.1