From nobody Wed Sep 17 15:58:53 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4A15C4332F for ; Sat, 17 Dec 2022 04:45:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230122AbiLQEo5 (ORCPT ); Fri, 16 Dec 2022 23:44:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230046AbiLQEou (ORCPT ); Fri, 16 Dec 2022 23:44:50 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C41B130562 for ; Fri, 16 Dec 2022 20:44:48 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id 84-20020a630257000000b00477f88d334eso2582894pgc.11 for ; Fri, 16 Dec 2022 20:44:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=oCkOLeUT8z9uWy5v5k8t9XGXY+OZQL+wMiMJpjklfMk=; b=NkQAhros/6X1C1DqT6opfUL3F1fT6++iMSU6wymnZhCK5ti0wioHiihwyt8oVKB0Nu MgUxlCztzY3GF0CsapECuOVpjQzsA/HfxIxj+HUz4spuCfAnTFk1I3TqTawO2XpqG6UU 56J6gfM57ah6xKmO6caUJfUfZx3tNLKF2KhkvRLvfNvFqMBBsEhHyB3A7TvYLarcLN6P fKVvVrpvUkOfhUDpOOzx2dUl5F1s46Ffosa6phFHdnfhYsFDpD/qgpTwV2UOy/FRNJvl OQIDtS8w7AaUhUhw5rDfSJQ6xtVHReyzqm5xpHermfANmJjYUhaP8hnhRxrFGiuGYe1a ancQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oCkOLeUT8z9uWy5v5k8t9XGXY+OZQL+wMiMJpjklfMk=; b=LzMPZngVpw93w2GDKKyuoXSI4hjd/t/F6JL7RGSLKDxdyzvxWLvUTrHeJXXGRNLpZk dd1hlbRZnOZJ0f1Y81zLRlv+j4EWiNFidsCM9QIpnB8W8IvYRWrw8IFksle2/nsiCvtj eWouwgELE3qDoLczwQ9xYe+g5BbZ6ZJokksnoC/Z4Cze2I0uZIQ8pWCQVpLgt5W+GDYH 8dbNI3hoiwnUeS2dKvk54G0R04iPpSsX+HwZDwTDt+QxEtQaITvL5Sce5J4lf1kxtzEy JOfyWYa4niGecTf/xF8qiKtAhSpD5TBx3JZLQ1hgE6WJjV3dig4iyp9e31FNbcRUYyeg KDBA== X-Gm-Message-State: ANoB5pnbg6giizovbaUHm+YpUUCuA7U/mbaFpDJPdYUk9TTPLRfVrb3s d5PcWi8uHVcL5dWHdUKHvv+1zxt9FBrzEg== X-Google-Smtp-Source: AA0mqf5WvCHE4FnTVtZCQe/4IUCPwpqYVRfZ0jHUmlZpfPT/x7sGQmkzk8ex0J4cnMv1HrvC8Eo90rNa2kROmQ== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a62:8342:0:b0:577:8eba:c019 with SMTP id h63-20020a628342000000b005778ebac019mr7776687pfe.35.1671252288299; Fri, 16 Dec 2022 20:44:48 -0800 (PST) Date: Sat, 17 Dec 2022 12:44:34 +0800 In-Reply-To: <20221217044436.4138642-1-davidgow@google.com> Mime-Version: 1.0 References: <20221217044436.4138642-1-davidgow@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221217044436.4138642-2-davidgow@google.com> Subject: [PATCH 1/3] rust: arch/um: Use 'pie' relocation mode under UML From: David Gow To: Miguel Ojeda , "=?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?=" , Richard Weinberger , Anton Ivanov , Johannes Berg , Thomas Gleixner , Ingo Molnar , Nathan Chancellor , Nick Desaulniers Cc: David Gow , rust-for-linux@vger.kernel.org, linux-um@lists.infradead.org, llvm@lists.linux.dev, linux-doc@vger.kernel.org, kunit-dev@googlegroups.com, x86@kernel.org, linux-kernel@vger.kernel.org, Wedson Almeida Filho , Gary Guo , Brendan Higgins , Daniel Latypov , Jonathan Corbet Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" UML expects a position independent executable for some reason, so tell rustc to generate pie objects. Otherwise we get a bunch of relocations we can't deal with in libcore. Signed-off-by: David Gow --- arch/um/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/um/Makefile b/arch/um/Makefile index f1d4d67157be..ae321282dc6f 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -68,6 +68,8 @@ KBUILD_CFLAGS +=3D $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \ -Din6addr_loopback=3Dkernel_in6addr_loopback \ -Din6addr_any=3Dkernel_in6addr_any -Dstrrchr=3Dkernel_strrchr =20 +KBUILD_RUSTFLAGS +=3D -Crelocation-model=3Dpie + KBUILD_AFLAGS +=3D $(ARCH_INCLUDE) =20 USER_CFLAGS =3D $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFL= AGS))) \ --=20 2.39.0.314.g84b9a713c41-goog From nobody Wed Sep 17 15:58:53 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB1C5C4332F for ; Sat, 17 Dec 2022 04:45:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230125AbiLQEpI (ORCPT ); Fri, 16 Dec 2022 23:45:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230108AbiLQEoy (ORCPT ); Fri, 16 Dec 2022 23:44:54 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7126939444 for ; Fri, 16 Dec 2022 20:44:53 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id z8-20020aa79588000000b00576e8050ec9so2488673pfj.5 for ; Fri, 16 Dec 2022 20:44:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Jwt0kX7GS9Jckw+q61cDxTvmoFnclM/QaQDYT1WYliI=; b=RQ2MUmTtopYEBs/CsWjtSAyRTvbAwWSpFqzIOEJodjsQaoaickkjjJcJM86W1PRm4+ L00WYFsnPLw6RPqkS5rZvaE70xfTxfyUMv79omPJp5QGU1h3uXSb9yo+1im3ScqkawMg 0B/OSMYKVttHgeP6PUEHZ/S/2Jj599bUE4n3VDzeHY6bvfvlw0RfzPSQoVlRq1hzGggA 17Q3yPTaMCL+y8dA9cjPe9lauNt+Cbb2UIEfwfJxjJ1rkiA/H6bAYxnVN2t3EqHd9pgc /PwIwuBDmPZlDtujda8rUptA0z951PK+Z8zZA/JQkFcBA3vT92ThAInyxKet9KPswEsB RkDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Jwt0kX7GS9Jckw+q61cDxTvmoFnclM/QaQDYT1WYliI=; b=bTY2ALdXyvH+bGl93vUmGGvtLVL1v8l14DE7AwWH32hzq+2j1g5t83f3pPB8mMt82N TnJJd/U4alMKG5sl5vnStpENFAhBElODuYGPoHl4cLHyfTJ/LuDZiJNcuGrX7V0rw0w4 3wTFxHTCdArUxx3FyXVmE3oZbe/PIKjLwT48H53T2rJ9XDhrHX7F2yi951gbiKEKsk4e YrTFPlHk9Yw8CF9ba7iqvwsp/JtJ30Szt4+AHHBr9nJVaDf/rZ+Ahuo7UiA4MJxurlH4 4ptJfpaQCcWMFu9Tp0oGm6RWRlYeVSC4DQyPGWB/2yrt4bjcs0BW2VDdSrdLlFDUFKYb m4EQ== X-Gm-Message-State: ANoB5pnPaaGMzGQNOZPnnlh06gQ6ZQK+wdlwIkdA9Ce9KGxPvYrRQGeA yNWQE6SuGjvCLrhhSTrW4itE3UKIV6KxaA== X-Google-Smtp-Source: AA0mqf6pD4dEjuFSn7wKhwS/R03VrxJSzS2ylnHvSFKZV2uccGUmlvQ5iNHEZZiveaurf+cNA4fNNoa/mp3DaQ== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:aa7:85cb:0:b0:575:871f:2e7a with SMTP id z11-20020aa785cb000000b00575871f2e7amr4562595pfn.35.1671252293098; Fri, 16 Dec 2022 20:44:53 -0800 (PST) Date: Sat, 17 Dec 2022 12:44:35 +0800 In-Reply-To: <20221217044436.4138642-1-davidgow@google.com> Mime-Version: 1.0 References: <20221217044436.4138642-1-davidgow@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221217044436.4138642-3-davidgow@google.com> Subject: [PATCH 2/3] rust: arch/um: Disable FP/SIMD instruction to match x86 From: David Gow To: Miguel Ojeda , "=?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?=" , Richard Weinberger , Anton Ivanov , Johannes Berg , Thomas Gleixner , Ingo Molnar , Nathan Chancellor , Nick Desaulniers Cc: David Gow , rust-for-linux@vger.kernel.org, linux-um@lists.infradead.org, llvm@lists.linux.dev, linux-doc@vger.kernel.org, kunit-dev@googlegroups.com, x86@kernel.org, linux-kernel@vger.kernel.org, Wedson Almeida Filho , Gary Guo , Brendan Higgins , Daniel Latypov , Jonathan Corbet Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The kernel disables all SSE and similar FP/SIMD instructions on x86-based architectures (partly because we shouldn't be using floats in the kernel, and partly to avoid the need for stack alignment, see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D53383 ) UML does not do the same thing, which isn't in itself a problem, but does add to the list of differences between UML and "normal" x86 builds. In addition, there was a crash bug with LLVM < 15 / rustc < 1.65 when building with SSE, so disabling it fixes rust builds with earlier compiler versions, see: https://github.com/Rust-for-Linux/linux/pull/881 Signed-off-by: David Gow Reviewed-by: Sergio Gonz=C3=A1lez Collado --- arch/x86/Makefile.um | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/Makefile.um b/arch/x86/Makefile.um index b3c1ae084180..d2e95d1d4db7 100644 --- a/arch/x86/Makefile.um +++ b/arch/x86/Makefile.um @@ -1,6 +1,12 @@ # SPDX-License-Identifier: GPL-2.0 core-y +=3D arch/x86/crypto/ =20 +# +# Disable SSE and other FP/SIMD instructions to match normal x86 +# +KBUILD_CFLAGS +=3D -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx +KBUILD_RUSTFLAGS +=3D -Ctarget-feature=3D-sse,-sse2,-sse3,-ssse3,-sse4.1,-= sse4.2,-avx,-avx2 + ifeq ($(CONFIG_X86_32),y) START :=3D 0x8048000 =20 --=20 2.39.0.314.g84b9a713c41-goog From nobody Wed Sep 17 15:58:53 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C9C4C4332F for ; Sat, 17 Dec 2022 04:45:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230206AbiLQEpf (ORCPT ); Fri, 16 Dec 2022 23:45:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230091AbiLQEpV (ORCPT ); Fri, 16 Dec 2022 23:45:21 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C9F03EAE0 for ; Fri, 16 Dec 2022 20:44:58 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id k18-20020a170902c41200b001896d523dc8so2992360plk.19 for ; Fri, 16 Dec 2022 20:44:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=YND6/2+MHvKx/dzQIvDqR3IvAStElNFUwtkZlZ3WKgQ=; b=QMd8J7EJRoRyHw9X4KgOQl8PvNtaLwUhiAS3fSGBCOFhPoHi9xnvzQDYxVD7j5amTH Q4GsEYMqTBsn7iQ3GKJlOQR7EYCNqdaNx2qM4/U0btqkZqTcRMc1G1ID4ksjk8w1ygdM DAJeLauQhKJzcld5IN4m9ojYJJXJWXH/+Ncc0RYib27ehXOQzrkybiAFl8r2x8Ptjl/S +YkSCxfYkmE6lb0ISCS9tQc9f+6I+0E0L/Tx5CAD18WVWeqB1ST40GnnDKUI3RFsEfBa yGtQZgSh/2My4u1fuJc0S39x7Y8SoUOc2boVv2C5FpiuBzR3ANMP90xclhrEoiRdL/87 jXCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YND6/2+MHvKx/dzQIvDqR3IvAStElNFUwtkZlZ3WKgQ=; b=UFEw17Ihmmo4cvVVCcP6HZA1puGKrT7fgj8HMW7mejWnGo2JxpIEXW3RAcFJFVL7zu CX4X58fnkEtjXqByDJZzfPwKVShsK8cJ/0ZeAGDb8vgUecIjUbQFQ+c2gY2PIJs8czxs GQcLxxisvO2vAjWS9eQb8MgKRT0R7d05xUB1otTEh208SPbpCWDxH53ZCe+rmCRgS4Un sKd+SlRAbz8LFP0h9WrFRu7jcMdOvIijaHVoU+K7q13fTgRlRgY0wyyWmPUH7ibyOEJx hL5bM2Ii86eRLNbF5j2Pruu5VDDf2yVh+p3sp38rTLlrtfWT0bj4JN3dFkLsaSJu68DE A0/g== X-Gm-Message-State: ANoB5pmeu5+2sMDOBb8UzGFm+JCvD2wCew1G6gea+JSayUp0qi5k6EaO 1JwhxEC5JUK86VuWVZ0uS7Ccyz30coRoIA== X-Google-Smtp-Source: AA0mqf6DRN18kEtRr6vU/bQebITkL+OzR7rXnAWVsO4WmsI6YKnoCOGcBUx49MMTn8GtKKmZYYEz8T0hXzfXAA== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a17:902:8698:b0:188:e255:39af with SMTP id g24-20020a170902869800b00188e25539afmr80407695plo.86.1671252297906; Fri, 16 Dec 2022 20:44:57 -0800 (PST) Date: Sat, 17 Dec 2022 12:44:36 +0800 In-Reply-To: <20221217044436.4138642-1-davidgow@google.com> Mime-Version: 1.0 References: <20221217044436.4138642-1-davidgow@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221217044436.4138642-4-davidgow@google.com> Subject: [PATCH 3/3] rust: arch/um: Add support for CONFIG_RUST under x86_64 UML From: David Gow To: Miguel Ojeda , "=?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?=" , Richard Weinberger , Anton Ivanov , Johannes Berg , Thomas Gleixner , Ingo Molnar , Nathan Chancellor , Nick Desaulniers Cc: David Gow , rust-for-linux@vger.kernel.org, linux-um@lists.infradead.org, llvm@lists.linux.dev, linux-doc@vger.kernel.org, kunit-dev@googlegroups.com, x86@kernel.org, linux-kernel@vger.kernel.org, Wedson Almeida Filho , Gary Guo , Brendan Higgins , Daniel Latypov , Jonathan Corbet Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" CONFIG_RUST currently supports x86_64, but does not support it under UML. With the previous patches applied, adding support is trivial: add CONFIG_HAVE_RUST to UML if X86_64 is set. The scripts/generate_rust_target.rs file already checks for CONFIG_X86_64, not CONFIG_X86, so is prepared for UML support. The Rust support does not currently support X86_32. Also, update the Rust architecture support documentation to not that this is being maintained: I intend to look after this as best I can. Signed-off-by: David Gow Reviewed-by: Sergio Gonz=C3=A1lez Collado Tested-by: Sergio Gonz=C3=A1lez Collado --- Documentation/rust/arch-support.rst | 2 ++ arch/um/Kconfig | 1 + 2 files changed, 3 insertions(+) diff --git a/Documentation/rust/arch-support.rst b/Documentation/rust/arch-= support.rst index 6982b63775da..a526ca1c688b 100644 --- a/Documentation/rust/arch-support.rst +++ b/Documentation/rust/arch-support.rst @@ -17,3 +17,5 @@ Architecture Level of support Constraints =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ``x86`` Maintained ``x86_64`` only. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D +``um`` Maintained ``x86_64`` only. +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D diff --git a/arch/um/Kconfig b/arch/um/Kconfig index ad4ff3b0e91e..4db186f019ae 100644 --- a/arch/um/Kconfig +++ b/arch/um/Kconfig @@ -28,6 +28,7 @@ config UML select TRACE_IRQFLAGS_SUPPORT select TTY # Needed for line.c select HAVE_ARCH_VMAP_STACK + select HAVE_RUST if X86_64 =20 config MMU bool --=20 2.39.0.314.g84b9a713c41-goog