From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KvEiF-0004Yo-HF for qemu-devel@nongnu.org; Wed, 29 Oct 2008 13:20:07 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KvEiB-0004Y1-N1 for qemu-devel@nongnu.org; Wed, 29 Oct 2008 13:20:06 -0400 Received: from [199.232.76.173] (port=56388 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KvEiB-0004Xx-Gg for qemu-devel@nongnu.org; Wed, 29 Oct 2008 13:20:03 -0400 Received: from raleigh.neotoma.org ([24.106.182.151]:59357 helo=pr.neotoma.org) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KvEiB-0007ji-0A for qemu-devel@nongnu.org; Wed, 29 Oct 2008 13:20:03 -0400 Date: Wed, 29 Oct 2008 13:19:42 -0400 From: Chris Dukes Message-ID: <20081029171942.GA19158@raleigh.neotoma.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="GvXjxJ+pjyke8COw" Content-Disposition: inline Subject: [Qemu-devel] kqemu does not build on hybrid x86_64/i386 system Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Daniel Baumann --GvXjxJ+pjyke8COw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I'm attempting to build kqemu 1.4.0~pre1 on a debian sid i386 system running debian's 2.6.26-1-amd64 kernel. It fails attemping to assemble nexus_asm.S with a combination of x86_64/nexus_asm.S:63: Error: bad register name `%rax' type errors and x86_64/nexus_asm.S:84: Error: `movzwq' is only supported in 64-bit mode I believe this is happening because the kqemu script makes extensive use of uname -m to determine the architecture for build and incorrectly assumes that just because it's x86_64ish that gcc will emit 64bit code. After much kludging (And it's incorrect for anything except Linux), I was able to have common/Makefile apply -m32 or -m64 as I thought was appropriate. Now the .S files assemble fine, but link fails with x86_64/monitor_asm.o: In function `__monitor_exception': (.text+0x68d): undefined reference to `KQEMU_STATE_monitor_ss_null_sel' x86_64/monitor_asm.o: In function `exception_return': (.text+0x6d3): undefined reference to `KQEMU_STATE_monitor_ss_null_sel' x86_64/monitor_asm.o: In function `exception_return16': (.text+0x776): undefined reference to `KQEMU_STATE_monitor_cs32_sel' x86_64/monitor_asm.o: In function `__monitor_interrupt': (.text+0x81c): undefined reference to `KQEMU_STATE_monitor_ss_null_sel' It's somewhat confusing as it builds fine for an x86_64 kernel with x86_64 userspace and 686 kernel with i386 userspace. Attached are the full logs, as well as my kludgery. -- Chris Dukes --GvXjxJ+pjyke8COw Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="fail1.txt" ./configure --kernel-path=/lib/modules/2.6.26-1-amd64/build Source path /usr/src/modules/kqemu C compiler gcc Host C compiler gcc make make host CPU x86_64 kernel sources /lib/modules/2.6.26-1-amd64/build kbuild type 2.6 /usr/bin/make make[2]: Entering directory `/usr/src/modules/kqemu' make -C common all make[3]: Entering directory `/usr/src/modules/kqemu/common' gcc -Wall -O2 -Werror -g -D__KERNEL__ -I.. -o genoffsets genoffsets.c ./genoffsets > monitor_def.h gcc -D__KERNEL__ -nostdinc -iwithprefix include -I. -I.. -D__ASSEMBLY__ -c -o x86_64/nexus_asm.o x86_64/nexus_asm.S x86_64/nexus_asm.S: Assembler messages: x86_64/nexus_asm.S:42: Error: bad register name `%rbp' x86_64/nexus_asm.S:43: Error: bad register name `%rsp' x86_64/nexus_asm.S:44: Error: bad register name `%rbx' x86_64/nexus_asm.S:45: Error: bad register name `%r12' x86_64/nexus_asm.S:46: Error: bad register name `%r13' x86_64/nexus_asm.S:47: Error: bad register name `%r14' x86_64/nexus_asm.S:48: Error: bad register name `%r15' x86_64/nexus_asm.S:50: Error: bad register name `%rdi)' x86_64/nexus_asm.S:51: Error: bad register name `%rdi)' x86_64/nexus_asm.S:52: Error: bad register name `%rdi)' x86_64/nexus_asm.S:53: Error: bad register name `%rdi)' x86_64/nexus_asm.S:54: Error: bad register name `%rdi)' x86_64/nexus_asm.S:56: Error: bad register name `%rdi)' x86_64/nexus_asm.S:57: Error: bad register name `%rsp' x86_64/nexus_asm.S:59: Error: bad register name `%rax' x86_64/nexus_asm.S:60: Error: bad register name `%rax' x86_64/nexus_asm.S:61: Error: bad register name `%rax' x86_64/nexus_asm.S:62: Error: bad register name `%rax' x86_64/nexus_asm.S:63: Error: bad register name `%rax' x86_64/nexus_asm.S:64: Error: bad register name `%rax' x86_64/nexus_asm.S:68: Error: bad register name `%rax' x86_64/nexus_asm.S:69: Error: bad register name `%rcx' x86_64/nexus_asm.S:70: Error: bad register name `%rax' x86_64/nexus_asm.S:71: Error: bad register name `%rax' x86_64/nexus_asm.S:73: Error: bad register name `%rdi)' x86_64/nexus_asm.S:74: Error: bad register name `%rdi)' x86_64/nexus_asm.S:75: Error: bad register name `%rax' x86_64/nexus_asm.S:76: Error: bad register name `%rcx' x86_64/nexus_asm.S:78: Error: bad register name `%rdi)' x86_64/nexus_asm.S:79: Error: bad register name `%rdi)' x86_64/nexus_asm.S:81: Error: bad register name `%rdi)' x86_64/nexus_asm.S:84: Error: `movzwq' is only supported in 64-bit mode x86_64/nexus_asm.S:85: Error: bad register name `%rax' x86_64/nexus_asm.S:86: Error: bad register name `%rdi)' x86_64/nexus_asm.S:87: Error: bad register name `%rax' x86_64/nexus_asm.S:88: Error: suffix or operands invalid for `lret' x86_64/nexus_asm.S:91: Error: bad register name `%rdi)' x86_64/nexus_asm.S:93: Error: bad register name `%rdi)' x86_64/nexus_asm.S:96: Error: bad register name `%rdi)' x86_64/nexus_asm.S:97: Error: bad register name `%rcx)' x86_64/nexus_asm.S:98: Error: bad register name `%rcx)' x86_64/nexus_asm.S:99: Error: bad register name `%rdi)' x86_64/nexus_asm.S:100: Error: bad register name `%rdx' x86_64/nexus_asm.S:101: Error: bad register name `%rdi)' x86_64/nexus_asm.S:102: Error: bad register name `%rdx' x86_64/nexus_asm.S:104: Error: bad register name `%r12' x86_64/nexus_asm.S:105: Error: bad register name `%r13' x86_64/nexus_asm.S:107: Error: bad register name `%rdi)' x86_64/nexus_asm.S:110: Error: bad register name `%rdi)' x86_64/nexus_asm.S:111: Error: bad register name `%rax' x86_64/nexus_asm.S:113: Error: bad register name `%rax' x86_64/nexus_asm.S:116: Error: bad register name `%r15' x86_64/nexus_asm.S:117: Error: bad register name `%r14' x86_64/nexus_asm.S:118: Error: bad register name `%r13' x86_64/nexus_asm.S:119: Error: bad register name `%r12' x86_64/nexus_asm.S:120: Error: bad register name `%rbx' x86_64/nexus_asm.S:121: Error: bad register name `%rbp' x86_64/nexus_asm.S:129: Error: bad register name `%rbp' x86_64/nexus_asm.S:130: Error: bad register name `%rsp' x86_64/nexus_asm.S:131: Error: bad register name `%rbx' x86_64/nexus_asm.S:132: Error: bad register name `%r12' x86_64/nexus_asm.S:133: Error: bad register name `%r13' x86_64/nexus_asm.S:134: Error: bad register name `%r14' x86_64/nexus_asm.S:135: Error: bad register name `%r15' x86_64/nexus_asm.S:137: Error: bad register name `%rsp' x86_64/nexus_asm.S:140: Error: bad register name `%rdi)' x86_64/nexus_asm.S:141: Error: bad register name `%rax' x86_64/nexus_asm.S:143: Error: bad register name `%rax' x86_64/nexus_asm.S:144: Error: bad register name `%rax' x86_64/nexus_asm.S:147: Error: bad register name `%rdi)' x86_64/nexus_asm.S:148: Error: bad register name `%rax' x86_64/nexus_asm.S:149: Error: bad register name `%rax' x86_64/nexus_asm.S:153: Error: bad register name `%rdi)' x86_64/nexus_asm.S:154: Error: bad register name `%rcx' x86_64/nexus_asm.S:155: Error: bad register name `%rax' x86_64/nexus_asm.S:156: Error: bad register name `%rax' x86_64/nexus_asm.S:159: Error: bad register name `%rdi)' x86_64/nexus_asm.S:160: Error: bad register name `%rdi)' x86_64/nexus_asm.S:161: Error: bad register name `%rax' x86_64/nexus_asm.S:162: Error: bad register name `%rcx' x86_64/nexus_asm.S:164: Error: bad register name `%rdi)' x86_64/nexus_asm.S:165: Error: bad register name `%rdi)' x86_64/nexus_asm.S:166: Error: bad register name `%rdi)' x86_64/nexus_asm.S:168: Error: bad register name `%rdi)' x86_64/nexus_asm.S:171: Error: `movzwq' is only supported in 64-bit mode x86_64/nexus_asm.S:172: Error: bad register name `%rax' x86_64/nexus_asm.S:173: Error: `monitor2kernel_jmp_offset(%rip)' is not a valid base/index expression x86_64/nexus_asm.S:174: Error: bad register name `%rax' x86_64/nexus_asm.S:175: Error: suffix or operands invalid for `lret' x86_64/nexus_asm.S:179: Error: bad register name `%rdi)' x86_64/nexus_asm.S:182: Error: bad register name `%rdi)' x86_64/nexus_asm.S:183: Error: bad register name `%rcx)' x86_64/nexus_asm.S:187: Error: bad register name `%rdi)' x86_64/nexus_asm.S:188: Error: bad register name `%rax' x86_64/nexus_asm.S:190: Error: bad register name `%rdi)' x86_64/nexus_asm.S:192: Error: bad register name `%r15' x86_64/nexus_asm.S:193: Error: bad register name `%r14' x86_64/nexus_asm.S:194: Error: bad register name `%r13' x86_64/nexus_asm.S:195: Error: bad register name `%r12' x86_64/nexus_asm.S:196: Error: bad register name `%rbx' x86_64/nexus_asm.S:197: Error: bad register name `%rbp' make[3]: *** [x86_64/nexus_asm.o] Error 1 make[3]: Leaving directory `/usr/src/modules/kqemu/common' make[2]: *** [kqemu.ko] Error 2 make[2]: Leaving directory `/usr/src/modules/kqemu' make[1]: *** [binary-modules] Error 2 make[1]: Leaving directory `/usr/src/modules/kqemu' make: *** [kdist_build] Error 2 --GvXjxJ+pjyke8COw Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="fail2.txt" ./configure --kernel-path=/lib/modules/2.6.26-1-amd64/build --cc=gcc-4.1 --host-cc=gcc-4.1 CONFIG_X86_64=y Source path /usr/src/modules/kqemu C compiler gcc-4.1 Host C compiler gcc-4.1 make make host CPU x86_64 kernel sources /lib/modules/2.6.26-1-amd64/build kbuild type 2.6 /usr/bin/make make[2]: Entering directory `/usr/src/modules/kqemu' make -C common all make[3]: Entering directory `/usr/src/modules/kqemu/common' gcc -Wall -O2 -Werror -g -D__KERNEL__ -I.. -o genoffsets genoffsets.c ./genoffsets > monitor_def.h gcc -m64 -march=k8 -D__KERNEL__ -nostdinc -iwithprefix include -I. -I.. -D__ASSEMBLY__ -c -o x86_64/nexus_asm.o x86_64/nexus_asm.S gcc -m64 -march=k8 -D__KERNEL__ -nostdinc -iwithprefix include -I. -I.. -D__ASSEMBLY__ -c -o x86_64/monitor_asm.o x86_64/monitor_asm.S gcc -m64 -march=k8 -Wall -O2 -fomit-frame-pointer -fno-strict-aliasing -Werror -mno-red-zone -fno-stack-protector -fpic -D__KERNEL__ -nostdinc -iwithprefix include -I. -I.. -c -o monitor.o monitor.c gcc -m64 -march=k8 -Wall -O2 -fomit-frame-pointer -fno-strict-aliasing -Werror -mno-red-zone -fno-stack-protector -fpic -D__KERNEL__ -nostdinc -iwithprefix include -I. -I.. -c -o monitor-utils.o monitor-utils.c gcc -m64 -march=k8 -Wall -O2 -fomit-frame-pointer -fno-strict-aliasing -Werror -mno-red-zone -fno-stack-protector -fpic -D__KERNEL__ -nostdinc -iwithprefix include -I. -I.. -c -o interp.o interp.c ld -m elf_x86_64 -T x86_64/monitor.ld -o monitor-image.out x86_64/nexus_asm.o x86_64/monitor_asm.o monitor.o monitor-utils.o interp.o x86_64/monitor_asm.o: In function `__monitor_exception': (.text+0x68d): undefined reference to `KQEMU_STATE_monitor_ss_null_sel' x86_64/monitor_asm.o: In function `exception_return': (.text+0x6d3): undefined reference to `KQEMU_STATE_monitor_ss_null_sel' x86_64/monitor_asm.o: In function `exception_return16': (.text+0x776): undefined reference to `KQEMU_STATE_monitor_cs32_sel' x86_64/monitor_asm.o: In function `__monitor_interrupt': (.text+0x81c): undefined reference to `KQEMU_STATE_monitor_ss_null_sel' make[3]: *** [monitor-image.out] Error 1 make[3]: Leaving directory `/usr/src/modules/kqemu/common' make[2]: *** [kqemu.ko] Error 2 make[2]: Leaving directory `/usr/src/modules/kqemu' make[1]: *** [binary-modules] Error 2 make[1]: Leaving directory `/usr/src/modules/kqemu' make: *** [kdist_build] Error 2 --GvXjxJ+pjyke8COw Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="kqemu.patch" diff -urwp kqemu.orig/common/Makefile kqemu/common/Makefile --- kqemu.orig/common/Makefile 2008-09-14 09:40:51.000000000 -0400 +++ kqemu/common/Makefile 2008-10-29 11:32:38.000000000 -0400 @@ -28,8 +28,8 @@ cc-option = $(shell if test -z "`$(1) $( /dev/null 2>&1`"; then echo "$(2)"; else echo "$(3)"; fi ;) HOST_CC=gcc -MON_CC=gcc -MON_LD=ld +MON_CC=$(CC) +MON_LD=ld -m elf_$(ARCH) ifdef CONFIG_WIN32 TARGET=../kqemu-mod-$(ARCH)-win32.o CC=i386-mingw32-gcc @@ -116,10 +116,10 @@ genmon: genmon.c $(HOST_CC) $(TOOLS_CFLAGS) -o $@ $< %.o: %.c - $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c -o $@ $< + $(CC) $(ASMMFLAG) $(CFLAGS) $(DEFINES) $(INCLUDES) -c -o $@ $< %.o: %.S - $(CC) $(DEFINES) $(INCLUDES) -D__ASSEMBLY__ -c -o $@ $< + $(CC) $(ASMMFLAG) $(DEFINES) $(INCLUDES) -D__ASSEMBLY__ -c -o $@ $< clean: rm -f *.o *~ monitor-image.h genoffsets genmon monitor_def.h \ diff -urwp kqemu.orig/config-host.mak kqemu/config-host.mak --- kqemu.orig/config-host.mak 2008-10-29 09:23:04.000000000 -0400 +++ kqemu/config-host.mak 2008-10-29 10:17:30.000000000 -0400 @@ -13,6 +13,7 @@ CFLAGS=-O2 LDFLAGS= EXESUF= ARCH=i386 +ASMMFLAG=-m32 KERNEL_PATH=/lib/modules/2.6.26-1-686/build CONFIG_KBUILD26=yes SRC_PATH=/usr/src/modules/kqemu diff -urwp kqemu.orig/configure kqemu/configure --- kqemu.orig/configure 2008-09-14 09:40:51.000000000 -0400 +++ kqemu/configure 2008-10-29 11:18:08.000000000 -0400 @@ -275,6 +275,19 @@ if test '!' -f "$kernel_path/Makefile" ; kqemu="no" fi +if test "$kqemu" = "yes" ; then + if grep '^CONFIG_X86_64=y$' $kernel_path/.config; then + ARCH=x86_64 + ASMMFLAG="-m64 -march=k8" + elif grep '^CONFIG_X86_32=y$' $kernel_path/.config; then + ARCH=i386 + ASMMFLAG="-m32 -march=generic" + else + echo "This kernel lacks CONFIG_X86_64 and CONFIG_X86_32 - kqemu cannot be built" + kqemu="no" + fi +fi + # find build system (2.6 or legacy) kbuild26="yes" if grep -q "PATCHLEVEL = 4" $kernel_path/Makefile ; then @@ -325,14 +338,16 @@ echo "STRIP=$strip -s -R .comment -R .no echo "CFLAGS=$CFLAGS" >> $config_mak echo "LDFLAGS=$LDFLAGS" >> $config_mak echo "EXESUF=$EXESUF" >> $config_mak -if test "$cpu" = "i386" ; then - echo "ARCH=i386" >> $config_mak -elif test "$cpu" = "x86_64" ; then - echo "ARCH=x86_64" >> $config_mak -else - echo "Unsupported CPU" - exit 1 -fi +#if test "$cpu" = "i386" ; then +# echo "ARCH=i386" >> $config_mak +#elif test "$cpu" = "x86_64" ; then +# echo "ARCH=x86_64" >> $config_mak +#else +# echo "Unsupported CPU" +# exit 1 +#fi +echo "ARCH=$ARCH" >> $config_mak +echo "ASMMFLAG=$ASMMFLAG" >> $config_mak if test "$bigendian" = "yes" ; then echo "WORDS_BIGENDIAN=yes" >> $config_mak fi diff -urwp kqemu.orig/debian/rules kqemu/debian/rules --- kqemu.orig/debian/rules 2008-09-14 09:40:53.000000000 -0400 +++ kqemu/debian/rules 2008-10-29 11:28:53.000000000 -0400 @@ -63,7 +63,7 @@ binary-modules: prep-deb-files dh_clean -k # Build the module - ./configure --kernel-path=$(KSRC) + ./configure --kernel-path=$(KSRC) --cc=$(CC) --host-cc=$(CC) $(MAKE) # Install the module --GvXjxJ+pjyke8COw--