From patchwork Wed May 18 09:25:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongren Zheng X-Patchwork-Id: 12853413 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31C85C433EF for ; Wed, 18 May 2022 09:25:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 962556B0072; Wed, 18 May 2022 05:25:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9117C6B0073; Wed, 18 May 2022 05:25:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B1C76B0074; Wed, 18 May 2022 05:25:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6C9736B0072 for ; Wed, 18 May 2022 05:25:13 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 45419605B8 for ; Wed, 18 May 2022 09:25:13 +0000 (UTC) X-FDA: 79478330106.26.481706E Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01on2126.outbound.protection.outlook.com [40.107.113.126]) by imf26.hostedemail.com (Postfix) with ESMTP id 3F5F21400CA for ; Wed, 18 May 2022 09:25:09 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LI3tp2blQtKDatHs7/Qpl9lSlAKCaJ0D++/3hGS3cOPMVXJngZFY4vSncdKbOKkpNnTar0TmzLucKgnZ6c4i5tXrJr65hOIsln889009kn/lif1mxG8V7LaqH4nC8Mrmn1MwDgYx/qp/1J1uZyYzYqUvl5SPO7oYYEwKohpaTHAFSFFTJ68BN8d+Mf9YvCRY1wMpFL4pcblzQUk3OtYY5lROCyU1qw29sB8g0CNJZDi7tISoR6IfjdAQQRQJttO+7/XZx9Zrx2qvkookPjZqZUUNxBG0HzS/XHCKSbjrKp6glFAQi2X6BK9kAf2ZCNZgK1UMwHVkXYP9yyLnsCUs7g== 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=wNfCgJR3Ja8v/vaWzIyIYaEoo716ETZ2a3s9k40pToE=; b=KNRvifhtIPBDb9AkhiTWSDDJYs3QB0K4sY47iOE/TNMv2ukE/oCqYfY1mwoqzEUJQeYP4kO0kfqvZDPQGBRtC/LuTHqoD6m4mdK0L100rQkoDZDfaQmWrjXFExA/sfALovJ4mvUz/HSoxWVlBKrupFJTJmG4fve+/0cvIq8TbsfoNQNUf8N+ORPLz3qRFiMh+6ZmvCtDVwfbG2evaH2vTWORWSiL1m+9TbTtw5QsRoOo8XNLvHpk/qyfTj4xyci5bFgbLN1BCxFukqNfqe7VFNUfB7ANGVAXc3PcstgrE99d1GsihgAWe6ciHJFcSCQ8Sg8zu7IUV0QKpt0jTJcAxA== 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=wNfCgJR3Ja8v/vaWzIyIYaEoo716ETZ2a3s9k40pToE=; b=CGnm6ehlNosvzLECymMLxnqaBw+R/5bcKpBdGK4qoREe3TbH3tVGAWLMGpiNN92Lh4uYiv2ivWeOKjZ3Fp5Al/hU4rJci2c/gM5fS5VIDsvOxLBuDZUhYHN3jI71eEzAqyCSwZSHEWZGHVWYmpHsOuUFvduBasSsn2iLOrykuls= Received: from TYCP286MB1393.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:c0::6) by OSZP286MB1324.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:13c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.14; Wed, 18 May 2022 09:25:09 +0000 Received: from TYCP286MB1393.JPNP286.PROD.OUTLOOK.COM ([fe80::bd99:5c83:e2dc:a8f7]) by TYCP286MB1393.JPNP286.PROD.OUTLOOK.COM ([fe80::bd99:5c83:e2dc:a8f7%7]) with mapi id 15.20.5273.014; Wed, 18 May 2022 09:25:09 +0000 Date: Wed, 18 May 2022 17:25:01 +0800 From: "Hongren (Zenithal) Zheng" To: Palmer Dabbelt , Paul Walmsley , Albert Ou , Heiko Stuebner 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 -next v2 1/3] RISC-V: add Bitmanip/Scalar Crypto parsing from DT 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: SJ0PR03CA0253.namprd03.prod.outlook.com (2603:10b6:a03:3a0::18) 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: b1367cf5-9f74-4a0b-016b-08da38b04d5f X-MS-TrafficTypeDiagnostic: OSZP286MB1324: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: nLCVBNFW/ym6Egm2cma/unEDH3IqPoGIv5CBjeiHZQJ0ye+Y7dvk/6QuACIhNURte/J1NptRERXY+bHExK4vwF4ZC9XOlvt6JKlv50O8VsYLWOxtiBVm7/5qySFA6VLZSXQPFCLHFEWMIbau9qp944cf1794KI7Jg2IJJC2AR6gBDRCIcZo7ec70zl5G9tWHdH+GznyBC31/Kxv6On7f6/kFwlAbd5wahoMyWrEkOG4Nf+DHBC8CJNFHOsxOOf9+AVNWXv1FXtjivwhfAaDh+ZfwPbJ0TrGcEj3n7qNGxaphuKNFuAN/f2yPcJzikM4s5pHjMBb6YtkIVWFNpU2ZarDhudEAv67tZuPOx8PzVB2AhwcF1QwXby1sAPSBERonrUIJAkxqq/+rqFgKAw4gAYGfMGAc+Y2OsLoHDKN5/RfKO9u3k41oXNJ12r+hnGfUacWwc7xV83fbiwI1KXX85CbXnGN3qa9aRzb/zxKgKX6UtrpM6ObUHN4nW9Sv1dE9M0aa1saCDVUsi5RQk9PN5pXdjrjDTaKwugF8CSeA9Xuq32ca05sRmuTNS56H9CHER7O/zDVGE5ywcbvzRQ/z5CYSYA7cFGU09gfrblzVXSyfFafRPXED+m8DRIr5HbSY9gCcVylkllcYyB4u/E9JRgs5rECcCnaboEGTtlLjEXLc+uIM6qstlP8EugZmYnG8KTI7ot/S1McuK4Q2lxzoQw== 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)(346002)(136003)(396003)(376002)(39830400003)(366004)(52116002)(6512007)(6506007)(186003)(38100700002)(508600001)(54906003)(110136005)(6486002)(2906002)(9686003)(33716001)(66946007)(8676002)(4326008)(66556008)(66476007)(6666004)(5660300002)(7416002)(8936002)(41300700001)(41320700001)(83380400001)(316002)(786003)(86362001)(49092004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +sSh0HCXhW53nvPgK6opv1Il17XDdSbOhPwpHWvbhwkfqqVCIn3nPWwQqmHxAgZY39NQmMXW2un/vcG/QM2t5Um/XbEVy0I1Otk8rxYhPZ8GUFHBw5ZN0D6P8HHsFrk9Iblm5VD1tCEzexIsm3iY5se53JVO2pUgDOT1XXSjOnW30+lFck253CSbGZpiFAjIk2XrVXGWossrkQwIcqPQIBCA7i06aggM7PcwzHqoRShkWWybhMANolv0ANteAcppuqE2SJkNk9KfucezndivtlwMbVSbZnNXe4SFb5KFm6ByCya+7CT91Dj83bsxzhxxIU5EICgH77EOEXT6CyoncQIbWk0A5cVZRtHpuIsxoC9+aNIMgrgrC0CdvpFLtQ45HnDdznM1wG64DChOZR9zokRTrQJoB8IFcZMHWCR3QZDHZu+abEC4KItmckZF8ZbeOSSUEU56js8cTneGj656H2T5ZrGbiIiKPlYNdTK0VKbCrSdkRqOZQPiRpW744XTaVMpXePGWTwRJVXbNkhf+k20DyvGecHf89H2RVFPRhxnZ+ULCeWyp4vHQ1jVgxlSpDMeYaPaSY13hpGtIghQtLFQ/azGZ8UATjTMPupMbjS8aEL9+fYiAJ+LryybuTPK8fyW31mlq29LEnSo3H15I40j/tGZiuxypaYIXTVTpd6/nYxOCC+7soh6l6tgnUvsfvubw4YhvGhA8ojGVBYNPkWvgh01TxUU3K3lb+iauxaTp4iaCGXrOd1ptCWYN+NlJgoB8gK0u6d3s4iV4jvbZ/NgZ0+g+DvMuhOOW403zV1L55CukW1A6J31ie4fsYGEzOjNBcGZ+poOl9iHQ56OpWL5HaHvr2zjRx2tRc71IRIJjLrgiE+zyjIq+YSBboczXmUMmkjkVCFd+nA1cVmTeLdInDApX+sg6yDHLr/XRtdguf9ibVyRINOPVZ33etANBG0PD2GLV4H0iCSwilygwObkkOrXz+FU1GoEDPnLOrMQ+0mopX2UERWliIobaJz2dKcjaxMS5egOGW5iGuWB5gib+zcg9/sv3MJtq8JORkV98TgCj0CiZYBLTmRaPLcEY7ni99eAOUfX6rwPO2N8b9ENg/UIeeawlo3wkKL0o1fyUw9SFmHkGHTcWr2qThUFScIjb0FODOiwxpP1aAuVAPdvLRGChXJ1Xk+W+hnteRJcEK1NzPdxsza4QN4LqPrH4+ZoIf1cSRnjbzjDX2hYtrE+A8wbzN3RQNNqjYDRqcmecaOhRwb7MdVDtKGE9Lx9/x9jGVcdqfT1Bw/lIqWP4v0maJWzkjafBF02GqTYWzUvWgmOfPtFTmo1oeL+M5xOrPHtWmAvHi3Uqjc/v7LoBG8ambJDKjU2LVe23SP/BfJNlSmFYZqLt0SUzMVwgxg2fjzLmEOzXf8I9qRZQMcnbbX9QEYK1ij2rScDvzrnCLUesAGTn7irJR9epghLSPEDen43ckMy4EA6KiR8zM6FdajSuh2Hfg2jml3mwPP3GqhhnxLSARkAJZOupxflpPdDH3IZaF5a3LgTLNXqhTBodNo1L1cUVDjWI+SCvCJXVzvn6CPJ70kYIyYWKXpy8L7ahgiDr8FmOcgKqu7x18pcqvTFbSNdOaRJkBJx1ZZ54dBVSayP4aknm3Y3Qt+8xbvw4outzyWcTyWMSQ8H5lUMPCDHA8Ow1EH8zwirHsIa7c3BlCyjLpOP2NdFAKMWtoz4yS+FkSTLirKLbPaBlcto6Lg== X-OriginatorOrg: zenithal.me X-MS-Exchange-CrossTenant-Network-Message-Id: b1367cf5-9f74-4a0b-016b-08da38b04d5f X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB1393.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2022 09:25:09.1236 (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: jyxS+IJqzRrj1PiJmSXIWXKPZeYO/BkV2ouC8pg0ThH50lKjGTi4t+WhgoZ0u6D0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZP286MB1324 X-Stat-Signature: wcg9zfrfg8hsxfwz5s4w1188qa5y1frg X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3F5F21400CA X-Rspam-User: Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=zenithal.me header.s=selector1 header.b=CGnm6ehl; dmarc=pass (policy=none) header.from=zenithal.me; spf=pass (imf26.hostedemail.com: domain of i@zenithal.me designates 40.107.113.126 as permitted sender) smtp.mailfrom=i@zenithal.me X-HE-Tag: 1652865909-593737 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This commit parses Zb/Zk related string from DT and output them in cpuinfo One thing worth noting is that if DT provides zk, all zbkb, zbkc, zbkx and zkn, zkr, zkt would be enabled. Note that zk is a valid extension name and the current DT binding spec allows this. This commit also changes the logical id of existing multi-letter extensions and adds a statement that instead of logical id compatibility, the order is needed. There currently lacks a mechanism to merge them when producing cpuinfo. Namely if you provide a riscv,isa "rv64imafdc_zk_zks", the cpuinfo output would be "rv64imafdc_zbkb_zbkc_zbkx_zknd_zkne_zknh_zkr_zksed _zksh_zkt" Tested-by: Jiatai He Signed-off-by: Hongren (Zenithal) Zheng --- arch/riscv/include/asm/hwcap.h | 20 +++++++++++++++++++- arch/riscv/kernel/cpu.c | 14 ++++++++++++++ arch/riscv/kernel/cpufeature.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index 4e2486881840..02c454a12683 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -49,9 +49,27 @@ extern unsigned long elf_hwcap; * RISCV_ISA_EXT_MAX. 0-25 range is reserved for single letter * extensions while all the multi-letter extensions should define the next * available logical extension id. + * + * The order of them should be maintained according to the riscv-isa-manual. + * As this is an internal API, changing the id of one extension does + * not affect compatibility. */ enum riscv_isa_ext_id { - RISCV_ISA_EXT_SSCOFPMF = RISCV_ISA_EXT_BASE, + RISCV_ISA_EXT_ZBA = RISCV_ISA_EXT_BASE, + RISCV_ISA_EXT_ZBB, + RISCV_ISA_EXT_ZBC, + RISCV_ISA_EXT_ZBKB, + RISCV_ISA_EXT_ZBKC, + RISCV_ISA_EXT_ZBKX, + RISCV_ISA_EXT_ZBS, + RISCV_ISA_EXT_ZKND, + RISCV_ISA_EXT_ZKNE, + RISCV_ISA_EXT_ZKNH, + RISCV_ISA_EXT_ZKR, + RISCV_ISA_EXT_ZKSED, + RISCV_ISA_EXT_ZKSH, + RISCV_ISA_EXT_ZKT, + RISCV_ISA_EXT_SSCOFPMF, RISCV_ISA_EXT_SVPBMT, RISCV_ISA_EXT_ID_MAX = RISCV_ISA_EXT_MAX, }; diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 40c8776aec12..9d2bed2c1a37 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -87,6 +87,20 @@ int riscv_of_parent_hartid(struct device_node *node) * extensions by an underscore. */ static struct riscv_isa_ext_data isa_ext_arr[] = { + __RISCV_ISA_EXT_DATA(zba, RISCV_ISA_EXT_ZBA), + __RISCV_ISA_EXT_DATA(zbb, RISCV_ISA_EXT_ZBB), + __RISCV_ISA_EXT_DATA(zbc, RISCV_ISA_EXT_ZBC), + __RISCV_ISA_EXT_DATA(zbkb, RISCV_ISA_EXT_ZBKB), + __RISCV_ISA_EXT_DATA(zbkc, RISCV_ISA_EXT_ZBKC), + __RISCV_ISA_EXT_DATA(zbkx, RISCV_ISA_EXT_ZBKX), + __RISCV_ISA_EXT_DATA(zbs, RISCV_ISA_EXT_ZBS), + __RISCV_ISA_EXT_DATA(zknd, RISCV_ISA_EXT_ZKND), + __RISCV_ISA_EXT_DATA(zkne, RISCV_ISA_EXT_ZKNE), + __RISCV_ISA_EXT_DATA(zknh, RISCV_ISA_EXT_ZKNH), + __RISCV_ISA_EXT_DATA(zkr, RISCV_ISA_EXT_ZKR), + __RISCV_ISA_EXT_DATA(zksed, RISCV_ISA_EXT_ZKSED), + __RISCV_ISA_EXT_DATA(zksh, RISCV_ISA_EXT_ZKSH), + __RISCV_ISA_EXT_DATA(zkt, RISCV_ISA_EXT_ZKT), __RISCV_ISA_EXT_DATA(sscofpmf, RISCV_ISA_EXT_SSCOFPMF), __RISCV_ISA_EXT_DATA(svpbmt, RISCV_ISA_EXT_SVPBMT), __RISCV_ISA_EXT_DATA("", RISCV_ISA_EXT_MAX), diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index dea3ea19deee..800a7aebced3 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -199,6 +199,39 @@ void __init riscv_fill_hwcap(void) } else { SET_ISA_EXT_MAP("sscofpmf", RISCV_ISA_EXT_SSCOFPMF); SET_ISA_EXT_MAP("svpbmt", RISCV_ISA_EXT_SVPBMT); + SET_ISA_EXT_MAP("zba", RISCV_ISA_EXT_ZBA); + SET_ISA_EXT_MAP("zbb", RISCV_ISA_EXT_ZBB); + SET_ISA_EXT_MAP("zbc", RISCV_ISA_EXT_ZBC); + SET_ISA_EXT_MAP("zbs", RISCV_ISA_EXT_ZBS); + SET_ISA_EXT_MAP("zbkb", RISCV_ISA_EXT_ZBKB); + SET_ISA_EXT_MAP("zbkc", RISCV_ISA_EXT_ZBKC); + SET_ISA_EXT_MAP("zbks", RISCV_ISA_EXT_ZBKX); + SET_ISA_EXT_MAP("zknd", RISCV_ISA_EXT_ZKND); + SET_ISA_EXT_MAP("zkne", RISCV_ISA_EXT_ZKNE); + SET_ISA_EXT_MAP("zknh", RISCV_ISA_EXT_ZKNH); + SET_ISA_EXT_MAP("zksed", RISCV_ISA_EXT_ZKSED); + SET_ISA_EXT_MAP("zksh", RISCV_ISA_EXT_ZKSH); + SET_ISA_EXT_MAP("zkr", RISCV_ISA_EXT_ZKR); + SET_ISA_EXT_MAP("zkt", RISCV_ISA_EXT_ZKT); + SET_ISA_EXT_MAP("zkn", RISCV_ISA_EXT_ZBKB); + SET_ISA_EXT_MAP("zkn", RISCV_ISA_EXT_ZBKC); + SET_ISA_EXT_MAP("zkn", RISCV_ISA_EXT_ZBKX); + SET_ISA_EXT_MAP("zkn", RISCV_ISA_EXT_ZKND); + SET_ISA_EXT_MAP("zkn", RISCV_ISA_EXT_ZKNE); + SET_ISA_EXT_MAP("zkn", RISCV_ISA_EXT_ZKNH); + SET_ISA_EXT_MAP("zks", RISCV_ISA_EXT_ZBKB); + SET_ISA_EXT_MAP("zks", RISCV_ISA_EXT_ZBKC); + SET_ISA_EXT_MAP("zks", RISCV_ISA_EXT_ZBKX); + SET_ISA_EXT_MAP("zks", RISCV_ISA_EXT_ZKSED); + SET_ISA_EXT_MAP("zks", RISCV_ISA_EXT_ZKSH); + SET_ISA_EXT_MAP("zk", RISCV_ISA_EXT_ZBKB); + SET_ISA_EXT_MAP("zk", RISCV_ISA_EXT_ZBKC); + SET_ISA_EXT_MAP("zk", RISCV_ISA_EXT_ZBKX); + SET_ISA_EXT_MAP("zk", RISCV_ISA_EXT_ZKND); + SET_ISA_EXT_MAP("zk", RISCV_ISA_EXT_ZKNE); + SET_ISA_EXT_MAP("zk", RISCV_ISA_EXT_ZKNH); + SET_ISA_EXT_MAP("zk", RISCV_ISA_EXT_ZKR); + SET_ISA_EXT_MAP("zk", RISCV_ISA_EXT_ZKT); } #undef SET_ISA_EXT_MAP }