Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2175223rdb; Mon, 9 Oct 2023 15:44:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFxO8ITeGIFMbtKjyzJz8Ar9uN4ADgUCV17ld4OnaM9o2P8o6D5M3IY8+e0kP/j32CElgH X-Received: by 2002:a17:90b:895:b0:279:d59:6150 with SMTP id bj21-20020a17090b089500b002790d596150mr16504354pjb.17.1696891454217; Mon, 09 Oct 2023 15:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696891454; cv=none; d=google.com; s=arc-20160816; b=y6ap6yasmqf9AtlUDZJt5WS3n5uY51ztsrG5x7A3WkFY2wX87ExqtfKVDfCLkWeC4D tOLxZHxEuD6Su9W8OcoSbP0ruo9e1KStVc267zb6um+MG6B8VUAvORE/oSt+LpdAdb1J IOg/IcPNfQ3uEQd3cfTeEz/Pmpz6LTqMZWreonOFIb8acFITfKksfHij0V6eOPFKWFaa C34ZHXKv0CUkNStkDEAs+q6x81tSFLbf6Xns5/t7iZlA5tOcu1+gPg5OmXwt8/0WSl5d umW42iieTvnO9Q1CQ0PWe+c1VySu+CuZgpYOIq333Hfj/w+1Ds+BLCa1ofl8J6C2UyX2 g3Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=DKAs9FiDWAh3UClUoSgrNgZ5MWCcyLnU7t6CMgdnzXQ=; fh=57l8RX8So/QJXKkk5pqf7sQrCEuIIPc1WpHorI0Tqz8=; b=t0gAFrAcJ2KZwhzFZglr2keUfU1k+0FhuRgqIjREbatlvsnL7qAZkgTayyRo4BlW2P +068k+VTr5ngkPOxQ/FxzWVw6pzBf3lxF99VIrDLL4uHjEphXF0yqYudki+K/YKyo4oG jeOi1KPqbMSIqOJfDEgw2tS9ZMLPMuEatZZiALg+Od1wiUVg7oWtVyocA/GH/KQOTmu2 cRhcco1gYSyzO2hhP/T/GIsXwah8MxMdSYMNq8p6tAfdyXhso3P3UZl5xop4/U1+Wmj1 yxh5KfKLmdtSXPztzQD95vJvS9xmK3S03lGJ4peMI210RUtDvM6qeUN0PzRuQlQbfe/K 8j0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lDZKkevm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id n5-20020a170902d2c500b001c5f5153e41si11452311plc.535.2023.10.09.15.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 15:44:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lDZKkevm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 0D40A80B2D6F; Mon, 9 Oct 2023 15:44:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378233AbjJIWoE (ORCPT + 99 others); Mon, 9 Oct 2023 18:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234587AbjJIWn7 (ORCPT ); Mon, 9 Oct 2023 18:43:59 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 731849F for ; Mon, 9 Oct 2023 15:43:55 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59ee66806d7so76386447b3.0 for ; Mon, 09 Oct 2023 15:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696891434; x=1697496234; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=DKAs9FiDWAh3UClUoSgrNgZ5MWCcyLnU7t6CMgdnzXQ=; b=lDZKkevmol2pCZr/NOIiqWqTwwEJMZT2szqyAVAo7kJdmOiFQUlIlRmz6vubU2M2+7 N7VWj+WVL96gYmFpoeAWbjleeySLssS8xLaw7+Oko67rWXWUsgx/+SbX2R4BRUwIdvcC OQyJI+H4cE+Ri3MbyyNe4Wk+N9ttV8gSqibEueCpB4DBpWTwb+C15QrBlbH4OSoS2LWf xulIcvCFNYF7IfMePbp2WyUcydIZWaRdpYakeysmLIfXMUpg2+J+fEWXdF/zwXtq37bZ I4ihwAeeOsS2JRDnH9qM8nEzfScR3P2nfVKgEiEJQhCGk0ooXKsjO3ImDlzHqjQ5H4zX B2OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696891434; x=1697496234; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DKAs9FiDWAh3UClUoSgrNgZ5MWCcyLnU7t6CMgdnzXQ=; b=kkAbrAWr/dyjcoW3QxyvGC9kORL/ZDzJRi4dY+EZXUYn6DwzN72s513qX5gEz9maZn 0xJyh3yEiu8+wccJwWfyqPVoUvjx8rR0x/JagDpsIMkhpndnWZYTOrVQWhOkvZCV1+GB sspLdYMRaAvy7061NIWWG7S2x6mBVUoczdd8AoVik0+SRJ8Z36cgW9VLLfqMY3HpN36m XT+k/z8uMkKLbSzMsC0n+9foTGr2AOO9kN2tYO4WNVD+7fdaCXVbYCghrVVVDOmlXD46 ZN1kzqbTCHUVOv0fwhJ6EqAwmDukEnAC1NM6UkLkCos93ATI1wJ34GOlMt1R6EGEI3Av rOMQ== X-Gm-Message-State: AOJu0Yw0kcOipXjccjPO7U2uy14wirj/V4ec2+MIeYqcSWwn9AvxBH5p HJIr9o1urW24mx5PzlLsdMQetG1+v7/g X-Received: from anyblade.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1791]) (user=mmaurer job=sendgmr) by 2002:a81:aa4d:0:b0:592:83d2:1f86 with SMTP id z13-20020a81aa4d000000b0059283d21f86mr290212ywk.4.1696891434703; Mon, 09 Oct 2023 15:43:54 -0700 (PDT) Date: Mon, 9 Oct 2023 22:42:54 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Message-ID: <20231009224347.2076221-1-mmaurer@google.com> Subject: [PATCH] x86: Enable IBT in Rust if enabled in C From: Matthew Maurer To: peterz@infradead.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho Cc: Matthew Maurer , "H. Peter Anvin" , Boqun Feng , Gary Guo , "=?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?=" , Benno Lossin , Andreas Hindborg , Alice Ryhl , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 09 Oct 2023 15:44:11 -0700 (PDT) These flags are not made conditional on compiler support because at the moment exactly one version of rustc supported, and that one supports these flags. Building without these additional flags will manifest as objtool printing a large number of errors about missing ENDBR and if CFI is enabled (not currently possible) will result in incorrectly structured function prefixes. Signed-off-by: Matthew Maurer --- Split out the IBT additions as per https://lkml.kernel.org/linux-fsdevel/CANiq72kK6ppBE7j=z7uua1cJMKaLoR5U3NUAZXT5MrNEs9ZhfQ@mail.gmail.com/ arch/x86/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 5bfe5caaa444..941f7abf6dbf 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -81,6 +81,7 @@ ifeq ($(CONFIG_X86_KERNEL_IBT),y) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104816 # KBUILD_CFLAGS += $(call cc-option,-fcf-protection=branch -fno-jump-tables) +KBUILD_RUSTFLAGS += -Zcf-protection=branch -Zno-jump-tables else KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) endif -- 2.42.0.609.gbb76f46606-goog