From patchwork Fri Aug 18 19:49:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 110443 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1345869qge; Fri, 18 Aug 2017 12:52:41 -0700 (PDT) X-Received: by 10.99.103.6 with SMTP id b6mr9589066pgc.336.1503085961085; Fri, 18 Aug 2017 12:52:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503085961; cv=none; d=google.com; s=arc-20160816; b=Y/+5n73HZAWPDDtbJ9DTEiVrlVaCDgKle7yYIeZ72uw3IMhcogH9J02h6b8rPgtwM2 qQEMU8t3Jo1c8X4ZsrJEH7+WBO7WYKuqYBkMe9Alqw4jbk6T8l0jM9ygC6hbyqqIr+aP l51ZrJI6zlaw3JxbJf/K4jLcSnLRQ4GEoTqYhWmupesrR2SoiP4LyELEKfjq5acdZl5/ KhtRS2fuibrAXf7jkrCGKNj+GDCuGVXZbJEbnl1vbLSmBkXIg3733DYMTVlcek+l9h2+ BVJUmSi+Jv3DBGzx3ZYOsYdF0SgDSpFfFjAhQZJJchetlFHTh+0LOzfbjRz14A3TH2/+ BNIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=IHfiWsmSwmFrWaFFXqnCLzNgZCfFqTgAp2MvSCL0oV0=; b=n66ncmImDt6wVlAgMMQWKpqEX2yU/JVCLaHVVU56+OfJZj19OfaLkng5DVcNvxpkPB moF6e6aXLyH6+N6e1AsR8hzaFFKv63wfQCZ9k75UsTH2mbcWnE444xm3CB10dbU8//uk TvhJVq1BTO3RChz7kg1CacPl/XkBiXvL7N9KExLyjwPo6KuAo16wmtjXeD+fdt3WsteR u/2T17jZnQOs4ShIKWDjfxSVmczG6B0Qo84fp3CLWd9PQLoa3sF8DR0PpcMRnlqKM5h9 n7iEC/PbvXsnuR8h3n+uLr3F7AGjLvN72Qb1iyMzX6eJonXdDqx5EZ81UHOtMDNZyZzd Ly9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=itzu5IgD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v67si2667031pfd.551.2017.08.18.12.52.40; Fri, 18 Aug 2017 12:52:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=itzu5IgD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752376AbdHRTuP (ORCPT + 26 others); Fri, 18 Aug 2017 15:50:15 -0400 Received: from mail-wr0-f169.google.com ([209.85.128.169]:33981 "EHLO mail-wr0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752250AbdHRTuK (ORCPT ); Fri, 18 Aug 2017 15:50:10 -0400 Received: by mail-wr0-f169.google.com with SMTP id y96so70961332wrc.1 for ; Fri, 18 Aug 2017 12:50:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IHfiWsmSwmFrWaFFXqnCLzNgZCfFqTgAp2MvSCL0oV0=; b=itzu5IgDoRF31onOcEU+VtZAs7HgZZOgrL2piJYP6oI3clG62a3cSmzSyioB8X3VqJ XvV+UQhZhiiuC7dQCsVplPoa5ReGN/+2mYQsvdlEA8aKqs/fJgjFj6PlpdFPZVJgur3z G6Gm18P7Qfq/7cKzEuKvuc9pWXpKmXmMmKsy8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IHfiWsmSwmFrWaFFXqnCLzNgZCfFqTgAp2MvSCL0oV0=; b=GsDhGQxSyg6YU3Gn7LxxnpjZ1yxngl9+VkbifnO30pSNaTNvWaTFwKkxg+USWzE21/ Nvrt6XYiZLiMRek0+9zGi/0/qPoWAINb8jZZma4g6/7S5Oae8KtJxOrLHhxWBHdTyGhN pbQ6+iZE53mia9geKEaxsMTsfjKpDaygp5l7kUaPFKu0wc7fjBLMaZXRUMcKyxAnquQW BTOIx+GNnbEQz05dYcc+H3HTtgW3IWokr2XPNSfwHhiDqkrssfqzUmL3+lzPNc66sc8b 0TOl8OmJbW2jyp1J7yGPlRlfSUnHQyC5Jj4K2tNhFdF57Xw1kOxMwRvjeOs8QD5QN701 TihQ== X-Gm-Message-State: AHYfb5hVrC3jVxM4SwklECMTEIjHDnOpMmxXvi4GJ7SPrcyZ9ryznj41 IinHczYG6+wpvgEE X-Received: by 10.223.146.195 with SMTP id 61mr6731954wrn.169.1503085809145; Fri, 18 Aug 2017 12:50:09 -0700 (PDT) Received: from localhost.localdomain ([154.146.161.128]) by smtp.gmail.com with ESMTPSA id k29sm5571168wrk.56.2017.08.18.12.50.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Aug 2017 12:50:08 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Matt Fleming Subject: [PATCH 04/14] efi/libstub: arm64: set -fpie when building the EFI stub Date: Fri, 18 Aug 2017 20:49:37 +0100 Message-Id: <20170818194947.19347-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170818194947.19347-1-ard.biesheuvel@linaro.org> References: <20170818194947.19347-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clang may emit absolute symbol references when building in non-PIC mode, even when using the default 'small' code model, which is already mostly position independent to begin with, due to its use of adrp/add pairs that have a relative range of +/- 4 GB. The remedy is to pass the -fpie flag, which can be done safely now that the code has been updated to avoid GOT indirections (which may be emitted due to the compiler assuming that the PIC/PIE code may end up in a shared library that is subject to ELF symbol preemption) Passing -fpie when building code that needs to execute at an a priori unknown offset is arguably an improvement in any case, and given that the recent visibility changes allow the PIC build to pass with GCC as well, let's add -fpie for all arm64 builds rather than only for Clang. Cc: Matt Fleming Tested-by: Matthias Kaehlcke Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index 37e24f525162..cf81e6cf5ae8 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -10,7 +10,7 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -O2 \ -fPIC -fno-strict-aliasing -mno-red-zone \ -mno-mmx -mno-sse -cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS)) +cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS)) -fpie cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \ -fno-builtin -fpic -mno-single-pic-base