From nobody Fri May 17 03:54:42 2024 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=1653299602; cv=none; d=zohomail.com; s=zohoarc; b=lOpKlLYxrzLt/izmLSHUSVpaNuEMaZ5l6dlip+BzVLPEVpy89E/0kmf8tPP1bR+7YKKq/JtcJuzNkcY78PgA1EENBB2UiA2eMqhLJWxZRlMdmL4NOV4VwhHtVxevOOubPdGrzsAM+bThgYLcUGkmIorW5fjdtP0zVZAlEkkLnM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653299602; 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=w7+PgKReGVoP7/OCZfC5C1/jLs2Ouh7WmcUwFvqpxB8=; b=CfxYMyXV9/2oiZY3r/41ApKJZkylhH3/6XIgDZcIPf39Sln+PL9Wr45TIkDw6mBp94aeDzSC2/GP+pvBJcsPbXREiNAgh599r4dtSOrKQ4zqlAKxAxT6Hdy4uz9WZREV34spsO5W7WfQsBj24tSDJrCZSw8/PzT9LxAC21Vmw4E= 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 1653299602705762.0221715239556; Mon, 23 May 2022 02:53:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.335654.559819 (Exim 4.92) (envelope-from ) id 1nt4k3-0002eH-Qc; Mon, 23 May 2022 09:52:47 +0000 Received: by outflank-mailman (output) from mailman id 335654.559819; Mon, 23 May 2022 09:52:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nt4k3-0002e5-LP; Mon, 23 May 2022 09:52:47 +0000 Received: by outflank-mailman (input) for mailman id 335654; Mon, 23 May 2022 09:52:46 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nt4k2-0002dq-JR for xen-devel@lists.xenproject.org; Mon, 23 May 2022 09:52:46 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 17077772-da7e-11ec-bd2c-47488cf2e6aa; Mon, 23 May 2022 11:52:44 +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: 17077772-da7e-11ec-bd2c-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1653299564; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JBHSAD2WTCaM2SftEiZKTTucLKJZ7SWdUx1sAhYs8n4=; b=QxBqD4z7V4hIPZGm2gS6+hxvm+wdFn6vbFnKD6expCN1NQZ/p8Zr1ddt StbtK/lW4Og1OR2Nwamk0ZwfYQ9yjegIAEkkO18IFrjZObIAAnt65NdBm wBeUU7oI/YjU7b38c8ZvjCal+IO3Xk7O412sXvTt/wwHkWtaCEBr2C4A8 Q=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 71787716 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:+h2RBK/CFFOuVFq8qCFsDrUDtX6TJUtcMsCJ2f8bNWPcYEJGY0x3z zQaWGDSO/7ZZzPzfNt+PY7g9x8Cup7cx4JjTwBt+y88E34SpcT7XtnIdU2Y0wF+jyHgoOCLy +1EN7Es+ehtFie0Si+Fa+Sn9T8mvU2xbuKU5NTsY0idfic5DnZ44f5fs7Rh2NQw3ILiW1rlV e7a+KUzBnf0g1aYDUpMg06zgEsHUCPa4W5wUvQWPJinjXeG/5UnJMt3yZKZdhMUdrJ8DO+iL 9sv+Znilo/vE7XBPfv++lrzWhVirrc/pmFigFIOM0SpqkAqSiDfTs/XnRfTAKtao2zhojx/9 DlCnayeaxU5BfDjodYidEVILy9SDfB//KCSdBBTseTLp6HHW37lwvEoB0AqJ4wIvO1wBAmi9 9RBdmpLNErawbvrnvTrEYGAhex6RCXvFIcevDdkzCzxBvc6W5HTBa7N4Le02R9v358eQqmHO aL1bxJgSRn/WR9IamxMEY09kvanuF64QSFx/Qf9Sa0fvDGIkV0ZPKLWGNjfd8GORM5Vtl2Fv W+A9GP8ajkYKdiexDyt4n+qwOjVkkvTR4Y6BLC+sPlwjzW7+GsXDxEHUEqhltOwgEW+RtF3J lQd/2wlqq1a3FymSJzxUgO1pFaAvwUAQJxAHusi8gaPx6HIpQGDCQAsVSVdYdYrsMs3Qz0C1 VKTmd7tQzt1v9W9Q3+H6q2dqz/0PCEPNHIDfgcNVw5D6N7myLzflTqWEIwlSvTsyISoR3egm FhmsRTSmZ0jo+wZx57m0mn1vBXwtqTHYj5o3wHICzfNAhxCWGK1W2C5wQGFsK0ad9bJFQPpU GsswJbHsr1XZX2ZvGnUGbhWQun0jxqQGGeE6WODCaXN4NhEF5SLWYlLqA9zK05yWirvUW+4O RSD0e+9CXI6AZdLUUOUS9joYyjS5fK8fekJr9iNBja0XrB/dRWc4AZlblOK0mbmnSAEyP9iY s3HLZr1Vy5DWcyLKQZaoM9EjNcWKt0WnzuPFfgXMTz5uVZhWJJlYehcawbfBgzIxKiFvB/U4 75i2ziikn1ivBnFSnCPq+Y7dAlSRVBiXMCeg5EGLYarf1s5cFzN/teMmNvNjaQ+x/QL/goJl 1ngMnJlJK3X3i2WdV7QMyk8AF4tNL4mxU8G0eUXFQ7A8xAejUyHsM/zq7NfkWEbydFe IronPort-HdrOrdr: A9a23:9Qjl8a7Y7RYnTc1JxwPXwPDXdLJyesId70hD6qhwISY6TiX+rb HWoB17726TtN9/YhEdcLy7VJVoBEmskKKdgrNhWotKPjOW21dARbsKheCJrgEIWReOktK1vZ 0QC5SWY+eQMbEVt6nHCXGDYrQd/OU= X-IronPort-AV: E=Sophos;i="5.91,246,1647316800"; d="scan'208";a="71787716" From: Lin Liu To: CC: Lin Liu , Andrew Cooper , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , George Dunlap , "Jan Beulich" , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v4 1/6] xen: implement byteswap Date: Mon, 23 May 2022 05:52:17 -0400 Message-ID: <89b15afe026a84748ac0d9ca28e8608085454e78.1653295437.git.lin.liu@citrix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1653299604186100011 swab() is massively over complicated and can be simplified by re-implementing using compiler builtins. The compilers provide builtin function to swap bytes. * gcc: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html * clang: https://clang.llvm.org/docs/LanguageExtensions.html This patch introduces a new byteswapping infrastructure in terms of compiler builtins and bswapXX(), so the swab() infrastructure can be retired. Signed-off-by: Lin Liu Reviewed-by: Andrew Cooper --- Cc: Stefano Stabellini Cc: Julien Grall Cc: Bertrand Marquis Cc: Volodymyr Babchuk Cc: Andrew Cooper Cc: George Dunlap Cc: Jan Beulich Cc: Wei Liu Cc: "Roger Pau Monn=C3=A9" Changes in v4: - Move `PASTE` definition to xen/compiler.h to support tools - Revert emacs magics Changes in v3: - Check __has_builtin instead of GNUC version=20 Changes in v2: - Add fallback for compilers without __builtin_bswap - Implement with plain C instead of macros --- xen/arch/arm/include/asm/byteorder.h | 6 ++- xen/arch/x86/include/asm/byteorder.h | 34 ++--------------- xen/include/xen/byteorder.h | 56 ++++++++++++++++++++++++++++ xen/include/xen/byteswap.h | 44 ++++++++++++++++++++++ xen/include/xen/compiler.h | 24 ++++++++++++ xen/include/xen/lib.h | 4 -- 6 files changed, 132 insertions(+), 36 deletions(-) create mode 100644 xen/include/xen/byteorder.h create mode 100644 xen/include/xen/byteswap.h diff --git a/xen/arch/arm/include/asm/byteorder.h b/xen/arch/arm/include/as= m/byteorder.h index 9c712c4788..b6a33b23c0 100644 --- a/xen/arch/arm/include/asm/byteorder.h +++ b/xen/arch/arm/include/asm/byteorder.h @@ -1,9 +1,11 @@ #ifndef __ASM_ARM_BYTEORDER_H__ #define __ASM_ARM_BYTEORDER_H__ =20 -#define __BYTEORDER_HAS_U64__ +#ifndef __BYTE_ORDER__ + #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ +#endif =20 -#include +#include =20 #endif /* __ASM_ARM_BYTEORDER_H__ */ /* diff --git a/xen/arch/x86/include/asm/byteorder.h b/xen/arch/x86/include/as= m/byteorder.h index 1f77e502a5..82aadee7bd 100644 --- a/xen/arch/x86/include/asm/byteorder.h +++ b/xen/arch/x86/include/asm/byteorder.h @@ -1,36 +1,10 @@ #ifndef __ASM_X86_BYTEORDER_H__ #define __ASM_X86_BYTEORDER_H__ =20 -#include -#include +#ifndef __BYTE_ORDER__ + #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ +#endif =20 -static inline __attribute_const__ __u32 ___arch__swab32(__u32 x) -{ - asm("bswap %0" : "=3Dr" (x) : "0" (x)); - return x; -} - -static inline __attribute_const__ __u64 ___arch__swab64(__u64 val) -{=20 - union {=20 - struct { __u32 a,b; } s; - __u64 u; - } v; - v.u =3D val; - asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1"=20 - : "=3Dr" (v.s.a), "=3Dr" (v.s.b)=20 - : "0" (v.s.a), "1" (v.s.b));=20 - return v.u; -}=20 - -/* Do not define swab16. Gcc is smart enough to recognize "C" version and - convert it into rotation or exhange. */ - -#define __arch__swab64(x) ___arch__swab64(x) -#define __arch__swab32(x) ___arch__swab32(x) - -#define __BYTEORDER_HAS_U64__ - -#include +#include =20 #endif /* __ASM_X86_BYTEORDER_H__ */ diff --git a/xen/include/xen/byteorder.h b/xen/include/xen/byteorder.h new file mode 100644 index 0000000000..2ec434e6a6 --- /dev/null +++ b/xen/include/xen/byteorder.h @@ -0,0 +1,56 @@ +#ifndef __XEN_BYTEORDER_H__ +#define __XEN_BYTEORDER_H__ + +#include + +#if __BYTE_ORDER__ =3D=3D __ORDER_LITTLE_ENDIAN__ + +# ifndef __LITTLE_ENDIAN +# define __LITTLE_ENDIAN 1234 +# endif + +# ifndef __LITTLE_ENDIAN_BITFIELD +# define __LITTLE_ENDIAN_BITFIELD +# endif + +# define cpu_to_le64(x) (x) +# define le64_to_cpu(x) (x) +# define cpu_to_le32(x) (x) +# define le32_to_cpu(x) (x) +# define cpu_to_le16(x) (x) +# define le16_to_cpu(x) (x) +# define cpu_to_be64(x) bswap64(x) +# define be64_to_cpu(x) bswap64(x) +# define cpu_to_be32(x) bswap32(x) +# define be32_to_cpu(x) bswap32(x) +# define cpu_to_be16(x) bswap16(x) +# define be16_to_cpu(x) bswap16(x) + +#elif __BYTE_ORDER__ =3D=3D __ORDER_BIG_ENDIAN__ + +# ifndef __BIG_ENDIAN +# define __BIG_ENDIAN 4321 +# endif + +# ifndef __BIG_ENDIAN_BITFIELD +# define __BIG_ENDIAN_BITFIELD +# endif + +# define cpu_to_le64(x) bswap64(x) +# define le64_to_cpu(x) bswap64(x) +# define cpu_to_le32(x) bswap32(x) +# define le32_to_cpu(x) bswap32(x) +# define cpu_to_le16(x) bswap16(x) +# define le16_to_cpu(x) bswap16(x) +# define cpu_to_be64(x) (x) +# define be64_to_cpu(x) (x) +# define cpu_to_be32(x) (x) +# define be32_to_cpu(x) (x) +# define cpu_to_be16(x) (x) +# define be16_to_cpu(x) (x) + +#else +# error "Unknown Endianness" +#endif /* __BYTE_ORDER__ */ + +#endif /* __XEN_BYTEORDER_H__ */ diff --git a/xen/include/xen/byteswap.h b/xen/include/xen/byteswap.h new file mode 100644 index 0000000000..d2e371fbe7 --- /dev/null +++ b/xen/include/xen/byteswap.h @@ -0,0 +1,44 @@ +#ifndef __XEN_BYTESWAP_H__ +#define __XEN_BYTESWAP_H__ + +#include +#include + +#if !__has_builtin(__builtin_bswap16) +static always_inline uint16_t __builtin_bswap16(uint16_t val) +{ + return ((val & 0x00FF) << 8) | ((val & 0xFF00) >> 8); +} +#endif + +#if !__has_builtin(__builtin_bswap32) +static always_inline uint32_t __builtin_bswap32(uint32_t val) +{ + return ((val & 0x000000FF) << 24) | + ((val & 0x0000FF00) << 8) | + ((val & 0x00FF0000) >> 8) | + ((val & 0xFF000000) >> 24); +} +#endif + +#if !__has_builtin(__builtin_bswap64) +static always_inline uint64_t __builtin_bswap64(uint64_t val) +{ + return ((val & 0x00000000000000FF) << 56) | + ((val & 0x000000000000FF00) << 40) | + ((val & 0x0000000000FF0000) << 24) | + ((val & 0x00000000FF000000) << 8) | + ((val & 0x000000FF00000000) >> 8) | + ((val & 0x0000FF0000000000) >> 24) | + ((val & 0x00FF000000000000) >> 40) | + ((val & 0xFF00000000000000) >> 56); +} +#endif + +#define bswap16(x) __builtin_bswap16(x) +#define bswap32(x) __builtin_bswap32(x) +#define bswap64(x) __builtin_bswap64(x) + +#define bswap_ul(x) PASTE(bswap,BITS_PER_LONG)(x) + +#endif /* __XEN_BYTESWAP_H__ */ diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h index 933aec09a9..ae029afa14 100644 --- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -185,4 +185,28 @@ # define CLANG_DISABLE_WARN_GCC_COMPAT_END #endif =20 +#ifndef __has_builtin +/* + * Backwards compatibility for GCC < 10. + * All supported versions of Clang support __has_builtin + * */ +#define __has_builtin(x) GCC_has ## x + +#define GCC_has__builtin_bswap16 (CONFIG_GCC_VERSION >=3D 40800) +#define GCC_has__builtin_bswap32 (CONFIG_GCC_VERSION >=3D 40400) +#define GCC_has__builtin_bswap64 (CONFIG_GCC_VERSION >=3D 40400) +#endif + +#ifndef __ORDER_LITTLE_ENDIAN__ +# define __ORDER_LITTLE_ENDIAN__ 1234 +#endif + +#ifndef __ORDER_BIG_ENDIAN__ +# define __ORDER_BIG_ENDIAN__ 4321 +#endif + +/* Indirect macros required for expanded argument pasting. */ +#define PASTE_(a, b) a ## b +#define PASTE(a, b) PASTE_(a, b) + #endif /* __LINUX_COMPILER_H */ diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index aab1fc7c4a..ebf2193569 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -15,10 +15,6 @@ #define count_args(args...) \ count_args_(., ## args, 8, 7, 6, 5, 4, 3, 2, 1, 0) =20 -/* Indirect macros required for expanded argument pasting. */ -#define PASTE_(a, b) a ## b -#define PASTE(a, b) PASTE_(a, b) - #define __STR(...) #__VA_ARGS__ #define STR(...) __STR(__VA_ARGS__) =20 --=20 2.27.0 From nobody Fri May 17 03:54:42 2024 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 From nobody Fri May 17 03:54:42 2024 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=1653299602; cv=none; d=zohomail.com; s=zohoarc; b=Za2vs/jYTvus0tdOuaBK4v7wpyVpSybHHL2qwC8tFRxQj4icCKxV/cg2wBQR4ZAYrAXz4wr7+svH0Rt4Nr4yhJJB3c4zbf3BZivXf7Ra3AZJ3kIqqv+a4HlGbEjdfr9csE+82A4oT8HyyJ/bqQVkp+dgaUn5cHtQ+SH40nGTooY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653299602; 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=OIGiVDs7mKhGYFyuxaTnTpkz+MiZOVy9sOGVWXOlMGI=; b=Iz/+mChETD31PuxQDJMPxyD3yyUWfB5+jt6aHNVY4aIvveoyvzdsGimwWHUL+PdWqHfdrvjI5xfp4a+1cGZKv/hJXDKXMCLM0RSkkEdkDasv1v/eHOfC7YU5+ztO5sCiTJqwxI8gH/n0L4zafFUB6tgUAYMQhpCfqiO2dQKzqYM= 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 1653299602289850.211618830886; Mon, 23 May 2022 02:53:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.335659.559865 (Exim 4.92) (envelope-from ) id 1nt4k6-0003Zb-RB; Mon, 23 May 2022 09:52:50 +0000 Received: by outflank-mailman (output) from mailman id 335659.559865; Mon, 23 May 2022 09:52:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nt4k6-0003Vx-Gi; Mon, 23 May 2022 09:52:50 +0000 Received: by outflank-mailman (input) for mailman id 335659; 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-ON 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 18e08260-da7e-11ec-837e-e5687231ffcc; Mon, 23 May 2022 11:52:46 +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: 18e08260-da7e-11ec-837e-e5687231ffcc DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1653299566; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YEOHu0aPYMpRRwah1nehuHESqF4dTCOGh65pg9RBCsU=; b=ag+m0g+QVMleGGMofc0dvnl/T+RVQW6LQuPsfTMXIHcSLU0+L+pN9b88 fXl7OrGEMBcKEbyV4EbNy305zTEnwL2IpBD+JmyqqYopEyaCk8F7L2aYX CpSRV2oAQYMU3tx05uvwdt/VrKnxEpIt6P9E5uwXxq8gjs/jFZUs4y1k2 s=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 74445150 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:rLCqU6jgwGWJxIN78pwa5VTYX161dBAKZh0ujC45NGQN5FlHY01je htvWjuAaf6KY2Kkeoh+aYSw8xlTvZ+ExtM1SgtpryljQXwb9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oDJ9CU6jefSLlbFILas1hpZHGeIcw98z0M68wIFqtQw24LhXlnW4 YqaT/D3YzdJ5RYlagr41IrbwP9flKyaVOQw5wFWiVhj5TcyplFNZH4tDfjZw0jQG+G4KtWSV efbpIxVy0uCl/sb5nFJpZ6gGqECaua60QFjERO6UYD66vRJjnRaPqrWqJPwwKqY4tmEt4kZ9 TlDiXC/YTcrI/Pdk7QQaDd/GgFvDINGv4D9HkHq5KR/z2WeG5ft6/BnDUVwNowE4OdnR2pJ8 JT0KhhUMErF3bjvhuvmFK883azPL+GyVG8bknVhy3fdDOsOSpHfWaTao9Rf2V/cg+gRQaqCO pNEMVKDajzJahEVFH0VOKsEo970qyfnUg1kkhW88P9fD2/7k1UqjemF3MDuUtaHX9lPl0CU4 GfP5X3kAwoyPcaajzGC9xqEuOjLmi/qXZMII5ex/PVqnV67y3QaDVsdUl7Tifukjk+zXfpPJ kpS/TAhxYAi+UruQtTjUhmQpH+fogVaS9dWC/c96gyG1uzT+QnxLnMfUjdLZdgitck3bT8nz FmEm5XuHzMHjVGOYSvDrPHO92r0YHVLaz9ZDcMZcecby+nhvd8ihULCdfhEGY6kv/P1Xg7K/ Anf+UDSmI4vYd43O7STpA6a2Gj39siSFGbZ9S2MADv7s1oRiJqNItXxtAOFtasowJOxFAHpg ZQSpySJAAni57mpnTfFfugCFarBCx2tYGyF2g4H83XMGl2QF5+fkWN4umgWyL9BaJpsRNMQS Ba7VfltzJFSJmC2SqR8fpi8Dc8npYC5S4m+DKyIMoMUOsEhHONiwM2JTRfNt10BbWB2yf1vU XtlWZjE4Ykm5VRPk2PtGrZ1PU4DzSEi32LDLa0XPDz+uYdykEW9EO9fWHPXN7hRxPrd8G39r ocEX+PXmko3bQELSnSOmWLlBQtSfSZT6FGfg5E/S9Nv1SI9SDB9UKWImOxJlk4Mt/09q9okN 0qVAidwoGcTT1WeQelWQhiPsI/SYKs= IronPort-HdrOrdr: A9a23:igdNq69rBSGM+tJcG0xuk+DgI+orL9Y04lQ7vn2YSXRuHPBw8P re+sjztCWE8Ar5N0tBpTntAsW9qDbnhPtICOoqTNCftWvdyQiVxehZhOOIqVDd8m/Fh4pgPM 9bAtFD4bbLbGSS4/yU3ODBKadD/OW6 X-IronPort-AV: E=Sophos;i="5.91,246,1647316800"; d="scan'208";a="74445150" From: Lin Liu To: CC: Lin Liu , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH v4 3/6] arm64/find_next_bit: Remove ext2_swab() Date: Mon, 23 May 2022 05:52:19 -0400 Message-ID: <906b399ee86969fb86304c60c3b725326620d50f.1653295437.git.lin.liu@citrix.com> 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: 1653299604158100010 Content-Type: text/plain; charset="utf-8" ext2 has nothing to do with this logic. Clean up the code with xen/byteswap.h which now has an unsigned long helper. No functional change. Signed-off-by: Lin Liu --- Cc: Stefano Stabellini Cc: Julien Grall Cc: Bertrand Marquis Cc: Volodymyr Babchuk --- xen/arch/arm/arm64/lib/find_next_bit.c | 36 +++++--------------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/xen/arch/arm/arm64/lib/find_next_bit.c b/xen/arch/arm/arm64/li= b/find_next_bit.c index 8ebf8bfe97..e3b3720ff4 100644 --- a/xen/arch/arm/arm64/lib/find_next_bit.c +++ b/xen/arch/arm/arm64/lib/find_next_bit.c @@ -161,30 +161,6 @@ EXPORT_SYMBOL(find_first_zero_bit); =20 #ifdef __BIG_ENDIAN =20 -/* include/linux/byteorder does not support "unsigned long" type */ -static inline unsigned long ext2_swabp(const unsigned long * x) -{ -#if BITS_PER_LONG =3D=3D 64 - return (unsigned long) __swab64p((u64 *) x); -#elif BITS_PER_LONG =3D=3D 32 - return (unsigned long) __swab32p((u32 *) x); -#else -#error BITS_PER_LONG not defined -#endif -} - -/* include/linux/byteorder doesn't support "unsigned long" type */ -static inline unsigned long ext2_swab(const unsigned long y) -{ -#if BITS_PER_LONG =3D=3D 64 - return (unsigned long) __swab64((u64) y); -#elif BITS_PER_LONG =3D=3D 32 - return (unsigned long) __swab32((u32) y); -#else -#error BITS_PER_LONG not defined -#endif -} - #ifndef find_next_zero_bit_le unsigned long find_next_zero_bit_le(const void *addr, unsigned long size, unsigned long offset) @@ -199,7 +175,7 @@ unsigned long find_next_zero_bit_le(const void *addr, u= nsigned size -=3D result; offset &=3D (BITS_PER_LONG - 1UL); if (offset) { - tmp =3D ext2_swabp(p++); + tmp =3D bswap_ul(*p++); tmp |=3D (~0UL >> (BITS_PER_LONG - offset)); if (size < BITS_PER_LONG) goto found_first; @@ -217,7 +193,7 @@ unsigned long find_next_zero_bit_le(const void *addr, u= nsigned } if (!size) return result; - tmp =3D ext2_swabp(p); + tmp =3D bswap_ul(*p); found_first: tmp |=3D ~0UL << size; if (tmp =3D=3D ~0UL) /* Are any bits zero? */ @@ -226,7 +202,7 @@ found_middle: return result + ffz(tmp); =20 found_middle_swap: - return result + ffz(ext2_swab(tmp)); + return result + ffz(bswap_ul(tmp)); } EXPORT_SYMBOL(find_next_zero_bit_le); #endif @@ -245,7 +221,7 @@ unsigned long find_next_bit_le(const void *addr, unsign= ed size -=3D result; offset &=3D (BITS_PER_LONG - 1UL); if (offset) { - tmp =3D ext2_swabp(p++); + tmp =3D bswap_ul(*p++); tmp &=3D (~0UL << offset); if (size < BITS_PER_LONG) goto found_first; @@ -264,7 +240,7 @@ unsigned long find_next_bit_le(const void *addr, unsign= ed } if (!size) return result; - tmp =3D ext2_swabp(p); + tmp =3D bswap_ul(*p); found_first: tmp &=3D (~0UL >> (BITS_PER_LONG - size)); if (tmp =3D=3D 0UL) /* Are any bits set? */ @@ -273,7 +249,7 @@ found_middle: return result + __ffs(tmp); =20 found_middle_swap: - return result + __ffs(ext2_swab(tmp)); + return result + __ffs(bswap_ul(tmp)); } EXPORT_SYMBOL(find_next_bit_le); #endif --=20 2.27.0 From nobody Fri May 17 03:54:42 2024 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=1653299601; cv=none; d=zohomail.com; s=zohoarc; b=mQQ+wtcaHx5kyVpFck5CHY9k02zCd9jef4zQKmawNpLKsU55lN9pf4pO1DXW5lDyxp1ywrLdGQrRZOGP+L9CkqYSVOTpn0TTRC11cBikdlsi2Z0BpfP8y4puj3yHUvY3444bhkbQZgPrRDr5xlxxBNesasAMbhdijqEwIeB7EEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653299601; 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=TEDfaFLjd7pLWBc2OS9Mggnkv3kO4NsOHz2lYu6vPho=; b=g5ewAPxGn1dATHIhM2wNpxOEXrqIi3k1K1mYIsKVFIXye5/W7IEsVoDzLqle3PpJpsNHCCgTIW9kpZk8puDpfqTdxSZ+1JmCooVFGTblO3c5rvD5Xr3oTusLRAuwDi3bTJoApmVvs3wq6V9Qio+7UcoIi0H3mRy0h3INwWIMH9s= 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 1653299601531415.9625920154265; Mon, 23 May 2022 02:53:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.335657.559847 (Exim 4.92) (envelope-from ) id 1nt4k5-0003Cf-Ks; Mon, 23 May 2022 09:52:49 +0000 Received: by outflank-mailman (output) from mailman id 335657.559847; 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-0003Bl-Dy; Mon, 23 May 2022 09:52:49 +0000 Received: by outflank-mailman (input) for mailman id 335657; Mon, 23 May 2022 09:52:47 +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 1nt4k3-0002dp-Ih for xen-devel@lists.xenproject.org; Mon, 23 May 2022 09:52:47 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 16ab978c-da7e-11ec-837e-e5687231ffcc; Mon, 23 May 2022 11:52:43 +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: 16ab978c-da7e-11ec-837e-e5687231ffcc DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1653299564; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=++cTDuCI2eUXrno3sLGrk+Z0rJmvgXXtlDQhmlqs4d8=; b=Ekg2mjOdfnMeNaz9GQ7soDSqN01naxIyr0zR6QQmK8KUxSn2c8iLF32U xnoZZ2RS7mDaPiM8mXZiTyjDtIXA38zH7p9XShqo7brg+3yOBdKx6wAbo /XxIv5PeRMpkXPZRCBj+iZJFIMv/5uoikST7N66F2pCzTPYeLirup8k61 M=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 71298197 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:Bagp7qPJz19mqCrvrR20l8FynXyQoLVcMsEvi/4bfWQNrUp0hTAPz zYWWT2FbqmDZDSgedEgOYqwoRhV75XRyd9kTAto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdleF+lH1dOKJQUBUjclkfJKlYAL/En03FFYMpBsJ00o5wbZk2NUw2LBVPivW0 T/Mi5yHULOa82Yc3lI8s8pvfzs24ZweEBtB1rAPTagjUG32zhH5P7pGTU2FFFPqQ5E8IwKPb 72rIIdVXI/u10xF5tuNyt4Xe6CRK1LYFVDmZnF+A8BOjvXez8CbP2lS2Pc0MC9qZzu1c99Z0 v9t77agUioVF4rSuNQFfyVyKCdMBPgTkFPHCSDXXc27ykTHdz3nwul0DVFwNoodkgp1KTgQr 7pCcmlLN03dwbLtqF64YrAEasALKMjteocep1lrzC3DDOZgSpfGK0nPzYABhmZg35ERdRrYT 4kUM2JkS0//WRdwfXUcE5IPveuDjXaqJlW0r3rK/PFqsgA/1jdZ0rLgLd7UcdyiXthOkwCTo Weu12bkBhAXMvSPxDzD9Wij7sfQmQvrVYRUE6e3ntZ6jVvWymENBRk+UVqgveL/mkO4Q8hYK UEf5mwpt6da3FewUtD3Uhm8oXiFlh0RQdxdF6s98g7l4qDZ+RqDD24ICDtIcsU7tdQeTCYvk FSOmrvU6SdH6ePPDyjHr/HN8G30aXN9wXI+iTEsVyElufPzu6wPpzXRbuZ7PJKftdvHIGSlq 9yVlxTSl4n/nOZSifjgpwuX02n2znTaZlVrv1uKBwpJ+is8Pdf4PNLwtDA3+N4adO6kok+9U G/ociR0xMQHFtmzmSOEW43h95n5tq/eYFUwbbOCdqTNFghBGFb5JOi8GBkkeC9U3j8sIFcFm nP7twJL/4N0N3C3d6JxaI/ZI510kPO6SYi5D6qMN4omjn1NmOivpXwGWKJt9zq1zBhEfV8XZ /93jvpA/V5FUP86nVJats8W0KMxxzBW+I8gbcmT8vhT6pLHPCT9Ye5caDOmN7lphIvZ8V692 4sOaKO3J+B3DbSWjt//qtZDczjn7BETWPjLliCgXrXTc1Y9Qjh4VJc8A9oJIuRYokicrc+Ql lnVZ6OS4ACXaaHvQelSVk1eVQ== IronPort-HdrOrdr: A9a23:UywuyaitvpBc9ry8dDDEPQ623nBQXuAji2hC6mlwRA09TySZ// rOoB19726MtN9xYgBapTnuAtjifZqxz/FICMwqTNOftWrdyQ2VxeNZnOnfKlTbckWUnIMw6U 4jSdkYNDSZNykDsS+Q2mmF+rgbruVviJrY4Nvj8w== X-IronPort-AV: E=Sophos;i="5.91,246,1647316800"; d="scan'208";a="71298197" From: Lin Liu To: CC: Lin Liu , Stefano Stabellini , Julien Grall , Bertrand Marquis , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu Subject: [PATCH v4 4/6] xen: Switch to byteswap Date: Mon, 23 May 2022 05:52:20 -0400 Message-ID: <3f8e73fdfb222b0d1ff391a18fa2a799f68a467c.1653295437.git.lin.liu@citrix.com> 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: 1653299602516100004 Content-Type: text/plain; charset="utf-8" Update to use byteswap to swap bytes. No functional change. Signed-off-by: Lin Liu --- Cc: Stefano Stabellini Cc: Julien Grall Cc: Bertrand Marquis Cc: Andrew Cooper Cc: George Dunlap Cc: Jan Beulich Cc: Wei Liu Changes in v4: - Revert the __force in type casting Changes in v3: - Update xen/common/device_tree.c to use be32_to_cpu - Keep const in type cast in unaligned.h --- xen/common/device_tree.c | 44 +++++++++++++++--------------- xen/common/libelf/libelf-private.h | 6 ++-- xen/common/xz/private.h | 2 +- xen/include/xen/unaligned.h | 12 ++++---- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 4aae281e89..70d3be3be6 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -171,7 +171,7 @@ bool_t dt_property_read_u32(const struct dt_device_node= *np, if ( !val || len < sizeof(*out_value) ) return 0; =20 - *out_value =3D be32_to_cpup(val); + *out_value =3D be32_to_cpu(*val); =20 return 1; } @@ -264,7 +264,7 @@ int dt_property_read_variable_u32_array(const struct dt= _device_node *np, =20 count =3D sz; while ( count-- ) - *out_values++ =3D be32_to_cpup(val++); + *out_values++ =3D be32_to_cpu(*val++); =20 return sz; } @@ -490,7 +490,7 @@ static int __dt_n_addr_cells(const struct dt_device_nod= e *np, bool_t parent) =20 ip =3D dt_get_property(np, "#address-cells", NULL); if ( ip ) - return be32_to_cpup(ip); + return be32_to_cpu(*ip); } while ( np->parent ); /* No #address-cells property for the root node */ return DT_ROOT_NODE_ADDR_CELLS_DEFAULT; @@ -507,7 +507,7 @@ int __dt_n_size_cells(const struct dt_device_node *np, = bool_t parent) =20 ip =3D dt_get_property(np, "#size-cells", NULL); if ( ip ) - return be32_to_cpup(ip); + return be32_to_cpu(*ip); } while ( np->parent ); /* No #address-cells property for the root node */ return DT_ROOT_NODE_SIZE_CELLS_DEFAULT; @@ -660,7 +660,7 @@ static void dt_bus_pci_count_cells(const struct dt_devi= ce_node *np, static unsigned int dt_bus_pci_get_flags(const __be32 *addr) { unsigned int flags =3D 0; - u32 w =3D be32_to_cpup(addr); + u32 w =3D be32_to_cpu(*addr); =20 switch((w >> 24) & 0x03) { case 0x01: @@ -1077,7 +1077,7 @@ dt_irq_find_parent(const struct dt_device_node *child) if ( parp =3D=3D NULL ) p =3D dt_get_parent(child); else - p =3D dt_find_node_by_phandle(be32_to_cpup(parp)); + p =3D dt_find_node_by_phandle(be32_to_cpu(*parp)); child =3D p; } while ( p && dt_get_property(p, "#interrupt-cells", NULL) =3D=3D NUL= L ); =20 @@ -1110,7 +1110,7 @@ unsigned int dt_number_of_irq(const struct dt_device_= node *device) intlen /=3D sizeof(*intspec); =20 dt_dprintk(" using 'interrupts' property\n"); - dt_dprintk(" intspec=3D%d intlen=3D%d\n", be32_to_cpup(intspec), intle= n); + dt_dprintk(" intspec=3D%d intlen=3D%d\n", be32_to_cpu(*intspec), intle= n); =20 /* Look for the interrupt parent. */ p =3D dt_irq_find_parent(device); @@ -1241,7 +1241,7 @@ int dt_for_each_irq_map(const struct dt_device_node *= dev, imaplen -=3D addrsize + intsize; =20 /* Get the interrupt parent */ - ipar =3D dt_find_node_by_phandle(be32_to_cpup(imap)); + ipar =3D dt_find_node_by_phandle(be32_to_cpu(*imap)); imap++; --imaplen; =20 @@ -1358,8 +1358,8 @@ static int dt_irq_map_raw(const struct dt_device_node= *parent, int match, i; =20 dt_dprintk("dt_irq_map_raw: par=3D%s,intspec=3D[0x%08x 0x%08x...],oint= size=3D%d\n", - parent->full_name, be32_to_cpup(intspec), - be32_to_cpup(intspec + 1), ointsize); + parent->full_name, be32_to_cpu(*intspec), + be32_to_cpu(*(intspec+1)), ointsize); =20 ipar =3D parent; =20 @@ -1471,7 +1471,7 @@ static int dt_irq_map_raw(const struct dt_device_node= *parent, dt_dprintk(" -> match=3D%d (imaplen=3D%d)\n", match, imaplen); =20 /* Get the interrupt parent */ - newpar =3D dt_find_node_by_phandle(be32_to_cpup(imap)); + newpar =3D dt_find_node_by_phandle(be32_to_cpu(*imap)); imap++; --imaplen; =20 @@ -1565,7 +1565,7 @@ int dt_device_get_raw_irq(const struct dt_device_node= *device, intlen /=3D sizeof(*intspec); =20 dt_dprintk(" using 'interrupts' property\n"); - dt_dprintk(" intspec=3D%d intlen=3D%d\n", be32_to_cpup(intspec), intle= n); + dt_dprintk(" intspec=3D%d intlen=3D%d\n", be32_to_cpu(*intspec), intle= n); =20 /* Look for the interrupt parent. */ p =3D dt_irq_find_parent(device); @@ -1676,7 +1676,7 @@ static int __dt_parse_phandle_with_args(const struct = dt_device_node *np, * If phandle is 0, then it is an empty entry with no * arguments. Skip forward to the next entry. * */ - phandle =3D be32_to_cpup(list++); + phandle =3D be32_to_cpu(*list++); if ( phandle ) { /* @@ -1745,7 +1745,7 @@ static int __dt_parse_phandle_with_args(const struct = dt_device_node *np, out_args->np =3D node; out_args->args_count =3D count; for ( i =3D 0; i < count; i++ ) - out_args->args[i] =3D be32_to_cpup(list++); + out_args->args[i] =3D be32_to_cpu(*list++); } =20 /* Found it! return success */ @@ -1826,7 +1826,7 @@ static unsigned long __init unflatten_dt_node(const v= oid *fdt, int has_name =3D 0; int new_format =3D 0; =20 - tag =3D be32_to_cpup((__be32 *)(*p)); + tag =3D be32_to_cpu(*(__be32 *)(*p)); if ( tag !=3D FDT_BEGIN_NODE ) { printk(XENLOG_WARNING "Weird tag at start of node: %x\n", tag); @@ -1919,7 +1919,7 @@ static unsigned long __init unflatten_dt_node(const v= oid *fdt, u32 sz, noff; const char *pname; =20 - tag =3D be32_to_cpup((__be32 *)(*p)); + tag =3D be32_to_cpu(*(__be32 *)(*p)); if ( tag =3D=3D FDT_NOP ) { *p +=3D 4; @@ -1928,8 +1928,8 @@ static unsigned long __init unflatten_dt_node(const v= oid *fdt, if ( tag !=3D FDT_PROP ) break; *p +=3D 4; - sz =3D be32_to_cpup((__be32 *)(*p)); - noff =3D be32_to_cpup((__be32 *)((*p) + 4)); + sz =3D be32_to_cpu(*(__be32 *)(*p)); + noff =3D be32_to_cpu(*(__be32 *)((*p) + 4)); *p +=3D 8; if ( fdt_version(fdt) < 0x10 ) *p =3D ROUNDUP(*p, sz >=3D 8 ? 8 : 4); @@ -1956,13 +1956,13 @@ static unsigned long __init unflatten_dt_node(const= void *fdt, (strcmp(pname, "linux,phandle") =3D=3D 0) ) { if ( np->phandle =3D=3D 0 ) - np->phandle =3D be32_to_cpup((__be32*)*p); + np->phandle =3D be32_to_cpu(*(__be32*)*p); } /* And we process the "ibm,phandle" property * used in pSeries dynamic device tree * stuff */ if ( strcmp(pname, "ibm,phandle") =3D=3D 0 ) - np->phandle =3D be32_to_cpup((__be32 *)*p); + np->phandle =3D be32_to_cpu(*(__be32 *)*p); pp->name =3D pname; pp->length =3D sz; pp->value =3D (void *)*p; @@ -2034,7 +2034,7 @@ static unsigned long __init unflatten_dt_node(const v= oid *fdt, *p +=3D 4; else mem =3D unflatten_dt_node(fdt, mem, p, np, allnextpp, fpsize); - tag =3D be32_to_cpup((__be32 *)(*p)); + tag =3D be32_to_cpu(*(__be32 *)(*p)); } if ( tag !=3D FDT_END_NODE ) { @@ -2086,7 +2086,7 @@ static void __init __unflatten_device_tree(const void= *fdt, /* Second pass, do actual unflattening */ start =3D ((unsigned long)fdt) + fdt_off_dt_struct(fdt); unflatten_dt_node(fdt, mem, &start, NULL, &allnextp, 0); - if ( be32_to_cpup((__be32 *)start) !=3D FDT_END ) + if ( be32_to_cpu(*(__be32 *)start) !=3D FDT_END ) printk(XENLOG_WARNING "Weird tag at end of tree: %08x\n", *((u32 *)start)); if ( be32_to_cpu(((__be32 *)mem)[size / 4]) !=3D 0xdeadbeef ) diff --git a/xen/common/libelf/libelf-private.h b/xen/common/libelf/libelf-= private.h index 47db679966..6062598fb8 100644 --- a/xen/common/libelf/libelf-private.h +++ b/xen/common/libelf/libelf-private.h @@ -31,9 +31,9 @@ printk(fmt, ## args ) =20 #define strtoull(str, end, base) simple_strtoull(str, end, base) -#define bswap_16(x) swab16(x) -#define bswap_32(x) swab32(x) -#define bswap_64(x) swab64(x) +#define bswap_16(x) bswap16(x) +#define bswap_32(x) bswap32(x) +#define bswap_64(x) bswap64(x) =20 #else /* !__XEN__ */ =20 diff --git a/xen/common/xz/private.h b/xen/common/xz/private.h index 511343fcc2..97131fa714 100644 --- a/xen/common/xz/private.h +++ b/xen/common/xz/private.h @@ -28,7 +28,7 @@ static inline void put_unaligned_le32(u32 val, void *p) =20 #endif =20 -#define get_le32(p) le32_to_cpup((const uint32_t *)(p)) +#define get_le32(p) le32_to_cpu(*(const uint32_t *)(p)) =20 #define false 0 #define true 1 diff --git a/xen/include/xen/unaligned.h b/xen/include/xen/unaligned.h index 0a2b16d05d..56807bd157 100644 --- a/xen/include/xen/unaligned.h +++ b/xen/include/xen/unaligned.h @@ -20,7 +20,7 @@ =20 static inline uint16_t get_unaligned_be16(const void *p) { - return be16_to_cpup(p); + return be16_to_cpu(*(const uint16_t *)p); } =20 static inline void put_unaligned_be16(uint16_t val, void *p) @@ -30,7 +30,7 @@ static inline void put_unaligned_be16(uint16_t val, void = *p) =20 static inline uint32_t get_unaligned_be32(const void *p) { - return be32_to_cpup(p); + return be32_to_cpu(*(const uint32_t *)p); } =20 static inline void put_unaligned_be32(uint32_t val, void *p) @@ -40,7 +40,7 @@ static inline void put_unaligned_be32(uint32_t val, void = *p) =20 static inline uint64_t get_unaligned_be64(const void *p) { - return be64_to_cpup(p); + return be64_to_cpu(*(const uint64_t *)p); } =20 static inline void put_unaligned_be64(uint64_t val, void *p) @@ -50,7 +50,7 @@ static inline void put_unaligned_be64(uint64_t val, void = *p) =20 static inline uint16_t get_unaligned_le16(const void *p) { - return le16_to_cpup(p); + return le16_to_cpu(*(const uint16_t *)p); } =20 static inline void put_unaligned_le16(uint16_t val, void *p) @@ -60,7 +60,7 @@ static inline void put_unaligned_le16(uint16_t val, void = *p) =20 static inline uint32_t get_unaligned_le32(const void *p) { - return le32_to_cpup(p); + return le32_to_cpu(*(const uint32_t *)p); } =20 static inline void put_unaligned_le32(uint32_t val, void *p) @@ -70,7 +70,7 @@ static inline void put_unaligned_le32(uint32_t val, void = *p) =20 static inline uint64_t get_unaligned_le64(const void *p) { - return le64_to_cpup(p); + return le64_to_cpu(*(const uint64_t *)p); } =20 static inline void put_unaligned_le64(uint64_t val, void *p) --=20 2.27.0 From nobody Fri May 17 03:54:42 2024 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=1653299603; cv=none; d=zohomail.com; s=zohoarc; b=mG8+VRMhQgJUbUJ7zo5rmZVsgLw/hq9IRmOr4dnZdV/Ji6rZfhp8z1vnmM5zCK5GUKZOmuzgn3XWRdnBo0KL+4OhMn1wfdOQdxh8tPRa5udImR2jVumC6f7vWiMzOFqXP2bZoI+ynW3Q4M7JcJDY4RlIoZMZ36rv1uFydGCbHLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653299603; 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=vj6LM1eCDOMIdXzzNQdIg58lZNc2eanub9dHl5g+cjE=; b=ebiaJHkRnCw4EHxokqf6DbNZ5KermbN4rswJ8/z/Q08IKXff5cp7w30kpu1v3r/YFHLvgb0x94g8Ntc9HrqPNZh2Z/R4MFBzwTmbdIAQVv8ScIeIKo+70+YbMby2tNTeG5qhwEjlZ+DiiMSrqPEHBBURfxnGRcCq/Lt7Nmk/WZU= 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 1653299603611470.01215167693533; Mon, 23 May 2022 02:53:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.335655.559822 (Exim 4.92) (envelope-from ) id 1nt4k4-0002g6-04; Mon, 23 May 2022 09:52:48 +0000 Received: by outflank-mailman (output) from mailman id 335655.559822; Mon, 23 May 2022 09:52:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nt4k3-0002fU-Sm; Mon, 23 May 2022 09:52:47 +0000 Received: by outflank-mailman (input) for mailman id 335655; Mon, 23 May 2022 09:52:47 +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 1nt4k3-0002dp-1s for xen-devel@lists.xenproject.org; Mon, 23 May 2022 09:52:47 +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 16a63e5a-da7e-11ec-837e-e5687231ffcc; Mon, 23 May 2022 11:52:43 +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: 16a63e5a-da7e-11ec-837e-e5687231ffcc DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1653299564; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fEkEMnPb+q1gLdgxKH7ndanRPUKwGzgXMdy6eBWVxBI=; b=KcSzmiiDACObnkdzFPCcFC+0HszyloCyEwN3hVSa9kSAvL93QgSmhbm8 ffYcNsk2GM1PK0R9Pc2yy26bxkfesqPvjDkAZo4u59B+pu+CQPC0+SSwe n/DXDV+3aT+E2NB0i0lQCoAU3cEyV66c1/762pmQCTmeHF/L5hyrhEKXy c=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 74445148 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:iQmXt6kRhckX7sWuOuVaf2Lo5gzUJkRdPkR7XQ2eYbSJt1+Wr1Gzt xJMWG3VafzeYmb3cogkPdy2/EtXsZfWz9U1QAdo+yEwFiMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BCpC48T8kk/vgqoPUUIYoAAgoLeNfYHpn2EsLd9IR2NYy24DkWVjV4 LsenuWEULOb828sWo4rw/rrRCNH5JwebxtB4zTSzdgS1LPvvyF94KA3fMldHFOhKmVgJcaoR v6r8V2M1jixEyHBqD+Suu2TnkUiGtY+NOUV45Zcc/DKbhNq/kTe3kunXRa1hIg+ZzihxrhMJ NtxWZOYeSEDJZbcvNomXCJXSQ9sD5VgxeWWPi3q2SCT5xWun3rExvxvCAc9PJEC+/YxCmZLn RAaAGlTNFbZ3bvwme/lDLk37iggBJCD0Ic3vnBmizXYEN4tQIzZQrWM7thdtNs1rp8SQaqDP pZJAdZpRCuHaiNsHFoVMpIFkf6BoXvEagwAl03A8MLb5ECMlVcsgdABKuH9eNOQQt5Otl2Fv W+A9GP8ajkFMPSPxDzD9Wij7sffkCW+VI8MGbmQ8v9xnEbV1mEVEAcRV1awvb++kEHWZj5EA xVKoGx09/F0rRH1CImmN/GlnJKali46ccFrA8kE0w62xfD68TShIFVeHyEUPbTKq/QKqSwWO k6hxo20XmY04O3OExpx5Z/P82rsZHF9wXsqIHZdEFBbu4SLTJQb1Eqnczp1LEKiYjQZ8xnUy ivCkiUxjq57YSUjh/TipgCvb95BS/H0ou8JCub/BDvNAvtRPtLNWmBRwQGzAQx8BIiYVEKdm 3MPhtKT6usDZbnUynHWGrlRQOjzv6/VWNE5vbKIN8B8nwlBBlb5JdwAiN2ADBkB3jk4lc/BP xaI5FI5CG57N3q2d65nC79d+OxzpZUM4e/ND6iOBvIXO8AZXFberElGOB/Lt0iwwRdErE3KE crCGSpaJS1CWfoPIfvfb7p17ILHMQhllTKPHsqilkvPPHj3TCf9dIrp+WCmNogRhJ5oai2Pm zqDH6NmEylibdA= IronPort-HdrOrdr: A9a23:BSCFIquqKXSpjDe62mMIRMwg7skDTtV00zEX/kB9WHVpmszxra 6TdZMgpHnJYVcqKQkdcL+7WJVoLUmxyXcx2/h1AV7AZniAhILLFvAA0WKK+VSJcEeSygce79 YFT0EXMqyIMbEQt6fHCWeDfOrIuOP3kpyVuQ== X-IronPort-AV: E=Sophos;i="5.91,246,1647316800"; d="scan'208";a="74445148" From: Lin Liu To: CC: Lin Liu , Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH v4 5/6] tools: Use new byteswap helper Date: Mon, 23 May 2022 05:52:21 -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: 1653299604146100009 Content-Type: text/plain; charset="utf-8" Include new header to use new byteswap helper No functional change. Signed-off-by: Lin Liu --- Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross --- tools/libs/guest/xg_dom_decompress_unsafe_xz.c | 5 +++++ tools/libs/guest/xg_dom_decompress_unsafe_zstd.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_xz.c b/tools/libs/gu= est/xg_dom_decompress_unsafe_xz.c index fc48198741..493427d517 100644 --- a/tools/libs/guest/xg_dom_decompress_unsafe_xz.c +++ b/tools/libs/guest/xg_dom_decompress_unsafe_xz.c @@ -34,6 +34,11 @@ static inline u32 le32_to_cpup(const u32 *p) return cpu_to_le32(*p); } =20 +static inline u32 le32_to_cpu(u32 val) +{ + return le32_to_cpup((const u32 *)&val); +} + #define __force #define always_inline =20 diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c b/tools/libs/= guest/xg_dom_decompress_unsafe_zstd.c index 01eafaaaa6..b06f2e767f 100644 --- a/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c +++ b/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c @@ -31,7 +31,8 @@ typedef uint64_t __be64; =20 #define __BYTEORDER_HAS_U64__ #define __TYPES_H__ /* xen/types.h guard */ -#include "../../xen/include/xen/byteorder/little_endian.h" +#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ +#include "../../xen/include/xen/byteorder.h" #define __ASM_UNALIGNED_H__ /* asm/unaligned.h guard */ #include "../../xen/include/xen/unaligned.h" #include "../../xen/include/xen/xxhash.h" --=20 2.27.0 From nobody Fri May 17 03:54:42 2024 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=1653299601; cv=none; d=zohomail.com; s=zohoarc; b=VlJxhy2dMKoSkUp2xWm+n3bNyRyuFFsc25U5btR/GFHewXLsYjwkXujZlFE40Z176aGMRug6JZo/wwEksf6fZTm8i0AQp9BxCGhOim+ed8j9BL+4n1MGzS8c+VX9tp6hg8doSl9vspTEDSOlThtujWKCZuGzlEOR01h97FUs/uI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653299601; 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=BvpWNFkxplWQK4ZUU7lTNJZcm5HZgb9dcz3qg1tRqaw=; b=G/NFsn4+qTiKTDUZZf1L+GoLWRDTabtbxDX18/uBqJqd5tco0Zj96Mmckk8UcK1cGUhUpG2JudbUhB9tQckzYHLpa6qvuqojVR8bQ/2LrRwa7weYeedN4FaHK4Vrh2LRHmlSjp/gLXmCZXcFIdtWPUIJ+ImPx/PFT3lsLDLxojQ= 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 1653299601128894.6267395294763; Mon, 23 May 2022 02:53:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.335660.559885 (Exim 4.92) (envelope-from ) id 1nt4kD-0004PS-2t; Mon, 23 May 2022 09:52:57 +0000 Received: by outflank-mailman (output) from mailman id 335660.559885; Mon, 23 May 2022 09:52:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nt4kC-0004PJ-Tp; Mon, 23 May 2022 09:52:56 +0000 Received: by outflank-mailman (input) for mailman id 335660; Mon, 23 May 2022 09:52:55 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nt4kB-0002dq-3N for xen-devel@lists.xenproject.org; Mon, 23 May 2022 09:52:55 +0000 Received: from esa1.hc3370-68.iphmx.com (esa1.hc3370-68.iphmx.com [216.71.145.142]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1bf98f02-da7e-11ec-bd2c-47488cf2e6aa; Mon, 23 May 2022 11:52:53 +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: 1bf98f02-da7e-11ec-bd2c-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1653299573; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ENKGHyqakgatMFXhjwFCV+ZEI5TqFZ1FQ890jq+2cI4=; b=O6o4MRDHBc5v+CjikR3vegbYg6GkLXYXTiXZ5FEb2ROOfkgnfDsQ4pNF +P9z7pVv1Hnk/foFnsKt+6MDBwm+352KsJE74R3SbpNqUQCUjWe/2HFWV pkZpDxs52wHSwTqIpWHp7/YV2J6z1h+BAdSTiB03fawlqImS1c/Hq/xGv I=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 72327724 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:D4y7FqLsZsgLmUGEFE+RwJUlxSXFcZb7ZxGr2PjKsXjdYENShjEOn WVMXDrXbvzbNmqjc990b46//EoCuJSGz9RiS1FlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokf0/0vrav67xZVF/fngqoDUUYYoAQgsA149IMsdoUg7wbRh39Qz2YHR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 OVMipeAY1kRArfvws1afBgAPgx9YbITrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBM3qOsUbu2xIxjDFF/c2B5vERs0m4PcHhmxq2Z8UQZ4yY eI6Q2pWaRf/RCdNAX4JJc8wh8mvoGXWJmgwRFW9+vNsvjm7IBZK+KP2LNPfd9iORMNUtkWVv GTL+yL+GB5yHN6CzTuI9Fq8i+mJmjn0MKoNEJWo+/gsh0ecrkQDBRtTWValrP2Rjk+lR8kZO 0ES4jApr6U56AqsVNaVdx+yrWOAvxUcc8FNCOB84waIooLe7hyFHGECQnhEYcY/qc4tbTUw0 xmCmNaBONB0mOTLEzTHrO7S9G7sf3hORYMfWcMaZTsE3NLTit8LsgjsFP8kP6/to/D2RS6ll lhmsxMCa6UvYd8jjvvmpgqc02L3/PAlXSZuuFyJAzvNAhdRIdf8Otf2sQWzAeNodt7xc7WXg JQTdyFyBsgqBIrFqiGCSf5l8FqBt6fca220bbKC8vAcG9WRF52LJ9k4DMlWfhsBDyr9UWaBj LXvkQ1Q/oRPG3ChcLV6ZYm8Y+xzk/W7T4i5CqmONoMeCnSUSONg1HgzDXN8Iki3yBR8+U3BE cnznTmQ4YYyVv08kWveqxY12r433CEurV4/triipylLJYG2PSbPIZ9caQPmRrlgvMus/VSOm /4CZpTi9vmqeLCnCsUh2dVLfQ5iwLlSLc2elvG7gcbYcls6Qzt4UqC5LHFIU9UNopm5X9zgp hmVMnK0AnKi7ZEbAW1mskxeVY4= IronPort-HdrOrdr: A9a23:9UCHSqAf2AdXZbXlHemW55DYdb4zR+YMi2TC1yhKKCC9Ffbo7v xG/c5rriMc5wxhO03I9eruBEDEewK5yXcX2/h2AV7BZniFhILAFugLhuGOrwEIWReOkdK1vZ 0QC5SWY+eRMbEVt6jHCXGDYrMd/OU= X-IronPort-AV: E=Sophos;i="5.91,246,1647316800"; d="scan'208";a="72327724" From: Lin Liu To: CC: Lin Liu , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Bertrand Marquis , Stefano Stabellini , Wei Liu Subject: [PATCH v4 6/6] byteorder: Remove byteorder Date: Mon, 23 May 2022 05:52:22 -0400 Message-ID: <8c025497fb679c92e33c036caa705d23ffd18fbb.1653295437.git.lin.liu@citrix.com> 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: 1653299602526100005 Content-Type: text/plain; charset="utf-8" include/xen/byteswap.h has simplify the interface, just clean the old interface No functional change Signed-off-by: Lin Liu 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/include/xen/byteorder/big_endian.h | 102 ------------ xen/include/xen/byteorder/generic.h | 68 -------- xen/include/xen/byteorder/little_endian.h | 102 ------------ xen/include/xen/byteorder/swab.h | 183 ---------------------- 4 files changed, 455 deletions(-) delete mode 100644 xen/include/xen/byteorder/big_endian.h delete mode 100644 xen/include/xen/byteorder/generic.h delete mode 100644 xen/include/xen/byteorder/little_endian.h delete mode 100644 xen/include/xen/byteorder/swab.h diff --git a/xen/include/xen/byteorder/big_endian.h b/xen/include/xen/byteo= rder/big_endian.h deleted file mode 100644 index 40eb80a390..0000000000 --- a/xen/include/xen/byteorder/big_endian.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef __XEN_BYTEORDER_BIG_ENDIAN_H__ -#define __XEN_BYTEORDER_BIG_ENDIAN_H__ - -#ifndef __BIG_ENDIAN -#define __BIG_ENDIAN 4321 -#endif -#ifndef __BIG_ENDIAN_BITFIELD -#define __BIG_ENDIAN_BITFIELD -#endif - -#include -#include - -#define __constant_cpu_to_le64(x) ((__force __le64)___constant_swab64((x))) -#define __constant_le64_to_cpu(x) ___constant_swab64((__force __u64)(__le6= 4)(x)) -#define __constant_cpu_to_le32(x) ((__force __le32)___constant_swab32((x))) -#define __constant_le32_to_cpu(x) ___constant_swab32((__force __u32)(__le3= 2)(x)) -#define __constant_cpu_to_le16(x) ((__force __le16)___constant_swab16((x))) -#define __constant_le16_to_cpu(x) ___constant_swab16((__force __u16)(__le1= 6)(x)) -#define __constant_cpu_to_be64(x) ((__force __be64)(__u64)(x)) -#define __constant_be64_to_cpu(x) ((__force __u64)(__be64)(x)) -#define __constant_cpu_to_be32(x) ((__force __be32)(__u32)(x)) -#define __constant_be32_to_cpu(x) ((__force __u32)(__be32)(x)) -#define __constant_cpu_to_be16(x) ((__force __be16)(__u16)(x)) -#define __constant_be16_to_cpu(x) ((__force __u16)(__be16)(x)) -#define __cpu_to_le64(x) ((__force __le64)__swab64((x))) -#define __le64_to_cpu(x) __swab64((__force __u64)(__le64)(x)) -#define __cpu_to_le32(x) ((__force __le32)__swab32((x))) -#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x)) -#define __cpu_to_le16(x) ((__force __le16)__swab16((x))) -#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x)) -#define __cpu_to_be64(x) ((__force __be64)(__u64)(x)) -#define __be64_to_cpu(x) ((__force __u64)(__be64)(x)) -#define __cpu_to_be32(x) ((__force __be32)(__u32)(x)) -#define __be32_to_cpu(x) ((__force __u32)(__be32)(x)) -#define __cpu_to_be16(x) ((__force __be16)(__u16)(x)) -#define __be16_to_cpu(x) ((__force __u16)(__be16)(x)) - -static inline __le64 __cpu_to_le64p(const __u64 *p) -{ - return (__force __le64)__swab64p(p); -} -static inline __u64 __le64_to_cpup(const __le64 *p) -{ - return __swab64p((__u64 *)p); -} -static inline __le32 __cpu_to_le32p(const __u32 *p) -{ - return (__force __le32)__swab32p(p); -} -static inline __u32 __le32_to_cpup(const __le32 *p) -{ - return __swab32p((__u32 *)p); -} -static inline __le16 __cpu_to_le16p(const __u16 *p) -{ - return (__force __le16)__swab16p(p); -} -static inline __u16 __le16_to_cpup(const __le16 *p) -{ - return __swab16p((__u16 *)p); -} -static inline __be64 __cpu_to_be64p(const __u64 *p) -{ - return (__force __be64)*p; -} -static inline __u64 __be64_to_cpup(const __be64 *p) -{ - return (__force __u64)*p; -} -static inline __be32 __cpu_to_be32p(const __u32 *p) -{ - return (__force __be32)*p; -} -static inline __u32 __be32_to_cpup(const __be32 *p) -{ - return (__force __u32)*p; -} -static inline __be16 __cpu_to_be16p(const __u16 *p) -{ - return (__force __be16)*p; -} -static inline __u16 __be16_to_cpup(const __be16 *p) -{ - return (__force __u16)*p; -} -#define __cpu_to_le64s(x) __swab64s((x)) -#define __le64_to_cpus(x) __swab64s((x)) -#define __cpu_to_le32s(x) __swab32s((x)) -#define __le32_to_cpus(x) __swab32s((x)) -#define __cpu_to_le16s(x) __swab16s((x)) -#define __le16_to_cpus(x) __swab16s((x)) -#define __cpu_to_be64s(x) do {} while (0) -#define __be64_to_cpus(x) do {} while (0) -#define __cpu_to_be32s(x) do {} while (0) -#define __be32_to_cpus(x) do {} while (0) -#define __cpu_to_be16s(x) do {} while (0) -#define __be16_to_cpus(x) do {} while (0) - -#include - -#endif /* __XEN_BYTEORDER_BIG_ENDIAN_H__ */ diff --git a/xen/include/xen/byteorder/generic.h b/xen/include/xen/byteorde= r/generic.h deleted file mode 100644 index 8a0006b755..0000000000 --- a/xen/include/xen/byteorder/generic.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef __XEN_BYTEORDER_GENERIC_H__ -#define __XEN_BYTEORDER_GENERIC_H__ - -/* - * Generic Byte-reordering support - * - * The "... p" macros, like le64_to_cpup, can be used with pointers - * to unaligned data, but there will be a performance penalty on=20 - * some architectures. Use get_unaligned for unaligned data. - * - * The following macros are to be defined by : - * - * Conversion of XX-bit integers (16- 32- or 64-) - * between native CPU format and little/big endian format - * 64-bit stuff only defined for proper architectures - * cpu_to_[bl]eXX(__uXX x) - * [bl]eXX_to_cpu(__uXX x) - * - * The same, but takes a pointer to the value to convert - * cpu_to_[bl]eXXp(__uXX x) - * [bl]eXX_to_cpup(__uXX x) - * - * The same, but change in situ - * cpu_to_[bl]eXXs(__uXX x) - * [bl]eXX_to_cpus(__uXX x) - * - * See asm-foo/byteorder.h for examples of how to provide - * architecture-optimized versions - */ - -#define cpu_to_le64 __cpu_to_le64 -#define le64_to_cpu __le64_to_cpu -#define cpu_to_le32 __cpu_to_le32 -#define le32_to_cpu __le32_to_cpu -#define cpu_to_le16 __cpu_to_le16 -#define le16_to_cpu __le16_to_cpu -#define cpu_to_be64 __cpu_to_be64 -#define be64_to_cpu __be64_to_cpu -#define cpu_to_be32 __cpu_to_be32 -#define be32_to_cpu __be32_to_cpu -#define cpu_to_be16 __cpu_to_be16 -#define be16_to_cpu __be16_to_cpu -#define cpu_to_le64p __cpu_to_le64p -#define le64_to_cpup __le64_to_cpup -#define cpu_to_le32p __cpu_to_le32p -#define le32_to_cpup __le32_to_cpup -#define cpu_to_le16p __cpu_to_le16p -#define le16_to_cpup __le16_to_cpup -#define cpu_to_be64p __cpu_to_be64p -#define be64_to_cpup __be64_to_cpup -#define cpu_to_be32p __cpu_to_be32p -#define be32_to_cpup __be32_to_cpup -#define cpu_to_be16p __cpu_to_be16p -#define be16_to_cpup __be16_to_cpup -#define cpu_to_le64s __cpu_to_le64s -#define le64_to_cpus __le64_to_cpus -#define cpu_to_le32s __cpu_to_le32s -#define le32_to_cpus __le32_to_cpus -#define cpu_to_le16s __cpu_to_le16s -#define le16_to_cpus __le16_to_cpus -#define cpu_to_be64s __cpu_to_be64s -#define be64_to_cpus __be64_to_cpus -#define cpu_to_be32s __cpu_to_be32s -#define be32_to_cpus __be32_to_cpus -#define cpu_to_be16s __cpu_to_be16s -#define be16_to_cpus __be16_to_cpus - -#endif /* __XEN_BYTEORDER_GENERIC_H__ */ diff --git a/xen/include/xen/byteorder/little_endian.h b/xen/include/xen/by= teorder/little_endian.h deleted file mode 100644 index 4955632793..0000000000 --- a/xen/include/xen/byteorder/little_endian.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef __XEN_BYTEORDER_LITTLE_ENDIAN_H__ -#define __XEN_BYTEORDER_LITTLE_ENDIAN_H__ - -#ifndef __LITTLE_ENDIAN -#define __LITTLE_ENDIAN 1234 -#endif -#ifndef __LITTLE_ENDIAN_BITFIELD -#define __LITTLE_ENDIAN_BITFIELD -#endif - -#include -#include - -#define __constant_cpu_to_le64(x) ((__force __le64)(__u64)(x)) -#define __constant_le64_to_cpu(x) ((__force __u64)(__le64)(x)) -#define __constant_cpu_to_le32(x) ((__force __le32)(__u32)(x)) -#define __constant_le32_to_cpu(x) ((__force __u32)(__le32)(x)) -#define __constant_cpu_to_le16(x) ((__force __le16)(__u16)(x)) -#define __constant_le16_to_cpu(x) ((__force __u16)(__le16)(x)) -#define __constant_cpu_to_be64(x) ((__force __be64)___constant_swab64((x))) -#define __constant_be64_to_cpu(x) ___constant_swab64((__force __u64)(__be6= 4)(x)) -#define __constant_cpu_to_be32(x) ((__force __be32)___constant_swab32((x))) -#define __constant_be32_to_cpu(x) ___constant_swab32((__force __u32)(__be3= 2)(x)) -#define __constant_cpu_to_be16(x) ((__force __be16)___constant_swab16((x))) -#define __constant_be16_to_cpu(x) ___constant_swab16((__force __u16)(__be1= 6)(x)) -#define __cpu_to_le64(x) ((__force __le64)(__u64)(x)) -#define __le64_to_cpu(x) ((__force __u64)(__le64)(x)) -#define __cpu_to_le32(x) ((__force __le32)(__u32)(x)) -#define __le32_to_cpu(x) ((__force __u32)(__le32)(x)) -#define __cpu_to_le16(x) ((__force __le16)(__u16)(x)) -#define __le16_to_cpu(x) ((__force __u16)(__le16)(x)) -#define __cpu_to_be64(x) ((__force __be64)__swab64((x))) -#define __be64_to_cpu(x) __swab64((__force __u64)(__be64)(x)) -#define __cpu_to_be32(x) ((__force __be32)__swab32((x))) -#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x)) -#define __cpu_to_be16(x) ((__force __be16)__swab16((x))) -#define __be16_to_cpu(x) __swab16((__force __u16)(__be16)(x)) - -static inline __le64 __cpu_to_le64p(const __u64 *p) -{ - return (__force __le64)*p; -} -static inline __u64 __le64_to_cpup(const __le64 *p) -{ - return (__force __u64)*p; -} -static inline __le32 __cpu_to_le32p(const __u32 *p) -{ - return (__force __le32)*p; -} -static inline __u32 __le32_to_cpup(const __le32 *p) -{ - return (__force __u32)*p; -} -static inline __le16 __cpu_to_le16p(const __u16 *p) -{ - return (__force __le16)*p; -} -static inline __u16 __le16_to_cpup(const __le16 *p) -{ - return (__force __u16)*p; -} -static inline __be64 __cpu_to_be64p(const __u64 *p) -{ - return (__force __be64)__swab64p(p); -} -static inline __u64 __be64_to_cpup(const __be64 *p) -{ - return __swab64p((__u64 *)p); -} -static inline __be32 __cpu_to_be32p(const __u32 *p) -{ - return (__force __be32)__swab32p(p); -} -static inline __u32 __be32_to_cpup(const __be32 *p) -{ - return __swab32p((__u32 *)p); -} -static inline __be16 __cpu_to_be16p(const __u16 *p) -{ - return (__force __be16)__swab16p(p); -} -static inline __u16 __be16_to_cpup(const __be16 *p) -{ - return __swab16p((__u16 *)p); -} -#define __cpu_to_le64s(x) do {} while (0) -#define __le64_to_cpus(x) do {} while (0) -#define __cpu_to_le32s(x) do {} while (0) -#define __le32_to_cpus(x) do {} while (0) -#define __cpu_to_le16s(x) do {} while (0) -#define __le16_to_cpus(x) do {} while (0) -#define __cpu_to_be64s(x) __swab64s((x)) -#define __be64_to_cpus(x) __swab64s((x)) -#define __cpu_to_be32s(x) __swab32s((x)) -#define __be32_to_cpus(x) __swab32s((x)) -#define __cpu_to_be16s(x) __swab16s((x)) -#define __be16_to_cpus(x) __swab16s((x)) - -#include - -#endif /* __XEN_BYTEORDER_LITTLE_ENDIAN_H__ */ diff --git a/xen/include/xen/byteorder/swab.h b/xen/include/xen/byteorder/s= wab.h deleted file mode 100644 index b7e30f0503..0000000000 --- a/xen/include/xen/byteorder/swab.h +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef __XEN_BYTEORDER_SWAB_H__ -#define __XEN_BYTEORDER_SWAB_H__ - -/* - * Byte-swapping, independently from CPU endianness - * swabXX[ps]?(foo) - * - * Francois-Rene Rideau 19971205 - * separated swab functions from cpu_to_XX, - * to clean up support for bizarre-endian architectures. - */ - -/* casts are necessary for constants, because we never know how for sure - * how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way. - */ -#define ___swab16(x) \ -({ \ - __u16 __x =3D (x); \ - ((__u16)( \ - (((__u16)(__x) & (__u16)0x00ffU) << 8) | \ - (((__u16)(__x) & (__u16)0xff00U) >> 8) )); \ -}) - -#define ___swab32(x) \ -({ \ - __u32 __x =3D (x); \ - ((__u32)( \ - (((__u32)(__x) & (__u32)0x000000ffUL) << 24) | \ - (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) | \ - (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) | \ - (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); \ -}) - -#define ___swab64(x) = \ -({ = \ - __u64 __x =3D (x); = \ - ((__u64)( = \ - (__u64)(((__u64)(__x) & (__u64)0x00000000000000ffULL) << 56) | = \ - (__u64)(((__u64)(__x) & (__u64)0x000000000000ff00ULL) << 40) | = \ - (__u64)(((__u64)(__x) & (__u64)0x0000000000ff0000ULL) << 24) | = \ - (__u64)(((__u64)(__x) & (__u64)0x00000000ff000000ULL) << 8) | = \ - (__u64)(((__u64)(__x) & (__u64)0x000000ff00000000ULL) >> 8) |= \ - (__u64)(((__u64)(__x) & (__u64)0x0000ff0000000000ULL) >> 24) | = \ - (__u64)(((__u64)(__x) & (__u64)0x00ff000000000000ULL) >> 40) | = \ - (__u64)(((__u64)(__x) & (__u64)0xff00000000000000ULL) >> 56) )); = \ -}) - -#define ___constant_swab16(x) \ - ((__u16)( \ - (((__u16)(x) & (__u16)0x00ffU) << 8) | \ - (((__u16)(x) & (__u16)0xff00U) >> 8) )) -#define ___constant_swab32(x) \ - ((__u32)( \ - (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \ - (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \ - (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \ - (((__u32)(x) & (__u32)0xff000000UL) >> 24) )) -#define ___constant_swab64(x) \ - ((__u64)( \ - (__u64)(((__u64)(x) & (__u64)0x00000000000000ffULL) << 56) | \ - (__u64)(((__u64)(x) & (__u64)0x000000000000ff00ULL) << 40) | \ - (__u64)(((__u64)(x) & (__u64)0x0000000000ff0000ULL) << 24) | \ - (__u64)(((__u64)(x) & (__u64)0x00000000ff000000ULL) << 8) | \ - (__u64)(((__u64)(x) & (__u64)0x000000ff00000000ULL) >> 8) | \ - (__u64)(((__u64)(x) & (__u64)0x0000ff0000000000ULL) >> 24) | \ - (__u64)(((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) | \ - (__u64)(((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56) )) - -/* - * provide defaults when no architecture-specific optimization is detected - */ -#ifndef __arch__swab16 -# define __arch__swab16(x) ({ __u16 __tmp =3D (x) ; ___swab16(__tmp); }) -#endif -#ifndef __arch__swab32 -# define __arch__swab32(x) ({ __u32 __tmp =3D (x) ; ___swab32(__tmp); }) -#endif -#ifndef __arch__swab64 -# define __arch__swab64(x) ({ __u64 __tmp =3D (x) ; ___swab64(__tmp); }) -#endif - -#ifndef __arch__swab16p -# define __arch__swab16p(x) __arch__swab16(*(x)) -#endif -#ifndef __arch__swab32p -# define __arch__swab32p(x) __arch__swab32(*(x)) -#endif -#ifndef __arch__swab64p -# define __arch__swab64p(x) __arch__swab64(*(x)) -#endif - -#ifndef __arch__swab16s -# define __arch__swab16s(x) do { *(x) =3D __arch__swab16p((x)); } while (= 0) -#endif -#ifndef __arch__swab32s -# define __arch__swab32s(x) do { *(x) =3D __arch__swab32p((x)); } while (= 0) -#endif -#ifndef __arch__swab64s -# define __arch__swab64s(x) do { *(x) =3D __arch__swab64p((x)); } while (= 0) -#endif - - -/* - * Allow constant folding - */ -#if defined(__GNUC__) && defined(__OPTIMIZE__) -# define __swab16(x) \ -(__builtin_constant_p((__u16)(x)) ? \ - ___swab16((x)) : \ - __fswab16((x))) -# define __swab32(x) \ -(__builtin_constant_p((__u32)(x)) ? \ - ___swab32((x)) : \ - __fswab32((x))) -# define __swab64(x) \ -(__builtin_constant_p((__u64)(x)) ? \ - ___swab64((x)) : \ - __fswab64((x))) -#else -# define __swab16(x) __fswab16(x) -# define __swab32(x) __fswab32(x) -# define __swab64(x) __fswab64(x) -#endif /* OPTIMIZE */ - - -static inline __attribute_const__ __u16 __fswab16(__u16 x) -{ - return __arch__swab16(x); -} -static inline __u16 __swab16p(const __u16 *x) -{ - return __arch__swab16p(x); -} -static inline void __swab16s(__u16 *addr) -{ - __arch__swab16s(addr); -} - -static inline __attribute_const__ __u32 __fswab32(__u32 x) -{ - return __arch__swab32(x); -} -static inline __u32 __swab32p(const __u32 *x) -{ - return __arch__swab32p(x); -} -static inline void __swab32s(__u32 *addr) -{ - __arch__swab32s(addr); -} - -#ifdef __BYTEORDER_HAS_U64__ -static inline __attribute_const__ __u64 __fswab64(__u64 x) -{ -# ifdef __SWAB_64_THRU_32__ - __u32 h =3D x >> 32; - __u32 l =3D x & ((1ULL<<32)-1); - return (((__u64)__swab32(l)) << 32) | ((__u64)(__swab32(h))); -# else - return __arch__swab64(x); -# endif -} -static inline __u64 __swab64p(const __u64 *x) -{ - return __arch__swab64p(x); -} -static inline void __swab64s(__u64 *addr) -{ - __arch__swab64s(addr); -} -#endif /* __BYTEORDER_HAS_U64__ */ - -#define swab16 __swab16 -#define swab32 __swab32 -#define swab64 __swab64 -#define swab16p __swab16p -#define swab32p __swab32p -#define swab64p __swab64p -#define swab16s __swab16s -#define swab32s __swab32s -#define swab64s __swab64s - -#endif /* __XEN_BYTEORDER_SWAB_H__ */ --=20 2.27.0