From patchwork Wed Jan 24 09:05:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 10181941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1DCC8602B7 for ; Wed, 24 Jan 2018 09:06:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B512286E6 for ; Wed, 24 Jan 2018 09:06:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F305A286FF; Wed, 24 Jan 2018 09:06:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 52B72286E6 for ; Wed, 24 Jan 2018 09:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0X4LP5YDwzUxkBQuXH4j8zhDDsYhC4RsMjUHSTtti2c=; b=puWZIoO41Hdfx9 d0vGlifcxqwVYonAj+6FJdsRFzwR/vTNmPz0OtkUOtD3Lz5qN1p0W2HlS6uSy8uIl5WVwcg4+y1bz AFK+Es5Om9sDJCHtBEfIxqvmJtigfwa9JjdYMLlSGlbzMt1uEc0gVEjZTUBmQTvlEvHfJoQpUTkYz B1Ty9kX2nPLLzXbG4fGmOa5ZH8cxlfWMYtriLdQ9PBVUo/WYjsff6QhTE7NWDA6UwwbV/EUgfVeTq DJbmvUvIhfvOSrHWVz/LJamCVJQlHeW1dQdqXjzIlVf+m4q0F3zMoGe9a0zLe3XdYGw+pi6j7krD6 S5910lBCT1bNot0qJVSg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eeH0U-0000Z3-Sd; Wed, 24 Jan 2018 09:06:10 +0000 Received: from mail-bn3nam01on0055.outbound.protection.outlook.com ([104.47.33.55] helo=NAM01-BN3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eeH0M-0000Hh-GB for linux-arm-kernel@lists.infradead.org; Wed, 24 Jan 2018 09:06:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=2crrhqgzOa+enelW9tMKNYvMFjnuqRF3JTbJ9cqinh8=; b=ZetiVHgAtVnAVBUxxgd/o7TgoT9U5Z9CYnHU7P8gTM8cHPppTQ+7I87AGvTNGEqxNyWWwsF1+sC5oaKmP0TG1dK7t6ZHcMILuOYX2YtJlTt9fYtUndqzpqMrbikfcArDLrFo6sHFATgsKgrNiCh+p7At4yw3rQl+niHZ8V/jRdI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Received: from localhost (42.106.18.247) by MWHPR07MB2910.namprd07.prod.outlook.com (10.169.231.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Wed, 24 Jan 2018 09:05:47 +0000 From: Yury Norov To: linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Subject: [PATCH 1/3] UAPI: Introduce 128-bit types and byteswap operations Date: Wed, 24 Jan 2018 12:05:17 +0300 Message-Id: <20180124090519.6680-2-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180124090519.6680-1-ynorov@caviumnetworks.com> References: <20180124090519.6680-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [42.106.18.247] X-ClientProxiedBy: DB3PR0202CA0006.eurprd02.prod.outlook.com (52.134.64.147) To MWHPR07MB2910.namprd07.prod.outlook.com (10.169.231.22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 17fed08f-28d3-47a1-7bd6-08d56309a8f5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020); SRVR:MWHPR07MB2910; X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB2910; 3:fhuUP0qnnk2C342iyPCfd/2S40LEDgl8wiDhk2erRAvxJLl47GYxfwNmf4YxLXznoCfwjTQ0pVycLIENg0VY8Se8eMHn2agfCarNoZ1WwTBEslXHtr5EA4MkxGbxjpRTFQ0vCJQ1vZQZ+j6M2mztGvplh9yBTOpn0YFC9mLsLYlf3cR7oH9+hs4pmsRWc8EIrvofZuaFnlKuV2D6mN4RYlvw7U6fzg+aQjcC2S1MhgoUbeqoJIl7QHdFZiPJmZn+; 25:XOYP9/+/vz93M5OtOm4vR9nqvoOpvYlh679YY7IpgMwaClzKiYvr7twxqCz8lMdyWHLFYXvLaqcuBbShtM/IC73R7Yc76JN7D/aO8KvcH/Ivags28Etub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di1R4l3WZJkrFMQlRetM+j5dwUwm7KW3kbjt9DnzcDI5XsV1hzpD/Kmvgj1UG0BM3bAgB0=; 4:FcV6hutYbapaoZV6dni5JipvTCdVXOh4qBdfVOatqAxBq6qWDukJaYbu8Ns1xUbI48VswEIYhYApFcgfnH2llGiz6KguP17Ck/HhOtGXDlek4PO4eGQv5EoHYrXoXRpoVCZXshfp0ejJGDPcIrCWasHWxzmqI28GPNV4w5To8f9JUjLss3SD2lQf2bzXgK7IDZv7W2L89h0KAu8Nlwqa+PCRZvtrSDZvbjvMF6bhek4gWBz7Z7YVATuJX4onoaNCZLUnZ8ItIgpEqVo1XXHPvA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3002001)(3231023)(2400081)(944501161)(10201501046)(93006095)(6041288)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:MWHPR07MB2910; BCL:0; PCL:0; RULEID:; SRVR:MWHPR07MB2910; X-Forefront-PRVS: 056297E276 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(396003)(39860400002)(346002)(39380400002)(366004)(376002)(189003)(199004)(81166006)(81156014)(50466002)(42882006)(7736002)(16526018)(5009440100003)(4326008)(16586007)(26005)(6496006)(47776003)(52116002)(51416003)(2906002)(36756003)(7416002)(25786009)(59450400001)(386003)(54906003)(76176011)(478600001)(39060400002)(305945005)(106356001)(316002)(8676002)(72206003)(66066001)(97736004)(3846002)(6116002)(1076002)(53936002)(105586002)(6486002)(50226002)(8936002)(575784001)(5660300001)(2950100002)(6666003)(76506005)(68736007)(48376002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB2910; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR07MB2910; 23:cqeOKcySnwZdxZimFxhtT1nAblMf2RATvHMvTLM4P?= =?us-ascii?Q?c4OOK2nVoc3kFDAU2p7HQAFM4akFQIixOE6NSn1cI/qJF4SHCGs0W4+23OIR?= =?us-ascii?Q?PAQHE590lgXdQQEgiPtSJMqZSVHBVs98LqcQ0kYa8HpYdNB5luQcmQyCpH5P?= =?us-ascii?Q?Np8R+CCLZbNEKk38s95d/ZVZ63UdigeZ511BS193GfY4XcsGP8vye9oQgBGj?= =?us-ascii?Q?4IplDEhkBs40OUySGD06JwI65ofINhvAkZBU3rhM9F4GkGcYIcZIY9dHgjS+?= =?us-ascii?Q?boy3lWgM42qKmrNg/G8BNTWH5PzDzgMuVaof4WK6V/iOeAlg0OeXdLOvWYhl?= =?us-ascii?Q?2ttODUnAVVY8ROs2S88DcC31+ctWitlnebAt06v7bs+pHKzZ0A2EEQpb2L6j?= =?us-ascii?Q?uhCERrIRq7rCk0bqg7eeHivD/Gz/s9KRqi1z26hGSkbtYkBTIwIJ49LBisRY?= =?us-ascii?Q?9eS4VscBN6eqCLTo85wxw2ea8PcXYQGJIr3LZn9p3vS6WQ7cE/ngo4G+QtxJ?= =?us-ascii?Q?R1W4NEgYolStX30RPgL5hPD1RNR9jeXrNaBUm3RUIjwFJd+foDS+ERZ55Jbs?= =?us-ascii?Q?Pm5pAUv6D+WTtp+6bniGpDRhILCJ99kAZXh48fAM8hXN9XgWUD5MYWrQ6acg?= =?us-ascii?Q?98HmdspAuuPD4EnBWvMnkSc0EGkGZ1iIHvPCpfomuIcsQr4seu8fxsm960X0?= =?us-ascii?Q?jm23xGqO1tgRE+bAd9QAi4h/qIqGp/NK9PsAJ3ssDqJIb8gyOr9OOY5HXhZI?= =?us-ascii?Q?hwbwd66eEaKG7CACcIp8yvEF0AgXAjjcNp2iDdocT4w+QEnwsqUSSmV0kIjV?= =?us-ascii?Q?MX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4B6QQtvzgAE5WVuThwUcnoqKhldUEaC6sWpvPIa4epvVf4DxASoF5EJ47iI1cSujO0pSV1bcc=; 24:p3DZZ8yChSwMmXnSnFWG9IDrLe5gsCCnw+ldcVGVKlpgq+KjCCbWehQh70te0xsk9u+Aj1wShmzl6EM9zXQo4s2bzYbjIbvdZC2WxQIMf3E=; 7:/rZLR/dMdB4fjPAwGVYTiP0cdch/oKWo9rgHroyfXX3eKPYORFEYsI2viq/Tt1w+w7Mtlio6kw8IQ6AgnUi675OFhABCOUA9O4grtY00bxCsW1zHA09gxkeAAFmoPqDLerL4v0JtjlFYRYCYfvV77Cr9jLczKnTDgGHqmmesm5y6rRIDRInjMTjZ5j6kuV1tfiJfjU7Dud/uGg9rcZ7ps7+PxhZW18PSmw9BH6n8up26flomTEuMfv69jcmeC0Wp SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2018 09:05:47.2058 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17fed08f-28d3-47a1-7bd6-08d56309a8f5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB2910 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Pinski , Sunil Goutham , Kees Cook , Arnd Bergmann , Catalin Marinas , Will Deacon , Nicholas Piggin , Ingo Molnar , Geethasowjanya Akula , Yury Norov , Al Viro , Greg Kroah-Hartman , Andrew Morton , Laura Abbott , "David S . Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Architectures like arm64 support 128-bit integer types and operations. This patch introduces corresponding types and __swab128() operation for be/le conversions. They are required to implement 128-bit access to the memory, in following patches. Signed-off-by: Yury Norov --- include/linux/byteorder/generic.h | 8 ++++++++ include/uapi/asm-generic/int-ll64.h | 8 ++++++++ include/uapi/linux/byteorder/big_endian.h | 4 ++++ include/uapi/linux/byteorder/little_endian.h | 8 ++++++++ include/uapi/linux/swab.h | 22 ++++++++++++++++++++++ include/uapi/linux/types.h | 4 ++++ 6 files changed, 54 insertions(+) diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h index 451aaa0786ae..aa61662ee3dc 100644 --- a/include/linux/byteorder/generic.h +++ b/include/linux/byteorder/generic.h @@ -85,12 +85,20 @@ #define cpu_to_le64 __cpu_to_le64 #define le64_to_cpu __le64_to_cpu +#ifdef CONFIG_HAVE_128BIT_ACCESS +#define cpu_to_le128 __cpu_to_le128 +#define le128_to_cpu __le128_to_cpu +#endif #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 +#ifdef CONFIG_HAVE_128BIT_ACCESS +#define cpu_to_be128 __cpu_to_be128 +#define be128_to_cpu __be128_to_cpu +#endif #define cpu_to_be32 __cpu_to_be32 #define be32_to_cpu __be32_to_cpu #define cpu_to_be16 __cpu_to_be16 diff --git a/include/uapi/asm-generic/int-ll64.h b/include/uapi/asm-generic/int-ll64.h index 1ed06964257c..4bc2241988a9 100644 --- a/include/uapi/asm-generic/int-ll64.h +++ b/include/uapi/asm-generic/int-ll64.h @@ -29,9 +29,17 @@ typedef unsigned int __u32; #ifdef __GNUC__ __extension__ typedef __signed__ long long __s64; __extension__ typedef unsigned long long __u64; +#ifdef CONFIG_HAVE_128BIT_ACCESS +__extension__ typedef __int128_t __s128; +__extension__ typedef __uint128_t __u128; +#endif #else typedef __signed__ long long __s64; typedef unsigned long long __u64; +#ifdef CONFIG_HAVE_128BIT_ACCESS +typedef __int128_t __s128; +typedef __uint128_t __u128; +#endif #endif #endif /* __ASSEMBLY__ */ diff --git a/include/uapi/linux/byteorder/big_endian.h b/include/uapi/linux/byteorder/big_endian.h index 2199adc6a6c2..28a69ec10dd2 100644 --- a/include/uapi/linux/byteorder/big_endian.h +++ b/include/uapi/linux/byteorder/big_endian.h @@ -30,6 +30,10 @@ #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)) +#ifdef CONFIG_HAVE_128BIT_ACCESS +#define __cpu_to_le128(x) ((__force __le128)__swab128((x))) +#define __le128_to_cpu(x) __swab128((__force __u128)(__le128)(x)) +#endif #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))) diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h index 601c904fd5cd..15365bd0fe29 100644 --- a/include/uapi/linux/byteorder/little_endian.h +++ b/include/uapi/linux/byteorder/little_endian.h @@ -18,6 +18,10 @@ #define __constant_ntohs(x) ___constant_swab16((__force __be16)(x)) #define __constant_cpu_to_le64(x) ((__force __le64)(__u64)(x)) #define __constant_le64_to_cpu(x) ((__force __u64)(__le64)(x)) +#ifdef CONFIG_HAVE_128BIT_ACCESS +#define __constant_cpu_to_le128(x) ((__force __le128)(__u128)(x)) +#define __constant_le128_to_cpu(x) ((__force __u128)(__le128)(x)) +#endif #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)) @@ -30,6 +34,10 @@ #define __constant_be16_to_cpu(x) ___constant_swab16((__force __u16)(__be16)(x)) #define __cpu_to_le64(x) ((__force __le64)(__u64)(x)) #define __le64_to_cpu(x) ((__force __u64)(__le64)(x)) +#ifdef CONFIG_HAVE_128BIT_ACCESS +#define __cpu_to_le128(x) ((__force __le128)(__u128)(x)) +#define __le128_to_cpu(x) ((__force __u128)(__le128)(x)) +#endif #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)) diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h index 23cd84868cc3..a7e97eb06a3e 100644 --- a/include/uapi/linux/swab.h +++ b/include/uapi/linux/swab.h @@ -75,6 +75,20 @@ static inline __attribute_const__ __u64 __fswab64(__u64 val) #endif } +#ifdef CONFIG_HAVE_128BIT_ACCESS +static inline __attribute_const__ __u128 __fswab128(__u128 val) +{ +#if defined(__arch_swab128) + return __arch_swab128(val); +#else + __u64 h = (__u64) (val >> 64); + __u64 l = (__u64) val; + + return (((__u128)__fswab64(l)) << 64) | (__u128)(__fswab64(h)); +#endif +} +#endif + static inline __attribute_const__ __u32 __fswahw32(__u32 val) { #ifdef __arch_swahw32 @@ -132,6 +146,14 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val) __fswab64(x)) #endif +#ifdef CONFIG_HAVE_128BIT_ACCESS +/** + * __swab128 - return a byteswapped 128-bit value + * @x: value to byteswap + */ +#define __swab128(x) __fswab128(x) +#endif + /** * __swahw32 - return a word-swapped 32-bit value * @x: value to wordswap diff --git a/include/uapi/linux/types.h b/include/uapi/linux/types.h index cd4f0b897a48..a4500baaccd6 100644 --- a/include/uapi/linux/types.h +++ b/include/uapi/linux/types.h @@ -32,6 +32,10 @@ typedef __u32 __bitwise __le32; typedef __u32 __bitwise __be32; typedef __u64 __bitwise __le64; typedef __u64 __bitwise __be64; +#ifdef CONFIG_HAVE_128BIT_ACCESS +typedef __u128 __bitwise __le128; +typedef __u128 __bitwise __be128; +#endif typedef __u16 __bitwise __sum16; typedef __u32 __bitwise __wsum;