Linux-EFI Archive on lore.kernel.org
 help / color / Atom feed
From: Arvind Sankar <nivedita@alum.mit.edu>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com,
	will@kernel.org, mark.rutland@arm.com, linux-efi@vger.kernel.org
Subject: Re: [PATCH 2/2] efi/arm64: increase the PE/COFF alignment so the kernel can run in place
Date: Sat, 28 Mar 2020 10:06:50 -0400
Message-ID: <20200328140648.GA234129@rani.riverdale.lan> (raw)
In-Reply-To: <20200326165905.2240-3-ardb@kernel.org>

On Thu, Mar 26, 2020 at 05:59:05PM +0100, Ard Biesheuvel wrote:
> Update the PE/COFF metadata so that the UEFI image loader will load the
> kernel image at an offset that allows it to execute in place.
> 
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
>  arch/arm64/kernel/efi-header.S | 2 +-
>  arch/arm64/kernel/image-vars.h | 7 +++++++
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/efi-header.S b/arch/arm64/kernel/efi-header.S
> index 914999ccaf8a..f9ee1c2a5fd6 100644
> --- a/arch/arm64/kernel/efi-header.S
> +++ b/arch/arm64/kernel/efi-header.S
> @@ -32,7 +32,7 @@ optional_header:
>  
>  extra_header_fields:
>  	.quad	0					// ImageBase
> -	.long	SZ_4K					// SectionAlignment
> +	.long	PECOFF_SECTION_ALIGNMENT		// SectionAlignment
>  	.long	PECOFF_FILE_ALIGNMENT			// FileAlignment
>  	.short	0					// MajorOperatingSystemVersion
>  	.short	0					// MinorOperatingSystemVersion
> diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h
> index be0a63ffed23..7a7fa3ba7b2f 100644
> --- a/arch/arm64/kernel/image-vars.h
> +++ b/arch/arm64/kernel/image-vars.h
> @@ -15,6 +15,13 @@
>  __efistub_kernel_size		= _edata - _text;
>  __efistub_primary_entry_offset	= primary_entry - _text;
>  
> +#ifndef CONFIG_RELOCATABLE
> +PECOFF_SECTION_ALIGNMENT = SZ_4K;
> +#elif THREAD_ALIGN > SEGMENT_ALIGN
> +PECOFF_SECTION_ALIGNMENT = THREAD_ALIGN;
> +#else
> +PECOFF_SECTION_ALIGNMENT = SEGMENT_ALIGN;
> +#endif
>  
>  /*
>   * The EFI stub has its own symbol namespace prefixed by __efistub_, to
> -- 
> 2.17.1
> 

The section virtual addresses and (possibly) size of image need to be
updated to be a multiple of PECOFF_SECTION_ALIGNMENT, no?

  reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 16:59 [PATCH 0/2] efi/arm64: execute the kernel in place if possible Ard Biesheuvel
2020-03-26 16:59 ` [PATCH 1/2] efi/libstub/arm64: avoid copying the kernel unnecessarily Ard Biesheuvel
2020-03-26 16:59 ` [PATCH 2/2] efi/arm64: increase the PE/COFF alignment so the kernel can run in place Ard Biesheuvel
2020-03-28 14:06   ` Arvind Sankar [this message]
2020-03-28 14:10     ` Ard Biesheuvel
2020-03-27 13:19 ` [PATCH 0/2] efi/arm64: execute the kernel in place if possible Jonathan Cameron
2020-03-27 16:39   ` Ard Biesheuvel

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=20200328140648.GA234129@rani.riverdale.lan \
    --to=nivedita@alum.mit.edu \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=will@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

Linux-EFI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-efi/0 linux-efi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-efi linux-efi/ https://lore.kernel.org/linux-efi \
		linux-efi@vger.kernel.org
	public-inbox-index linux-efi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-efi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git