[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKv+Gu9tejixb3Kb3YM_7sLcpKNuRHN+Dn+twFyCAXx99wYRCw@mail.gmail.com>
Date: Wed, 3 Sep 2014 21:57:59 +0200
From: Ard Biesheuvel <ard.biesheuvel@...aro.org>
To: Matt Fleming <matt@...sole-pimps.org>
Cc: Maarten Lankhorst <maarten.lankhorst@...onical.com>,
Ulf Winkelvos <ulf@...kelvos.de>,
Matt Fleming <matt.fleming@...el.com>,
LKML <linux-kernel@...r.kernel.org>,
"x86@...nel.org" <x86@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>,
"linux-efi@...r.kernel.org" <linux-efi@...r.kernel.org>,
Seth Forshee <seth.forshee@...onical.com>,
Matthew Garrett <mjg59@...f.ucam.org>
Subject: Re: [REGRESSION] "efi: efistub: Convert into static library" and
preparation patches
On 3 September 2014 19:59, Matt Fleming <matt@...sole-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.
--
Ard.
> ---
>
> diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
> index 2884e0c3e8a5..7618857fcc60 100644
> --- a/arch/x86/boot/compressed/head_64.S
> +++ b/arch/x86/boot/compressed/head_64.S
> @@ -32,6 +32,21 @@
> #include <asm/processor-flags.h>
> #include <asm/asm-offsets.h>
>
> +/*
> + * Adjust our own GOT
> + */
> +.macro FIXUP_GOT
> + leaq _got(%rip), %rdx
> + leaq _egot(%rip), %rcx
> +1:
> + cmpq %rcx, %rdx
> + jae 2f
> + addq %rbx, (%rdx)
> + addq $8, %rdx
> + jmp 1b
> +2:
> +.endm
> +
> __HEAD
> .code32
> ENTRY(startup_32)
> @@ -256,6 +271,8 @@ ENTRY(efi_pe_entry)
> */
> addq %rbp, efi64_config+88(%rip)
>
> + FIXUP_GOT
> +
> movq %rax, %rdi
> call make_boot_params
> cmpq $0,%rax
> @@ -275,6 +292,7 @@ handover_entry:
> */
> movq efi_config(%rip), %rax
> addq %rbp, 88(%rax)
> + FIXUP_GOT
> 2:
> movq efi_config(%rip), %rdi
> call efi_main
> @@ -385,19 +403,8 @@ relocated:
> shrq $3, %rcx
> rep stosq
>
> -/*
> - * Adjust our own GOT
> - */
> - leaq _got(%rip), %rdx
> - leaq _egot(%rip), %rcx
> -1:
> - cmpq %rcx, %rdx
> - jae 2f
> - addq %rbx, (%rdx)
> - addq $8, %rdx
> - jmp 1b
> -2:
> -
> + FIXUP_GOT
> +
> /*
> * Do the decompression, and jump to the new kernel..
> */
>
> --
> Matt Fleming, Intel Open Source Technology Center
View attachment "0001-x86-eliminate-x86_64-GOT-relocations-in-early-boot-c.patch" of type "text/x-patch" (2007 bytes)
Powered by blists - more mailing lists