From patchwork Fri Aug 7 19:41:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 247554 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2751600ilo; Fri, 7 Aug 2020 12:41:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWIjRgHzyT/39JM8K4Xar0XHAD6siXimxJXISLUp0XFEcRHKy3UGF1DH4HnHBUn9GC2f1e X-Received: by 2002:a17:906:ce59:: with SMTP id se25mr11576460ejb.359.1596829281405; Fri, 07 Aug 2020 12:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596829281; cv=none; d=google.com; s=arc-20160816; b=Kp1omPiXGQ/7+nGi+qz0LFbNa9kVPv68ULbIbDIRxNviVWU5Rz227+DdXv3FxC06HP n7DBDb/1LgtPRL4tT+IV4EcIq2OEhl9T8ZUbCzKNujXU3THgwBLSYqgDxJy8HYhNagnA nEYv7aErOP18qUHFTB5hEjGSBlymoRtR7qrjzUYlKCQKEhjFVGCNND1y2cNBTtKrSyyU a6VA1lGZ9uiIi5JeJt8Uu2uz60oqZCrWHL8TjzN5ZATdHH8I9aG0qlFKp1frkdSP9wh6 kDw/7LfpAYh7IpBo9KxpslggTN1otvMZ/WpjTiW3zCeMtYfQYor3gMxJuUeZ7hp98ks9 rJjw== 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=JwBLrsJLpAzwsD2X7wBziR8Tzk7u6ix2sL8+bm7aoRohFXYOl9Fn2YDRSjppuOHk/w JfGDVi+CNaZqM9dx9QTZ0PeD7b+cPoTFUFvz8rnoEeN9D6owZ/djUupGNH4gnmHBwDeS P1C9pYCTM0P0KqNhNLGA9nUlgB9y3JRE8O6jfHQxe9sH9k/J+0AkgqYu+cjr0ePRh2ZC PS3nIjSI5aGsqkofQPGkfJd8mot5yA8g9cIA9B5QwefdCFfJm9tbX7cSxDKruwNBghqo y9iUsxkh29K7XgW2ZNA7ZiXhbcp4VgXC8gtAgCBuKtzVt9vs9tGlywPVNY2XVOCPc9o5 QUyQ== 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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 l21si5878691eje.61.2020.08.07.12.41.21; Fri, 07 Aug 2020 12:41:21 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S1726045AbgHGTlR (ORCPT + 15 others); Fri, 7 Aug 2020 15:41:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725934AbgHGTlQ (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 8F191C061757 for ; Fri, 7 Aug 2020 12:41:16 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id a5so4015958ybh.3 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=jQZ4fPw/Ap9HuGdzAvJHRh+1eQH3NgvXwmlVHGMw3boySzb8CyglsWRt0ZPzroihfb Az8ePihjompwLOgTP093CP2xu2ty5MGfCsTs64g/H3sfvfbX/aLwFtZSbywMkeuaq7D4 e3Z+iTImBo0lwwuRB3v8U8/zm0gtvUYqT0hGoo+KVxxMLkP5Z6hCtLhzVZZxPu8qZe7A oGta5PkWaaSQPrl5huCVrvJttJZjTjC8EzwVl7vBPdaWOXXSuUTqKLwiyVJMA/dTtyly B75cjVvAfU3aVSp9msj3aGK+6j8bHvmmv2Y9GdICj3DyS1kHhVuVBwN/7vXVzm3oq4Pn W+Yg== X-Gm-Message-State: AOAM530R5lg2uVsx7I0Pma0bGeO/7MIw+YLDxRmVt6z8G7tDr3AIt1/V ZJf/blZTJwCni5xGtTFzA/hNp+ww5cGYzLJz2vo= 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 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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(+) -- 2.28.0.236.gb10cc79966-goog Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers Tested-by: Sedat Dilek Acked-by: Ard Biesheuvel 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