Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1369770iol; Sun, 12 Jun 2022 14:15:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxm9z+DZsa9I6dXIOjRHuh3I0TEucPrtkoSKceej4BVkU3hb/8Hu7fHj26oWjGeGaCz2ftB X-Received: by 2002:a17:90b:350b:b0:1e8:5177:fe7d with SMTP id ls11-20020a17090b350b00b001e85177fe7dmr12259625pjb.142.1655068545496; Sun, 12 Jun 2022 14:15:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655068545; cv=pass; d=google.com; s=arc-20160816; b=IyFhiD/1SXlX/UBPZfmFjpXxfhWUYr+KeYSdZlCTptlLBzvLcuFB7xvU1MYJPIuVhr o+J+1ZLi+SC2PEdEX6KsiOQjiBM/m4xtECsa34g4UwaEhTUsEtfiYIRpefXySzBKjAgR +3BiNBJY1N3qYx9JbczbcqiV/O/ekliO9+o2KW6HeYsgniYFTOgpdgtw4HQlldQAlbKT 1NxOYo39dAngOtMBDccDGUew9JgKtwur7DtmzeOnfPWOsDSsQAKd104pJK2G8R2BGLpj tTL1VmCHZlB7MQsiF++U7H8JZPAyJdwPaC1kV3DeVj8fsoSu1zpwagwEJNnN3XwtM6X5 X3MQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=s6iF86d0klIhnVYVoG4MMBhAtxWA0VNgvmGZaOQZolE=; b=F9kSWE8eoTl71mSaO7nTnt+vvAzZfhguULzlmhsHP09HAOmdOo6X/42jlPgXsr/YYO u+quMnHVkrfdrjP6vpavmgkiZSxzxc8ZEPlDO7Sr1TkKuni6RkOhrBOmB/KwVepLukk5 AOGKaIx/HEnaEj+bET840Vt0WHBW/CmnN/fCxJSpm9wPYeQSEU/0d5wJM1A2m0XgTIrR ywRg6GBACRirAfHzURAkxfK7nd/SVFFLIdIA1rQg4FjUP0HW6hGygNysg1XxsN27r4pI lkqIcjzKLAWdwNXkbZT2cka/j5CBxmnzaSS152UUx3DhAF7+wbpBFjUn8VEeINVynCJA H52w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@zenithal.me header.s=selector1 header.b="K/FiWPq0"; arc=pass (i=1 spf=pass spfdomain=zenithal.me dkim=pass dkdomain=zenithal.me dmarc=pass fromdomain=zenithal.me); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zenithal.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t69-20020a638148000000b00401e73b4dc0si6703314pgd.550.2022.06.12.14.15.34; Sun, 12 Jun 2022 14:15:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@zenithal.me header.s=selector1 header.b="K/FiWPq0"; arc=pass (i=1 spf=pass spfdomain=zenithal.me dkim=pass dkdomain=zenithal.me dmarc=pass fromdomain=zenithal.me); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zenithal.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233367AbiFLSqr (ORCPT + 99 others); Sun, 12 Jun 2022 14:46:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231961AbiFLSqp (ORCPT ); Sun, 12 Jun 2022 14:46:45 -0400 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01on2099.outbound.protection.outlook.com [40.107.113.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA0315C857; Sun, 12 Jun 2022 11:46:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lhBuoORmUvd+pV9ZaxMl9X4qy+rnGRvM90NU2f2aWKTulIazHXBne4EmqABqmUygiS0M3g1YYGM6+ZA/z5by9iPiimRfRrHUH0G7WYytq12YM94PbVCyJtV7oIbucqjzIy9i+r20rfr7yMJAuAaDDglI2LYgOpV3d31yrhg6UpNDBgF5nXhwHLPfbp4tYXzau6O20UkBF6OhSI/S0i38iRl/5XWgQ2KeaPB9rorADazRX7JIenjAnmzVBH1KSVftN0dYMw1fKs9PUpwCMoBbWeU0jU5I8lOFctRgN4O44Re3uZpcogNKgmF/187Ln7U7dsU9qOyU9ea1eSmvtmFPTw== 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=s6iF86d0klIhnVYVoG4MMBhAtxWA0VNgvmGZaOQZolE=; b=MzQJfUthycuTkYwAjykO1G02BN8dGCGh5ga3p9wgewOpTmlMqk2a2wVnA0iS9FvEoX2oDwoxDuo7bgDCNZzGMs8ecAkway4NYNaPvhBxVHuG04G45b5rGVajrNCQnklnWVLpMhLcPV6y4D81U6+d2/sIlbDFw7hJoxBxvHK7YMIe0XOdyY7cQFUi9/0TLpGCnSyS/pFAHgxBP3yCPVTCBXHKElxUrJeAZOejp3qetS3WA5m6IO6b7u26l/F7He+f/O8fiYy9tcDF7xZbQsK+uCLcdEtNdz5jLPU3hKfcFJ3YZ5OYwdeBPxyl4TDXPuSVRNm8mDLs0XZe5hfH3I7hMg== 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=s6iF86d0klIhnVYVoG4MMBhAtxWA0VNgvmGZaOQZolE=; b=K/FiWPq0aObJmLdnRXHrZPOKMIUuHBekJu7sYcOJBw2uztJ3ocE1Qkz8jcL/aTJqGYDnSUH2NUBjP9u6ofWgJ4ajDcc9tgdIfcirBBZIIM7hj35bRnTfRUhHiEcKUuveFUy6EdorvpXhZyzIkP8wFvnhSAr9pQcxUbJ84oYTxqI= 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 OSZP286MB1063.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:111::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Sun, 12 Jun 2022 18:46:42 +0000 Received: from TYCP286MB1393.JPNP286.PROD.OUTLOOK.COM ([fe80::a162:2f17:bb41:c95]) by TYCP286MB1393.JPNP286.PROD.OUTLOOK.COM ([fe80::a162:2f17:bb41:c95%9]) with mapi id 15.20.5332.020; Sun, 12 Jun 2022 18:46:42 +0000 Date: Mon, 13 Jun 2022 02:46:35 +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 , Heiko Stuebner , Conor.Dooley@microchip.com Subject: [PATCH v3 2/3] RISC-V: uapi: add HWCAP for Bitmanip/Scalar Crypto Message-ID: References: Content-Type: text/plain; charset=us-ascii 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: SJ0PR03CA0160.namprd03.prod.outlook.com (2603:10b6:a03:338::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: a8adcbdc-7f87-4771-a3a8-08da4ca3e474 X-MS-TrafficTypeDiagnostic: OSZP286MB1063: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: mtS3fzECMExrKFo+Cq105poPLucDKJAFdzgLeodCIq8gpdK34dgT7GEbpZEQJA/WHjPKOfJqIv5Lf4cH9TCmEL/k0ol1niasdGFRhFiM9M4QV2rCLSdBp7AEyvqxnkdBzNO16aZu7C2M5sBavK/hyjBdLv5v9FigOmlz5SKF+uT6+Mujx6zsl6DSzrdM5j/U46bbAmSO93XIAy80JUbmwiFQLKzYURC7a9KxPDeGKsPgA6cESVC6oxM9FVkXVki2OR0jRhqLqKT5fjudZhkpdKp8aZ2DePX/aJnpQbf7gqeaGXcwkMT3zl1bf3mPKUy/VzZwYi7XuFdGyYvxy3dMUFOKnITlh+xXYGdJDVw17xIwQu6w3nY9W2wrio7H/CLYbr7a27jql+p7Z/zJpNVr/z/X7eiZFYgfbu4VJoeG5ccgsB1iu3jlQRpUq3sEtCAyJA47ul3FDkq63pbC7z3h5S5rUo/eXkNX/XHsu1MsYX3VBMEWFi+pIZ7MDNi/eneVqnF4mzzuUuJlxnYw/SN/39C3U2OmjqKxR0WoWWlRcUHn4BXS1yBHGCignY1Pn4tXeh+yXMGsQThHo/ug7PS3HwfcEWbUNfIsdYGZkndMqlNbzw+z8oBFuSmMbguqy51yDPyHgWaiZ7sf/qIi/TvxdANS62sU4EYpUfKRNBqtHe+4H3yT1MxuaKxWivLSVC+nVP6Aef/p8c6Mg7q98LGsnuoSORZ8mtJ3qiXhlqFRZSiV0zcVwHjxXjjYTPCtLmjYumS3zV0ur9gDMen+cNsHqA== 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:(13230016)(7916004)(136003)(39830400003)(366004)(346002)(396003)(41300700001)(41320700001)(6506007)(52116002)(9686003)(6512007)(6666004)(786003)(316002)(110136005)(54906003)(66946007)(66556008)(66476007)(33716001)(6486002)(966005)(86362001)(508600001)(38100700002)(186003)(83380400001)(8676002)(4326008)(2906002)(7416002)(5660300002)(8936002)(49092004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?72ccEPmFxyu3JYVa5s4l3Tb6fW3wT7tQCTkJteyQlQRE3YnDs42SlZEhCC4m?= =?us-ascii?Q?FNbFl6mZ5vQ9okV+JWfYaINE8dIfveF9hLlQlu66mMdLFRWRIgZdbTYLHWbO?= =?us-ascii?Q?GG+BxE3DLyGiy+TGHFA/BZfUU7JPbpmgJyy22NyKZrjbd8zW5DzHpeaBoaWL?= =?us-ascii?Q?0nGfMpI5j0iM46r+mTzclOI5vuMXTwGobH0+EZ0sRFc291zO9laNXphFZOWg?= =?us-ascii?Q?mLO+mOEooVXBl3iYp/pa4sGBT4CLUOEazrYCjcXvppwxqiEbSID+swPQbvkQ?= =?us-ascii?Q?02bXHH7BxGv7elc00i6JJj22Y36Tlygo+8l/JqkEEHN56WzuFg/O7TTNgPUz?= =?us-ascii?Q?09OkhhRb4hc1QnGDt8Dwt8Zr31+FCqBMpKZtqJlKNT3o+EgLdMHscsnkXZLM?= =?us-ascii?Q?WV81Y7OJVunnO/WhUBNfJEyZKw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?us-ascii?Q?hmU/mZlPD4ktJ2EHl3cLGRGuwUk2VFxbr+6mx/x+4Ac/r55zKEIkU4JX4EhT?= =?us-ascii?Q?kK/WwPNmiC2lsRmW/tzHmATWJ7qAmw/A82u9K81Rgkb0tD2qhv/XQ7FA4WBg?= =?us-ascii?Q?GaPp+MwndffTHB+Xhu23/K38EZyeZD5L4ALb77iyB7DI6tilgGDc9nTZUlI9?= =?us-ascii?Q?xFVly+HASYFOQsaVx+jQfasAp1IXxqR0FtmPfkyFGQ5Mg9xo0XqaqsFDv88A?= =?us-ascii?Q?72nQuLtILyyrVedm8gjlPG7/x6xFcooBbWhDBX7sXmVqp8qzwmuztBBF7cqh?= =?us-ascii?Q?7GJkjG/MszPN517piaw3AMbGYAURbCFvOw7Ir/ZovrODSSCtyS/3yh48RZ/h?= =?us-ascii?Q?4QAAa6/X3MKf/LYGuPBOPR1Y3iC6Aq0p9YPtrfQgL3ZD3hcaXXEJHcvKKhpc?= =?us-ascii?Q?5n6fXSItXw=3D=3D?= X-OriginatorOrg: zenithal.me X-MS-Exchange-CrossTenant-Network-Message-Id: a8adcbdc-7f87-4771-a3a8-08da4ca3e474 X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB1393.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2022 18:46:42.5387 (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: R50NL+1EL2nhqSl2wvcDOstg3ctZapYmQUWktGc1llzEL7FBb+1NWtXfJ5X1Tfm0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZP286MB1063 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org userspace currently lacks a way to detect whether the platform has Bitmanip/Scalar Crypto capability, this patch adds an interface 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 In short, userspace currently has to use env var to detect them. This interface does not make any assumptions about the underlying hardware 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 */ -- 2.35.1