On 7/13/06, Jeff Dike <[EMAIL PROTECTED]> wrote:
>
> Instead of the patch mentioned earlier, you might also try the one
> below - it depends on klibc, so you need to apply it to a recent -mm
> UML. I'm thinking about sending this to Andrew, despite it's
> nastinesses.
>
> It applies on top of (and backs out) the other jmpbuf patch.
>
Is there any drawbacks in applying this directly on top of a pure
vanilla kernel (2.6.17.7) or do I need to apply the other jmpbuf patch
before this one?
/Samuel
>
> Index: linux-2.6.17/arch/um/os-Linux/sys-i386/registers.c
> ===================================================================
> --- linux-2.6.17.orig/arch/um/os-Linux/sys-i386/registers.c 2006-07-12
> 11:51:15.000000000 -0400
> +++ linux-2.6.17/arch/um/os-Linux/sys-i386/registers.c 2006-07-12
> 11:51:17.000000000 -0400
> @@ -5,12 +5,12 @@
>
> #include <errno.h>
> #include <string.h>
> -#include <setjmp.h>
> #include "sysdep/ptrace_user.h"
> #include "sysdep/ptrace.h"
> #include "uml-config.h"
> #include "skas_ptregs.h"
> #include "registers.h"
> +#include "longjmp.h"
> #include "user.h"
>
> /* These are set once at boot time and not changed thereafter */
> @@ -130,17 +130,11 @@ void get_safe_registers(unsigned long *r
> HOST_FP_SIZE * sizeof(unsigned long));
> }
>
> -#ifndef JB_PC
> -#define JB_PC 5
> -#define JB_SP 4
> -#define JB_BP 3
> -#endif
> -
> void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer)
> {
> - struct __jmp_buf_tag *jmpbuf = buffer;
> + struct __jmp_buf *jmpbuf = buffer;
>
> - UPT_SET(uml_regs, EIP, jmpbuf->__jmpbuf[JB_PC]);
> - UPT_SET(uml_regs, UESP, jmpbuf->__jmpbuf[JB_SP]);
> - UPT_SET(uml_regs, EBP, jmpbuf->__jmpbuf[JB_BP]);
> + UPT_SET(uml_regs, EIP, jmpbuf->__eip);
> + UPT_SET(uml_regs, UESP, jmpbuf->__esp);
> + UPT_SET(uml_regs, EBP, jmpbuf->__ebp);
> }
> Index: linux-2.6.17/arch/um/os-Linux/sys-x86_64/registers.c
> ===================================================================
> --- linux-2.6.17.orig/arch/um/os-Linux/sys-x86_64/registers.c 2006-07-12
> 11:51:15.000000000 -0400
> +++ linux-2.6.17/arch/um/os-Linux/sys-x86_64/registers.c 2006-07-12
> 11:51:17.000000000 -0400
> @@ -5,11 +5,11 @@
>
> #include <errno.h>
> #include <string.h>
> -#include <setjmp.h>
> #include "ptrace_user.h"
> #include "uml-config.h"
> #include "skas_ptregs.h"
> #include "registers.h"
> +#include "longjmp.h"
> #include "user.h"
>
> /* These are set once at boot time and not changed thereafter */
> @@ -78,17 +78,11 @@ void get_safe_registers(unsigned long *r
> HOST_FP_SIZE * sizeof(unsigned long));
> }
>
> -#ifndef JB_PC
> -#define JB_PC 7
> -#define JB_RSP 6
> -#define JB_RBP 1
> -#endif
> -
> void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer)
> {
> - struct __jmp_buf_tag *jmpbuf = buffer;
> + struct __jmp_buf *jmpbuf = buffer;
>
> - UPT_SET(uml_regs, RIP, jmpbuf->__jmpbuf[JB_PC]);
> - UPT_SET(uml_regs, RSP, jmpbuf->__jmpbuf[JB_RSP]);
> - UPT_SET(uml_regs, RBP, jmpbuf->__jmpbuf[JB_RBP]);
> + UPT_SET(uml_regs, RIP, jmpbuf->__rip);
> + UPT_SET(uml_regs, RSP, jmpbuf->__rsp);
> + UPT_SET(uml_regs, RBP, jmpbuf->__rbp);
> }
> Index: linux-2.6.17/arch/um/Makefile
> ===================================================================
> --- linux-2.6.17.orig/arch/um/Makefile 2006-07-12 11:51:15.000000000 -0400
> +++ linux-2.6.17/arch/um/Makefile 2006-07-12 11:51:17.000000000 -0400
> @@ -29,7 +29,8 @@ SYMLINK_HEADERS := $(foreach header,$(SY
> # These are cleaned up during mrproper. Please DO NOT fix it again, this is
> # the Correct Thing(tm) to do!
> ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep
> $(ARCH_DIR)/os \
> - $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h
> + $(ARCH_DIR)/include/klibc $(SYMLINK_HEADERS) \
> + $(ARCH_DIR)/include/uml-config.h
>
> um-modes-$(CONFIG_MODE_TT) += tt
> um-modes-$(CONFIG_MODE_SKAS) += skas
> @@ -52,6 +53,12 @@ SYS_DIR := $(ARCH_DIR)/include/sysdep-$
>
> KLIBCARCH := $(SUBARCH)
>
> +ifneq ($(KBUILD_SRC),)
> +KLIBC_ARCH_INCLUDE := -I$(srctree)/usr/include/arch/$(SUBARCH)
> +else
> +KLIBC_ARCH_INCLUDE := -Iusr/include/arch/$(SUBARCH)
> +endif
> +
> # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol
> so
> # named - it's a common symbol in libpcap, so we get a binary which crashes.
> #
> @@ -68,7 +75,7 @@ AFLAGS += $(ARCH_INCLUDE)
>
> USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
> USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
> - $(MODE_INCLUDE) -D_FILE_OFFSET_BITS=64
> + $(MODE_INCLUDE) $(KLIBC_ARCH_INCLUDE) -D_FILE_OFFSET_BITS=64
>
> # -Derrno=kernel_errno - This turns all kernel references to errno into
> # kernel_errno to separate them from the libc errno. This allows -fno-common
> @@ -202,6 +209,14 @@ else
> $(Q)cd $(ARCH_DIR) && ln -sf os-$(OS) os
> endif
>
> +$(ARCH_DIR)/include/klibc:
> + @echo ' SYMLINK $@'
> +ifneq ($(KBUILD_SRC),)
> + $(Q)ln -fsn $(srctree)/usr/include/klibc $(ARCH_DIR)/include/klibc
> +else
> + $(Q)ln -sf usr/include/klibc $(ARCH_DIR)/include/klibc
> +endif
> +
> # Generated files
> define filechk_umlconfig
> sed 's/ CONFIG/ UML_CONFIG/'
> Index: linux-2.6.17/arch/um/include/longjmp.h
> ===================================================================
> --- linux-2.6.17.orig/arch/um/include/longjmp.h 2006-07-12 11:51:15.000000000
> -0400
> +++ linux-2.6.17/arch/um/include/longjmp.h 2006-07-12 11:51:17.000000000
> -0400
> @@ -1,7 +1,7 @@
> #ifndef __UML_LONGJMP_H
> #define __UML_LONGJMP_H
>
> -#include <setjmp.h>
> +#include "../../../usr/include/setjmp.h"
> #include "os.h"
>
> #define UML_LONGJMP(buf, val) do { \
> Index: linux-2.6.17/arch/um/os-Linux/trap.c
> ===================================================================
> --- linux-2.6.17.orig/arch/um/os-Linux/trap.c 2006-07-12 11:51:15.000000000
> -0400
> +++ linux-2.6.17/arch/um/os-Linux/trap.c 2006-07-12 11:51:17.000000000
> -0400
> @@ -5,7 +5,6 @@
>
> #include <stdlib.h>
> #include <signal.h>
> -#include <setjmp.h>
> #include "kern_util.h"
> #include "user_util.h"
> #include "os.h"
> Index: linux-2.6.17/arch/um/os-Linux/uaccess.c
> ===================================================================
> --- linux-2.6.17.orig/arch/um/os-Linux/uaccess.c 2006-07-12
> 11:51:15.000000000 -0400
> +++ linux-2.6.17/arch/um/os-Linux/uaccess.c 2006-07-12 11:51:17.000000000
> -0400
> @@ -4,8 +4,7 @@
> * Licensed under the GPL
> */
>
> -#include <setjmp.h>
> -#include <string.h>
> +#include <stddef.h>
> #include "longjmp.h"
>
> unsigned long __do_user_copy(void *to, const void *from, int n,
> Index: linux-2.6.17/arch/um/os-Linux/util.c
> ===================================================================
> --- linux-2.6.17.orig/arch/um/os-Linux/util.c 2006-07-12 11:51:15.000000000
> -0400
> +++ linux-2.6.17/arch/um/os-Linux/util.c 2006-07-12 12:04:38.000000000
> -0400
> @@ -7,7 +7,6 @@
> #include <stdlib.h>
> #include <unistd.h>
> #include <limits.h>
> -#include <setjmp.h>
> #include <sys/mman.h>
> #include <sys/stat.h>
> #include <sys/utsname.h>
> @@ -107,11 +106,11 @@ int setjmp_wrapper(void (*proc)(void *,
> jmp_buf buf;
> int n;
>
> - n = sigsetjmp(buf, 1);
> + n = UML_SETJMP(&buf);
> if(n == 0){
> va_start(args, proc);
> (*proc)(&buf, &args);
> }
> va_end(args);
> - return(n);
> + return n;
> }
> Index: linux-2.6.17/arch/um/os-Linux/process.c
> ===================================================================
> --- linux-2.6.17.orig/arch/um/os-Linux/process.c 2006-07-12
> 11:51:15.000000000 -0400
> +++ linux-2.6.17/arch/um/os-Linux/process.c 2006-07-12 12:04:41.000000000
> -0400
> @@ -7,7 +7,6 @@
> #include <stdio.h>
> #include <errno.h>
> #include <signal.h>
> -#include <setjmp.h>
> #include <linux/unistd.h>
> #include <sys/mman.h>
> #include <sys/wait.h>
> Index: linux-2.6.17/arch/um/os-Linux/skas/process.c
> ===================================================================
> --- linux-2.6.17.orig/arch/um/os-Linux/skas/process.c 2006-07-12
> 11:51:15.000000000 -0400
> +++ linux-2.6.17/arch/um/os-Linux/skas/process.c 2006-07-12
> 12:04:41.000000000 -0400
> @@ -8,7 +8,6 @@
> #include <unistd.h>
> #include <errno.h>
> #include <signal.h>
> -#include <setjmp.h>
> #include <sched.h>
> #include "ptrace_user.h"
> #include <sys/wait.h>
> @@ -470,7 +469,7 @@ void thread_wait(void *sw, void *fb)
> *switch_buf = &buf;
> fork_buf = fb;
> if(UML_SETJMP(&buf) == 0)
> - siglongjmp(*fork_buf, INIT_JMP_REMOVE_SIGSTACK);
> + UML_LONGJMP(fork_buf, INIT_JMP_REMOVE_SIGSTACK);
> }
>
> void switch_threads(void *me, void *next)
> Index: linux-2.6.17/arch/um/os-Linux/Makefile
> ===================================================================
> --- linux-2.6.17.orig/arch/um/os-Linux/Makefile 2006-07-12 11:51:15.000000000
> -0400
> +++ linux-2.6.17/arch/um/os-Linux/Makefile 2006-07-12 11:51:17.000000000
> -0400
> @@ -5,7 +5,8 @@
>
> obj-y = aio.o elf_aux.o file.o helper.o irq.o main.o mem.o process.o sigio.o
> \
> signal.o start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o tls.o \
> - user_syms.o util.o drivers/ sys-$(SUBARCH)/
> + user_syms.o util.o setjmp.o \
> + drivers/ sys-$(SUBARCH)/
>
> obj-$(CONFIG_MODE_SKAS) += skas/
> obj-$(CONFIG_TTY_LOG) += tty_log.o
> @@ -22,3 +23,6 @@ HAVE_AIO_ABI := $(shell [ -r /usr/includ
> CFLAGS_aio.o += $(HAVE_AIO_ABI)
>
> include arch/um/scripts/Makefile.rules
> +
> +arch/um/os-Linux/setjmp.o :
> + ln -sf $(objtree)/usr/klibc/arch/$(SUBARCH)/setjmp.o $@
>
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user