All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Brown <mbrown-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>
To: Michael Brown <mbrown-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH] efi: Include a .bss section within the PE/COFF headers
Date: Wed, 09 Jul 2014 23:20:40 +0100	[thread overview]
Message-ID: <53BDC038.1090003@fensystems.co.uk> (raw)
In-Reply-To: <1404942094-29447-1-git-send-email-mbrown-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>

On 09/07/14 22:41, Michael Brown wrote:
> The PE/COFF headers currently describe only the initialised-data
> portions of the image, and result in no space being allocated for the
> uninitialised-data portions.  Consequently, the EFI boot stub will end
> up overwriting unexpected areas of memory, with unpredictable results.
>
> Fix by including a .bss section in the PE/COFF headers (functionally
> equivalent to the init_size field in the bzImage header).

Following on from this: hpa mentioned via IRC that we should also take 
alignment into account.  I am unsure if init_size already includes 
padding for alignment; on my sample kernel init_size is >16MB (with 16MB 
alignment), so it looks plausible to me that alignment is already 
accounted for.

If not, then the following trivial patch exposes the desired alignment 
via the PE/COFF headers:

diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index 7a6d43a..16ef025 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -154,7 +154,7 @@ extra_header_fields:
  #else
  	.quad	0				# ImageBase
  #endif
-	.long	0x20				# SectionAlignment
+	.long	CONFIG_PHYSICAL_ALIGN		# SectionAlignment
  	.long	0x20				# FileAlignment
  	.word	0				# MajorOperatingSystemVersion
  	.word	0				# MinorOperatingSystemVersion
-- 
1.8.4.5

Michael

  parent reply	other threads:[~2014-07-09 22:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-09 21:41 [PATCH] efi: Include a .bss section within the PE/COFF headers Michael Brown
     [not found] ` <1404942094-29447-1-git-send-email-mbrown-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>
2014-07-09 22:20   ` Michael Brown [this message]
     [not found]     ` <53BDC038.1090003-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>
2014-07-09 22:41       ` H. Peter Anvin
2014-07-10 10:34   ` Matt Fleming
     [not found]     ` <20140710103431.GE15932-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-07-10 14:48       ` Matt Fleming
     [not found]         ` <20140710144815.GG15932-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-07-11 17:22           ` Thomas Bächler
  -- strict thread matches above, loose matches on Subject: below --
2014-07-28 13:21 Michael Brown
     [not found] ` <1406553713-7479-1-git-send-email-mbrown-OViyBiuKJBuK421+ScFKDQ@public.gmane.org>
2014-07-28 22:54   ` H. Peter Anvin
2014-07-30 13:57   ` Luis Henriques

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=53BDC038.1090003@fensystems.co.uk \
    --to=mbrown-oviybiukjbuk421+scfkdq@public.gmane.org \
    --cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
    --cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.