From patchwork Fri Feb 23 13:38:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 205386 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp588781dyb; Fri, 23 Feb 2024 05:39:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUFJvsc5kKOMBGuPC7q++ZHJAWcoBGqrJcwD+av0j5hqKLk7KP4fQuh3sKyMypAr2e03jcgvdj2ci/oxbh6o8pWPeu34Q== X-Google-Smtp-Source: AGHT+IHX6V3C9jq0k6X772DswnNfIG9pd1nZEc2+zmOll/ThSwSTmlpd/ww70vuAj9OrQp59uRG8 X-Received: by 2002:a37:e30a:0:b0:787:680b:120b with SMTP id y10-20020a37e30a000000b00787680b120bmr1966283qki.23.1708695576102; Fri, 23 Feb 2024 05:39:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708695576; cv=pass; d=google.com; s=arc-20160816; b=LWatKew9FJ7myzZ6TKnTwQtPRsRtBRa0BonHrOUpE4yjiE4PQAOtcNqJKsc84Mve4X 2qFx+QdIQPYFBdPr8V+Lr0lA78ngItatutZCjbWGPy+16N72USnrXkKo4+jXPt9Q+2D9 s66USZ3Ws6A4JhiPWyNaKPso7HSBabWk7XlK2njrCZhVrPlzHPJe6OaDAgfcCNZoARby d6sQ68LjTqZJxy9tZqvU6Gx5i6Ko0ZfeWSJn/UZozhBzMc6pnd7F/X+XG5cbjqqEUtN0 buFjU3J7hl0UQ48e5UCs4kC1q4EhbD+5MZXNAH6eTeypC8rosKobYKQZrqLewU9WLn1B 7npQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5hqF9w8DFgVKR/Eyrd2ddO5zxVEwtUx0qQpGMlIJntQ=; fh=jXAL6cDlEDHkZNd0n3MBuX9Vxi0pyun7LxUg18Vx5PA=; b=A+DlUIRhq66WBdy/T2Nfp3dU/o9HCVZKYEN+3wLxQ4CN8vOEz2DNtws7diFzDmUFrq RX3h8/2k2vjMzlhPgU+s//cDoKh47gZPHhzCQjY8qzLbDpTs0PxpGjN+Tii2vfHkFqA1 k9PlFPjyUDWfQFztVXtUbbD2jE2mWCM5w/mYqTUFseWj+y+NrGwQpYFTjeKfgZBUVB+T QG0EMwfpBBJt5JfqzLjo7RETu/+f1oSZP/tTV92SJPQM98hauLDnNPd2RxX3ivqr1Fh0 1qiEaelHTid4kpdgfKUFMiGGCNoZtyiIzll2yn09IRkpCk+Jr3u605PCXA4RrFXJZOC+ 1wMw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Na5p+TP8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-78392-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78392-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v10-20020a05620a0a8a00b00787b7f02325si596429qkg.428.2024.02.23.05.39.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 05:39:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78392-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Na5p+TP8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-78392-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78392-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 DE77A1C21AFB for ; Fri, 23 Feb 2024 13:39:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 390F781ABE; Fri, 23 Feb 2024 13:38:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Na5p+TP8" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84B137FBA7; Fri, 23 Feb 2024 13:38:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708695517; cv=none; b=kBZSFmSfE/Jn3LdahfFsWEAwaF7nRMeGOwzPWlo5WCGZGbWC+jZVMC19g5mAXtHYBlUwW1OCChZTzj5tr3r7XmX3OfWwzu+qT7xV0Jm+kNw73u9cXmzlkzh+or7CjQwbwdZowrMlSXdOce8UzFbaZhSL+AWBgcVsXZAOSw9Az/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708695517; c=relaxed/simple; bh=VltUvQLlmLwkpl8kRnLO58R3H1pbUYjiNeAYAhm4vK4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QaJ/c/2exwFYr1WSrg1BoI1QlYDXCqk0PchzXrx/RWF8J1/TPYimKKSI+VjDa67THgBilCwWf6dJ0jucvN6y9fcuk/T16lBSh4Tyv5DNVL8V+NGF8H060BAU4pTDMqQo6hI3AE68nxlnPwYa3r+mmCMN/x3ZYuqeqoIYEmjHiB4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Na5p+TP8; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 611A5C433A6; Fri, 23 Feb 2024 13:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708695517; bh=VltUvQLlmLwkpl8kRnLO58R3H1pbUYjiNeAYAhm4vK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Na5p+TP86HhyZXIS9INaL8dQBTOiswdRzULSa5FNq46+4a22pnBtTtloyqFR8cWc8 n8yn1MMy2W7P2cqPCBcS0OBpjP8xSadnJJcXmWRnWauvwKGLaTU4cll8SATYAhUv17 cYr9GnNe6g5JhklC6GcTpLtBe8w85TjlaGno0uWLbIrlH/aNG/uJRDYpZM3bkdYj3O 6K09xONc0jMaq1Kpvw0KdV/Jv/lw63QSQ/NRvdyygkYqtcjNvcy+e76orulwxLVITl SAMd1plaBCYXZCO4bQkgBlK3+NOpjLRsMt5hBqFLEl/aBsq/mk/quDjslSCEZG5OE4 rVGmCyn2+AIGw== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Nathan Chancellor , Nick Desaulniers , Tom Rix , rust-for-linux@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, stable@vger.kernel.org Subject: [PATCH v2 1/3] rust: make mutually exclusive with CFI_CLANG Date: Fri, 23 Feb 2024 13:38:03 +0000 Message-ID: <20240223-perjury-preshow-fc2cf73d552e@spud> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240223-leverage-walmart-5424542cd8bd@spud> References: <20240223-leverage-walmart-5424542cd8bd@spud> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1069; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=CGpXuPYcXKOyMHoYWd5SM3467xfR+bc0vpqwYOI3iyQ=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDKk35u8JtHm+ZsH5Sc/CPbpmzj1yYUtL5lVNtfKQGyezj SYVXz8p0FHKwiDGwSArpsiSeLuvRWr9H5cdzj1vYeawMoEMYeDiFICJzJRhZHj+yWvHNJapDg0f b5+5HpMl+Cir0HdTfvXKf1lxFjVqwf4M/4v2a3lvq1kyS7umuGfKg7ig3pUBuwU4+zsuViUvVFZ YygsA X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791697172579580783 X-GMAIL-MSGID: 1791697172579580783 From: Conor Dooley On RISC-V, and presumably x86/arm64, if CFI_CLANG is enabled loading a rust module will trigger a kernel panic. Support for sanitisers, including kcfi (CFI_CLANG), is in the works, but for now they're nightly-only options in rustc. Make RUST depend on !CFI_CLANG to prevent configuring a kernel without symmetrical support for kfi. Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support") cc: stable@vger.kernel.org Signed-off-by: Conor Dooley --- This probably needs to go to stable. The correct fixes tag for that I am not sure of however, but since CFI_CLANG predates RUST, I blamed the commit adding rust support. --- init/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/init/Kconfig b/init/Kconfig index 8d4e836e1b6b..6cf05824859e 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1895,6 +1895,7 @@ config RUST bool "Rust support" depends on HAVE_RUST depends on RUST_IS_AVAILABLE + depends on !CFI_CLANG depends on !MODVERSIONS depends on !GCC_PLUGINS depends on !RANDSTRUCT From patchwork Fri Feb 23 13:38:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 205387 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp588893dyb; Fri, 23 Feb 2024 05:39:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXE95Ml+sEVxuVADPYkYpdV6UujvU6kmXp+QLmVxYqKJuL/fGzAUbp8ZfsA6nMnAfetB3Vdggcydy3YT6pvjFM6lxusOw== X-Google-Smtp-Source: AGHT+IEBetM5O0VrACuYx7xEL6A8GDe2+Rdjn/+JZYOhy0IJv4wcae7LmZTlmOOIU7GGsTYoBHa/ X-Received: by 2002:a05:622a:1306:b0:42e:411d:ee50 with SMTP id v6-20020a05622a130600b0042e411dee50mr9020273qtk.15.1708695592162; Fri, 23 Feb 2024 05:39:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708695592; cv=pass; d=google.com; s=arc-20160816; b=dDKnc7B34156ehUTWNUbdfiNp9yDUIFZghgeCqJ0c8tlpWVjbYh1/0kffucPFrmNn6 Yo8y084UlhWvtxVfBGmWJmOMHe9/aI/0m6fC3zUX3KeUa5+TCCxC470g1bmzprtxJ6V+ P7iUz6xnyYFdo77gqejBizyxLsaOvrJXKUMivs8fBV4QZIwi/ctrxfh8qVQ9M8z0DhhF lUs7szfxuzEu1BEhQgTQrIwgYhdA8mEkYKkgjTm6QgXvPdG/e7s18yWwNLdRH+StnlfE zPYYkg+XEQSaHXdmPHerNXqEbpJqxquf0aDtnUoUB3uxzooyxY8lUxO6Znw3IhUnWyJF zY1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=d9zTG9Q/D7hjqGdJH9bas9VTeOur6ufthRK5sGKsQCc=; fh=dCTP4Ymdp7PEyus72y/np7wEnm5YMONLCB550f4Y5pY=; b=bgcXhMhs/Cp96XWKf0+Isb5Ivk4R334ghLGJXUIcd32/e7NC+V0mXjpuLRdOVzl3wh nD0VixXtTRnP7az/jWw0Tcty8neCvNIAvHICV4wVVqiL8Bq95SeJkEUcivYMC0nfb0k8 /8mOOgHDw49o7+EzIQCO8hBiJ8XGSfwKjZa6lIu3NxvXD8CjeUaLsAs+Y0MWOfdTS78P rYFJ4C50qwpGr3ec0uk2TQ6pzRtAjj9TSrqL3cPh+KzxqvrbFjhd/RKnZ3jPz34S1hJR 0EfyeTAxaGFGOVtOC3BEkj9dBxcPfPoT/FRNW/dhW5cDVYkrLCPszym92dCwKlx6DHIB bOlw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NAYoe9Wa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-78393-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78393-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w12-20020a05622a134c00b0042e02fcfc98si13671553qtk.795.2024.02.23.05.39.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 05:39:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78393-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NAYoe9Wa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-78393-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78393-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 ECE8E1C221F2 for ; Fri, 23 Feb 2024 13:39:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEF9F81AD4; Fri, 23 Feb 2024 13:38:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NAYoe9Wa" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35DB97FBA7; Fri, 23 Feb 2024 13:38:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708695521; cv=none; b=CiTAHvJXwgRBh+P9/JR4URTN6n1SVq8YAmd7ysEZeCiLZVmMvLqy1TUYmVWzo+3IryFV1t2hB+HIlyX0dOhZ2YWdlgj3QWzVnal+EGDlnWd3WPqPlS9mcibXPC3w6qDBuU0U0TYDGxOm1R5UJ9pmSfaKPivhK/NbqnKnutPS2Gc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708695521; c=relaxed/simple; bh=GBY3CxtFjRdlkWk0xQcPhghSUX/TMHc7PXVii3OW0UI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PggK4/WE18tkMe3xk0ZkF5I3vMO5DydSZxRioKKI5bcIGRpB4RbBmScVSFOKw0Ml17TgmBV8W1WqWBoCF96laPo/Xe3c5NC7LzRUt3fT2OO2V9qCksMlCXVoqD3pW+opZOdsFY4dq97G8JdrG1WGRqt5aZGBTX2MVQ8Ola0YGZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NAYoe9Wa; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84281C433C7; Fri, 23 Feb 2024 13:38:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708695521; bh=GBY3CxtFjRdlkWk0xQcPhghSUX/TMHc7PXVii3OW0UI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NAYoe9WaOvWjK1nqOgnvCRLfNM1vZZ77ud9LwZ25q4toItC75bJj1HTjri6c2gXdA qx6gYl6UK3FaZPRWQtXRkeKeMNxLZH7BloLltp+gB9ahCt1OG+0ZTwxb3EoKpi6GYN Mbq4hQSa43Hf4YoY1B0DUu9QUvy3j4JJyAdd74AV3Avzt5xg6Ox4FylJRDHG1oSfts zB8IHxJFvZpDcgNweVSDpkC0wMuv3OWRL6SRzq91BNBWy7zk/+idBiurodqRLm6qSt lGDm6eVu3pt63byZpq3ks1rLII5B+W750e8gG1wICoaebGb7eaw3n4SUrkPrpfsh/r UHJujfNg9x3dg== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Nathan Chancellor , Nick Desaulniers , Tom Rix , rust-for-linux@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v2 2/3] scripts: generate_rust_target: enable building on RISC-V Date: Fri, 23 Feb 2024 13:38:04 +0000 Message-ID: <20240223-employee-pessimism-03ba0b58db6b@spud> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240223-leverage-walmart-5424542cd8bd@spud> References: <20240223-leverage-walmart-5424542cd8bd@spud> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1601; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=p3JdpTjlU4Gcdumuom76iCrubxUFIi9NJkWxSpqwhJ0=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDKk35u/5lrFAdfnzD1GuIt8lz140CmXaqXr44cXs8KWGK R2WOsGHOkpZGMQ4GGTFFFkSb/e1SK3/47LDuectzBxWJpAhDFycAjCRPSsYGSan/60+PG/FqTAG kUlzFlW8U7p6xSjmJYeo5ZTlD5iZ9rkxMnwt/bL+85NpTZyR6SErzVtmXlqpyCW6YMKvR3qGn5M 3MbMDAA== X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791697189036756498 X-GMAIL-MSGID: 1791697189036756498 From: Miguel Ojeda Add the required bits from rust-for-linux to enable generating a RISC-V target for rust. The script, written by Miguel, was originally a config file contributed by Gary. Co-developed-by: Gary Guo Signed-off-by: Gary Guo Signed-off-by: Miguel Ojeda Signed-off-by: Conor Dooley --- scripts/generate_rust_target.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs index 416c6b89e806..942ddca57ee4 100644 --- a/scripts/generate_rust_target.rs +++ b/scripts/generate_rust_target.rs @@ -171,6 +171,22 @@ fn main() { ts.push("llvm-target", "loongarch64-linux-gnusf"); ts.push("llvm-abiname", "lp64s"); ts.push("target-pointer-width", "64"); + } else if cfg.has("RISCV") { + if cfg.has("64BIT") { + ts.push("arch", "riscv64"); + ts.push("data-layout", "e-m:e-p:64:64-i64:64-i128:128-n64-S128"); + ts.push("llvm-target", "riscv64-linux-gnu"); + ts.push("target-pointer-width", "64"); + } else { + panic!("32-bit RISC-V is an unsupported architecture"); + } + ts.push("code-model", "medium"); + ts.push("disable-redzone", true); + let mut features = "+m,+a".to_string(); + if cfg.has("RISCV_ISA_C") { + features += ",+c"; + } + ts.push("features", features); } else { panic!("Unsupported architecture"); } From patchwork Fri Feb 23 13:38:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 205388 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp589044dyb; Fri, 23 Feb 2024 05:40:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUVqbhRxtqrW7hiALMAVpKJ8H4uRrSRkoXsqGmv76JmTzy7nmsWIT0vpX24WgjmxSqPLi23axl4QTsfYS6ncXWOp+5bgA== X-Google-Smtp-Source: AGHT+IG3Wv2ocEmYuQ/nuoRnuhrDjSDc+6t2UBHYC6nkUJzuPoYGHOl5WXBbeuPfYbOOBmmA7qQG X-Received: by 2002:a17:906:ae4a:b0:a3e:dcd2:2741 with SMTP id lf10-20020a170906ae4a00b00a3edcd22741mr1361438ejb.38.1708695609792; Fri, 23 Feb 2024 05:40:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708695609; cv=pass; d=google.com; s=arc-20160816; b=QwIZg9/YpimGTmU7yOBJy9BSd0DLc+Lr19xvM+AzHaAbg34MucfKGwTxuEEPJZXsSh Yqm4cTi9RFFDRBguafdymAh+2MqfkgkSe3zIiC23NwGymd2TGDW7QJlBYACiQCl817in IJgVc6sIWicyMg6mTe2VnwgMO+YbVVZlWgXsx2QWcn6uK4IxE9vTVU5sehwiqm4AcaWt rpso4ktq3s/cf63dgIyoHZYUftZ8K/q1lIqBmp1QoUEwip0klgeyIdb8uiROtPJg5Rb7 1hMsjeOq3MLZ9SoYwnN2awCQj2GRi8v6fR3MDVs4nsMrzwTydar619xsZTzZouZPYuYm vjag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ys+wJgrZznihbi9Xh1hYavCduOHIvNK+HAQZmu+dDxQ=; fh=dCTP4Ymdp7PEyus72y/np7wEnm5YMONLCB550f4Y5pY=; b=efX9daiwQwU/pF2Wmd5JBMCV+bN11Qm9p3yWVsfnBKrL6nQCR47ed154hywVep7Azk uB2wySWvj31aGxKD+gQ3Tx+K0NxicHCNMot+ep5Wh7WY9qtrCsdLX2LATVomLh/DViR9 uwcwgK2xEBVBs5PJYLbrnQ6KZwGIefOZPS5PKX/1sUsmarjmvW4sB0++UEWHzENuwlzR y5XiUJpI0KOqDOWAFmshNZHIEHRN9dVXe8jUIPdgtusi6+gfQJZ3zETxIpvn1xcC3AMh NNtTI3uY8gmVGUjtj+f/ASoAOGzWAnKZDwTfX3jRrLOQgLKrnUKaG2kJNOxQDp5/uK96 MybA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YnagCjM0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-78394-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78394-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gt25-20020a170906f21900b00a3e3ca0eaeasi5396780ejb.544.2024.02.23.05.40.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 05:40:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78394-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YnagCjM0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-78394-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78394-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 67A471F2394C for ; Fri, 23 Feb 2024 13:40:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB28D80040; Fri, 23 Feb 2024 13:38:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YnagCjM0" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E2F6823AE; Fri, 23 Feb 2024 13:38:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708695525; cv=none; b=pTPsrx8VIZaSJ6AN9tjcp1IMu/4aTbA8iiNmxM11zBaEqfInDMgItrZdqHIzivmC90uwt2m9VspZRF+vT308pb92S2q0SOKSJIDyhZv9Mi/54Vh8wCGW/xMNHBpVnusBPifrLu6s3qCbHkV4DwYjj6E0VairnTCkBtw4bkAR7b8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708695525; c=relaxed/simple; bh=n7EJGb6r/9uWhXBTxysKjx17Y2iaQNTqlPUbVd030hI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rxERmYSxqCzqbm5LOvrItHeLk1lMJRWMeL7z+m6e0VGNECKG9urm4i+GtostmpWZ/0Me4sOku11MwW/oRowz2DUAGtGDzNdqm7Bpy6+mX3C297Eo7eXx9XIvjZfFogTVRwPF4Et6LpKBdLNu871aFJ6/leM250Acds/saPY7ITw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YnagCjM0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D0BAC43399; Fri, 23 Feb 2024 13:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708695525; bh=n7EJGb6r/9uWhXBTxysKjx17Y2iaQNTqlPUbVd030hI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YnagCjM0KBRU4knIa5ukmyCLbIBQ79mVq8ZFaUsG4bPoq3W2BaAfbzZvmZXqEfMtQ YYmdDI6hwLjWm88p8iugiOesjBI7iZxep5trLFczsqllK4hpZ/qXJGzNeDR4h2fg+J XfR4Xs48Ge1PZ8kmw6IVM1ETX8+ykApcfKU7+kbEl0YfhUTmIh/6bCoD6J+79yZO55 2jPbKdE3fhQQWwIKWFQ8ZJSH78wyHoY0ZMjuiBRZb+ZZ9dEoc78qmnj6RZKr3Vlpot L6eYVy1EjkbMwlLCm3iCTXf2YQDgGfCqRjRbPBj0PCbYI0ErS8EEwSqwMYIiQ5hXi8 6QYi5pY8GEQnA== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Nathan Chancellor , Nick Desaulniers , Tom Rix , rust-for-linux@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH v2 3/3] RISC-V: enable building 64-bit kernels with rust support Date: Fri, 23 Feb 2024 13:38:05 +0000 Message-ID: <20240223-palatable-quintuple-ed221a517407@spud> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240223-leverage-walmart-5424542cd8bd@spud> References: <20240223-leverage-walmart-5424542cd8bd@spud> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2571; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=dXiTCnXsPq6szb52W4FfTLrkIWRphwTLGk/WpEPIpxA=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDKk35u+R+n7i+OwT39IUWaQPMGd9WVleuj/N9dhv5lkZX 950bXrd0VHKwiDGwSArpsiSeLuvRWr9H5cdzj1vYeawMoEMYeDiFICJeL1nZNg/wWKXZM7OpDYn 8zeiOy94+N68+CslNMT1aGxkUqdO6GWGP1wisa+2BoUt0/q+ds2FPTL/DtavLuPzr4z/Oe/D15q /ZWwA X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791697207670530687 X-GMAIL-MSGID: 1791697207670530687 From: Miguel Ojeda The rust modules work on 64-bit RISC-V, with no twiddling required. Select HAVE_RUST and provide the required flags to kbuild so that the modules can be used. The Makefile and Kconfig changes are lifted from work done by Miguel in the Rust-for-Linux tree, hence his authorship. Following the rabbit hole, the Makefile changes originated in a script, created based on config files originally added by Gary, hence his co-authorship. 32-bit is broken in core rust code, so support is limited to 64-bit: ld.lld: error: undefined symbol: __udivdi3 As 64-bit RISC-V is now supported, add it to the arch support table, taking the opportunity to sort the table in alphabetical order. Co-developed-by: Gary Guo Signed-off-by: Gary Guo Signed-off-by: Miguel Ojeda Signed-off-by: Conor Dooley --- Documentation/rust/arch-support.rst | 1 + arch/riscv/Kconfig | 1 + arch/riscv/Makefile | 2 ++ 3 files changed, 4 insertions(+) diff --git a/Documentation/rust/arch-support.rst b/Documentation/rust/arch-support.rst index 73203ba1e901..9e18a81fc2ef 100644 --- a/Documentation/rust/arch-support.rst +++ b/Documentation/rust/arch-support.rst @@ -16,6 +16,7 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file. Architecture Level of support Constraints ============= ================ ============================================== ``loongarch`` Maintained - +``riscv`` Maintained ``riscv64`` only. ``um`` Maintained ``x86_64`` only. ``x86`` Maintained ``x86_64`` only. ============= ================ ============================================== diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 5c59e00405e3..3eaae08e1d5c 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -142,6 +142,7 @@ config RISCV select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RETHOOK if !XIP_KERNEL select HAVE_RSEQ + select HAVE_RUST if 64BIT select HAVE_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS select HOTPLUG_CORE_SYNC_DEAD if HOTPLUG_CPU diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index ebbe02628a27..22fdb1e83744 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -34,6 +34,8 @@ ifeq ($(CONFIG_ARCH_RV64I),y) KBUILD_AFLAGS += -mabi=lp64 KBUILD_LDFLAGS += -melf64lriscv + + KBUILD_RUSTFLAGS += -Ctarget-cpu=generic-rv64 else BITS := 32 UTS_MACHINE := riscv32