Received: by 2002:a05:7208:3188:b0:7e:5202:c8b4 with SMTP id r8csp849691rbd; Fri, 23 Feb 2024 05:40:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUMrQDgnhVtiJ1EEwnVudgPB3R1Knq6nRX4DVydo6u9iLqcZrmzZpzLZ2yLE5hYc0Y/il+L6NPL0KB6kuqbMArfluEfY8YS9RDtbicezA== X-Google-Smtp-Source: AGHT+IHsa1tVNsj0cssKGlE2M8+n4sRly3gm6HGM9PIUR/kRuoDYGZZi1XVw8fxV7OpJ5i/Kooaa X-Received: by 2002:a17:906:3905:b0:a3f:6302:1e61 with SMTP id f5-20020a170906390500b00a3f63021e61mr1217636eje.73.1708695602178; Fri, 23 Feb 2024 05:40:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708695602; cv=pass; d=google.com; s=arc-20160816; b=mRxBaXNzhp2Bv3beK2ujj7IdgZDnUfxV2UVWT1iN4r9CT5U5PtbuVXmJrR8oFEviBX 4UU+YXIugFdKAo9YzjjG1wIcYFb7B6N/daws0O2D3SL8HsgzO9++CzQ66Ccjqza/UYKr iQ+X0dxRGwnTe2W5OLslqNxZtOZBenirJLTPME7pa1G/2x6jOWsOr4N7e1FAb3jdML3K 4JKtRPvoA7KlD3ePToEH+Bp5NDmsCe8NKgzJH0QKb/78tp++MEKoFKfOkUcIgnTZgyAg pbGn5zwWKOLgqiatYQHfQXeaxi/hsauEyYNlI+MLt8p4BojSL2DnJyc5cZO33vDhfghz AKPQ== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78394-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lv11-20020a170906bc8b00b00a3eb888c782si4369963ejb.488.2024.02.23.05.40.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 05:40:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78394-linux.lists.archive=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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78394-linux.lists.archive=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 BE8D81F239A5 for ; Fri, 23 Feb 2024 13:40:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24CC8823CE; Fri, 23 Feb 2024 13:38:46 +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=20Roy=20Baron?= , 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 Content-Transfer-Encoding: 8bit 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 -- 2.43.0