From patchwork Tue Oct 17 13:14:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 154273 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4126726vqb; Tue, 17 Oct 2023 06:16:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJoOghYcvTY1/HhsKyAaGapq05aimSwFU5X0r8gugpJ0DPucKFYtJC7ujMFsugv8DVEHd0 X-Received: by 2002:a05:6a00:2a41:b0:6bc:67ca:671d with SMTP id cf1-20020a056a002a4100b006bc67ca671dmr2116432pfb.1.1697548590139; Tue, 17 Oct 2023 06:16:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697548590; cv=none; d=google.com; s=arc-20160816; b=joqAeRWZFXvzM9ZvDxymOoPWe4ai9ZE/28lv/KDaC04QmOs5vEF/qKzHZsNzUNtoUU N7JmQx/wuN43ZP3ns6YeRE5K3TN7vUyc82rzggfDrQds1yi0LHT3sAyWTJawoOYjC0ux J1MyJAixNd8UDLQxgyOcUHjRPevEbJa3Vdv2cp/A7Qabk8XQSfdcARcC3FwC6YXBEacW a8r9P1ue3wcUl2iTWyQdQceIAf3jKI0Fufkb0f3FURBDGF6up6GTIHxUJKLNw8ZHbyXy ld6DGrh9MRHXWm+MgovsZlEyXqbBb2iR4y1WludTmnLdvSlRlmY+hLfMyUT8WiDMrlJC xIQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kAwzEIcm8h808xpQc++6VSntDVwJ3qhe3e6hBMESJ6w=; fh=lvGFqwUxN+Dx1jonz8cRGrvjuKDcjMXylffmtrJGOYA=; b=dDE5mIuJcd5tc2zdcf+xGeR9SJ50Nc0CylfABJ9quua2AQOlBmT6b8L5rFkQ9DN/Pw ZjYyoUCFM57olsgL/aZTHOUMn+U9JmXwAto29Q1/zKPQPbkuKPx3fTw97jIkS2Q19A8z CoWU2wVmSU4eAuvgOeaoH3zZWV/hl9TbnJoigpMFhOdxwUt1cqLe+1pcf0T3fWEeWzTn lGEqwLB3cu+Oha5murn8Vk7isdwOtWiis4G3Ota1AqE+dyMkCY4VhWfg3SGug3NX+NLe oIk6iXtWyQcPH/Awn5WMKVg0PDCxK3TwTxrT1PfQ53z6wINy9uaaUsAqbCHtGlP+k1SU rvIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=3OAPtVaP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id x13-20020aa79a4d000000b006bd92721f4esi1596517pfj.293.2023.10.17.06.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 06:16:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=3OAPtVaP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 653B68033DEA; Tue, 17 Oct 2023 06:16:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234970AbjJQNPx (ORCPT + 19 others); Tue, 17 Oct 2023 09:15:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343611AbjJQNPf (ORCPT ); Tue, 17 Oct 2023 09:15:35 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0588ED for ; Tue, 17 Oct 2023 06:15:33 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2c519eab81fso3998031fa.1 for ; Tue, 17 Oct 2023 06:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1697548532; x=1698153332; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kAwzEIcm8h808xpQc++6VSntDVwJ3qhe3e6hBMESJ6w=; b=3OAPtVaPDwxeYj2/Vaywhdl5nKRxznfJRIMCbal1tcUXD3yvxyYlj/8HrBcuwQuPMs K5/kVwRimwnr2xeEAeaz0d4P1p6FfwQFxEB1CzyytWhk63vAJtT/PErQPEXeLNV3c7tk RR604JV1bZ3AfuG/nqlLEgxqrks6ZqnKmoL4h4BFWiLc2vkL4bFBZUXR6CZ834OhTFrh OQt6FsHTiPujAxsxgDv1SiPHth60PUP0QKRVjUi2RLL6rkIJDHtqBPX4Yd9IXff2slaI OlUu37Bpkayp0cu33WtEt6DSK0aydC+gH3lcKaeGnWRCb8Aen07wIMQVMfAeUFQcldcz RakA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697548532; x=1698153332; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kAwzEIcm8h808xpQc++6VSntDVwJ3qhe3e6hBMESJ6w=; b=MkVG8OgowPk07BCVJvNNR/WHG+rqkAzofcFqSNceIe29OEdPEzdVLEPDezgef4FYY0 p7AUZb7oWSWL0Mpo2vPpABkCFcvc0RqKLPHFk2n11+EbEAGZHiIhrX3qMOdPBVuN1/jY 1aqiuZTOvnv63UTvg+eRtvsww2i2nVerlisFTqBeCsr+/N4kAA19tdUPiGz1FlFRGw18 r6pWII9OkOyedt3Zrzv5YB00ODErqOtwvxKn4fiPseSrlBP3w2yYxm3r7sVe6FBL/M5h OclgDZoHYydSX5aTbqU9KkxinUakzFX8/PJcNCBlIFeMmG0mZDfUC9of8ZuZEbBoyYlL YVYw== X-Gm-Message-State: AOJu0YxevR+iibNhAgfB1zg0V5CczpnlO436lvnHuMWvM7oIrB0fYEUC SGdnv14Hel+P734laBgpvuaZAw== X-Received: by 2002:a2e:b5ad:0:b0:2c5:36e:31bf with SMTP id f13-20020a2eb5ad000000b002c5036e31bfmr1328347ljn.5.1697548531317; Tue, 17 Oct 2023 06:15:31 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:96:820c:ecf7:a817]) by smtp.gmail.com with ESMTPSA id fj7-20020a05600c0c8700b0040772138bb7sm9873393wmb.2.2023.10.17.06.15.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 06:15:30 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Palmer Dabbelt , Paul Walmsley , Rob Herring , Krzysztof Kozlowski , Albert Ou , Jonathan Corbet , Andrew Jones , Evan Green , Conor Dooley , Samuel Ortiz Subject: [PATCH v2 05/19] riscv: add ISA extension parsing for vector crypto extensions Date: Tue, 17 Oct 2023 15:14:42 +0200 Message-ID: <20231017131456.2053396-6-cleger@rivosinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231017131456.2053396-1-cleger@rivosinc.com> References: <20231017131456.2053396-1-cleger@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 17 Oct 2023 06:16:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780008710662242818 X-GMAIL-MSGID: 1780008710662242818 Add parsing of some Zv* vector crypto ISA extensions that are mentioned in "RISC-V Cryptography Extensions Volume II" [1]. These ISA extensions are the following: - Zvbb: Vector Basic Bit-manipulation - Zvbc: Vector Carryless Multiplication - Zvkb: Vector Cryptography Bit-manipulation - Zvkg: Vector GCM/GMAC. - Zvkned: NIST Suite: Vector AES Block Cipher - Zvknh[ab]: NIST Suite: Vector SHA-2 Secure Hash - Zvksed: ShangMi Suite: SM4 Block Cipher - Zvksh: ShangMi Suite: SM3 Secure Hash - Zvkn: NIST Algorithm Suite - Zvknc: NIST Algorithm Suite with carryless multiply - Zvkng: NIST Algorithm Suite with GCM. - Zvks: ShangMi Algorithm Suite - Zvksc: ShangMi Algorithm Suite with carryless multiplication - Zvksg: ShangMi Algorithm Suite with GCM. - Zvkt: Vector Data-Independent Execution Latency. Link: https://drive.google.com/file/d/1gb9OLH-DhbCgWp7VwpPOVrrY6f3oSJLL/view [1] Signed-off-by: Clément Léger --- arch/riscv/include/asm/hwcap.h | 10 ++++++ arch/riscv/kernel/cpufeature.c | 56 ++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index ab80d822c847..a2fac23b0cc0 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -69,6 +69,16 @@ #define RISCV_ISA_EXT_ZKSED 51 #define RISCV_ISA_EXT_ZKSH 52 #define RISCV_ISA_EXT_ZKT 53 +#define RISCV_ISA_EXT_ZVBB 54 +#define RISCV_ISA_EXT_ZVBC 55 +#define RISCV_ISA_EXT_ZVKB 56 +#define RISCV_ISA_EXT_ZVKG 57 +#define RISCV_ISA_EXT_ZVKNED 58 +#define RISCV_ISA_EXT_ZVKNHA 59 +#define RISCV_ISA_EXT_ZVKNHB 60 +#define RISCV_ISA_EXT_ZVKSED 61 +#define RISCV_ISA_EXT_ZVKSH 62 +#define RISCV_ISA_EXT_ZVKT 63 #define RISCV_ISA_EXT_MAX 64 diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index d3682fdfd9f1..8cf0b8b442ae 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -144,6 +144,46 @@ static const unsigned int riscv_zks_bundled_exts[] = { RISCV_ISA_EXT_ZKSH }; +#define RISCV_ISA_EXT_ZVKN \ + RISCV_ISA_EXT_ZVKNED, \ + RISCV_ISA_EXT_ZVKNHB, \ + RISCV_ISA_EXT_ZVKB, \ + RISCV_ISA_EXT_ZVKT + +static const unsigned int riscv_zvkn_bundled_exts[] = { + RISCV_ISA_EXT_ZVKN +}; + +static const unsigned int riscv_zvknc_bundled_exts[] = { + RISCV_ISA_EXT_ZVKN, + RISCV_ISA_EXT_ZVBC, +}; + +static const unsigned int riscv_zvkng_bundled_exts[] = { + RISCV_ISA_EXT_ZVKN, + RISCV_ISA_EXT_ZVKG, +}; + +#define RISCV_ISA_EXT_ZVKS \ + RISCV_ISA_EXT_ZVKSED, \ + RISCV_ISA_EXT_ZVKSH, \ + RISCV_ISA_EXT_ZVKB, \ + RISCV_ISA_EXT_ZVKT + +static const unsigned int riscv_zvks_bundled_exts[] = { + RISCV_ISA_EXT_ZVKS +}; + +static const unsigned int riscv_zvksc_bundled_exts[] = { + RISCV_ISA_EXT_ZVKS, + RISCV_ISA_EXT_ZVBC, +}; + +static const unsigned int riscv_zvksg_bundled_exts[] = { + RISCV_ISA_EXT_ZVKS, + RISCV_ISA_EXT_ZVKG, +}; + /* * The canonical order of ISA extension names in the ISA string is defined in * chapter 27 of the unprivileged specification. @@ -221,6 +261,22 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __RISCV_ISA_EXT_DATA(zkt, RISCV_ISA_EXT_ZKT), __RISCV_ISA_EXT_DATA(zksed, RISCV_ISA_EXT_ZKSED), __RISCV_ISA_EXT_DATA(zksh, RISCV_ISA_EXT_ZKSH), + __RISCV_ISA_EXT_DATA(zvbb, RISCV_ISA_EXT_ZVBB), + __RISCV_ISA_EXT_DATA(zvbc, RISCV_ISA_EXT_ZVBC), + __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB), + __RISCV_ISA_EXT_DATA(zvkg, RISCV_ISA_EXT_ZVKG), + __RISCV_ISA_EXT_BUNDLE(zvkn, riscv_zvkn_bundled_exts), + __RISCV_ISA_EXT_BUNDLE(zvknc, riscv_zvknc_bundled_exts), + __RISCV_ISA_EXT_DATA(zvkned, RISCV_ISA_EXT_ZVKNED), + __RISCV_ISA_EXT_BUNDLE(zvkng, riscv_zvkng_bundled_exts), + __RISCV_ISA_EXT_DATA(zvknha, RISCV_ISA_EXT_ZVKNHA), + __RISCV_ISA_EXT_DATA(zvknhb, RISCV_ISA_EXT_ZVKNHB), + __RISCV_ISA_EXT_BUNDLE(zvks, riscv_zvks_bundled_exts), + __RISCV_ISA_EXT_BUNDLE(zvksc, riscv_zvksc_bundled_exts), + __RISCV_ISA_EXT_DATA(zvksed, RISCV_ISA_EXT_ZVKSED), + __RISCV_ISA_EXT_DATA(zvksh, RISCV_ISA_EXT_ZVKSH), + __RISCV_ISA_EXT_BUNDLE(zvksg, riscv_zvksg_bundled_exts), + __RISCV_ISA_EXT_DATA(zvkt, RISCV_ISA_EXT_ZVKT), __RISCV_ISA_EXT_DATA(smaia, RISCV_ISA_EXT_SMAIA), __RISCV_ISA_EXT_DATA(ssaia, RISCV_ISA_EXT_SSAIA), __RISCV_ISA_EXT_DATA(sscofpmf, RISCV_ISA_EXT_SSCOFPMF),