linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: Arvind Sankar <nivedita@alum.mit.edu>
Cc: linux-efi <linux-efi@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	X86 ML <x86@kernel.org>, Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/5] efi/x86: Remove __efistub_global annotation
Date: Thu, 16 Apr 2020 09:51:30 +0200	[thread overview]
Message-ID: <CAMj1kXFMgrj8POtc0UQ6D-dbDKU+RmuHjUH-bAkMBAqjL_p+mg@mail.gmail.com> (raw)
In-Reply-To: <20200415221520.2692512-4-nivedita@alum.mit.edu>

On Thu, 16 Apr 2020 at 00:15, Arvind Sankar <nivedita@alum.mit.edu> wrote:
>
> Instead of using __efistub_global to force variables into the .data
> section, leave them in the .bss but pull the EFI stub's .bss section
> into .data in the linker script for the compressed kernel.
>
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>

With the R_386_32/R_X86_64_64 check folded in:

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>

> ---
>  arch/x86/boot/compressed/vmlinux.lds.S |  1 +
>  drivers/firmware/efi/libstub/Makefile  | 12 ++++++++++--
>  drivers/firmware/efi/libstub/efistub.h |  4 ----
>  3 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S
> index 508cfa6828c5..0dc5c2b9614b 100644
> --- a/arch/x86/boot/compressed/vmlinux.lds.S
> +++ b/arch/x86/boot/compressed/vmlinux.lds.S
> @@ -52,6 +52,7 @@ SECTIONS
>                 _data = . ;
>                 *(.data)
>                 *(.data.*)
> +               *(.bss.efistub)
>                 _edata = . ;
>         }
>         . = ALIGN(L1_CACHE_BYTES);
> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
> index e5e76677f2da..0bb2916eb12b 100644
> --- a/drivers/firmware/efi/libstub/Makefile
> +++ b/drivers/firmware/efi/libstub/Makefile
> @@ -73,8 +73,8 @@ CFLAGS_arm64-stub.o           := -DTEXT_OFFSET=$(TEXT_OFFSET)
>  # a verification pass to see if any absolute relocations exist in any of the
>  # object files.
>  #
> -extra-$(CONFIG_EFI_ARMSTUB)    := $(lib-y)
> -lib-$(CONFIG_EFI_ARMSTUB)      := $(patsubst %.o,%.stub.o,$(lib-y))
> +extra-y        := $(lib-y)
> +lib-y  := $(patsubst %.o,%.stub.o,$(lib-y))
>
>  STUBCOPY_FLAGS-$(CONFIG_ARM64) += --prefix-alloc-sections=.init \
>                                    --prefix-symbols=__efistub_
> @@ -89,6 +89,14 @@ STUBCOPY_FLAGS-$(CONFIG_ARM) += --rename-section .data=.data.efistub \
>                                    --rename-section .bss=.bss.efistub,load,alloc
>  STUBCOPY_RELOC-$(CONFIG_ARM)   := R_ARM_ABS
>
> +#
> +# For x86, bootloaders like systemd-boot or grub-efi do not zero-initialize the
> +# .bss section, so the .bss section of the EFI stub needs to be included in the
> +# .data section of the compressed kernel to ensure initialization. Rename the
> +# .bss section here so it's easy to pick out in the linker script.
> +#
> +STUBCOPY_FLAGS-$(CONFIG_X86)   += --rename-section .bss=.bss.efistub,load,alloc
> +
>  $(obj)/%.stub.o: $(obj)/%.o FORCE
>         $(call if_changed,stubcopy)
>
> diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
> index a92d42ffd9f7..49651e20bb9f 100644
> --- a/drivers/firmware/efi/libstub/efistub.h
> +++ b/drivers/firmware/efi/libstub/efistub.h
> @@ -25,11 +25,7 @@
>  #define EFI_ALLOC_ALIGN                EFI_PAGE_SIZE
>  #endif
>
> -#if defined(CONFIG_X86)
> -#define __efistub_global       __section(.data)
> -#else
>  #define __efistub_global
> -#endif
>
>  extern bool __pure nochunk(void);
>  extern bool __pure nokaslr(void);
> --
> 2.24.1
>

  reply	other threads:[~2020-04-16  7:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15 22:15 [PATCH 0/5] efi: Remove __efistub_global annotation Arvind Sankar
2020-04-15 22:15 ` [PATCH 1/5] efi/arm: " Arvind Sankar
2020-04-16  7:50   ` Ard Biesheuvel
2020-04-15 22:15 ` [PATCH 2/5] efi/libstub: Factor out relocation checking Arvind Sankar
2020-04-15 22:15 ` [PATCH 3/5] efi/x86: Remove __efistub_global annotation Arvind Sankar
2020-04-16  7:51   ` Ard Biesheuvel [this message]
2020-04-15 22:15 ` [PATCH 4/5] efi: Kill __efistub_global Arvind Sankar
2020-04-16  7:51   ` Ard Biesheuvel
2020-04-15 22:15 ` [PATCH 5/5] efi/x86: Check for bad relocations Arvind Sankar
2020-04-16  7:38   ` Ard Biesheuvel
2020-04-16 14:48     ` Arvind Sankar
2020-04-16 15:12 ` [PATCH v2 0/3] efi: Remove __efistub_global annotation Arvind Sankar
2020-04-16 16:01   ` Ard Biesheuvel
2020-04-16 15:12 ` [PATCH v2 1/3] efi/arm: " Arvind Sankar
2020-04-16 15:12 ` [PATCH v2 2/3] efi/x86: Remove __efistub_global and add relocation check Arvind Sankar
2020-04-16 15:12 ` [PATCH v2 3/3] efi: Kill __efistub_global Arvind Sankar

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=CAMj1kXFMgrj8POtc0UQ6D-dbDKU+RmuHjUH-bAkMBAqjL_p+mg@mail.gmail.com \
    --to=ardb@kernel.org \
    --cc=bp@alien8.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nivedita@alum.mit.edu \
    --cc=tglx@linutronix.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;
as well as URLs for NNTP newsgroup(s).