From nobody Wed Nov 27 13:02:17 2024 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 1092F1BE236 for ; Thu, 10 Oct 2024 09:38:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728553120; cv=none; b=rqn5vtLrSO6FfNyskzCwTyOnmt+HHHthCkE2aEU/Ef0j4wiMYWzUthPO+rEdf7V7WoQLhoXfqWIMWc0VMShFL9pnaXV6cg6PYcNEwkN/J3uObabX7bUms63DONVeOI0wtKm4rzmZknfjXlT0s5FxLRGQsht8a0TIne5i2wczS70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728553120; c=relaxed/simple; bh=sprZWicbSYX/wuK86XaKNqOKKGSxgjIajbIesmsLRa8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UFKBS+4cwQohXgoc7ZmYoZCFo+riY74lFPBywsr1RXdCajJoo9Oq+UtN0VUlqXfd6Z2vFDiz8Dm8ef5tuoC7XJLuOAU1do7c0zY0QhbCIRoScdPjzFwIPUUbVZ+XK8a6UHwig/UzeJ/qCCtTKVAClI+m1vkdHTZpyUFf0b5z4E0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SZmBS5TI; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SZmBS5TI" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e28eea1074dso1100334276.0 for ; Thu, 10 Oct 2024 02:38:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728553118; x=1729157918; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=O+AhvaeBWw5/RdolKgGnr5greoh9tZKs03Mr9gvw9kc=; b=SZmBS5TIdBy8AWRHgacIv2cBU3SdzXYCyCi0rlZuys3W2MoftD+0CgVxUUsR9oQpOC SSoZyMKKUmv4GQtD+P939nZ3PZ6IIqbBJPdF4/KaZALr+nCV/yfxZxnLvIXUnQ/0mMDU c5H9hnYwSRZ5VupneL2sfMNuSlfA7qgb7XmCZabQ8wZ6uZuGMgSN9pZ8fA0OWk8P/kEz JYLeK0N6vzEBsADDTFYGg4kFslMWoJHudHV0nZ7/nHxwyCG6AKxCZBICqbfDULoeG1HT SFJPR/1+gU4yDq9FAVVdvj320enq3xMPwYWTxoNwbJnKJVxWsbo8LQ3mY8QLxyn3RxVr dBUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728553118; x=1729157918; 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=O+AhvaeBWw5/RdolKgGnr5greoh9tZKs03Mr9gvw9kc=; b=n4zbgSI+gOmYEtsBUw+5OfsNmmrZSNPeb5z/qt8N+hp2STpw9iY3Kf1sG3IGi/eZ+h faSEBkp5eykeeTilTYK7tpoKY9JWsz5Q/g0CBsaKHCIzgGFgyYAIrX2VgsDVjqWe0+bV HJ9JQ2oK3AtrviAThiD0F3/ycBxt6fRZv4Yx7IhG5k1nIwF37HMoEGo9xTM+X4DbDyNI 0XMg1h7gfV3QDzRqi/HHhvzxlkNlgGDLdc+69+QEvg3jXFRf0BsRewTqlqIDGSiEydXZ GNFsONsqOLvZGc1JOYgN4Tc5s1SbBp/STGZwrDa2+B8UNqTHmrwIgWh4pT48LNLULh5x 3w8g== X-Forwarded-Encrypted: i=1; AJvYcCVL+MVDPHInNZUIfYkvkrz/025NElpYUF7OC7QJ3PqDYYjDx9bD9lD40sVhTw6uapqjXd988KBcUwk1qKM=@vger.kernel.org X-Gm-Message-State: AOJu0YyRmiJn6F9YTqD4baSLMCRFbwT76jwlBx4+3oImfyYMO4AhAzQf 8aBybVRFkC49jWV2HYPIEOPI0d2bSAPH+IXhbsfgMcjh1lPCL/oOMULl+04ZR+JWNERgM8K/fUY Rsgp0CPMliu7G9A== X-Google-Smtp-Source: AGHT+IGeUBivrsQSq+PuNVUTTRBZI+h4vM5m+PDMtlURQ9Ehj+kRy0g7Kk3HN2DNX8RKbhDakX9kqmGo1oBnmoc= X-Received: from aliceryhl.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:35bd]) (user=aliceryhl job=sendgmr) by 2002:a25:d681:0:b0:e0b:a712:2ceb with SMTP id 3f1490d57ef6-e28fe3665b7mr121379276.5.1728553118005; Thu, 10 Oct 2024 02:38:38 -0700 (PDT) Date: Thu, 10 Oct 2024 09:38:26 +0000 In-Reply-To: <20241010-icall-detect-vers-v1-0-8f114956aa88@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241010-icall-detect-vers-v1-0-8f114956aa88@google.com> X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=3960; i=aliceryhl@google.com; h=from:subject:message-id; bh=ioyjOajrFUcSJsPSpIsZJ5SxB5UOY0I6EBrBjM/1voU=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBnB6CYAC51tAnp8Qhdz59K5IFjoWW12e6tR9tLn kG/RmSvGhaJAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCZwegmAAKCRAEWL7uWMY5 RgmyEACujMB3w0rEef116bx1bRT21n1YSunfGZXdQCCu2RtRyUVgsAEUwAVB5pdwVkC4eO9k2y4 J/0P5OFmndf5+KsZZT6jdQdRtUkNY8h/5fUPuTNsLQZt4LEgQ4MQyqbC6/hJWb9ZfrXZGokMuYk NPi5w6WZScxVBt9QEKvSCQ0AlJ0Q+1WvZbt3JJBKLZOhVJPlQZXik7JbThTpSdZzkVPp+MM/HKc zP6pz5u+VmWY7AqGTE/N1n2FgHIe8Ooyl9l5lWwbX0tXfmHPdAfZ6o8A0EQHT4MUHzM5263Qn9R /CoMZ61NeRmxv9nAlddUSP9xEokmrVy5CdIHQINBKsvaGjnuXrg0kpaaFWvvrXNO4zxsPaOy19M owZX8cAsQQ0wFtN3lrRuy5FkSlhWgnjPYEIbI7YW0uY005s6dhdRFXSJ665W0KcPG6Q9FKJiW7m hauSngZ5cbsX55pxwJVDXXZJ0rxbX8ySptvJeCUmoi87os8k0vy8FwUvbpdrAL2dgibjLbgRb+J kwDlcUEtlnNnltQST23BIiQm3Erw7fHHdbeC0Igr5CWNKGEIXvk36XAdt2dDb4tU4jOq0t5aCVQ mKOsr+/PeiQ9vHdAhu97yN5Jqtp85cbystbJ0XaJNX80jGj5HcMzRwB87Q4nX8NJkU98RoQbEQK HoWTPx+0j4qrp6w== X-Mailer: b4 0.13.0 Message-ID: <20241010-icall-detect-vers-v1-1-8f114956aa88@google.com> Subject: [PATCH 1/2] kbuild: rust: add `CONFIG_RUSTC_LLVM_VERSION` From: Alice Ryhl To: Masahiro Yamada , Miguel Ojeda , Sami Tolvanen , Kees Cook , Nathan Chancellor Cc: Alex Gaynor , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Trevor Gross , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, rust-for-linux@vger.kernel.org, llvm@lists.linux.dev, Alice Ryhl Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Gary Guo Each version of Rust supports a range of LLVM versions. There are cases whe= re we want to gate a config on the LLVM version instead of the Rust version. Normalized cfi integer tags are one example [1]. For consistency with cc-version and ld-version, the new version number is a= dded to the existing rustc-version script, rather than being added to a new scri= pt. The invocation of rustc-version is being moved from init/Kconfig to scripts/Kconfig.include to avoid invoking rustc-version.sh twice and for consistency with cc-version. Link: https://lore.kernel.org/all/20240925-cfi-norm-kasan-fix-v1-1-0328985c= df33@google.com/ [1] Signed-off-by: Gary Guo Reviewed-by: Sami Tolvanen --- init/Kconfig | 6 +++++- scripts/Kconfig.include | 4 ++++ scripts/rustc-version.sh | 31 +++++++++++++++++++++++++------ 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index 530a382ee0fe..98cf859d58c2 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -62,7 +62,7 @@ config LLD_VERSION =20 config RUSTC_VERSION int - default $(shell,$(srctree)/scripts/rustc-version.sh $(RUSTC)) + default $(rustc-version) help It does not depend on `RUST` since that one may need to use the version in a `depends on`. @@ -78,6 +78,10 @@ config RUST_IS_AVAILABLE In particular, the Makefile target 'rustavailable' is useful to check why the Rust toolchain is not being detected. =20 +config RUSTC_LLVM_VERSION + int + default $(rustc-llvm-version) + config CC_CAN_LINK bool default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) = $(USERCFLAGS) $(USERLDFLAGS) $(m64-flag)) if 64BIT diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include index 785a491e5996..788097a55731 100644 --- a/scripts/Kconfig.include +++ b/scripts/Kconfig.include @@ -65,6 +65,10 @@ cc-option-bit =3D $(if-success,$(CC) -Werror $(1) -E -x = c /dev/null -o /dev/null,$ m32-flag :=3D $(cc-option-bit,-m32) m64-flag :=3D $(cc-option-bit,-m64) =20 +rustc-info :=3D $(shell,$(srctree)/scripts/rustc-version.sh $(RUSTC)) +rustc-version :=3D $(shell,set -- $(rustc-info) && echo $1) +rustc-llvm-version :=3D $(shell,set -- $(rustc-info) && echo $2) + # $(rustc-option,) # Return y if the Rust compiler supports , n otherwise # Calls to this should be guarded so that they are not evaluated if diff --git a/scripts/rustc-version.sh b/scripts/rustc-version.sh index 4e22593e2eab..24e19ed8f234 100755 --- a/scripts/rustc-version.sh +++ b/scripts/rustc-version.sh @@ -3,14 +3,23 @@ # # Usage: $ ./rustc-version.sh rustc # -# Print the Rust compiler version in a 6 or 7-digit form. +# Print the Rust compiler version and the LLVM version it uses in a 6 or +# 7-digit form. + +# Convert the version string x.y.z to a canonical up-to-6-digits form. +get_llvm_canonical_version() +{ + IFS=3D. + set -- $1 + echo $((10000 * $1 + 100 * $2 + $3)) +} =20 # Convert the version string x.y.z to a canonical up-to-7-digits form. # -# Note that this function uses one more digit (compared to other -# instances in other version scripts) to give a bit more space to +# Note that this function uses one more digit (compared to other instances= in +# other version scripts and the instance above) to give a bit more space to # `rustc` since it will reach 1.100.0 in late 2026. -get_canonical_version() +get_rustc_canonical_version() { IFS=3D. set -- $1 @@ -19,8 +28,18 @@ get_canonical_version() =20 if output=3D$("$@" --version 2>/dev/null); then set -- $output - get_canonical_version $2 + rustc_version=3D$(get_rustc_canonical_version $2) else - echo 0 + echo 0 0 exit 1 fi + +if output=3D$("$@" --version --verbose 2>/dev/null | grep LLVM); then + set -- $output + rustc_llvm_version=3D$(get_llvm_canonical_version $3) +else + echo 0 0 + exit 1 +fi + +echo $rustc_version $rustc_llvm_version --=20 2.47.0.rc0.187.ge670bccf7e-goog From nobody Wed Nov 27 13:02:17 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 4622D1BF80A for ; Thu, 10 Oct 2024 09:38:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728553124; cv=none; b=sCvmRw7KL8SD42Z8ISj/4MeQzEIA1q6u+v26OLMDu0OZrDgG861royjrNrYfKog6kC19TzbQe2Wp1qVHLfdbGfx7H6SfbOVzjGnUKyvMdUHqOUuVuTcScNchjckBQLlUWaIPSEtoPvzXvQmliM4Uez3BJHevpmwKNNy0xDf2Yns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728553124; c=relaxed/simple; bh=VT2SuDcWVnMzBAVEldlhHzTMoIA8IDGupx5zZhlV3n0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Z8AZntQNl6BwIrWHi55iA/PoWOItEeR/Mo6e7MPNNKBHSX1fIzAljTIH5c9mibAFTkmNtPOrdDv0oZ7BBr88bEwHrCbzeLt3BRoTEZ5DxjQ7QRCFqg5QX1llisIe9regdrYig1cJXRglH/TUmIsJDEEYoT2w9baclXA3W3f0o7g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=sNBVSsNn; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sNBVSsNn" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e31d9c8efcso16212117b3.0 for ; Thu, 10 Oct 2024 02:38:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728553120; x=1729157920; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eACD4XRROaCtgnocFX5+RB0Y2dfNcR6e9CG+8sSoYh4=; b=sNBVSsNnhylM6WSpK6/6EfmclcZZOAZ9BnNhGA2O77iUB009VHT/xu/XxxDvpAt5m7 trH3PXmyh+6XRaRmJs7anXJZs7lvdkrIFPnKo9jkUNeNnZysLjGSXVBIWnVleF827YAM /McQGfpp3zPsBN35xjFcrboXnnApx0TraY+HEUChqCpKfjp6GzaY3fUtv2lHbSKSdvTN JrlKCn0eOVytHgrnBEL9q/K4i5ApyTNuFV7Jb18rmqLcnJVrg/tkF/zeHA1BziLwMgey 3GZPSBeeuaTk+4cJr9le7F8epoJzzoJ//InvmDUC02peRx2P7LkLvW4XheNVRQ8hMVH/ TH2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728553120; x=1729157920; 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=eACD4XRROaCtgnocFX5+RB0Y2dfNcR6e9CG+8sSoYh4=; b=Y+UUfdUOT3/6qFNnl9OI6sqDd7A/k+6P4vjtZeQDIo39Vwrrn1PGT7a4rh+2hmTx+7 kj1Do2xKF9o7v+pv0/pCx5Qkqigd40VSmcbCEOWzpTxrWshDDev5WyB3ZMSeDQ7UUQHz 61EEsuNrBqQ/3tUB43qHb+nTLhjgqd3uHX5Aks5Hp6Sv2koCXOjIU6DcCHW5VLZYGpFN urvKs0zUGRHEMqthf5Tapdd1k/CLzGlmCOfcuy/xEh4w3coJh1vLh8/7ErBjiQ7o6tJX cK7/YhJk323rB+yX7gBNIPkDgeWYROfrEvuUpG5TFY5AoZ9Z+W4ii2t6/Y1V8NjW+PnJ xqXw== X-Forwarded-Encrypted: i=1; AJvYcCVXwV1g2BqROJoFv11jNGurMOHsZMux6MWbZIOZQn5+fhaWrk97xQ5Xo4t75u7D89iA6zb5AJcyqPUyDsQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyXJySTa6FLom3BQHFLAwHJ7GhLqfHr/3kI9hx49tyizetETFaQ zlX0YZQZER6D1W1R1pHQQkw10pLldkUx3PGx5ElgW6dm7rjaoHHHC+axpdsYjp8fxuJPke4fWJo qNyGDOMwKvRK0Jg== X-Google-Smtp-Source: AGHT+IEGcui+HlgSNQoktbhQh3A2G5+Kd6G/NcYjKQUmJw3bmKVSjI3w7gKgtE/Edkv8/1W9cri6mLPryjmTGjI= X-Received: from aliceryhl.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:35bd]) (user=aliceryhl job=sendgmr) by 2002:a05:690c:2c01:b0:6db:d257:b98 with SMTP id 00721157ae682-6e32215253bmr516967b3.3.1728553120372; Thu, 10 Oct 2024 02:38:40 -0700 (PDT) Date: Thu, 10 Oct 2024 09:38:27 +0000 In-Reply-To: <20241010-icall-detect-vers-v1-0-8f114956aa88@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241010-icall-detect-vers-v1-0-8f114956aa88@google.com> X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=4239; i=aliceryhl@google.com; h=from:subject:message-id; bh=VT2SuDcWVnMzBAVEldlhHzTMoIA8IDGupx5zZhlV3n0=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBnB6CYs0u7blh+ZX5hDv0dKotrih6IeVcBm5Vhp EN1T0iq4B2JAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCZwegmAAKCRAEWL7uWMY5 RhQFEACswAkfF3tGCsn7bv37wtSYjM0N0Gh3kSpV81MBZrV8NDPZJKdw5njIOrmlRvMtiVqZ0vn uaGVEOCtCJnJQgfUF3OVzu2Q5yBB54S1oXq3f3DNEuB2R9hHIexEM5E2QvXxNOvYPXR6REEwBR9 xyXVgO0l6/Lx2O4GHUULGr2aULI7kGBqJMUQOt21mp1PS6lGMaWVeUq8OpmdBWOGQmPbXj0slsc XRVgymT4v5Nf1kWcQmQnZ6+w5ZfAMhw/CikqMwDIRlvV0cx8YgXvIDsJDDDcua0FR3MDhn84xFL jisqTVf+0h+1A9BRgwMz5wbgDvr/uUogd6A4nM32lL4tUBMl0KeruMKA8qIw+SfMYO21XmTrosy 1WmuqELMXSwO28R/oPaIdH+OS7Po874Nin7ktneBKuPIS6UPhdZuIXEBrf1tYs6t46AvdhHEktO AWkfHpXQCRiZ7LWiEngFArYMRDNCOfSKXBmEt4re54CTQOWvu2Qw2DI+EcOkvuUDIye+j7KEAVG Lb9b+s2UBP6k3+2DD2NKRlPPnors/rPhp7vRzBH2YKAujl1zfmCCl1OlqWyGwXI8Wg7FsPxeWZ3 4ItweSD98EgjTVkS/xw9FeweugxAKS6Z9ryfioYx1l8lVqsoyPacr4/LA3Uz6WSQC3HRtfi0Yl+ ISH/VMpZbdy3FoA== X-Mailer: b4 0.13.0 Message-ID: <20241010-icall-detect-vers-v1-2-8f114956aa88@google.com> Subject: [PATCH 2/2] cfi: fix conditions for HAVE_CFI_ICALL_NORMALIZE_INTEGERS From: Alice Ryhl To: Masahiro Yamada , Miguel Ojeda , Sami Tolvanen , Kees Cook , Nathan Chancellor Cc: Alex Gaynor , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Trevor Gross , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, rust-for-linux@vger.kernel.org, llvm@lists.linux.dev, Alice Ryhl Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The HAVE_CFI_ICALL_NORMALIZE_INTEGERS option has some tricky conditions when KASAN or GCOV are turned on, as in that case we need some clang and rustc fixes [1][2] to avoid boot failures. The intent with the current setup is that you should be able to override the check and turn on the option if your clang/rustc has the fix. However, this override does not work in practice. Thus, use the new RUSTC_LLVM_VERSION to correctly implement the check for whether the fix is available. Additionally, remove KASAN_HW_TAGS from the list of incompatible options. The CFI_ICALL_NORMALIZE_INTEGERS option is incompatible with KASAN because LLVM will emit some constructors when using KASAN that are assigned incorrect CFI tags. These constructors are emitted due to use of -fsanitize=3Dkernel-address or -fsanitize=3Dkernel-hwaddress that are respectively passed when KASAN_GENERIC or KASAN_SW_TAGS are enabled. However, the KASAN_HW_TAGS option relies on hardware support for MTE instead and does not pass either flag. (Note also that KASAN_HW_TAGS does not `select CONSTRUCTORS`.) Link: https://github.com/llvm/llvm-project/pull/104826 [1] Link: https://github.com/rust-lang/rust/pull/129373 [2] Fixes: 4c66f8307ac0 ("cfi: encode cfi normalized integers + kasan/gcov bug = in Kconfig") Signed-off-by: Alice Ryhl Reviewed-by: Sami Tolvanen --- arch/Kconfig | 26 ++++++++++++-------------- init/Kconfig | 2 +- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 8af374ea1adc..00163e4a237c 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -838,7 +838,7 @@ config CFI_CLANG config CFI_ICALL_NORMALIZE_INTEGERS bool "Normalize CFI tags for integers" depends on CFI_CLANG - depends on HAVE_CFI_ICALL_NORMALIZE_INTEGERS + depends on HAVE_CFI_ICALL_NORMALIZE_INTEGERS_CLANG help This option normalizes the CFI tags for integer types so that all integer types of the same size and signedness receive the same CFI @@ -851,21 +851,19 @@ config CFI_ICALL_NORMALIZE_INTEGERS =20 This option is necessary for using CFI with Rust. If unsure, say N. =20 -config HAVE_CFI_ICALL_NORMALIZE_INTEGERS - def_bool !GCOV_KERNEL && !KASAN - depends on CFI_CLANG +config HAVE_CFI_ICALL_NORMALIZE_INTEGERS_CLANG + def_bool y depends on $(cc-option,-fsanitize=3Dkcfi -fsanitize-cfi-icall-experimenta= l-normalize-integers) - help - Is CFI_ICALL_NORMALIZE_INTEGERS supported with the set of compilers - currently in use? + # With GCOV/KASAN we need this fix: https://github.com/llvm/llvm-project/= pull/104826 + depends on CLANG_VERSION >=3D 190000 || (!GCOV_KERNEL && !KASAN_GENERIC &= & !KASAN_SW_TAGS) =20 - This option defaults to false if GCOV or KASAN is enabled, as there is - an LLVM bug that makes normalized integers tags incompatible with - KASAN and GCOV. Kconfig currently does not have the infrastructure to - detect whether your rustc compiler contains the fix for this bug, so - it is assumed that it doesn't. If your compiler has the fix, you can - explicitly enable this option in your config file. The Kconfig logic - needed to detect this will be added in a future kernel release. +config HAVE_CFI_ICALL_NORMALIZE_INTEGERS_RUSTC + def_bool y + depends on HAVE_CFI_ICALL_NORMALIZE_INTEGERS_CLANG + depends on RUSTC_VERSION >=3D 107900 + # With GCOV/KASAN we need this fix: https://github.com/rust-lang/rust/pul= l/129373 + depends on (RUSTC_LLVM_VERSION >=3D 190000 && RUSTC_VERSION >=3D 108200) = || \ + (!GCOV_KERNEL && !KASAN_GENERIC && !KASAN_SW_TAGS) =20 config CFI_PERMISSIVE bool "Use CFI in permissive mode" diff --git a/init/Kconfig b/init/Kconfig index 98cf859d58c2..c521e1421ad4 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1950,7 +1950,7 @@ config RUST depends on !GCC_PLUGIN_RANDSTRUCT depends on !RANDSTRUCT depends on !DEBUG_INFO_BTF || PAHOLE_HAS_LANG_EXCLUDE - depends on !CFI_CLANG || RUSTC_VERSION >=3D 107900 && HAVE_CFI_ICALL_NORM= ALIZE_INTEGERS + depends on !CFI_CLANG || HAVE_CFI_ICALL_NORMALIZE_INTEGERS_RUSTC select CFI_ICALL_NORMALIZE_INTEGERS if CFI_CLANG depends on !CALL_PADDING || RUSTC_VERSION >=3D 108100 depends on !KASAN_SW_TAGS --=20 2.47.0.rc0.187.ge670bccf7e-goog