Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp242897lqh; Mon, 6 May 2024 18:44:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWiKp/0FFtplcjBgrTaqJ7AVrX/odIjqTNrzwjzGF9fH0UsECT095eu8GNKprmRFjH61+k40pbKJxCOXU2ZKEK9kQ0zhn9k/mC/lCsSDg== X-Google-Smtp-Source: AGHT+IHra4mu5dIDOyD6hy3WjBoHFokTIrAcUwSDRd8hiR84pMGddKNj/L1FPrqzA7UPmj0un9k/ X-Received: by 2002:a05:622a:207:b0:43b:b8a:1bf1 with SMTP id b7-20020a05622a020700b0043b0b8a1bf1mr14838917qtx.33.1715046275799; Mon, 06 May 2024 18:44:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715046275; cv=pass; d=google.com; s=arc-20160816; b=gp2t+7l7MvTeWCNa5Kz4NjIs4JoobB/FGPcW26v8vuInQPevNdeFDRXBTFsBn/QIMs aI4NXWJQojPIpxpXRRHHT6LbfUSzbYOnXgrOlsl2jSoF1hmdkLo4hFe0ygocwPPRKaiE gxJ8fK3W3qwBCfDzoiEFuG0xIcBl90e/6Z2qmi2dm25FEQip4+z/H5NVciAOvKAhZClv YUofN2yJLoF+wqLPk87YR4MbRrVQ38XQWUG740ZlG5QZ+nqXPpIqsxlsCugYnJwDcd4y 12Fp5Ols+tRReTCGKKzVWSNJKFYRjm/3tAYz8nQronNsCjgS5t9JCW+4T471UBXmlRJm BsEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=Mrbuhf8lERW/x3AUUGdC3eD15JM+519sglQ52hQ7AhA=; fh=mkBR3xKrkHJWsWDf+JEIQw58hBV8nrATUSngVblC/mk=; b=oTTE3T/wHon/2ZqvgF2qNsWfUWqPBwQ+jDfO2SW1R9k2Yo0as+g+BCG32/KT3D9J/z 9Nw0zMQ21fyragPNsGZbALqln1UGsW8oK0V0y335S50ntWDx+160o7u1qAHnD8TToBjN jImijBLKtaLUHQJd7nzubcSr7PDsHQ21XYqQxMzR3D8a1XxeDvm14BsSOt38W7YgnYcl MHu8Vpade8QQXnOL4+d1L7tk3MgGj6vYnsv7Eb8ddY3QEzjS2f5El0nozS8HquBzvvtA RxkyaCWN1f0yuy5JXO3TxtTT6/j6hbap46diqmgGrDIX2/N7GuETmcb1fN64NTW69nuu HUhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=go1yy0vT; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-170566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170566-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o15-20020a05622a044f00b0043abd5b255bsi10983478qtx.414.2024.05.06.18.44.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 18:44:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=go1yy0vT; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-170566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170566-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 76A311C21D42 for ; Tue, 7 May 2024 01:44:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 239C1524B7; Tue, 7 May 2024 01:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="go1yy0vT" Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB3C84436 for ; Tue, 7 May 2024 01:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715046174; cv=none; b=ApZMtKoSl8zSwqVEF7Lcg3WYPSu76G06f5TWdl9Igd0iFTqjoohnfaumMsRWCL+KHlXX0yDsvwxvbTLpGL4c77H5mL5U5/Mto8Y+9/ELD2BzXILjvtY7Sunv86JGC8sTUjbAa0AcSLXnm8gr2rrdBa+ZI2AJJpN53CXIsDaQgjk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715046174; c=relaxed/simple; bh=VSGPqebqjCkV+Jce+IU74T8AjKJ/iHF/vPW/Bia4uwk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UHAhgwXYiom0J6XnPwhMQMkS9x7re69S2ynoHX3usuVsF7GUgzektQObtPSIrw0fskKgcZlVNSNUEdJFg42dAtcoQ551IdmBAbx9yTga1BDnOMDx4zB6cGNHsNvP+9wub5zdm8mpkbWn9Ir7TluoSi9QtcYno7OiUkwKpy+n9SE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=go1yy0vT; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1ee12baa01cso11784775ad.0 for ; Mon, 06 May 2024 18:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1715046172; x=1715650972; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Mrbuhf8lERW/x3AUUGdC3eD15JM+519sglQ52hQ7AhA=; b=go1yy0vThAgUZcD/bru6iM6pLf2hX1j+rb8s2D0IJ6dkJlILEwQcnlGfZhEDDGRP5N 1FsW/RT84KrOHlnHjY4fT8nNOdkjT6YQmSIzMqC1FjHA+3034now014CU8l068auMv3P p3pcTP1eAdAY8UvtbHiRZ1Aw5tbSpI5tjHFCruKHpFH/gY6kxDuoiiBMZmgndHpDzmlG UW7lFNSwQGV2yZQ+9Gy81jJa3UB1kVe951eMZ7/WOjE57p7uYFpDGWzI9L7gd1LCiJHC fPvI2f8LTJdmuaPqlakFbpQhUUPX6WqK50F95naTXYxTDZtVd5G2fqNsRcXHTBQLPU7q ALdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715046172; x=1715650972; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mrbuhf8lERW/x3AUUGdC3eD15JM+519sglQ52hQ7AhA=; b=YqxCWliBL3w5+UyoznsWTJp3ce1gVleX2rDeAB8UZUWAZ0qvMRuay1OkzmtkQx2YxN bVx6gT+WRnYlg3CCTQcvLCFY7rcmHbYVj2ILzP8WQOOpB7OY4k479rl4/puC3O8ceSn7 2kQeVt/HSBKNepmmWLea6+LjH8e5DJ/wqcYzaCAwSXxOmc8kd7aN0ApVEbZu2gmmsOlq VHwVrDiWJk7hLRknk7GdEcGvne3BA/BTYEU8aYatZqSVhoYzjM9apecgkwRlIufu+r1F lStrN6EjKHcDvmZHwVWw+T5HSPQkH18t6MBk4g7kDlawAc0DJs4enm44qIDJBQ4R+e9D xsUA== X-Forwarded-Encrypted: i=1; AJvYcCXp96XV1fqLVDcBLn4uLs/xacH4tXYIWi/Yq8twQ0QolawzzOrv7w5GBfC6W2Z1u2QpPbrfXAdMW8TLsUmRYFB/tzITd/UXMilKdrSt X-Gm-Message-State: AOJu0YznTTwxqJhtn1Mwx1HK3Y4A2yysa6Vohwl1CgcdhoaEALQXanT0 BV9vIFdFU/f1XWFXdkqIqgZec4ReIGQaDlsE0LhsaC1ZzIsefo+bWXEI8E5SQAY= X-Received: by 2002:a17:902:e548:b0:1e5:5ccd:30e1 with SMTP id n8-20020a170902e54800b001e55ccd30e1mr13723687plf.65.1715046171913; Mon, 06 May 2024 18:42:51 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id q8-20020a170902dac800b001eb3f705ddasm8915311plx.255.2024.05.06.18.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 18:42:51 -0700 (PDT) From: Charlie Jenkins Date: Mon, 06 May 2024 18:40:49 -0700 Subject: [PATCH 8/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBS Kconfig option Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240506-compile_kernel_with_extensions-v1-8-5c25c134c097@rivosinc.com> References: <20240506-compile_kernel_with_extensions-v1-0-5c25c134c097@rivosinc.com> In-Reply-To: <20240506-compile_kernel_with_extensions-v1-0-5c25c134c097@rivosinc.com> To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Song Liu , Xi Wang , =?utf-8?q?Bj=C3=B6rn_T=C3=B6pel?= , =?utf-8?q?Cl=C3=A9ment_L=C3=A9ger?= Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715046158; l=3086; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=VSGPqebqjCkV+Jce+IU74T8AjKJ/iHF/vPW/Bia4uwk=; b=PDnuVsyyK0HUPATpcCiqShVPqzG7qsmDrxcNZxQQptU20Eb8nLdqbPfj2AbCgNK4RPsM26oGZ gmZwE2MylTPC4jC6xpkZtKachs4HLLUOAvrnLkA+xKmCeSbzFLq0q8f X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= Zbs can optimize kernel instruction sequences. Add a config option PLATFORM_SUPPORTS_RISCV_ISA_ZBS that allows arbitrary Zbs instruction sequences to be emitted by the compiler. Signed-off-by: Charlie Jenkins --- arch/riscv/Kconfig.isa | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ arch/riscv/Makefile | 1 + 2 files changed, 52 insertions(+) diff --git a/arch/riscv/Kconfig.isa b/arch/riscv/Kconfig.isa index b7399f236bba..60ae1bf71c70 100644 --- a/arch/riscv/Kconfig.isa +++ b/arch/riscv/Kconfig.isa @@ -340,3 +340,54 @@ config PLATFORM_SUPPORTS_RISCV_ISA_ZBC systems that do not support the Zbc extension. endchoice + +config TOOLCHAIN_HAS_ZBS + bool + default y + depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbs) + depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbs) + depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900 + depends on AS_HAS_OPTION_ARCH + +config RISCV_ISA_ZBS + bool + +choice + prompt "Zbs extension for bit manipulation instructions support" + default PLATFORM_MAY_SUPPORT_RISCV_ISA_ZBS + help + This selects the level of support for Zbs instructions to be + built into the Linux Kernel. This does not impact whether Zbs + instructions are allowed to be emitted by user-space code. + + The Zbs extension provides instructions to accelerate carry-less + multiplication. + +config PROHIBIT_RISCV_ISA_ZBS + bool "Prohibit Zbs instruction sequences" + depends on NONPORTABLE + help + Regardless of if the platform supports Zbs instructions, + prohibit the kernel from emitting Zbs instructions. + +config PLATFORM_MAY_SUPPORT_RISCV_ISA_ZBS + bool "Allow Zbs instruction sequences if supported" + depends on TOOLCHAIN_HAS_ZBS + depends on RISCV_ALTERNATIVE + select RISCV_ISA_ZBS + help + Add support for enabling optimisations in the kernel when the + Zbs extension is detected at boot. + +config PLATFORM_SUPPORTS_RISCV_ISA_ZBS + bool "Emit Zbs instructions when building Linux" + depends on TOOLCHAIN_HAS_ZBS + depends on NONPORTABLE + select RISCV_ISA_ZBS + help + Adds "zbs" to the ISA subsets that the toolchain is allowed to emit + when building Linux, which results in Zbs instructions in the + Linux binary. This option produces a kernel that will not run on + systems that do not support the Zbs extension. + +endchoice diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index 30be0fec976a..7519b68c3bd5 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -70,6 +70,7 @@ riscv-march-$(CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_V) := $(riscv-march-y)v riscv-march-$(CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_ZBA) := $(riscv-march-y)_zba riscv-march-$(CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_ZBB) := $(riscv-march-y)_zbb riscv-march-$(CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_ZBC) := $(riscv-march-y)_zbc +riscv-march-$(CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_ZBS) := $(riscv-march-y)_zbs ifdef CONFIG_TOOLCHAIN_NEEDS_OLD_ISA_SPEC KBUILD_CFLAGS += -Wa,-misa-spec=2.2 -- 2.44.0