public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matt Fleming <matt@console-pimps.org>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com>,
	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: Wed, 3 Sep 2014 18:59:48 +0100	[thread overview]
Message-ID: <20140903175948.GH3001@console-pimps.org> (raw)
In-Reply-To: <CAKv+Gu9q1qTh6DZXsCG2tGVBn-uwuQKQa_6FEMmchDVFi5vJtw@mail.gmail.com>

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

  reply	other threads:[~2014-09-03 17:59 UTC|newest]

Thread overview: 29+ 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 19:29 ` Matt Fleming
2014-09-03  6:06   ` Ard Biesheuvel
2014-09-03  8:27     ` Maarten Lankhorst
2014-09-03 12:18       ` Ard Biesheuvel
2014-09-03 15:30         ` Maarten Lankhorst
2014-09-03 15:37           ` Ard Biesheuvel
2014-09-03 17:59             ` Matt Fleming [this message]
2014-09-03 19:57               ` Ard Biesheuvel
2014-09-03 21:28                 ` H. Peter Anvin
2014-09-04 10:48                 ` Maarten Lankhorst
2014-09-04 11:19                   ` Ard Biesheuvel
2014-09-04 11:24                     ` Maarten Lankhorst
2014-09-04 12:54                   ` Michael Brown
2014-09-04 19:12                     ` Ard Biesheuvel
2014-09-04 21:25                       ` Ard Biesheuvel
2014-09-04 21:37                         ` Matt Fleming
2014-09-05 20:27                           ` Matt Fleming
2014-09-08 12:55                             ` Ard Biesheuvel
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-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=20140903175948.GH3001@console-pimps.org \
    --to=matt@console-pimps.org \
    --cc=ard.biesheuvel@linaro.org \
    --cc=hpa@zytor.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@canonical.com \
    --cc=matt.fleming@intel.com \
    --cc=mjg59@srcf.ucam.org \
    --cc=seth.forshee@canonical.com \
    --cc=ulf@winkelvos.de \
    --cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox