Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp320047rwd; Mon, 12 Jun 2023 14:10:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5lfPEtoj2jvGkUcl0wK9jCFw3EGw3N91w5MtaIaAgQFlUFvAqfaKtCjwiwk75HUHQOFX05 X-Received: by 2002:a05:6402:3510:b0:50d:a9bb:356c with SMTP id b16-20020a056402351000b0050da9bb356cmr10993481edd.0.1686604212777; Mon, 12 Jun 2023 14:10:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604212; cv=none; d=google.com; s=arc-20160816; b=v++ZiIbEzcQwKrq4byfgjPPTVwTrEWkU37ZohVUx42mDFdE7ggRCOp0g52V3xE47Vc JHNdJkZK6xAg2XWOrpXq/qgYmSXA4U3A8IUZsqR/z5XZc5lbQOJFIYwXWSdlA9xfqU+C sSYDvoTFXrOULiiPUA88MZTBYZ1XcT2cr/UJ2X2OuhoeT2Buf309x/4DRD0M6vOUwW2R h1TspvYqULnKVLUa1xni1JQA8Jru9vLQlebmB6neiyTYVuCtiVQxn21yUFhAlmJZX0Ak jnu8GCef9uKv2fD5P6L3CMYu9VFWe64VwnZbiijEPdvXzAbqkW8Y1qdtfLqcpI4BaYej J0eg== 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; bh=ar+Dj81jVPDSvxVwFDSsOUHRWtl/Xgk5/7INYLdKHbU=; b=OL2RC6/JRlwBBm0cnlmMzeQtenBMhQwUm6nzwfIB4om7jlUonuynD2p5KnGGao3IlF rBKeJ66KIv49GYseCZAx2jkCQlbxn4dopOgc9+z56NwOexmGmWwb/o0WevwXXL5rq5x8 TKhy7551f+j5aJPUM4rJibDKG9m9Sxdanl8Mhcal4FKxK+SG+r6ACib88h90EqW/hjzp P8dJ7tqp/XFUyGalyLm/mDpkZFHLJmzEoGeMjKyiGMbV2PvZyi7kpZK7IuHed3SeGhIq /ZK3cVE8v/BfliR7vaDxhGRxIl0sifNkpU0LYuereYeXg+W/Q9pBgiNIbp676MT+9Der zU8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w17-20020aa7da51000000b00504a26aa3f8si2520784eds.422.2023.06.12.14.09.40; Mon, 12 Jun 2023 14:10:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238771AbjFLVId (ORCPT + 99 others); Mon, 12 Jun 2023 17:08:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238272AbjFLVH4 (ORCPT ); Mon, 12 Jun 2023 17:07:56 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E53C4187; Mon, 12 Jun 2023 14:05:02 -0700 (PDT) Received: from i53875b22.versanet.de ([83.135.91.34] helo=phil.lan) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q8oib-0005fR-6D; Mon, 12 Jun 2023 23:04:53 +0200 From: Heiko Stuebner To: palmer@dabbelt.com, paul.walmsley@sifive.com Cc: heiko@sntech.de, aou@eecs.berkeley.edu, herbert@gondor.apana.org.au, davem@davemloft.net, conor.dooley@microchip.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, christoph.muellner@vrull.eu, Heiko Stuebner Subject: [PATCH v5 1/4] RISC-V: add Zbc extension detection Date: Mon, 12 Jun 2023 23:04:39 +0200 Message-Id: <20230612210442.1805962-2-heiko.stuebner@vrull.eu> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230612210442.1805962-1-heiko.stuebner@vrull.eu> References: <20230612210442.1805962-1-heiko.stuebner@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_HELO_TEMPERROR 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-crypto@vger.kernel.org From: Heiko Stuebner Add handling for Zbc extension. Zbc provides instruction for carry-less multiplication. Signed-off-by: Heiko Stuebner --- arch/riscv/Kconfig | 22 ++++++++++++++++++++++ arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/kernel/cpu.c | 1 + arch/riscv/kernel/cpufeature.c | 1 + 4 files changed, 25 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index a3d54cd14fca..754cd154eca5 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -523,6 +523,28 @@ config RISCV_ISA_ZBB If you don't know what to do here, say Y. +config TOOLCHAIN_HAS_ZBC + bool + default y + depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbc) + depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbc) + depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900 + depends on AS_IS_GNU + +config RISCV_ISA_ZBC + bool "Zbc extension support for bit manipulation instructions" + depends on TOOLCHAIN_HAS_ZBC + depends on !XIP_KERNEL && MMU + default y + help + Adds support to dynamically detect the presence of the ZBC + extension (carry-less multiplication) and enable its usage. + + The Zbc extension provides instructions clmul, clmulh and clmulr + to accelerate carry-less multiplications. + + If you don't know what to do here, say Y. + config RISCV_ISA_ZICBOM bool "Zicbom extension support for non-coherent DMA operation" depends on MMU diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index e6c288ac4581..e48ac52b9174 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -47,6 +47,7 @@ #define RISCV_ISA_EXT_ZICBOZ 34 #define RISCV_ISA_EXT_SMAIA 35 #define RISCV_ISA_EXT_SSAIA 36 +#define RISCV_ISA_EXT_ZBC 37 #define RISCV_ISA_EXT_MAX 64 #define RISCV_ISA_EXT_NAME_LEN_MAX 32 diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 637263f9a7b9..bbff98d4712a 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -188,6 +188,7 @@ static struct riscv_isa_ext_data isa_ext_arr[] = { __RISCV_ISA_EXT_DATA(zicboz, RISCV_ISA_EXT_ZICBOZ), __RISCV_ISA_EXT_DATA(zihintpause, RISCV_ISA_EXT_ZIHINTPAUSE), __RISCV_ISA_EXT_DATA(zbb, RISCV_ISA_EXT_ZBB), + __RISCV_ISA_EXT_DATA(zbc, RISCV_ISA_EXT_ZBC), __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), diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index de2d16300f69..f46281f1e439 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -261,6 +261,7 @@ void __init riscv_fill_hwcap(void) SET_ISA_EXT_MAP("svnapot", RISCV_ISA_EXT_SVNAPOT); SET_ISA_EXT_MAP("svpbmt", RISCV_ISA_EXT_SVPBMT); SET_ISA_EXT_MAP("zbb", RISCV_ISA_EXT_ZBB); + SET_ISA_EXT_MAP("zbc", RISCV_ISA_EXT_ZBC); SET_ISA_EXT_MAP("zicbom", RISCV_ISA_EXT_ZICBOM); SET_ISA_EXT_MAP("zicboz", RISCV_ISA_EXT_ZICBOZ); SET_ISA_EXT_MAP("zihintpause", RISCV_ISA_EXT_ZIHINTPAUSE); -- 2.39.0