From: Ian Campbell Subject: Re: [PATCH RFC 15/19] Add PE/COFF header in head.S Date: Wed, 2 Jul 2014 13:02:23 +0100 Message-ID: <1404302543.5562.38.camel@kazak.uk.xensource.com> References: <1403918735-30027-1-git-send-email-roy.franz@linaro.org> <1403918735-30027-16-git-send-email-roy.franz@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1403918735-30027-16-git-send-email-roy.franz@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Roy Franz Cc: keir@xen.org, tim@xen.org, xen-devel@lists.xen.org, stefano.stabellini@citrix.com, jbeulich@suse.com, linaro-uefi@lists.linaro.org, fu.wei@linaro.org List-Id: xen-devel@lists.xenproject.org On Sat, 2014-06-28 at 02:25 +0100, Roy Franz wrote: > This patch adds a simple PE/COFF header in head.S. PE/COFF linker support > is not available for arm64, so a native build is not possible. Also, this > allows the binary to be both a PE/COFF EFI application, and a normal Image > file bootable like a Linux kernel. The arm and arm64 Linux kernels use the > same methodology to create a single image that is both an EFI application and > a zImage/Image file. This looks good to me. A few minor comments: Some of the whitespace is off (please use space and not hard tabs throughout) I think we could perhaps get rid of CONFIG_EFI_STUB at least at the arm64 subarch level. We don't in general support the same level of configurability in Xen as Linux -- it's mostly just a single configuration for everyone. It'd need to be retain at the arch level to cope with arm32 not doing efi, but removing it here would make things simpler I think? Would it be possible to find sort of link/reference to a spec for the header structs which you are adding and stick them in comments before each one please. > > Signed-off-by: Roy Franz > --- > xen/arch/arm/arm64/head.S | 118 +++++++++++++++++++++++++++++++++++++++++++++- > xen/arch/arm/xen.lds.S | 1 + > 2 files changed, 117 insertions(+), 2 deletions(-) > > diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S > index 2a13527..9b88aeb 100644 > --- a/xen/arch/arm/arm64/head.S > +++ b/xen/arch/arm/arm64/head.S > @@ -84,7 +84,7 @@ > #endif /* !CONFIG_EARLY_PRINTK */ > > /*.aarch64*/ > - > +#define CONFIG_EFI_STUB > /* > * Kernel startup entry point. > * --------------------------- > @@ -100,12 +100,24 @@ > */ > > .global start > +efi_stub_entry: /* Dummy symbol so we can compile before actual stub added */ > start: > +#ifdef CONFIG_EFI_STUB > /* > * DO NOT MODIFY. Image header expected by Linux boot-loaders. > */ > - b real_start /* branch to kernel start, magic */ > +efi_head: > + /* > + * This add instruction has no meaningful effect except that > + * its opcode forms the magic "MZ" signature of a PE/COFF file > + * that is required for UEFI applications. > + */ > + add x13, x18, #0x16 I love this hack ;-) Ian.