From patchwork Wed Sep 3 19:57:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 36637 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E8E0B2039B for ; Wed, 3 Sep 2014 19:58:55 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id x3sf28030258qcv.10 for ; Wed, 03 Sep 2014 12:58:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:cc:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=EpHJuLsyb6esoFzoN2LhT1mGjwFIxRA2/XfV+s0yyyU=; b=hX6BY1mUkPfSbf5cfhgCXAZHAEa87zqTc/6JmDBApQzGxCXyKEtK/j11elaJoLqm9N NHydfhE7F1lE1OvjB3+LAIwbD0YFd3y15qYE1csYfgaJMie0507zzn9OaaLsb0OSUHWe Xy1TPcA9ZFhgO5QE+INznQ9Bx14r3QvPshWufppx6SJ9pT7pKdTwfv3+7gLFPQ63k83s uYQDlU+wBgqUjb2CCaRgYDFhd0q6KdLGy+OdwcsByoxuzXhALuPFKemrKpGn59u1TTW2 vGWlJhsZ/UbQRSB7WM1TEYZjqeqvfTJgIADiMQf9e3sPSnQ+9D/MnFcMIF+Ql/nLZ36/ O8JA== X-Gm-Message-State: ALoCoQmNlMTcdu9hjaeTgWWIlGMQuZxSjjuzFvCQo35yyDWbQHC0Pm4l+83jhkCTOBlMcC4Q5Jbf X-Received: by 10.236.17.234 with SMTP id j70mr24200622yhj.26.1409774335811; Wed, 03 Sep 2014 12:58:55 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.48 with SMTP id m45ls3012811qgd.18.gmail; Wed, 03 Sep 2014 12:58:55 -0700 (PDT) X-Received: by 10.220.79.68 with SMTP id o4mr3255592vck.38.1409774335678; Wed, 03 Sep 2014 12:58:55 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id uv6si4325148vcb.3.2014.09.03.12.58.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Sep 2014 12:58:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id hy4so9455476vcb.19 for ; Wed, 03 Sep 2014 12:58:55 -0700 (PDT) X-Received: by 10.221.64.142 with SMTP id xi14mr8364952vcb.31.1409774335545; Wed, 03 Sep 2014 12:58:55 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp731236vcb; Wed, 3 Sep 2014 12:58:54 -0700 (PDT) X-Received: by 10.50.114.101 with SMTP id jf5mr1272901igb.38.1409774333740; Wed, 03 Sep 2014 12:58:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nj5si13252892pbc.1.2014.09.03.12.58.51 for ; Wed, 03 Sep 2014 12:58:51 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756196AbaICT6G (ORCPT + 26 others); Wed, 3 Sep 2014 15:58:06 -0400 Received: from mail-la0-f45.google.com ([209.85.215.45]:59745 "EHLO mail-la0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755194AbaICT6C (ORCPT ); Wed, 3 Sep 2014 15:58:02 -0400 Received: by mail-la0-f45.google.com with SMTP id pn19so10509379lab.32 for ; Wed, 03 Sep 2014 12:58:00 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.136.230 with SMTP id qd6mr5013717lbb.90.1409774279891; Wed, 03 Sep 2014 12:57:59 -0700 (PDT) Received: by 10.112.247.70 with HTTP; Wed, 3 Sep 2014 12:57:59 -0700 (PDT) In-Reply-To: <20140903175948.GH3001@console-pimps.org> References: <5405E186.2080406@canonical.com> <20140902192941.GB3001@console-pimps.org> <5406D0DB.90401@canonical.com> <54073409.6030004@canonical.com> <20140903175948.GH3001@console-pimps.org> Date: Wed, 3 Sep 2014 21:57:59 +0200 Message-ID: Subject: Re: [REGRESSION] "efi: efistub: Convert into static library" and preparation patches From: Ard Biesheuvel To: Matt Fleming Cc: Maarten Lankhorst , Ulf Winkelvos , Matt Fleming , LKML , "x86@kernel.org" , "H. Peter Anvin" , "linux-efi@vger.kernel.org" , Seth Forshee , Matthew Garrett Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On 3 September 2014 19:59, Matt Fleming wrote: > On Wed, 03 Sep, at 05:37:26PM, Ard Biesheuvel wrote: >> >> Will do, thanks. >> >> @Matt: so there is two ways to fix this, the patch above addressing >> this single instance, and alternatively, adding a #pragma GCC >> visiblilty push(hidden) to all .c files under libstub/, *before* the >> #includes. The latter would catch future problems regarding newly >> introduced global variables, but it may be a bit overkill in this >> case, as libstub is not expected to be in flux in the foreseeable >> future. >> >> Any preferences? > > Any reason we can't reuse the existing GOT fixup code in the early x86 > boot code? We're not executing it before the EFI boot stub atm, which is > the reason Maarten is hitting these difficulties. > I guess that is likely to work, I just wasn't aware it existed :-) I think adding another visibility(hidden) attribute or 2 would complete eliminate the need for GOT fixups, but I guess that is more sensitive to compiler versions being recent enough etc. The attached (build tested only) patch eliminates all GOT relocations under boot/compressed for a 64-bit EFI stub build. > Maarten, does the following help? > > If not, Ard please go ahead with option #2 above. Overkill yes, but I've > done the single __attribute__() hacks in other projects and someone > (usually me) always eventually forgets to tag some instance. > It appears we just got lucky on arm64, since we don't have any global variables, but the issue does exist there as well. >From ad1503c3c770180c3540e9c82a58f84e21bdb868 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Wed, 3 Sep 2014 21:48:41 +0200 Subject: [PATCH] x86: eliminate x86_64 GOT relocations in early boot code Signed-off-by: Ard Biesheuvel --- arch/x86/boot/boot.h | 4 ++++ arch/x86/boot/compressed/misc.h | 5 +++++ arch/x86/include/asm/efi.h | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h index bd49ec61255c..18a0010efc20 100644 --- a/arch/x86/boot/boot.h +++ b/arch/x86/boot/boot.h @@ -297,10 +297,14 @@ static inline int cmdline_find_option_bool(const char *option) int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr); int validate_cpu(void); +#pragma GCC visibility push(hidden) + /* early_serial_console.c */ extern int early_serial_base; void console_init(void); +#pragma GCC visibility pop + /* edd.c */ void query_edd(void); diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h index 24e3e569a13c..a0fd51f90add 100644 --- a/arch/x86/boot/compressed/misc.h +++ b/arch/x86/boot/compressed/misc.h @@ -29,10 +29,15 @@ #define memptr unsigned #endif +#pragma GCC visibility push(hidden) + /* misc.c */ extern memptr free_mem_ptr; extern memptr free_mem_end_ptr; extern struct boot_params *real_mode; /* Pointer to real-mode data */ + +#pragma GCC visibility pop + void __putstr(const char *s); #define error_putstr(__x) __putstr(__x) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 044a2fd3c5fe..8725d85f1903 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -178,7 +178,7 @@ struct efi_config { bool is64; } __packed; -extern struct efi_config *efi_early; +extern __attribute__((visibility("hidden"))) struct efi_config *efi_early; #define efi_call_early(f, ...) \ efi_early->call(efi_early->f, __VA_ARGS__); -- 1.8.3.2