Re: [REGRESSION] "efi: efistub: Convert into static library" and preparation patches

From: Matt Fleming
Date: Wed Sep 03 2014 - 13:59:57 EST


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.

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.

---

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/