On Tuesday 05 July 2005 13:40, Oleg Girko wrote:
> Hello!
>
> I develop software for a small router/firewall appliance
> (http://www.stratum.lv/), and use User-Mode Linux for testing and
> debugging. Recently, I've upgraded my development system to Fedora Core 4,
> and UML ceased to work.
I.e. your host system? For the guest system there are problems with NPTL since
UML does not support it; for the host one, yes, there could be some problems
with errno... probably I have an idea about them, and there's a patch
floating around which should solve them too (though it wasn't written for
your problem, but for a connected).
Try the attached patch version against 2.6.12-bs1...
> I've switched to UML 2.6.12-bs1, and the problem
> still persists. Look at the log of kernel invoked with “stderr=1” option
> (there are many other options specifying root filesystem and network
> interfaces, but they are irrelevant):
> [-- Begin of log --]
> Checking for /proc/mm...found
> Checking for the skas3 patch in the host...not found
> Checking PROT_EXEC mmap in /tmp...OK
> Failed to mkdir /home/ol/.uml/: Success
> tracing thread pid = 2745
> Linux version 2.6.12-bs1-um ([EMAIL PROTECTED]) (gcc version 4.0.0
> 20050519 (Red Hat 4.0.0-8)) #1 Tue Jul 5 09:49:10 EEST 2005
> Built 1 zonelists
> Kernel command line: rw root=/dev/root
> rootflags=/home/ol/work/svn/scf/head/build/image-um/root.i386
> rootfstype=hostfs con0=fd:0,fd:1 con=port:9101 ssl=port:9102
> eth0=tuntap,,,192.168.254.1 eth1=mcast ubd=3
> ubd0=/home/ol/work/svn/scf/head/build/image-um/hda fakehd fake_ide mem=128M
> stderr=1
> Setting extra ubd major number to 3
> fakehd : Changing ubd name to "hd".
> PID hash table entries: 1024 (order: 10, 16384 bytes)
> Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
> Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
> Memory: 125824k available
> Mount-cache hash table entries: 512
> Checking for host processor cmov support...Yes
> Checking for host processor xmm support...No
> Checking that ptrace can change system call numbers...OK
> Checking syscall emulation patch for ptrace...missing
> Checking that host ptys support output SIGIO...<0>Kernel panic - not
> syncing: check_sigio : write failed, errno = 0
>
>
> Kernel panic - not syncing: Segfault with no mm
>
> EIP: 0073:[<a002cb1c>] CPU: 0 Not tainted ESP: 007b:a01bbb40 EFLAGS:
> 00210202 Not tainted
> EAX: 00000000 EBX: 00000038 ECX: 00000001 EDX: a01bcf44
> ESI: a01bcf74 EDI: a0295120 EBP: a01bbeb4 DS: 007b ES: 007b
> a01bb690: [<a0031634>] printk+0x18/0x1c
> a01bb6a0: [<a0040dea>] notifier_call_chain+0x1e/0x38
> a01bb6c0: [<a0030c11>] panic+0x59/0x110
> a01bb6d0: [<a00153f3>] change_sig+0x4b/0x60
> a01bb6f0: [<a00174bd>] segv+0x211/0x250
> a01bb74c: [<a0128d77>] sigemptyset+0x17/0x34
> a01bb760: [<a0015446>] change_signals+0x3e/0x70
> a01bb7b0: [<a0017853>] segv_handler+0x10b/0x190
> a01bb7c0: [<a002cb1c>] show_regs+0x34/0x1f4
> a01bb7f0: [<a001a9fd>] sig_handler_common_tt+0xbd/0x114
> a01bb800: [<a001aa3d>] sig_handler_common_tt+0xfd/0x114
> a01bb840: [<a0028252>] sig_handler+0x1e/0x3c
> a01bb8a0: [<a002cb1c>] show_regs+0x34/0x1f4
> a01bbb5c: [<a0018052>] panic_exit+0x26/0x48
> a01bbb7c: [<a0031634>] printk+0x18/0x1c
> a01bbb8c: [<a0040dea>] notifier_call_chain+0x1e/0x38
> a01bbbac: [<a0030c11>] panic+0x59/0x110
> a01bbbdc: [<a0014426>] tty_output+0x66/0xf4
> a01bbbec: [<a0014411>] tty_output+0x51/0xf4
> a01bbdfc: [<a000894e>] check_one_sigio+0xee/0x1dc
> a01bbe28: [<a0008854>] handler+0x0/0xc
> a01bbe44: [<a0128d77>] sigemptyset+0x17/0x34
> a01bbe58: [<a001558d>] set_signals+0x79/0x178
> a01bbea8: [<a0141910>] __tcgetattr+0x60/0x84
> a01bbeb4: [<a0028234>] sig_handler+0x0/0x3c
> a01bbed0: [<a0128d77>] sigemptyset+0x17/0x34
> a01bbee4: [<a001558d>] set_signals+0x79/0x178
> a01bbf34: [<a0141910>] __tcgetattr+0x60/0x84
> a01bbf4c: [<a001a09c>] signal_tramp+0x0/0xf0
> a01bbf5c: [<a0008a5f>] check_sigio+0x23/0x64
> a01bbf60: [<a00143c0>] tty_output+0x0/0xf4
> a01bbf6c: [<a001a09c>] signal_tramp+0x0/0xf0
> a01bbf7c: [<a0008cc2>] check_bugs+0x12/0x1c
> a01bbf80: [<a001a09c>] signal_tramp+0x0/0xf0
> a01bbf8c: [<a0002598>] start_kernel+0x14c/0x1a8
> a01bbf94: [<a001a09c>] signal_tramp+0x0/0xf0
> a01bbf9c: [<a0002556>] start_kernel+0x10a/0x1a8
> a01bbfb4: [<a001a09c>] signal_tramp+0x0/0xf0
> a01bbfbc: [<a001976a>] start_kernel_proc+0x42/0x48
> a01bbfc4: [<a0028234>] sig_handler+0x0/0x3c
> a01bbfcc: [<a001a0cf>] signal_tramp+0x33/0xf0
> a01bbfdc: [<a014247e>] __clone+0x6e/0x9c
>
> [-- End of log --]
>
> The first anomaly appears immediately after start:
>
> Checking for /proc/mm...found
>
> There is no “/proc/mm” file on my host system! I use unpatched kernel which
> comes with Fedora core 4. Inserting debugging output revealed very strange
> behaviour: access() system call in os_access() function in
> “arch/um/os-Linux/file.c” file returns -1, but errno is equal to zero!
>
> The same problem happens when on “Checking that host ptys support output
> SIGIO” phase:
>
> Checking that host ptys support output SIGIO...<0>Kernel panic - not
> syncing: check_sigio : write failed, errno = 0
>
> Again, debugging output inserted in file_io() finction in
> “arch/um/os-Linux/file.c” shows than write() system call returns -1, but
> errno is again equal to zero.
>
> I don't understand, how can it happen that system calls return failure
> without setting errno variable. I don't think that debugging output I was
> inserting messes errno value: I save and restore errno carefully, and the
> same effect persists both with and without additional debugging output.
> Also, it doesn't look like this error is caused by corrupt libraries on my
> particular system: I've reproduced the same error on two different Fedora
> Core 4 host installations. Did anyone encounter similar effect? Does anyone
> have an idea how to fix this problem?
>
> BTW, I call UML on Fedora under “setarch i386 -R” to turn off address space
> randomisation. Otherwise, UML dumps core immediately.
>
> P.S. Also, you can see from stack trace, than printk() in panic() causes
> double-panic. This looks like another error, but it will not have effect if
> the primary error I've describe above gets fixed.
>
> -- Oleg Girko, http://www.infoserver.ru/~ol/
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=Click
> _______________________________________________
> User-mode-linux-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user
--
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade
From: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>, Al Viro <[EMAIL PROTECTED]>
To make sure switcheroo() can execute when we remap all the executable image,
we used a trick to make it use a local copy of errno... this trick does not
work with NPTL glibc, only with LinuxThreads, so use another (simpler) one to
make it work anyway.
Hopefully, a lot improved thanks to merging with the version of Al Viro (which
had his part of problems, though, i.e. removing a fix to another bug and not
fixing the problem on i386).
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>
---
vanilla-linux-2.6.12-paolo/arch/um/Makefile | 8 +--
vanilla-linux-2.6.12-paolo/arch/um/kernel/tt/Makefile | 15 ------
vanilla-linux-2.6.12-paolo/arch/um/kernel/uml.lds.S | 15 +-----
vanilla-linux-2.6.12-paolo/arch/um/scripts/Makefile.unmap | 25 +++++++++++
vanilla-linux-2.6.12-paolo/arch/um/sys-i386/Makefile | 2
vanilla-linux-2.6.12-paolo/arch/um/sys-i386/unmap.c | 26 +++++++++++
vanilla-linux-2.6.12-paolo/arch/um/sys-x86_64/Makefile | 2
vanilla-linux-2.6.12-paolo/arch/um/sys-x86_64/unmap.c | 26 +++++++++++
vanilla-linux-2.6.12/arch/um/kernel/tt/unmap.c | 31 --------------
9 files changed, 88 insertions(+), 62 deletions(-)
diff -L arch/um/kernel/tt/unmap.c -puN arch/um/kernel/tt/unmap.c~uml-link-tt-mode-against-nptl /dev/null
--- vanilla-linux-2.6.12/arch/um/kernel/tt/unmap.c
+++ /dev/null 2005-06-27 20:00:42.865153360 +0200
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2000 Jeff Dike ([EMAIL PROTECTED])
- * Licensed under the GPL
- */
-
-#include <sys/mman.h>
-
-int switcheroo(int fd, int prot, void *from, void *to, int size)
-{
- if(munmap(to, size) < 0){
- return(-1);
- }
- if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){
- return(-1);
- }
- if(munmap(from, size) < 0){
- return(-1);
- }
- return(0);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -puN arch/um/kernel/uml.lds.S~uml-link-tt-mode-against-nptl arch/um/kernel/uml.lds.S
--- vanilla-linux-2.6.12/arch/um/kernel/uml.lds.S~uml-link-tt-mode-against-nptl 2005-07-06 20:09:19.000000000 +0200
+++ vanilla-linux-2.6.12-paolo/arch/um/kernel/uml.lds.S 2005-07-06 20:09:20.000000000 +0200
@@ -14,19 +14,10 @@ SECTIONS
/* Used in arch/um/kernel/mem.c. Any memory between START and __binary_start
* is remapped.*/
__binary_start = .;
-#ifdef MODE_TT
- .thread_private : {
- __start_thread_private = .;
- errno = .;
- . += 4;
- arch/um/kernel/tt/unmap_fin.o (.data)
- __end_thread_private = .;
- }
- . = ALIGN(4096);
- .remap : { arch/um/kernel/tt/unmap_fin.o (.text) }
- /* We want it only if we are in MODE_TT. In both cases, however, when MODE_TT
- * is off the resulting binary segfaults.*/
+#ifdef MODE_TT
+ .remap_data : { arch/um/sys-SUBARCH/unmap_fin.o (.data .bss) }
+ .remap : { arch/um/sys-SUBARCH/unmap_fin.o (.text) }
. = ALIGN(4096); /* Init code and data */
#endif
diff -puN /dev/null arch/um/sys-i386/unmap.c
--- /dev/null 2005-06-27 20:00:42.865153360 +0200
+++ vanilla-linux-2.6.12-paolo/arch/um/sys-i386/unmap.c 2005-07-06 20:09:20.000000000 +0200
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2000 Jeff Dike ([EMAIL PROTECTED])
+ * Licensed under the GPL
+ */
+
+#include <linux/mman.h>
+#include <asm/unistd.h>
+
+static int errno;
+
+static inline _syscall2(int,munmap,void *,start,size_t,len)
+static inline _syscall6(void *,mmap2,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
+int switcheroo(int fd, int prot, void *from, void *to, int size)
+{
+ if(munmap(to, size) < 0){
+ return(-1);
+ }
+ /* if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){ */
+ if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){
+ return(-1);
+ }
+ if(munmap(from, size) < 0){
+ return(-1);
+ }
+ return(0);
+}
diff -puN /dev/null arch/um/sys-x86_64/unmap.c
--- /dev/null 2005-06-27 20:00:42.865153360 +0200
+++ vanilla-linux-2.6.12-paolo/arch/um/sys-x86_64/unmap.c 2005-07-06 20:09:20.000000000 +0200
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2000 Jeff Dike ([EMAIL PROTECTED])
+ * Licensed under the GPL
+ */
+
+#include <linux/mman.h>
+#include <asm/unistd.h>
+
+static int errno;
+
+static inline _syscall2(int,munmap,void *,start,size_t,len)
+static inline _syscall6(void *,mmap,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
+int switcheroo(int fd, int prot, void *from, void *to, int size)
+{
+ if(munmap(to, size) < 0){
+ return(-1);
+ }
+ /* if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){ */
+ if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){
+ return(-1);
+ }
+ if(munmap(from, size) < 0){
+ return(-1);
+ }
+ return(0);
+}
diff -puN arch/um/kernel/tt/Makefile~uml-link-tt-mode-against-nptl arch/um/kernel/tt/Makefile
--- vanilla-linux-2.6.12/arch/um/kernel/tt/Makefile~uml-link-tt-mode-against-nptl 2005-07-06 20:09:19.000000000 +0200
+++ vanilla-linux-2.6.12-paolo/arch/um/kernel/tt/Makefile 2005-07-06 20:09:20.000000000 +0200
@@ -3,10 +3,6 @@
# Licensed under the GPL
#
-extra-y := unmap_fin.o
-targets := unmap.o
-clean-files := unmap_tmp.o
-
obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \
syscall_kern.o syscall_user.o time.o tlb.o tracer.o trap_user.o \
uaccess.o uaccess_user.o
@@ -16,14 +12,3 @@ obj-$(CONFIG_PT_PROXY) += gdb_kern.o ptp
USER_OBJS := gdb.o time.o tracer.o
include arch/um/scripts/Makefile.rules
-
-UNMAP_CFLAGS := $(patsubst -pg -DPROFILING,,$(USER_CFLAGS))
-UNMAP_CFLAGS := $(patsubst -fprofile-arcs -ftest-coverage,,$(UNMAP_CFLAGS))
-
-#XXX: partially copied from arch/um/scripts/Makefile.rules
-$(obj)/unmap.o: c_flags = -Wp,-MD,$(depfile) $(UNMAP_CFLAGS)
-
-$(obj)/unmap_fin.o : $(obj)/unmap.o
- $(LD) -r -o $(obj)/unmap_tmp.o $< $(shell $(CC) -print-file-name=libc.a)
- $(OBJCOPY) $(obj)/unmap_tmp.o $@ -G switcheroo
-
diff -puN arch/um/sys-i386/Makefile~uml-link-tt-mode-against-nptl arch/um/sys-i386/Makefile
--- vanilla-linux-2.6.12/arch/um/sys-i386/Makefile~uml-link-tt-mode-against-nptl 2005-07-06 20:09:20.000000000 +0200
+++ vanilla-linux-2.6.12-paolo/arch/um/sys-i386/Makefile 2005-07-06 20:09:20.000000000 +0200
@@ -17,3 +17,5 @@ highmem.c-dir = mm
module.c-dir = kernel
subdir- := util
+
+include arch/um/scripts/Makefile.unmap
diff -puN arch/um/sys-x86_64/Makefile~uml-link-tt-mode-against-nptl arch/um/sys-x86_64/Makefile
--- vanilla-linux-2.6.12/arch/um/sys-x86_64/Makefile~uml-link-tt-mode-against-nptl 2005-07-06 20:09:20.000000000 +0200
+++ vanilla-linux-2.6.12-paolo/arch/um/sys-x86_64/Makefile 2005-07-06 20:09:20.000000000 +0200
@@ -29,3 +29,5 @@ thunk.S-dir = lib
module.c-dir = kernel
subdir- := util
+
+include arch/um/scripts/Makefile.unmap
diff -puN /dev/null arch/um/scripts/Makefile.unmap
--- /dev/null 2005-06-27 20:00:42.865153360 +0200
+++ vanilla-linux-2.6.12-paolo/arch/um/scripts/Makefile.unmap 2005-07-06 20:09:20.000000000 +0200
@@ -0,0 +1,25 @@
+clean-files += unmap_tmp.o unmap_fin.o unmap.o
+
+ifdef CONFIG_MODE_TT
+
+#Always build unmap_fin.o
+extra-y += unmap_fin.o
+#Do dependency tracking for unmap.o (it will be always built, but won't get the tracking unless we use this).
+targets += unmap.o
+
+__UNMAP_CFLAGS := $(patsubst -pg -DPROFILING,,$(USER_CFLAGS))
+__UNMAP_CFLAGS := $(patsubst -fprofile-arcs -ftest-coverage,,$(__UNMAP_CFLAGS))
+
+#XXX: partially copied from arch/um/scripts/Makefile.rules
+$(obj)/unmap.o: _c_flags = $(__UNMAP_CFLAGS)
+
+quiet_cmd_wrapld = LD $@
+define cmd_wrapld
+ $(LD) -r -o $(obj)/unmap_tmp.o $< $(shell $(CC) -print-file-name=libc.a); \
+ $(OBJCOPY) $(obj)/unmap_tmp.o $@ -G switcheroo
+endef
+
+$(obj)/unmap_fin.o : $(obj)/unmap.o FORCE
+ $(call if_changed,wrapld)
+
+endif
diff -puN arch/um/Makefile~uml-link-tt-mode-against-nptl arch/um/Makefile
--- vanilla-linux-2.6.12/arch/um/Makefile~uml-link-tt-mode-against-nptl 2005-07-06 20:09:20.000000000 +0200
+++ vanilla-linux-2.6.12-paolo/arch/um/Makefile 2005-07-06 20:09:20.000000000 +0200
@@ -116,13 +116,13 @@ CONFIG_KERNEL_STACK_ORDER ?= 2
STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
ifndef START
- START = $$(($(TOP_ADDR) - $(SIZE)))
+ START = $(shell echo $$[ $(TOP_ADDR) - $(SIZE) ] )
endif
-CPPFLAGS_vmlinux.lds = $(shell echo -U$(SUBARCH) \
+CPPFLAGS_vmlinux.lds = -U$(SUBARCH) \
-DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \
- -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE-y) \
- -DKERNEL_STACK_SIZE=$(STACK_SIZE))
+ -DELF_FORMAT="$(ELF_FORMAT)" $(CPP_MODE-y) \
+ -DKERNEL_STACK_SIZE=$(STACK_SIZE) -DSUBARCH=$(SUBARCH)
#The wrappers will select whether using "malloc" or the kernel allocator.
LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
_