Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4111060pxk; Tue, 29 Sep 2020 14:52:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB5GnrVuJwj6vtLZj298ev18oqQoiX9otWx6ZXussNlmL1jsRazsSHP3JIQVT9GlMb4+S6 X-Received: by 2002:a50:9b19:: with SMTP id o25mr5321126edi.340.1601416356240; Tue, 29 Sep 2020 14:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601416356; cv=none; d=google.com; s=arc-20160816; b=D9urh7e9xEhrrun/atkjJlTw1UaO5ojOlclBrsrGe76dEYSsjZ8kSqW1Ew2JS+JNPD tMOz1Au7viTHEecl/XpnBY3WrT0nJZz0xOgQrHlp4o30AGHAtTUp7ngYivzPFKhVubpj OgCV/YVNkkymKD3Xg0+gJWxgAZMmDSLjn8VEQ0FNJXiDNAIya7BtApEBRQMVcO+/EyZp t2q6v7Qc4rfzcMUuV7hSjJe2OWFY/uO5rDj8roxRtPdcYWdGO9VNwPv6tHd4jYzoHF6a 1uv2joXo2/kTU6nU3MsIYwD0tr5YoZgV23cxDNGqj6ZFTR+EvQMBbTgmLeZ45VOJ9fiB gnEw== 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:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=Dx9e+jODClwF/iJJnqk8YtFURfMacOCvss9V22Z0Fc8=; b=X+hoz/CkA+XHFBBnOlvCAnsqqe6ylZtFCWLaxT/Sb0972LL1Egj0tHbrEohbIVDinc 9cU2zCDmFck91+G0Qk87jUML1D/jq7IHbmr5BCFnID/Ei3vOzs9B/pfb/ljxiVrZhJJN 4WZVkfAP2/bhU+AFkE6RHCq45QAOsNFFGd1LY7G1WIB1hdK9n8RMOTKsAhjhuojuiFqp qnFjPrYTLc9/cuyAwJL88yaWxAKHkqfV+YMDVHlDtwsiQwGR6tTCmxcy7gFIOUNjc7Fp zfenf6x9b0VstuhnDAb/sxUxpxbo6KC5zxw+xXhkkf43wv7YBrhGRnHzq7m1U+knB6FL m0HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=eAC3sd7F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z4si3327975ejf.594.2020.09.29.14.52.13; Tue, 29 Sep 2020 14:52:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=eAC3sd7F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729448AbgI2Vsk (ORCPT + 99 others); Tue, 29 Sep 2020 17:48:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728401AbgI2Vsh (ORCPT ); Tue, 29 Sep 2020 17:48:37 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ED6CC0613B1 for ; Tue, 29 Sep 2020 14:47:41 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id k3so6458004ybp.1 for ; Tue, 29 Sep 2020 14:47:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=Dx9e+jODClwF/iJJnqk8YtFURfMacOCvss9V22Z0Fc8=; b=eAC3sd7FrybIqBNLqwYFttqKxR61Obt0chM7GPqJ2OxngMW62bPdYhZA03LkxasyLY B3iIEkAaae/i6FcyaXra7MzsSeTktk9SwvMjM5fm2HSdLmalbA1n/A2LnoW2enoNz2xH Pa+KaLqo0+4ezjXKZ3nIXcw8vdNmqiqgTTdM1O4aI1LZoCE0afJrbw/Lg6fCj7Knl79R dCZ2OQwKJA3VuP7P5zfT+/aSxe8doPfdOU5zwJ44DkhelW0fuXKUxoxboiSN5Vgcgh8/ 1UpdKZV3POTPW1YqyNWdduZmHvQs7b6iJJF0ZHtHSgHddEocODQ/IaHpeomSTeSTfXWd 9F7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Dx9e+jODClwF/iJJnqk8YtFURfMacOCvss9V22Z0Fc8=; b=EAmmLQFgOuaW97DC1TusjbE3hYB9PPACji5Mk0W4kB3TlqVREDpH2iwbsgoMXYdYOT VBu9HML+I6gGnqsqVAN59woOt4hWRchGIx9l0EzGLNP0qDkVoTujXo3WAhsKGXnVKtb5 L5IH31ibWY2X3eGPN3s/oU3J0DD/jEdvmIjiIA779cUgihXLwG60nbAPNQsedEItW+9l 4jk3BcAcOd/Uxnaueg1wu0nw3px8zfUanZKWPP+0i7Ufd9EiQbrNoFtCPEMx2ZmtUKxR dI/zlSG7edfwgD9DP7b312HQzRNPaDIJt6Ubqzs4GrD6GXkcgCy3neuiVY8MY5+IHsxM G60w== X-Gm-Message-State: AOAM530q+9bJUJbL5IGOPF6YN7S+8b0Y6gdT/jmvF3q12+l5jwzNcTAU 3dyEgIBrMOZJCf3qQ9TyBVv7x5onahnbeK0kImU= Sender: "samitolvanen via sendgmr" X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) (user=samitolvanen job=sendgmr) by 2002:a25:bfcf:: with SMTP id q15mr8695443ybm.133.1601416060255; Tue, 29 Sep 2020 14:47:40 -0700 (PDT) Date: Tue, 29 Sep 2020 14:46:31 -0700 In-Reply-To: <20200929214631.3516445-1-samitolvanen@google.com> Message-Id: <20200929214631.3516445-30-samitolvanen@google.com> Mime-Version: 1.0 References: <20200929214631.3516445-1-samitolvanen@google.com> X-Mailer: git-send-email 2.28.0.709.gb0816b6eb0-goog Subject: [PATCH v4 29/29] x86, build: allow LTO_CLANG and THINLTO to be selected From: Sami Tolvanen To: Masahiro Yamada , Will Deacon , Steven Rostedt Cc: Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, x86@kernel.org, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pass code model and stack alignment to the linker as these are not stored in LLVM bitcode, and allow both CONFIG_LTO_CLANG and CONFIG_THINLTO to be selected. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- arch/x86/Kconfig | 2 ++ arch/x86/Makefile | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 6de2e5c0bdba..0a49008c2363 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -92,6 +92,8 @@ config X86 select ARCH_SUPPORTS_ACPI select ARCH_SUPPORTS_ATOMIC_RMW select ARCH_SUPPORTS_NUMA_BALANCING if X86_64 + select ARCH_SUPPORTS_LTO_CLANG if X86_64 + select ARCH_SUPPORTS_THINLTO if X86_64 select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_QUEUED_RWLOCKS select ARCH_USE_QUEUED_SPINLOCKS diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 4346ffb2e39f..49e3b8674eb5 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -173,6 +173,11 @@ ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1) KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,) endif +ifdef CONFIG_LTO_CLANG +KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel \ + -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8) +endif + # Workaround for a gcc prelease that unfortunately was shipped in a suse release KBUILD_CFLAGS += -Wno-sign-compare # -- 2.28.0.709.gb0816b6eb0-goog