2014-11-22 09:51:10

by Chris Clayton

[permalink] [raw]
Subject: [PATCH]: cross-compiling x86_64 kernel on i386 user-space fails

Hi,

Commit e6023367d779060fddc9a52d1f474085b2b36298 broke building an x86_64 kernel in an i386. The change added a call to
objdump but neglected to cater for cross-compiling.

The patch below fixes the problem for me. I see the commit is now in 3.14 and 3.17 -stable, so the patch needs to go
there too.

CC: Junjie Mao <[email protected]>
CC: Kees Cook <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: Ingo Molnar <[email protected]>
Signed-off-by: Chris Clayton <[email protected]>
---
--- linux/arch/x86/boot/compressed/Makefile~ 2014-11-22 08:56:50.359706324 +0000
+++ linux/arch/x86/boot/compressed/Makefile 2014-11-22 09:04:06.615693435 +0000
@@ -76,7 +76,7 @@ suffix-$(CONFIG_KERNEL_XZ) := xz
suffix-$(CONFIG_KERNEL_LZO) := lzo
suffix-$(CONFIG_KERNEL_LZ4) := lz4

-RUN_SIZE = $(shell objdump -h vmlinux | \
+RUN_SIZE = $(shell ${CROSS_COMPILE}objdump -h vmlinux | \
perl $(srctree)/arch/x86/tools/calc_run_size.pl)
quiet_cmd_mkpiggy = MKPIGGY $@
cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )


2014-11-22 11:14:48

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH]: cross-compiling x86_64 kernel on i386 user-space fails

On Sat, Nov 22, 2014 at 09:51:10AM +0000, Chris Clayton wrote:
> Hi,

Yeah, next time make sure you actually CC people :-)

I've added them to CC now.

> Commit e6023367d779060fddc9a52d1f474085b2b36298 broke building an x86_64 kernel in an i386. The change added a call to
> objdump but neglected to cater for cross-compiling.
>
> The patch below fixes the problem for me. I see the commit is now in 3.14 and 3.17 -stable, so the patch needs to go
> there too.

CC: [email protected]

in the commit message should help there.


> CC: Junjie Mao <[email protected]>
> CC: Kees Cook <[email protected]>
> CC: Thomas Gleixner <[email protected]>
> CC: Ingo Molnar <[email protected]>
> Signed-off-by: Chris Clayton <[email protected]>

Acked-by: Borislav Petkov <[email protected]>

> ---
> --- linux/arch/x86/boot/compressed/Makefile~ 2014-11-22 08:56:50.359706324 +0000
> +++ linux/arch/x86/boot/compressed/Makefile 2014-11-22 09:04:06.615693435 +0000
> @@ -76,7 +76,7 @@ suffix-$(CONFIG_KERNEL_XZ) := xz
> suffix-$(CONFIG_KERNEL_LZO) := lzo
> suffix-$(CONFIG_KERNEL_LZ4) := lz4
>
> -RUN_SIZE = $(shell objdump -h vmlinux | \
> +RUN_SIZE = $(shell ${CROSS_COMPILE}objdump -h vmlinux | \
> perl $(srctree)/arch/x86/tools/calc_run_size.pl)
> quiet_cmd_mkpiggy = MKPIGGY $@
> cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2014-11-22 16:00:28

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH]: cross-compiling x86_64 kernel on i386 user-space fails

On Sat, Nov 22, 2014 at 3:14 AM, Borislav Petkov <[email protected]> wrote:
> On Sat, Nov 22, 2014 at 09:51:10AM +0000, Chris Clayton wrote:
>> Hi,
>
> Yeah, next time make sure you actually CC people :-)
>
> I've added them to CC now.
>
>> Commit e6023367d779060fddc9a52d1f474085b2b36298 broke building an x86_64 kernel in an i386. The change added a call to
>> objdump but neglected to cater for cross-compiling.
>>
>> The patch below fixes the problem for me. I see the commit is now in 3.14 and 3.17 -stable, so the patch needs to go
>> there too.

Good catch, thanks!

>
> CC: [email protected]
>
> in the commit message should help there.
>
>
>> CC: Junjie Mao <[email protected]>
>> CC: Kees Cook <[email protected]>
>> CC: Thomas Gleixner <[email protected]>
>> CC: Ingo Molnar <[email protected]>
>> Signed-off-by: Chris Clayton <[email protected]>
>
> Acked-by: Borislav Petkov <[email protected]>

Acked-by: Kees Cook <[email protected]>

-Kees

>
>> ---
>> --- linux/arch/x86/boot/compressed/Makefile~ 2014-11-22 08:56:50.359706324 +0000
>> +++ linux/arch/x86/boot/compressed/Makefile 2014-11-22 09:04:06.615693435 +0000
>> @@ -76,7 +76,7 @@ suffix-$(CONFIG_KERNEL_XZ) := xz
>> suffix-$(CONFIG_KERNEL_LZO) := lzo
>> suffix-$(CONFIG_KERNEL_LZ4) := lz4
>>
>> -RUN_SIZE = $(shell objdump -h vmlinux | \
>> +RUN_SIZE = $(shell ${CROSS_COMPILE}objdump -h vmlinux | \
>> perl $(srctree)/arch/x86/tools/calc_run_size.pl)
>> quiet_cmd_mkpiggy = MKPIGGY $@
>> cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://www.tux.org/lkml/
>>
>
> --
> Regards/Gruss,
> Boris.
>
> Sent from a fat crate under my desk. Formatting is fine.
> --



--
Kees Cook
Chrome OS Security

2014-11-23 19:27:28

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH]: cross-compiling x86_64 kernel on i386 user-space fails

On Sat, 22 Nov 2014, Borislav Petkov wrote:

> On Sat, Nov 22, 2014 at 09:51:10AM +0000, Chris Clayton wrote:
> > Hi,
>
> Yeah, next time make sure you actually CC people :-)
>
> I've added them to CC now.
>
> > Commit e6023367d779060fddc9a52d1f474085b2b36298 broke building an x86_64 kernel in an i386. The change added a call to
> > objdump but neglected to cater for cross-compiling.
> >
> > The patch below fixes the problem for me. I see the commit is now in 3.14 and 3.17 -stable, so the patch needs to go
> > there too.

That's not a specific problem of building x86_64 on i386. The missing
cross compile prefix prevents any cross build of x86.

> CC: [email protected]
>
> in the commit message should help there.
>
>
> > CC: Junjie Mao <[email protected]>
> > CC: Kees Cook <[email protected]>
> > CC: Thomas Gleixner <[email protected]>
> > CC: Ingo Molnar <[email protected]>
> > Signed-off-by: Chris Clayton <[email protected]>
>
> Acked-by: Borislav Petkov <[email protected]>
>
> > ---
> > --- linux/arch/x86/boot/compressed/Makefile~ 2014-11-22 08:56:50.359706324 +0000
> > +++ linux/arch/x86/boot/compressed/Makefile 2014-11-22 09:04:06.615693435 +0000
> > @@ -76,7 +76,7 @@ suffix-$(CONFIG_KERNEL_XZ) := xz
> > suffix-$(CONFIG_KERNEL_LZO) := lzo
> > suffix-$(CONFIG_KERNEL_LZ4) := lz4
> >
> > -RUN_SIZE = $(shell objdump -h vmlinux | \
> > +RUN_SIZE = $(shell ${CROSS_COMPILE}objdump -h vmlinux | \

While that works, this wants to be:

+RUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \

I'll fix it up.

Thanks,

tglx

2014-11-23 19:57:12

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH]: cross-compiling x86_64 kernel on i386 user-space fails

On Sun, Nov 23, 2014 at 08:27:24PM +0100, Thomas Gleixner wrote:
> While that works, this wants to be:
>
> +RUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \

Ah, true:

$ git grep OBJDUMP Makefile
Makefile:363:OBJDUMP = $(CROSS_COMPILE)objdump
Makefile:420:export CPP AR NM STRIP OBJCOPY OBJDUMP
Makefile:1483: $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \

Thanks.

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

Subject: [tip:x86/urgent] x86: Use $(OBJDUMP) instead of plain objdump

Commit-ID: e2e68ae688b0a3766cd75aedf4ed4e39be402009
Gitweb: http://git.kernel.org/tip/e2e68ae688b0a3766cd75aedf4ed4e39be402009
Author: Chris Clayton <[email protected]>
AuthorDate: Sat, 22 Nov 2014 09:51:10 +0000
Committer: Thomas Gleixner <[email protected]>
CommitDate: Sun, 23 Nov 2014 21:21:53 +0100

x86: Use $(OBJDUMP) instead of plain objdump

commit e6023367d779 'x86, kaslr: Prevent .bss from overlaping initrd'
broke the cross compile of x86. It added a objdump invocation, which
invokes the host native objdump and ignores an active cross tool
chain.

Use $(OBJDUMP) instead which takes the CROSS_COMPILE prefix into
account.

[ tglx: Massage changelog and use $(OBJDUMP) ]

Fixes: e6023367d779 'x86, kaslr: Prevent .bss from overlaping initrd'
Signed-off-by: Chris Clayton <[email protected]>
Acked-by: Kees Cook <[email protected]>
Acked-by: Borislav Petkov <[email protected]>
Cc: Junjie Mao <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Thomas Gleixner <[email protected]>
---
arch/x86/boot/compressed/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index be1e07d..45abc36 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -76,7 +76,7 @@ suffix-$(CONFIG_KERNEL_XZ) := xz
suffix-$(CONFIG_KERNEL_LZO) := lzo
suffix-$(CONFIG_KERNEL_LZ4) := lz4

-RUN_SIZE = $(shell objdump -h vmlinux | \
+RUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \
perl $(srctree)/arch/x86/tools/calc_run_size.pl)
quiet_cmd_mkpiggy = MKPIGGY $@
cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )

2014-12-01 20:48:16

by Chris Clayton

[permalink] [raw]
Subject: Re: [tip:x86/urgent] x86: Use $(OBJDUMP) instead of plain objdump

Hi,

Is it planned to get this fix through in time for release of 3.18? It appears to have been in -next for a week.

Chris

On 11/23/14 20:24, tip-bot for Chris Clayton wrote:
> Commit-ID: e2e68ae688b0a3766cd75aedf4ed4e39be402009
> Gitweb: http://git.kernel.org/tip/e2e68ae688b0a3766cd75aedf4ed4e39be402009
> Author: Chris Clayton <[email protected]>
> AuthorDate: Sat, 22 Nov 2014 09:51:10 +0000
> Committer: Thomas Gleixner <[email protected]>
> CommitDate: Sun, 23 Nov 2014 21:21:53 +0100
>
> x86: Use $(OBJDUMP) instead of plain objdump
>
> commit e6023367d779 'x86, kaslr: Prevent .bss from overlaping initrd'
> broke the cross compile of x86. It added a objdump invocation, which
> invokes the host native objdump and ignores an active cross tool
> chain.
>
> Use $(OBJDUMP) instead which takes the CROSS_COMPILE prefix into
> account.
>
> [ tglx: Massage changelog and use $(OBJDUMP) ]
>
> Fixes: e6023367d779 'x86, kaslr: Prevent .bss from overlaping initrd'
> Signed-off-by: Chris Clayton <[email protected]>
> Acked-by: Kees Cook <[email protected]>
> Acked-by: Borislav Petkov <[email protected]>
> Cc: Junjie Mao <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: H. Peter Anvin <[email protected]>
> Cc: [email protected]
> Link: http://lkml.kernel.org/r/[email protected]
> Signed-off-by: Thomas Gleixner <[email protected]>
> ---
> arch/x86/boot/compressed/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
> index be1e07d..45abc36 100644
> --- a/arch/x86/boot/compressed/Makefile
> +++ b/arch/x86/boot/compressed/Makefile
> @@ -76,7 +76,7 @@ suffix-$(CONFIG_KERNEL_XZ) := xz
> suffix-$(CONFIG_KERNEL_LZO) := lzo
> suffix-$(CONFIG_KERNEL_LZ4) := lz4
>
> -RUN_SIZE = $(shell objdump -h vmlinux | \
> +RUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \
> perl $(srctree)/arch/x86/tools/calc_run_size.pl)
> quiet_cmd_mkpiggy = MKPIGGY $@
> cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )
>

2014-12-01 21:14:11

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [tip:x86/urgent] x86: Use $(OBJDUMP) instead of plain objdump

On Mon, 1 Dec 2014, Chris Clayton wrote:
> Is it planned to get this fix through in time for release of 3.18?
> It appears to have been in -next for a week.

Yes. I missed it for rc7, but its scheduled for 3.18 final.

Thanks,

tglx