Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2500597pxa; Fri, 7 Aug 2020 12:42:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5pBQvH1EDJRz9TjdHIpLXc4kdepOzNfC1XtFcgYwzY2v95biZ74vHngqwOZIb2l1lXda+ X-Received: by 2002:a17:906:3911:: with SMTP id f17mr11473042eje.56.1596829332124; Fri, 07 Aug 2020 12:42:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596829332; cv=none; d=google.com; s=arc-20160816; b=oif/BarLDd0dh12WaluTm5CijCAr45cbZ6u9WLfsT63hgtXNiFZdd4B/UxHl1aAi9R RzLdGkwc9+ARLAIp8/uyU/Pc5aKsND1syB22ONXq252nQVk1RJ0LRMjw4CeAWXkJ/ZC8 bY1OuHUdr0NGRjOGKH1qpYlQbKmUAVLYKLr+7EpM1gYX9ZseNHRjzMEr4+cPleYfM5e5 C3f71GRTeUD70jk8G9N6VMOR/B+8KSwb7Xs5Ot1gpsj2ySVxzgpUGCeajxTgkX5PDLKC nKSuDetJSbRFnd+60Lx+9XTJFIlnWORKnzYPJRFrX/q+O+AmNOa10uRMMhn2fxMI3LEk ET0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=5n0w4AsANVZZcp3jIgW7OYwnXyM3bWVVuSXkfYvbUl4=; b=tStyL/5IYqvdsY8mjOLWJhIH9Ldk/CQQWWC4piE1QIxa+Umk2+/e7J0ZkxsIKzjeo6 d1oS85rmCerNMdUPMMWY9+6XEV07tCixQKib3aOG9x6hBG1dMv0Oi2zN+3kuY/qJqHeZ 63ToaBnvJQ/8Lzh2ucOCW1AkHME70ABDEfATeWBKUyO3Q1FH4ijUkmS5gLPYV1Y84n3R MrXs/2CVhmyQaIUQMlCqtJLTGjMOqAF3nH5HURzv6LZ7cvQAbk1VT3Z5t5JjvUsvzwtd EoXgRE5VwhQ3cUy5JERB2LCrD3OF/D6hDqa2ohuPr8ph7qcLPEY21VcwW0hGtusl8Cc5 yj0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WoKT11jR; 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 dm7si5753405edb.342.2020.08.07.12.41.48; Fri, 07 Aug 2020 12:42:12 -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=WoKT11jR; 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 S1726066AbgHGTlR (ORCPT + 99 others); Fri, 7 Aug 2020 15:41:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725893AbgHGTlQ (ORCPT ); Fri, 7 Aug 2020 15:41:16 -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 89412C061756 for ; Fri, 7 Aug 2020 12:41:16 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id v65so3995811ybv.9 for ; Fri, 07 Aug 2020 12:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=5n0w4AsANVZZcp3jIgW7OYwnXyM3bWVVuSXkfYvbUl4=; b=WoKT11jR5jq/vQb3JNLV25H6iflkXWudcxfP6rTqgMokNc8wuvhdV871BhnFNvsvhq qcUCcS3CyBMPMYSk00SqeMIFCim9HusgHp5n9bI/UVP4PKlenKWo5Ow+d98zN6ESLN1f ptGrXZMrKbm7sc+l+aI760IdJO+JrbC+N6J3qHbTqNd2vv/Erj9AoVGphW45V7pA0bYC ROFWsOCvNbBWZ5KmrSJK005wiXxh4RRVcqE1W6A7RN4OanMO/fF5ZnNW3fUOKEd0ZrPw db/osdd+sp9woxBRA+k9CuwBske9+y1Hbj7J0mB2Le4sNL5evawsrlaGNWRZQtsx6JVp r1BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=5n0w4AsANVZZcp3jIgW7OYwnXyM3bWVVuSXkfYvbUl4=; b=QIdxjkOU6LB+jEGxVdh7tOnY3Rys2OTnpRd5IyjTt+rdUX/bIIpGx+6rjNqnG5F+tR ayZXNa7wNRclvOBwiyvc/jP/MRQld2WjphS5rYeSdfQhIJjW7DxF8evQMF+GZc7YFEaH R9mquFrgUMLJUNlK8GGhJf9X/xzJ7qDbIbxdIQLnXrw/3vTzDMiiZq43KGFM7GEosHSj VrGboh+Qkc3agME/H5Q5YVRzBFZPqC8PTVqey/jpsw0eAgnFyVXaAgq33RuFv7FKcJhs mFF6g1qFnS8y/CsXpizpsgHWcKsfwWivIzkx9CJeb8j2mVuxFFPiazLWIF8fQBJzaFpM 6/Yg== X-Gm-Message-State: AOAM532CZqwqPV0FdSSgw2OGMBf7YfjpXJLz79pb8/kpNGLcMpnP/PV3 pyWKHGwUqD/yhjB2Fsw5JCwQuKJVZh+vaX3BtCw= X-Received: by 2002:a25:d8c3:: with SMTP id p186mr24793342ybg.50.1596829273517; Fri, 07 Aug 2020 12:41:13 -0700 (PDT) Date: Fri, 7 Aug 2020 12:41:00 -0700 Message-Id: <20200807194100.3570838-1-ndesaulniers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog Subject: [PATCH] x86/boot: avoid relaxable symbols with Clang From: Nick Desaulniers To: Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Fangrui Song , clang-built-linux@googlegroups.com, e5ten.arch@gmail.com, Nick Desaulniers , stable@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" , Masahiro Yamada , Ard Biesheuvel , Kees Cook , Arvind Sankar , Dmitry Golovin , Marco Elver , Nick Terrell , Daniel Kiper , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A recent change to a default value of configuration variable (ENABLE_X86_RELAX_RELOCATIONS OFF -> ON) in LLVM now causes Clang's integrated assembler to emit R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX relocations. LLD will relax instructions with these relocations based on whether the image is being linked as position independent or not. When not, then LLD will relax these instructions to use absolute addressing mode (R_RELAX_GOT_PC_NOPIC). This causes kernels built with Clang and linked with LLD to fail to boot. Also, the LLVM commit notes that these relocation types aren't supported until binutils 2.26. Since we support binutils 2.23+, avoid the relocations regardless of linker. The proper solution is to build the compressed boot image as position independent. There's a series working its way through code review currently that does that, but it's unlikely to be backported to stable, due to its size. For now, cut a smaller patch that's more likely to be easily picked up into stable, so that we can get our kernels booting again. Cc: stable@vger.kernel.org # 4.14.y Link: https://github.com/ClangBuiltLinux/linux/issues/1121 Link: https://reviews.llvm.org/rGc41a18cf61790fc898dcda1055c3efbf442c14c0 Link: https://travis-ci.com/github/ClangBuiltLinux/continuous-integration/builds/178868465 Signed-off-by: Nick Desaulniers --- https://lore.kernel.org/lkml/20200731230820.1742553-7-keescook@chromium.org/ is the patch I'm hopeful for building the compressed image as -pie, but I don't think the series will be backported. Regardless, we probably want this for older binutils support. arch/x86/boot/compressed/Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 3962f592633d..ab0f7e7dabf9 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -44,6 +44,13 @@ KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) KBUILD_CFLAGS += -fno-asynchronous-unwind-tables KBUILD_CFLAGS += -D__DISABLE_EXPORTS +# Until we can build arch/x86/boot/compressed/vmlinux as -Wl,-pie, don't emit +# R_X86_64_GOTPCRELX or R_X86_64_REX_GOTPCRELX relocations that LLD will relax +# into absolute addressed operands, and that BFD didn't support until 2.26. +ifdef CONFIG_CC_IS_CLANG +KBUILD_CFLAGS += -Wa,-mrelax-relocations=no +endif + KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ GCOV_PROFILE := n UBSAN_SANITIZE :=n -- 2.28.0.236.gb10cc79966-goog