From patchwork Sat Apr 30 13:51:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongren Zheng X-Patchwork-Id: 12833281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C13B7C433F5 for ; Sat, 30 Apr 2022 13:51:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W98tRNWw4o4yvJBHrgAn0huQJmv1ud0x7OliZIv2Nks=; b=3H6PsCHRH0D0Ez 5gK2rJVcGpHLWH92TLgiAMpwH37xpkIAb/SQehQtQZ4+7AssjR9xWer20DP+0XojlCuzqVxYKvnNf 7ZVc4IZM0I+/GYvId0PtBPXQUukoS+K0g234KSGM4xpAE4IwqNVnJk8O/nCViyRVmbL4BJGriH33f 7cS9zIFD5EoEC31bYs8bxiyavtC5k83SRAi/l1DTSqXnIiWPHYt+tATP2TbGTH4RmTOM5Bx2R6Aqn a+Qw0kP8AKmlppG/gqztJbbJdDjYDWADV+PxXGgZZeeaSDvyreOjSsb2M+d6gCbr65QXawlz7OjyR e4zlTRE7NKREkI3gWe7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nknVX-00ENC2-Qh; Sat, 30 Apr 2022 13:51:35 +0000 Received: from mail-tycjpn01on2071c.outbound.protection.outlook.com ([2a01:111:f403:7010::71c] helo=JPN01-TYC-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nknVU-00ENAK-Nk for linux-riscv@lists.infradead.org; Sat, 30 Apr 2022 13:51:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AHxBNurMNGE0buCWOHfsHk13gTQtFtn68vStkY66oirTYWkNORCi0unLAijOKhEG501hkRUgOpIYKWnHe3z/NNTqh9D/hmDIcWpBYlR6DxVrOe2uvZi02xJnVUXp7vLSVvQCL77VmcIhFv6VaaV37I1YQBxmFZVelbAidMrH/uytE0u8YcUA+wb5UzdTmZDlIpparh7Yx1rLweWuHB3PBZ+OdCYm13ADTSMfC2RDRJMjjz6ntVKaUc8UBUgeGpqzNuDfFUH1JNrx0khsiFKhXOiwBHcUn8tQ0UzL2w6u5P2to8BOVWaCmJCm3xTq+hB4oNypb4wMvPb/zwRd0CDsEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LmgCsUrRFQiDkhjhuP0NOx/lzAJkFtwARE4FbvL7+C0=; b=d8eP2LKw+ByVU+EV6RkJLdlkOcLeQcj/8VNL+h4G0hF6v3IUu2A/DgH/blrgL0Ivqc9b3UFgBAH2pygq437a7G/ZIGzNhBPHssaE5vjwLSlKZX2FAiavnsasMHkf8v+ZAohoQrkEozpRURjNSHosjtWSGPQ1B6QBgazpMWOohdMXu+0d5Hlcc+2mpUDbJxvFFFYBMk83pdGHg9WkzA7li/KydCMk0IjVkd1W28PXoBu8A8hW7eGBp9GVQGS3jIHDYGwn1bxKnySFdNlqnMF+4xFKMG+CjdnouMa1KUf7yiytwv2GRyjc+qkD4/6QmjpC+54M8g55Lfw9WQ6SV2SGkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=zenithal.me; dmarc=pass action=none header.from=zenithal.me; dkim=pass header.d=zenithal.me; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zenithal.me; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LmgCsUrRFQiDkhjhuP0NOx/lzAJkFtwARE4FbvL7+C0=; b=AyJPX6NiAe2dK9ODObFRGl/QH01b/mupEujQfHlJ6fWjpSA3fixSOgLB+ipEo2dWpsxn2NQg9eJH7jTGfsOmOmUzuEZVrzSv20wgEuXx8GzyX96hC/2joynUY0EL179978shMzoOFRkM1guVAKOyOUZ99SyIGtsPSy6qmT3pDbc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=zenithal.me; Received: from TYCP286MB1393.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:c0::6) by OSZP286MB1559.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1b4::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.14; Sat, 30 Apr 2022 13:51:24 +0000 Received: from TYCP286MB1393.JPNP286.PROD.OUTLOOK.COM ([fe80::bd99:5c83:e2dc:a8f7]) by TYCP286MB1393.JPNP286.PROD.OUTLOOK.COM ([fe80::bd99:5c83:e2dc:a8f7%6]) with mapi id 15.20.5206.012; Sat, 30 Apr 2022 13:51:24 +0000 Date: Sat, 30 Apr 2022 21:51:17 +0800 From: "Hongren (Zenithal) Zheng" To: Palmer Dabbelt , Paul Walmsley , Albert Ou Cc: Atish Patra , Anup Patel , Eric Biederman , Kees Cook , linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Michael Kerrisk , linux-man@vger.kernel.org, Jiatai He Subject: [PATCH 2/3] RISC-V: uapi: add HWCAP for Bitmanip/Scalar Crypto Message-ID: References: Content-Disposition: inline In-Reply-To: X-Operating-System: Linux Sun 5.15.26 X-Mailer: Mutt 2.2.1 (2022-02-19) X-ClientProxiedBy: BY3PR10CA0010.namprd10.prod.outlook.com (2603:10b6:a03:255::15) To TYCP286MB1393.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:c0::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1b8ba11a-9e21-4747-6a4b-08da2ab083b7 X-MS-TrafficTypeDiagnostic: OSZP286MB1559:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rgxlnJNqf8Wa11zhqqGI0eXt26A/pe7SIYfej+7A+EV+4nnSlVKjSC/78UWxOVLikmQvCVGqf7OVlOCPYBtjFBQBMtaUmBKHUChWKjJGjH5b8ze5z+eHGRBBL83crHCmRype/h2W5uidE1Vynevken8mFYMGlata/Mp2BWjxRZ5wCyqEEP8GCILAu0QYmlNWf+6hRZmK43lEvfPqUGAI1YBHPrRUYGg80HLqCUUYevFqbn7BOt51x4M/81AP3JTFR2DUGAE679dkfCZ/p0JeIlmx7x/EeARF9xWMNEwiWj551n3ly1D5FUGI0+HTbNzNUHY2Yvm7MplRqGV/ytkeIji0f+xF6kxcsPvkBvjXSlAbpCAKOqgY8+ao+fT2+/Wn/2AkJNrwqKqYLH2U5Q4tYEsDNljKcmsTR1TsMhnTtYE1JNHIMLkc72uI4phNw/fhdfMfTqhxvH4ib+M2SqUV276fWh+0DZ7o0y1ywzYJh0vrLLQVSxE7rpdpJ6PPwn7HNSmbPwxCMG4YYTAkKRHNSpyU/Wqjfb/BLVXkcOoXIt0vPK+W5atuSyThDe3RqjABLkQv5SJjiGa8NA4S0d1kKyy7J+UyWblHMy1ru0LBfdHJdqryctHCsWKlJeL/eBfOCqOvD+y081A28dyIhrLu8okZaId4wyH7R7XCGxIjwW07DDYmreJbtZ+FbN2b4SMGnwW49nq08clS7kaR/u/68N1u0BdiMAZtiissa1gjoze+yn0x2VOi+xOBGrE+N1aQP/kudaI2UresQJkD4ajRB8oXbDIWwh2htL9c2urHQKE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYCP286MB1393.JPNP286.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230001)(7916004)(136003)(396003)(366004)(39830400003)(346002)(376002)(6486002)(6666004)(6512007)(86362001)(52116002)(33716001)(6506007)(966005)(9686003)(508600001)(110136005)(186003)(38100700002)(83380400001)(786003)(54906003)(316002)(8936002)(5660300002)(7416002)(2906002)(4326008)(66946007)(66556008)(66476007)(8676002)(49092004)(67856001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 60lVRJIm7eBDrb4HnyO5HrKP40/R6etad5dVPNmDFqcHBOmuIf7ycFtIc4+AiEQ4GnNaN5BT2ePSKekVPWkXaGd2kfpiKrdbHM6WCkzafa8fzST1oMu5676hieSu9+WIYlIxAGyjMmwsQaVTiF9YMjmvIwjAmsJz+3XGfoW+PbGDLbWKD3yR73iEpkc3YKKxmEfdpbVJ2gFsnD6/2xSDe53o19xBK683cxGlJcUanCgsCOg6dEmW7kYeB7qOMTvHtwCn6gX0l6QLN16elDtRtl4RuEWvx3XLJJBsSSnG+piznEdINKRz2hzDVTV7lLpQSV11KDIf59im5JDJ3FqhX9kiVGb22yVBdjD4a8ghKXK89fjdPOgurTH5+W9ePsq0fIsbK3dTZ14EEZb7x8j1t7Iv1NTTf6MSIGw/G3KgxUJibsq/ZVDFGd30bKilJ1t0doIGc/uMe+h0LGTDVMZSKNH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T8am70TxZ2vXJYArh2JhgOBtozJ9xD8wl5LagE2vFEAJ/QRtM8/U4EZHgpS+DMWCDId7N89pEP+ZXbw8Kgk7invjjQi1nj/zp8B5WjDO53pMfwSXHu7P1I/7W2RQ1MhxHrbajaIXSTTHgwedZekfh5Vq7yhFp1K0Q4gwgS8DDoS/YDAqbyP54HDpuK0YtAkA== X-OriginatorOrg: zenithal.me X-MS-Exchange-CrossTenant-Network-Message-Id: 1b8ba11a-9e21-4747-6a4b-08da2ab083b7 X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB1393.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2022 13:51:24.1448 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 436d481c-43b1-4418-8d7f-84c1e4887cf0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1HAqmPl28AaZPCa74JvTfsW7h27OpeyX03LNu4HTbydelywpXkGpNXa/Wlk7hrrL X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZP286MB1559 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220430_065132_803681_CB2EE2AB X-CRM114-Status: GOOD ( 10.54 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org userspace currently lacks a way to detect whether the platform has Bitmanip/Scalar Crypto capability, this commit provides a way such that the userspace can detect it. RISC-V currently still has no mature mechanism, but no matter how things in the spec changes, (no matter how "M" mode things change), the kernel still needs to offer some API to the userspace. More discussion can be found at https://github.com/openssl/openssl/pull/18197 Userspace currently has to use env var to detect them. This commit along does not assume any specific mechanism below kernel. Tested-by: Jiatai He Signed-off-by: Hongren (Zenithal) Zheng --- arch/riscv/include/uapi/asm/hwcap.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/riscv/include/uapi/asm/hwcap.h b/arch/riscv/include/uapi/asm/hwcap.h index 46dc3f5ee99f..bfed3e5c338c 100644 --- a/arch/riscv/include/uapi/asm/hwcap.h +++ b/arch/riscv/include/uapi/asm/hwcap.h @@ -22,4 +22,26 @@ #define COMPAT_HWCAP_ISA_D (1 << ('D' - 'A')) #define COMPAT_HWCAP_ISA_C (1 << ('C' - 'A')) +/* + * HWCAP2 flags - for elf_hwcap2 (in kernel) and AT_HWCAP2 + * + * As only 32 bits of elf_hwcap (in kernel) could be used + * and RISC-V has reserved 26 bits of it, other caps like + * bitmanip and crypto can not be placed in AT_HWCAP + */ +#define COMPAT_HWCAP2_ISA_ZBA (1 << 0) +#define COMPAT_HWCAP2_ISA_ZBB (1 << 1) +#define COMPAT_HWCAP2_ISA_ZBC (1 << 2) +#define COMPAT_HWCAP2_ISA_ZBS (1 << 3) +#define COMPAT_HWCAP2_ISA_ZBKB (1 << 4) +#define COMPAT_HWCAP2_ISA_ZBKC (1 << 5) +#define COMPAT_HWCAP2_ISA_ZBKX (1 << 6) +#define COMPAT_HWCAP2_ISA_ZKND (1 << 7) +#define COMPAT_HWCAP2_ISA_ZKNE (1 << 8) +#define COMPAT_HWCAP2_ISA_ZKNH (1 << 9) +#define COMPAT_HWCAP2_ISA_ZKSED (1 << 10) +#define COMPAT_HWCAP2_ISA_ZKSH (1 << 11) +#define COMPAT_HWCAP2_ISA_ZKR (1 << 12) +#define COMPAT_HWCAP2_ISA_ZKT (1 << 13) + #endif /* _UAPI_ASM_RISCV_HWCAP_H */