From: Maarten Lankhorst <maarten.lankhorst-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
To: Ard Biesheuvel
<ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Matt Fleming
<matt-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
Cc: Ulf Winkelvos <ulf-rS3t9PEbhQ0OIzVOb1FTxg@public.gmane.org>,
Matt Fleming
<matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org"
<x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>,
"linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Seth Forshee
<seth.forshee-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>,
Matthew Garrett <mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org>
Subject: Re: [REGRESSION] "efi: efistub: Convert into static library" and preparation patches
Date: Thu, 04 Sep 2014 12:48:22 +0200 [thread overview]
Message-ID: <54084376.8090002@canonical.com> (raw)
In-Reply-To: <CAKv+Gu9tejixb3Kb3YM_7sLcpKNuRHN+Dn+twFyCAXx99wYRCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Op 03-09-14 om 21:57 schreef Ard Biesheuvel:
> On 3 September 2014 19:59, Matt Fleming <matt-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org> 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.
>
FWIW, visibility pushing doesn't seem to work for functions declared with extern.
Following seems to get rid of all GOTPCREL:
---
diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
index bd49ec61255c..221da1e53d87 100644
--- a/arch/x86/boot/boot.h
+++ b/arch/x86/boot/boot.h
@@ -298,8 +298,8 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr);
int validate_cpu(void);
/* early_serial_console.c */
-extern int early_serial_base;
-void console_init(void);
+extern __attribute__((__visibility__("hidden"))) int early_serial_base;
+__attribute__((__visibility__("hidden"))) void console_init(void);
/* edd.c */
void query_edd(void);
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index 24e3e569a13c..23ac047fd23e 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -30,9 +30,10 @@
#endif
/* misc.c */
-extern memptr free_mem_ptr;
-extern memptr free_mem_end_ptr;
-extern struct boot_params *real_mode; /* Pointer to real-mode data */
+extern __attribute__((__visibility__("hidden"))) memptr free_mem_ptr;
+extern __attribute__((__visibility__("hidden"))) memptr free_mem_end_ptr;
+extern __attribute__((__visibility__("hidden"))) struct boot_params *real_mode; /* Pointer to real-mode data */
+
void __putstr(const char *s);
#define error_putstr(__x) __putstr(__x)
@@ -75,7 +76,7 @@ unsigned char *choose_kernel_location(unsigned char *input,
#ifdef CONFIG_EARLY_PRINTK
/* early_serial_console.c */
-extern int early_serial_base;
+__attribute__((__visibility__("hidden"))) int early_serial_base;
void console_init(void);
#else
static const int early_serial_base;
diff --git a/arch/x86/boot/cpuflags.h b/arch/x86/boot/cpuflags.h
index ea97697e51e4..d01fcf94ece6 100644
--- a/arch/x86/boot/cpuflags.h
+++ b/arch/x86/boot/cpuflags.h
@@ -10,8 +10,8 @@ struct cpu_features {
u32 flags[NCAPINTS];
};
-extern struct cpu_features cpu;
-extern u32 cpu_vendor[3];
+__attribute__((visibility("hidden"))) extern struct cpu_features cpu;
+__attribute__((visibility("hidden"))) extern u32 cpu_vendor[3];
int has_eflag(unsigned long mask);
void get_cpuflags(void);
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__);
WARNING: multiple messages have this Message-ID (diff)
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Matt Fleming <matt@console-pimps.org>
Cc: Ulf Winkelvos <ulf@winkelvos.de>,
Matt Fleming <matt.fleming@intel.com>,
LKML <linux-kernel@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
"linux-efi@vger.kernel.org" <linux-efi@vger.kernel.org>,
Seth Forshee <seth.forshee@canonical.com>,
Matthew Garrett <mjg59@srcf.ucam.org>
Subject: Re: [REGRESSION] "efi: efistub: Convert into static library" and preparation patches
Date: Thu, 04 Sep 2014 12:48:22 +0200 [thread overview]
Message-ID: <54084376.8090002@canonical.com> (raw)
In-Reply-To: <CAKv+Gu9tejixb3Kb3YM_7sLcpKNuRHN+Dn+twFyCAXx99wYRCw@mail.gmail.com>
Op 03-09-14 om 21:57 schreef Ard Biesheuvel:
> On 3 September 2014 19:59, Matt Fleming <matt@console-pimps.org> 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.
>
FWIW, visibility pushing doesn't seem to work for functions declared with extern.
Following seems to get rid of all GOTPCREL:
---
diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
index bd49ec61255c..221da1e53d87 100644
--- a/arch/x86/boot/boot.h
+++ b/arch/x86/boot/boot.h
@@ -298,8 +298,8 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr);
int validate_cpu(void);
/* early_serial_console.c */
-extern int early_serial_base;
-void console_init(void);
+extern __attribute__((__visibility__("hidden"))) int early_serial_base;
+__attribute__((__visibility__("hidden"))) void console_init(void);
/* edd.c */
void query_edd(void);
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index 24e3e569a13c..23ac047fd23e 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -30,9 +30,10 @@
#endif
/* misc.c */
-extern memptr free_mem_ptr;
-extern memptr free_mem_end_ptr;
-extern struct boot_params *real_mode; /* Pointer to real-mode data */
+extern __attribute__((__visibility__("hidden"))) memptr free_mem_ptr;
+extern __attribute__((__visibility__("hidden"))) memptr free_mem_end_ptr;
+extern __attribute__((__visibility__("hidden"))) struct boot_params *real_mode; /* Pointer to real-mode data */
+
void __putstr(const char *s);
#define error_putstr(__x) __putstr(__x)
@@ -75,7 +76,7 @@ unsigned char *choose_kernel_location(unsigned char *input,
#ifdef CONFIG_EARLY_PRINTK
/* early_serial_console.c */
-extern int early_serial_base;
+__attribute__((__visibility__("hidden"))) int early_serial_base;
void console_init(void);
#else
static const int early_serial_base;
diff --git a/arch/x86/boot/cpuflags.h b/arch/x86/boot/cpuflags.h
index ea97697e51e4..d01fcf94ece6 100644
--- a/arch/x86/boot/cpuflags.h
+++ b/arch/x86/boot/cpuflags.h
@@ -10,8 +10,8 @@ struct cpu_features {
u32 flags[NCAPINTS];
};
-extern struct cpu_features cpu;
-extern u32 cpu_vendor[3];
+__attribute__((visibility("hidden"))) extern struct cpu_features cpu;
+__attribute__((visibility("hidden"))) extern u32 cpu_vendor[3];
int has_eflag(unsigned long mask);
void get_cpuflags(void);
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__);
next prev parent reply other threads:[~2014-09-04 10:48 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-02 15:25 [REGRESSION] "efi: efistub: Convert into static library" and preparation patches Maarten Lankhorst
2014-09-02 15:25 ` Maarten Lankhorst
2014-09-02 19:29 ` Matt Fleming
2014-09-03 6:06 ` Ard Biesheuvel
[not found] ` <CAKv+Gu_eSe+FeNkGm+w3sSsRn2_hr70xLVBieZgyhawAv6PQvw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-03 8:27 ` Maarten Lankhorst
2014-09-03 8:27 ` Maarten Lankhorst
[not found] ` <5406D0DB.90401-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2014-09-03 12:18 ` Ard Biesheuvel
2014-09-03 12:18 ` Ard Biesheuvel
2014-09-03 15:30 ` Maarten Lankhorst
[not found] ` <54073409.6030004-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2014-09-03 15:37 ` Ard Biesheuvel
2014-09-03 15:37 ` Ard Biesheuvel
[not found] ` <CAKv+Gu9q1qTh6DZXsCG2tGVBn-uwuQKQa_6FEMmchDVFi5vJtw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-03 17:59 ` Matt Fleming
2014-09-03 17:59 ` Matt Fleming
[not found] ` <20140903175948.GH3001-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-09-03 19:57 ` Ard Biesheuvel
2014-09-03 19:57 ` Ard Biesheuvel
[not found] ` <CAKv+Gu9tejixb3Kb3YM_7sLcpKNuRHN+Dn+twFyCAXx99wYRCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-03 21:28 ` H. Peter Anvin
2014-09-03 21:28 ` H. Peter Anvin
2014-09-04 10:48 ` Maarten Lankhorst [this message]
2014-09-04 10:48 ` Maarten Lankhorst
[not found] ` <54084376.8090002-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2014-09-04 11:19 ` Ard Biesheuvel
2014-09-04 11:19 ` Ard Biesheuvel
[not found] ` <BA3DE6F4-93D9-4CDE-90D7-280360929ABD-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-09-04 11:24 ` Maarten Lankhorst
2014-09-04 11:24 ` Maarten Lankhorst
2014-09-04 12:54 ` Michael Brown
2014-09-04 12:54 ` Michael Brown
[not found] ` <540860F1.6060801-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>
2014-09-04 19:12 ` Ard Biesheuvel
2014-09-04 19:12 ` Ard Biesheuvel
2014-09-04 21:25 ` Ard Biesheuvel
[not found] ` <CAKv+Gu_sLmkBHF-9GyPUgfAbLYirQTD4vk63o6HzdZhm6s_e0g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-04 21:37 ` Matt Fleming
2014-09-04 21:37 ` Matt Fleming
[not found] ` <20140904213753.GM3001-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-09-05 20:27 ` Matt Fleming
2014-09-05 20:27 ` Matt Fleming
[not found] ` <20140905202744.GO3001-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-09-08 12:55 ` Ard Biesheuvel
2014-09-08 12:55 ` Ard Biesheuvel
[not found] ` <CAKv+Gu8GOHMa=zVWBG7OdSG2i2Ag_XyEBE5NzU6ffLNP8zA3Ug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-08 13:01 ` Maarten Lankhorst
2014-09-08 13:01 ` Maarten Lankhorst
2014-09-08 13:16 ` Matt Fleming
2014-09-22 18:44 ` Josh Boyer
2014-09-22 21:07 ` Matt Fleming
2014-09-22 21:24 ` Josh Boyer
2014-09-03 21:47 ` H. Peter Anvin
2014-09-03 21:47 ` H. Peter Anvin
[not found] ` <54078C74.2060804-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2014-09-04 6:47 ` Ard Biesheuvel
2014-09-04 6:47 ` Ard Biesheuvel
2014-09-04 7:40 ` Matt Fleming
2014-09-04 7:50 ` Maarten Lankhorst
2014-09-04 7:29 ` Matt Fleming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54084376.8090002@canonical.com \
--to=maarten.lankhorst-z7wlfzj8ewms+fvcfc7uqw@public.gmane.org \
--cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matt-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org \
--cc=matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org \
--cc=seth.forshee-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org \
--cc=ulf-rS3t9PEbhQ0OIzVOb1FTxg@public.gmane.org \
--cc=x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.