diff mbox series

[v2,2/3] x86: check for multiboot{1, 2} header presence

Message ID 20190621163802.29808-3-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show
Series misc improvements | expand

Commit Message

Roger Pau Monne June 21, 2019, 4:38 p.m. UTC
After building the hypervisor binary. Note that the check is performed
by searching for the magic header value at the start of the binary.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Wei Liu <wl@xen.org>
---
Changes since v1:
 - Use an intermediate file to perform the header checks.
---
 xen/arch/x86/Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Andrew Cooper June 21, 2019, 5:20 p.m. UTC | #1
On 21/06/2019 17:38, Roger Pau Monne wrote:
> After building the hypervisor binary. Note that the check is performed
> by searching for the magic header value at the start of the binary.
>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: Wei Liu <wl@xen.org>

While the change is ok, won't this break the gitlab CI which is
currently using the llvm-8 toolchain?

> ---
> Changes since v1:
>  - Use an intermediate file to perform the header checks.
> ---
>  xen/arch/x86/Makefile | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
> index 8a8d8f060f..5c908c49e3 100644
> --- a/xen/arch/x86/Makefile
> +++ b/xen/arch/x86/Makefile
> @@ -100,8 +100,12 @@ syms-warn-dup-y := --warn-dup
>  syms-warn-dup-$(CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS) :=
>  
>  $(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32
> -	./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(TARGET) $(XEN_IMG_OFFSET) \
> +	./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(@D)/.$(@F) $(XEN_IMG_OFFSET) \
>  	               `$(NM) $(TARGET)-syms | sed -ne 's/^\([^ ]*\) . __2M_rwdata_end$$/0x\1/p'`
> +	# Check for multiboot{1,2} headers
> +	od -t x4 -N 8192 $(@D)/.$(@F) | grep 1badb002 > /dev/null
> +	od -t x4 -N 32768 $(@D)/.$(@F) | grep e85250d6 > /dev/null
> +	mv $(@D)/.$(@F) $(TARGET)

This might be a bit cleaner to read as

$(TARGET): tmp=$(@D)/.$(@F)
$(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32

rather than having $(@D)/.$(@F) spread throughout the rule.

~Andrew
Roger Pau Monne June 21, 2019, 5:30 p.m. UTC | #2
On Fri, Jun 21, 2019 at 06:20:54PM +0100, Andrew Cooper wrote:
> On 21/06/2019 17:38, Roger Pau Monne wrote:
> > After building the hypervisor binary. Note that the check is performed
> > by searching for the magic header value at the start of the binary.
> >
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > ---
> > Cc: Jan Beulich <jbeulich@suse.com>
> > Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> > Cc: Wei Liu <wl@xen.org>
> 
> While the change is ok, won't this break the gitlab CI which is
> currently using the llvm-8 toolchain?

Yes, that's right. It's also going to break the FreeBSD Xen build on
osstest (this is not part of the xen- flights however).

ATM the gitlab llvm-8 builds don't seem to correctly pick up the LD
env variable, so they still pass with this change applied.

> > ---
> > Changes since v1:
> >  - Use an intermediate file to perform the header checks.
> > ---
> >  xen/arch/x86/Makefile | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
> > index 8a8d8f060f..5c908c49e3 100644
> > --- a/xen/arch/x86/Makefile
> > +++ b/xen/arch/x86/Makefile
> > @@ -100,8 +100,12 @@ syms-warn-dup-y := --warn-dup
> >  syms-warn-dup-$(CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS) :=
> >  
> >  $(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32
> > -	./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(TARGET) $(XEN_IMG_OFFSET) \
> > +	./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(@D)/.$(@F) $(XEN_IMG_OFFSET) \
> >  	               `$(NM) $(TARGET)-syms | sed -ne 's/^\([^ ]*\) . __2M_rwdata_end$$/0x\1/p'`
> > +	# Check for multiboot{1,2} headers
> > +	od -t x4 -N 8192 $(@D)/.$(@F) | grep 1badb002 > /dev/null
> > +	od -t x4 -N 32768 $(@D)/.$(@F) | grep e85250d6 > /dev/null
> > +	mv $(@D)/.$(@F) $(TARGET)
> 
> This might be a bit cleaner to read as
> 
> $(TARGET): tmp=$(@D)/.$(@F)
> $(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32
> 
> rather than having $(@D)/.$(@F) spread throughout the rule.

Ack, Thanks!
diff mbox series

Patch

diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 8a8d8f060f..5c908c49e3 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -100,8 +100,12 @@  syms-warn-dup-y := --warn-dup
 syms-warn-dup-$(CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS) :=
 
 $(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32
-	./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(TARGET) $(XEN_IMG_OFFSET) \
+	./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(@D)/.$(@F) $(XEN_IMG_OFFSET) \
 	               `$(NM) $(TARGET)-syms | sed -ne 's/^\([^ ]*\) . __2M_rwdata_end$$/0x\1/p'`
+	# Check for multiboot{1,2} headers
+	od -t x4 -N 8192 $(@D)/.$(@F) | grep 1badb002 > /dev/null
+	od -t x4 -N 32768 $(@D)/.$(@F) | grep e85250d6 > /dev/null
+	mv $(@D)/.$(@F) $(TARGET)
 
 ALL_OBJS := $(BASEDIR)/arch/x86/boot/built_in.o $(BASEDIR)/arch/x86/efi/built_in.o $(ALL_OBJS)