From nobody Sun Feb 8 18:32:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1653299600; cv=none; d=zohomail.com; s=zohoarc; b=Ef48veDhtBL9Y4imCRvAWsjLzpbsUxqM6NsTlHLAnamvaQ8rLt27r32ITSVS8x1TgcdIQ+xlsVEZS651jS589uIjrd6+6f6V8bfrJw6DjXnFuJTXtcNl+yTi/0GDConJy6AEy2/aUuZlxKpXvyrxGJ98PJ3f6wzxyrZ/Wbfm5LI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653299600; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iQzETUrGEwrE0o1SuHsu27XZmv9ShyIbC2qlj/Imr2c=; b=VgZN+8N4vapU/sgVECe5GkJ6modqpbMnsf14LoxMDEtfrwZAAKhtTiEMw7vbJeCgx/Tv6yAqklAMOV0XlraTMQeVYeLYerywLw02seZAscws5WohSWjCNCvGHQWxDEy2B0sD8zz2pi3K0BnBv+Xm6/gjIycrmqRI3jUsYxq1fXY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1653299600883570.4488650650686; Mon, 23 May 2022 02:53:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.335658.559853 (Exim 4.92) (envelope-from ) id 1nt4k6-0003Kr-2Y; Mon, 23 May 2022 09:52:50 +0000 Received: by outflank-mailman (output) from mailman id 335658.559853; Mon, 23 May 2022 09:52:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nt4k5-0003Ip-Qw; Mon, 23 May 2022 09:52:49 +0000 Received: by outflank-mailman (input) for mailman id 335658; Mon, 23 May 2022 09:52:48 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nt4k4-0002dp-3K for xen-devel@lists.xenproject.org; Mon, 23 May 2022 09:52:48 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 182efc9e-da7e-11ec-837e-e5687231ffcc; Mon, 23 May 2022 11:52:45 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 182efc9e-da7e-11ec-837e-e5687231ffcc DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1653299565; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PIpXZNS/tomnFn9AY0+D+Gnk6UU+fhiL/46ZWzyvQm8=; b=CzZPOP/xt3g7MVprCG/6/Q6FBMqKgUlrOx/69ekjQmRVXp3PqvZ69z0a mjxFjYN7VE5VJP4r/A//mdoaDoWEdp6AaKK5aTDDzniGnu40srDrJk+F4 1KIzeCIZ3imrWpJgqCM842/eJ/X40WhDrEA450qaJj8MDtBUJzED7zFhL 4=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 74445149 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:LmU+9auhBGPlsTlAxMhLRG8udufnVEdeMUV32f8akzHdYApBsoF/q tZmKWCBM/2LYDake9l1atm2o0tXupLXzNNkHgZkqS8zQy1H+JbJXdiXEBz9bniYRiHhoOOLz Cm8hv3odp1coqr0/0/1WlTZhSAgk/nOHNIQMcacUsxLbVYMpBwJ1FQywobVvqYy2YLjW17X4 ouryyHiEATNNwBcYzp8B52r8HuDjNyq0N/PlgVjDRzjlAa2e0g9VPrzF4noR5fLatA88tqBb /TC1NmEElbxpH/BPD8HfoHTKSXmSpaKVeSHZ+E/t6KK2nCurQRquko32WZ1he66RFxlkvgoo Oihu6BcRi8ZGIfXo/Q5bSJXKC4kE790wJn6eymg5Jn7I03uKxMAwt1rBUAye4YZ5vx2ESdF8 vlwxDIlN07ZwbjsmfTiF7cq1p9LwMrDZevzvllkzDefCfc7aZvCX7/L9ZlT2zJYasVmQqqCO 5dANWsHgBLoeB5EPmUQK8oEsdyhgHr5TxdBlxWxnP9ii4TU5FMoi+W8WDbPQfSRXtlclEuco mPA/kz6DwscOdjZziCKmlqum+vOkCXTSI8UUrqi+ZZCn1m71mEVThoMWjOTsfS/z0KzRd9bA 0gV4TY167g/8lSxSdvwVAH+p2SL1jYeUddNF+wx6CmW17HZpQ2eAwAsRDNbdMYvssNwQDUwz 0KIhPvgHzkpu7qQIU9x7Z/N82n0Y3JMazZfO2lUFmPp/uUPvqkDqDjUdcZHLpW6tdKvNyPC+ xa39nkh0uB7YdEw60mrwbzWq2vy+8OTFV5lvV+/snGNtV0gOtP8D2C8wR2CtKsbct7EJrWUl CJc8/Vy+tziGn1keMalZOwWVI+k6P+eWNE3qQ4+RsJxn9hBFpPKQGyx3N2dDB0wWir8UWW1C HI/QCsIjHOpAFOkbLVsf6W6ANkwwK7rGLzND66JNYASPsQoLlferEmCgHJ8OEi0zSARfVwXY 8/HIa5A815EYUiY8NZGb7hEiuJ6rszP7WjSWYr633yaPUm2PRaopUM+GALWNIgRtfrcyC2Mq oY3H5bbkH13DbyhChQ7BKZOdDjm21BgXcCowyGWH8beSjdb9JYJUK+Aneh7ItU690mX/8+Rl kyAtoZj4AKXrRX6xc+iMxiPtJuHsU5DkE8G IronPort-HdrOrdr: A9a23:iFmkQqolqa4LfMCLd2rCiLgaV5oTeYIsimQD101hICG8cqSj+f xG+85rsyMc6QxhIE3I9urhBEDtex/hHNtOkOws1NSZLW7bUQmTXeJfBOLZqlWKcUDDH6xmpM NdmsBFeaTN5DNB7PoSjjPWLz9Z+qjkzJyV X-IronPort-AV: E=Sophos;i="5.91,246,1647316800"; d="scan'208";a="74445149" From: Lin Liu To: CC: Lin Liu , Jan Beulich , "Andrew Cooper" , George Dunlap , Julien Grall , Bertrand Marquis , Stefano Stabellini , Wei Liu Subject: [PATCH v4 2/6] crypto/vmac: Simplify code with byteswap Date: Mon, 23 May 2022 05:52:18 -0400 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1653299602405100001 Content-Type: text/plain; charset="utf-8" This file has its own implementation of swap bytes. Clean up the code with xen/byteswap.h. No functional change. Signed-off-by: Lin Liu Acked-by: Jan Beulich Reviewed-by: Andrew Cooper --- Cc: Andrew Cooper Cc: George Dunlap Cc: Jan Beulich Cc: Julien Grall Cc: Bertrand Marquis Cc: Stefano Stabellini Cc: Wei Liu ---- xen/crypto/vmac.c | 76 ++--------------------------------------------- 1 file changed, 3 insertions(+), 73 deletions(-) diff --git a/xen/crypto/vmac.c b/xen/crypto/vmac.c index 294dd16a52..acb4e015f5 100644 --- a/xen/crypto/vmac.c +++ b/xen/crypto/vmac.c @@ -8,6 +8,7 @@ =20 /* start for Xen */ #include +#include #include #include #include @@ -50,7 +51,6 @@ const uint64_t mpoly =3D UINT64_C(0x1fffffff1fffffff); /= * Poly key mask */ * MUL64: 64x64->128-bit multiplication * PMUL64: assumes top bits cleared on inputs * ADD128: 128x128->128-bit addition - * GET_REVERSED_64: load and byte-reverse 64-bit word =20 * -----------------------------------------------------------------------= */ =20 /* -----------------------------------------------------------------------= */ @@ -68,22 +68,6 @@ const uint64_t mpoly =3D UINT64_C(0x1fffffff1fffffff); = /* Poly key mask */ =20 #define PMUL64 MUL64 =20 -#define GET_REVERSED_64(p) \ - ({uint64_t x; \ - asm ("bswapq %0" : "=3Dr" (x) : "0"(*(uint64_t *)(p))); x;}) - -/* -----------------------------------------------------------------------= */ -#elif (__GNUC__ && __i386__) -/* -----------------------------------------------------------------------= */ - -#define GET_REVERSED_64(p) \ - ({ uint64_t x; \ - uint32_t *tp =3D (uint32_t *)(p); = \ - asm ("bswap %%edx\n\t" \ - "bswap %%eax" \ - : "=3DA"(x) = \ - : "a"(tp[1]), "d"(tp[0])); \ - x; }) =20 /* -----------------------------------------------------------------------= */ #elif (__GNUC__ && __ppc64__) @@ -103,37 +87,6 @@ const uint64_t mpoly =3D UINT64_C(0x1fffffff1fffffff); = /* Poly key mask */ =20 #define PMUL64 MUL64 =20 -#define GET_REVERSED_64(p) \ - ({ uint32_t hi, lo, *_p =3D (uint32_t *)(p); = \ - asm volatile ("lwbrx %0, %1, %2" : "=3Dr"(lo) : "b%"(0), "r"(_p) );= \ - asm volatile ("lwbrx %0, %1, %2" : "=3Dr"(hi) : "b%"(4), "r"(_p) );= \ - ((uint64_t)hi << 32) | (uint64_t)lo; } ) - -/* -----------------------------------------------------------------------= */ -#elif (__GNUC__ && (__ppc__ || __PPC__)) -/* -----------------------------------------------------------------------= */ - -#define GET_REVERSED_64(p) \ - ({ uint32_t hi, lo, *_p =3D (uint32_t *)(p); = \ - asm volatile ("lwbrx %0, %1, %2" : "=3Dr"(lo) : "b%"(0), "r"(_p) );= \ - asm volatile ("lwbrx %0, %1, %2" : "=3Dr"(hi) : "b%"(4), "r"(_p) );= \ - ((uint64_t)hi << 32) | (uint64_t)lo; } ) - -/* -----------------------------------------------------------------------= */ -#elif (__GNUC__ && (__ARMEL__ || __ARM__)) -/* -----------------------------------------------------------------------= */ - -#define bswap32(v) \ -({ uint32_t tmp,out; \ - asm volatile( \ - "eor %1, %2, %2, ror #16\n" \ - "bic %1, %1, #0x00ff0000\n" \ - "mov %0, %2, ror #8\n" \ - "eor %0, %0, %1, lsr #8" \ - : "=3Dr" (out), "=3D&r" (tmp) = \ - : "r" (v)); \ - out;}) - /* -----------------------------------------------------------------------= */ #elif _MSC_VER /* -----------------------------------------------------------------------= */ @@ -154,11 +107,6 @@ const uint64_t mpoly =3D UINT64_C(0x1fffffff1fffffff);= /* Poly key mask */ (rh) +=3D (ih) + ((rl) < (_il)); \ } =20 -#if _MSC_VER >=3D 1300 -#define GET_REVERSED_64(p) _byteswap_uint64(*(uint64_t *)(p)) -#pragma intrinsic(_byteswap_uint64) -#endif - #if _MSC_VER >=3D 1400 && \ (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >=3D 1000) #define MUL32(i1,i2) (__emulu((uint32_t)(i1),(uint32_t)(i2))) @@ -219,24 +167,6 @@ const uint64_t mpoly =3D UINT64_C(0x1fffffff1fffffff);= /* Poly key mask */ } #endif =20 -#ifndef GET_REVERSED_64 -#ifndef bswap64 -#ifndef bswap32 -#define bswap32(x) \ - ({ uint32_t bsx =3D (x); = \ - ((((bsx) & 0xff000000u) >> 24) | (((bsx) & 0x00ff0000u) >> 8) | \ - (((bsx) & 0x0000ff00u) << 8) | (((bsx) & 0x000000ffu) << 24)); }) -#endif -#define bswap64(x) \ - ({ union { uint64_t ll; uint32_t l[2]; } w, r; \ - w.ll =3D (x); = \ - r.l[0] =3D bswap32 (w.l[1]); = \ - r.l[1] =3D bswap32 (w.l[0]); = \ - r.ll; }) -#endif -#define GET_REVERSED_64(p) bswap64(*(uint64_t *)(p))=20 -#endif - /* -----------------------------------------------------------------------= */ =20 #if (VMAC_PREFER_BIG_ENDIAN) @@ -247,9 +177,9 @@ const uint64_t mpoly =3D UINT64_C(0x1fffffff1fffffff); = /* Poly key mask */ =20 #if (VMAC_ARCH_BIG_ENDIAN) # define get64BE(ptr) (*(uint64_t *)(ptr)) -# define get64LE(ptr) GET_REVERSED_64(ptr) +# define get64LE(ptr) bswap64(*(uint64_t *)(ptr)) #else /* assume little-endian */ -# define get64BE(ptr) GET_REVERSED_64(ptr) +# define get64BE(ptr) bswap64(*(uint64_t *)(ptr)) # define get64LE(ptr) (*(uint64_t *)(ptr)) #endif =20 --=20 2.27.0