* [BUG] Kernel built for i586 chip crashes instantly at boot time (CMOV instructions)
@ 2009-12-18 15:28 Chris Rankin
2009-12-18 17:12 ` H. Peter Anvin
2009-12-26 0:48 ` [tip:x86/urgent] x86, compress: Force i386 instructions for the decompressor tip-bot for H. Peter Anvin
0 siblings, 2 replies; 4+ messages in thread
From: Chris Rankin @ 2009-12-18 15:28 UTC (permalink / raw)
To: linux-kernel; +Cc: hpa
Hi,
I have been trying to build a 2.6.31.x kernel with Fedora 12's gcc compiler, and have discovered that this kernel crashes instantly at boot-time due to a pair of CMOV instructions in arch/x86/boot/compressed/misc.o. According to "make V=1", the command used to compile misc.c is:
gcc -Wp,-MD,arch/x86/boot/compressed/.misc.o.d -nostdinc -isystem /usr/lib/gcc/i686-redhat-linux/4.4.2/include -Iinclude -Iinclude2 -I/home/chris/LINUX/linux-2.6.31/include -I/home/chris/LINUX/linux-2.6.31/arch/x86/include -include include/linux/autoconf.h -I/home/chris/LINUX/linux-2.6.31/arch/x86/boot/compressed -Iarch/x86/boot/compressed -D__KERNEL__ -m32 -D__KERNEL__ -O2 -fno-strict-aliasing -fPIC -DDISABLE_BRANCH_PROFILING -ffreestanding -fno-stack-protector -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(misc)" -D"KBUILD_MODNAME=KBUILD_STR(misc)" -c -o arch/x86/boot/compressed/misc.o /home/chris/LINUX/linux-2.6.31/arch/x86/boot/compressed/misc.c
which apparently uses gcc's default architecture. However, Fedora has recently changed its gcc default architecture from i586 to i686, and so I end up with a pair on invalid instructions in my kernel binary.
Cheers,
Chris
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [BUG] Kernel built for i586 chip crashes instantly at boot time (CMOV instructions)
2009-12-18 15:28 [BUG] Kernel built for i586 chip crashes instantly at boot time (CMOV instructions) Chris Rankin
@ 2009-12-18 17:12 ` H. Peter Anvin
2009-12-19 11:40 ` Chris Rankin
2009-12-26 0:48 ` [tip:x86/urgent] x86, compress: Force i386 instructions for the decompressor tip-bot for H. Peter Anvin
1 sibling, 1 reply; 4+ messages in thread
From: H. Peter Anvin @ 2009-12-18 17:12 UTC (permalink / raw)
To: Chris Rankin; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1372 bytes --]
On 12/18/2009 07:28 AM, Chris Rankin wrote:
> Hi,
>
> I have been trying to build a 2.6.31.x kernel with Fedora 12's gcc compiler, and have discovered that this kernel crashes instantly at boot-time due to a pair of CMOV instructions in arch/x86/boot/compressed/misc.o. According to "make V=1", the command used to compile misc.c is:
>
> gcc -Wp,-MD,arch/x86/boot/compressed/.misc.o.d -nostdinc -isystem /usr/lib/gcc/i686-redhat-linux/4.4.2/include -Iinclude -Iinclude2 -I/home/chris/LINUX/linux-2.6.31/include -I/home/chris/LINUX/linux-2.6.31/arch/x86/include -include include/linux/autoconf.h -I/home/chris/LINUX/linux-2.6.31/arch/x86/boot/compressed -Iarch/x86/boot/compressed -D__KERNEL__ -m32 -D__KERNEL__ -O2 -fno-strict-aliasing -fPIC -DDISABLE_BRANCH_PROFILING -ffreestanding -fno-stack-protector -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(misc)" -D"KBUILD_MODNAME=KBUILD_STR(misc)" -c -o arch/x86/boot/compressed/misc.o /home/chris/LINUX/linux-2.6.31/arch/x86/boot/compressed/misc.c
>
> which apparently uses gcc's default architecture. However, Fedora has recently changed its gcc default architecture from i586 to i686, and so I end up with a pair on invalid instructions in my kernel binary.
>
Does this patch work for you?
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 606 bytes --]
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index f8ed065..f25bbd3 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -9,6 +9,7 @@ targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinu
KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
KBUILD_CFLAGS += -fno-strict-aliasing -fPIC
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
+cflags-$(CONFIG_X86_32) := -march=i386
cflags-$(CONFIG_X86_64) := -mcmodel=small
KBUILD_CFLAGS += $(cflags-y)
KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [BUG] Kernel built for i586 chip crashes instantly at boot time (CMOV instructions)
2009-12-18 17:12 ` H. Peter Anvin
@ 2009-12-19 11:40 ` Chris Rankin
0 siblings, 0 replies; 4+ messages in thread
From: Chris Rankin @ 2009-12-19 11:40 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: linux-kernel
--- On Fri, 18/12/09, H. Peter Anvin <hpa@zytor.com> wrote:
> Does this patch work for you?
Yes, that fixed it.
Thanks,
Chris
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip:x86/urgent] x86, compress: Force i386 instructions for the decompressor
2009-12-18 15:28 [BUG] Kernel built for i586 chip crashes instantly at boot time (CMOV instructions) Chris Rankin
2009-12-18 17:12 ` H. Peter Anvin
@ 2009-12-26 0:48 ` tip-bot for H. Peter Anvin
1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for H. Peter Anvin @ 2009-12-26 0:48 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, rankincj, tglx
Commit-ID: 17a2a9b57a9a7d2fd8f97df951b5e63e0bd56ef5
Gitweb: http://git.kernel.org/tip/17a2a9b57a9a7d2fd8f97df951b5e63e0bd56ef5
Author: H. Peter Anvin <hpa@zytor.com>
AuthorDate: Fri, 25 Dec 2009 15:40:38 -0800
Committer: H. Peter Anvin <hpa@zytor.com>
CommitDate: Fri, 25 Dec 2009 15:40:38 -0800
x86, compress: Force i386 instructions for the decompressor
Recently, some distros have started shipping versions of gcc which
default to -march=i686. This breaks building kernels for pre-i686
machines, even if they have been selected in Kconfig, due to the
generation of CMOV instructions.
There isn't enough benefit to try to preserve the generation of these
instructions even when selected, so simply force -march=i386 for the
decompressor when building a 32-bit kernel.
Reported-and-tested-by: Chris Rankin <rankincj@yahoo.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
LKML-Reference: <219280.97558.qm@web52907.mail.re2.yahoo.com>
---
arch/x86/boot/compressed/Makefile | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index f8ed065..f25bbd3 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -9,6 +9,7 @@ targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinu
KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
KBUILD_CFLAGS += -fno-strict-aliasing -fPIC
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
+cflags-$(CONFIG_X86_32) := -march=i386
cflags-$(CONFIG_X86_64) := -mcmodel=small
KBUILD_CFLAGS += $(cflags-y)
KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-12-26 0:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-18 15:28 [BUG] Kernel built for i586 chip crashes instantly at boot time (CMOV instructions) Chris Rankin
2009-12-18 17:12 ` H. Peter Anvin
2009-12-19 11:40 ` Chris Rankin
2009-12-26 0:48 ` [tip:x86/urgent] x86, compress: Force i386 instructions for the decompressor tip-bot for H. Peter Anvin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox