[uml-devel] [patch 05/12] uml: extend cmd line limits
From: Catalin(ux aka Dino) BOIE [EMAIL PROTECTED], Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED], Jeff Dike [EMAIL PROTECTED] Increase UML command line size. And fix a crash from passing an overly-long command line to UML. XXX: check that init can handle 128 params and 128 env. var. The original patch set this limit to 256, but it seems me too much. Think! Signed-off-by: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED] --- linux-2.6.11-paolo/arch/um/include/user_util.h |2 - linux-2.6.11-paolo/arch/um/kernel/um_arch.c| 34 ++--- linux-2.6.11-paolo/arch/um/kernel/user_util.c | 15 --- linux-2.6.11-paolo/include/asm-um/setup.h |5 ++- linux-2.6.11-paolo/init/Kconfig|8 + linux-2.6.11-paolo/init/main.c |4 +- 6 files changed, 35 insertions(+), 33 deletions(-) diff -puN arch/um/kernel/um_arch.c~uml-extend-cmd-line-limits arch/um/kernel/um_arch.c --- linux-2.6.11/arch/um/kernel/um_arch.c~uml-extend-cmd-line-limits 2005-03-21 15:25:42.0 +0100 +++ linux-2.6.11-paolo/arch/um/kernel/um_arch.c 2005-03-21 15:25:42.0 +0100 @@ -25,6 +25,7 @@ #include asm/user.h #include ubd_user.h #include asm/current.h +#include asm/setup.h #include user_util.h #include kern_util.h #include kern.h @@ -40,6 +41,20 @@ #define DEFAULT_COMMAND_LINE root=98:0 +/* Changed in linux_main and setup_arch, which run before SMP is started */ +char command_line[COMMAND_LINE_SIZE] = { 0 }; + +void add_arg(char *arg) +{ + if (strlen(command_line) + strlen(arg) + 1 COMMAND_LINE_SIZE) { + printf(add_arg: Too much command line!\n); + exit(1); + } + if(strlen(command_line) 0) + strcat(command_line, ); + strcat(command_line, arg); +} + struct cpuinfo_um boot_cpu_data = { .loops_per_jiffy= 0, .ipi_pipe = { -1, -1 } @@ -314,9 +329,11 @@ int linux_main(int argc, char **argv) if((i == 1) (argv[i][0] == ' ')) continue; add = 1; uml_checksetup(argv[i], add); - if(add) add_arg(saved_command_line, argv[i]); + if (add) + add_arg(argv[i]); } - if(have_root == 0) add_arg(saved_command_line, DEFAULT_COMMAND_LINE); + if(have_root == 0) + add_arg(DEFAULT_COMMAND_LINE); mode_tt = force_tt ? 1 : !can_do_skas(); #ifndef CONFIG_MODE_TT @@ -432,7 +449,7 @@ void __init setup_arch(char **cmdline_p) { notifier_chain_register(panic_notifier_list, panic_exit_notifier); paging_init(); - strcpy(command_line, saved_command_line); + strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); *cmdline_p = command_line; setup_hostinfo(); } @@ -448,14 +465,3 @@ void __init check_bugs(void) void apply_alternatives(void *start, void *end) { } - -/* - * 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/user_util.c~uml-extend-cmd-line-limits arch/um/kernel/user_util.c --- linux-2.6.11/arch/um/kernel/user_util.c~uml-extend-cmd-line-limits 2005-03-21 15:25:42.0 +0100 +++ linux-2.6.11-paolo/arch/um/kernel/user_util.c 2005-03-21 15:25:42.0 +0100 @@ -31,21 +31,6 @@ #include ptrace_user.h #include uml-config.h -#define COMMAND_LINE_SIZE _POSIX_ARG_MAX - -/* Changed in linux_main and setup_arch, which run before SMP is started */ -char command_line[COMMAND_LINE_SIZE] = { 0 }; - -void add_arg(char *cmd_line, char *arg) -{ - if (strlen(cmd_line) + strlen(arg) + 1 COMMAND_LINE_SIZE) { - printf(add_arg: Too much command line!\n); - exit(1); - } - if(strlen(cmd_line) 0) strcat(cmd_line, ); - strcat(cmd_line, arg); -} - void stop(void) { while(1) sleep(100); diff -puN include/asm-um/setup.h~uml-extend-cmd-line-limits include/asm-um/setup.h --- linux-2.6.11/include/asm-um/setup.h~uml-extend-cmd-line-limits 2005-03-21 15:25:42.0 +0100 +++ linux-2.6.11-paolo/include/asm-um/setup.h 2005-03-21 15:25:42.0 +0100 @@ -1,6 +1,9 @@ #ifndef SETUP_H_INCLUDED #define SETUP_H_INCLUDED -#define COMMAND_LINE_SIZE 512 +/* POSIX mandated with _POSIX_ARG_MAX that we can rely on 4096 chars in the + * command line, so this choice is ok.*/ + +#define COMMAND_LINE_SIZE 4096 #endif /* SETUP_H_INCLUDED */ diff -puN init/Kconfig~uml-extend-cmd-line-limits init/Kconfig --- linux-2.6.11/init/Kconfig~uml-extend-cmd-line-limits2005-03-21 15:25:42.0 +0100 +++ linux-2.6.11-paolo/init/Kconfig 2005-03-21
[uml-devel] [patch 07/12] Uml: little build fixes
From: Al Viro [EMAIL PROTECTED] Cc: Vadim Abrossimov [EMAIL PROTECTED] Easier parts from cross-build (or UML-kbuild) patch from Al Viro: *) abuses of host cc/ld/objcopy/paths are gone *) some #include path fixes *) other little abuses fixed *) remove LIBC_DIR var, ask gcc where libc.a is placed. This creates no problem so can be merged very likely. Note: only tested on i386, give a run on x86-64. Signed-off-by: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED] --- linux-2.6.11-paolo/arch/um/Makefile-x86_64|4 linux-2.6.11-paolo/arch/um/include/sysdep-i386/sigcontext.h |2 +- linux-2.6.11-paolo/arch/um/include/sysdep-x86_64/sigcontext.h |2 +- linux-2.6.11-paolo/arch/um/kernel/tt/Makefile |6 ++ linux-2.6.11-paolo/arch/um/sys-i386/Makefile |2 +- linux-2.6.11-paolo/fs/hppfs/Makefile | 10 -- linux-2.6.11-paolo/include/asm-um/archparam-i386.h|2 +- 7 files changed, 6 insertions(+), 22 deletions(-) diff -puN arch/um/include/sysdep-x86_64/sigcontext.h~uml-cross-build-little-fixes arch/um/include/sysdep-x86_64/sigcontext.h --- linux-2.6.11/arch/um/include/sysdep-x86_64/sigcontext.h~uml-cross-build-little-fixes 2005-03-21 15:25:47.0 +0100 +++ linux-2.6.11-paolo/arch/um/include/sysdep-x86_64/sigcontext.h 2005-03-21 15:25:47.0 +0100 @@ -7,7 +7,7 @@ #ifndef __SYSDEP_X86_64_SIGCONTEXT_H #define __SYSDEP_X86_64_SIGCONTEXT_H -#include sc.h +#include sysdep/sc.h #define IP_RESTART_SYSCALL(ip) ((ip) -= 2) diff -puN include/asm-um/archparam-i386.h~uml-cross-build-little-fixes include/asm-um/archparam-i386.h --- linux-2.6.11/include/asm-um/archparam-i386.h~uml-cross-build-little-fixes 2005-03-21 15:25:47.0 +0100 +++ linux-2.6.11-paolo/include/asm-um/archparam-i386.h 2005-03-21 15:25:47.0 +0100 @@ -8,7 +8,7 @@ /* Bits for asm-um/elf.h / -#include user.h +#include asm/user.h extern char * elf_aux_platform; #define ELF_PLATFORM (elf_aux_platform) diff -puN arch/um/include/sysdep-i386/sigcontext.h~uml-cross-build-little-fixes arch/um/include/sysdep-i386/sigcontext.h --- linux-2.6.11/arch/um/include/sysdep-i386/sigcontext.h~uml-cross-build-little-fixes 2005-03-21 15:25:47.0 +0100 +++ linux-2.6.11-paolo/arch/um/include/sysdep-i386/sigcontext.h 2005-03-21 15:25:47.0 +0100 @@ -6,7 +6,7 @@ #ifndef __SYS_SIGCONTEXT_I386_H #define __SYS_SIGCONTEXT_I386_H -#include sc.h +#include sysdep/sc.h #define IP_RESTART_SYSCALL(ip) ((ip) -= 2) diff -puN arch/um/sys-i386/Makefile~uml-cross-build-little-fixes arch/um/sys-i386/Makefile --- linux-2.6.11/arch/um/sys-i386/Makefile~uml-cross-build-little-fixes 2005-03-21 15:25:47.0 +0100 +++ linux-2.6.11-paolo/arch/um/sys-i386/Makefile2005-03-21 19:52:49.0 +0100 @@ -22,7 +22,7 @@ module.c-dir = kernel define make_link -rm -f $1 - ln -sf $(TOPDIR)/arch/i386/$($(notdir $1)-dir)/$(notdir $1) $1 + ln -sf $(srctree)/arch/i386/$($(notdir $1)-dir)/$(notdir $1) $1 endef $(USER_OBJS) : %.o: %.c diff -puN arch/um/kernel/tt/Makefile~uml-cross-build-little-fixes arch/um/kernel/tt/Makefile --- linux-2.6.11/arch/um/kernel/tt/Makefile~uml-cross-build-little-fixes 2005-03-21 15:25:47.0 +0100 +++ linux-2.6.11-paolo/arch/um/kernel/tt/Makefile 2005-03-21 19:52:49.0 +0100 @@ -24,9 +24,7 @@ $(USER_OBJS) : %.o: %.c $(obj)/unmap.o: $(src)/unmap.c $(CC) $(UNMAP_CFLAGS) -c -o $@ $ -LIBC_DIR ?= /usr/lib - $(obj)/unmap_fin.o : $(obj)/unmap.o - ld -r -o $(obj)/unmap_tmp.o $ -lc -L$(LIBC_DIR) - objcopy $(obj)/unmap_tmp.o $@ -G switcheroo + $(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/Makefile-x86_64~uml-cross-build-little-fixes arch/um/Makefile-x86_64 --- linux-2.6.11/arch/um/Makefile-x86_64~uml-cross-build-little-fixes 2005-03-21 15:25:47.0 +0100 +++ linux-2.6.11-paolo/arch/um/Makefile-x86_64 2005-03-21 15:25:47.0 +0100 @@ -30,7 +30,3 @@ $(SYS_UTIL_DIR)/mk_thread: scripts_basic $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ CLEAN_FILES += $(SYS_HEADERS) - -LIBC_DIR := /usr/lib64 - -export LIBC_DIR diff -puN fs/hppfs/Makefile~uml-cross-build-little-fixes fs/hppfs/Makefile --- linux-2.6.11/fs/hppfs/Makefile~uml-cross-build-little-fixes 2005-03-21 19:52:56.0 +0100 +++ linux-2.6.11-paolo/fs/hppfs/Makefile2005-03-21 19:53:17.0 +0100 @@ -7,13 +7,3 @@ hppfs-objs := hppfs_kern.o obj-y = obj-$(CONFIG_HPPFS) += hppfs.o - -clean: - -modules: - -fastdep: - -dep: - -archmrproper: clean _ --- This SF.net email is sponsored by: 2005 Windows Mobile Application Contest Submit applications for Windows Mobile(tm)-based Pocket PCs or Smartphones for the chance to
[uml-devel] [patch 08/12] uml: factor out common code in user-obj handling
From: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED], Vadim Abrossimov [EMAIL PROTECTED] *) Handle USER_OBJS through the general Kbuild infrastructure; the trick we use is to change c_flags only for USER_OBJS. This ain't at all worse than the previous kludgy solution, enables us to use a better dependency handling and to support MODVERSIONS. And it is UML-specific, as a bonus. So, no it ain't clean enough reasoning is allowed to hold this patch until you find a better solution. Leaving there the current broken code is not accepted. *) Move similar definitions from Makefiles to the newly created arch/um/scripts/Makefile.rules and include it everywhere needed. Please test on x86_64 subarch, I've tested it on i386. Signed-off-by: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED] --- linux-2.6.11-paolo/arch/um/drivers/Makefile |9 ++--- linux-2.6.11-paolo/arch/um/kernel/Makefile | 14 +++--- linux-2.6.11-paolo/arch/um/kernel/skas/Makefile |8 +++- linux-2.6.11-paolo/arch/um/kernel/tt/Makefile | 12 +--- linux-2.6.11-paolo/arch/um/kernel/tt/ptproxy/Makefile |5 ++--- linux-2.6.11-paolo/arch/um/os-Linux/Makefile|6 ++ linux-2.6.11-paolo/arch/um/os-Linux/drivers/Makefile|8 +--- linux-2.6.11-paolo/arch/um/os-Linux/sys-i386/Makefile |5 ++--- linux-2.6.11-paolo/arch/um/os-Linux/sys-x86_64/Makefile |5 ++--- linux-2.6.11-paolo/arch/um/scripts/Makefile.rules | 10 ++ linux-2.6.11-paolo/arch/um/sys-i386/Makefile|6 ++ linux-2.6.11-paolo/arch/um/sys-x86_64/Makefile |8 +++- linux-2.6.11-paolo/fs/hostfs/Makefile | 10 ++ 13 files changed, 43 insertions(+), 63 deletions(-) diff -puN arch/um/drivers/Makefile~uml-user-obj-cleanup arch/um/drivers/Makefile --- linux-2.6.11/arch/um/drivers/Makefile~uml-user-obj-cleanup 2005-03-21 15:25:50.0 +0100 +++ linux-2.6.11-paolo/arch/um/drivers/Makefile 2005-03-21 15:25:51.0 +0100 @@ -41,11 +41,6 @@ obj-$(CONFIG_UML_WATCHDOG) += harddog.o obj-$(CONFIG_BLK_DEV_COW_COMMON) += cow_user.o obj-$(CONFIG_UML_RANDOM) += random.o -USER_SINGLE_OBJS = $(foreach f,$(patsubst %.o,%,$(obj-y) $(obj-m)),$($(f)-objs)) +USER_OBJS := fd.o null.o pty.o tty.o xterm.o -USER_OBJS := $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS)) fd.o \ - null.o pty.o tty.o xterm.o -USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) - -$(USER_OBJS) : %.o: %.c - $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $ +include arch/um/scripts/Makefile.rules diff -puN arch/um/kernel/Makefile~uml-user-obj-cleanup arch/um/kernel/Makefile --- linux-2.6.11/arch/um/kernel/Makefile~uml-user-obj-cleanup 2005-03-21 15:25:50.0 +0100 +++ linux-2.6.11-paolo/arch/um/kernel/Makefile 2005-03-21 15:25:51.0 +0100 @@ -23,16 +23,16 @@ obj-$(CONFIG_SYSCALL_DEBUG) += syscall_u obj-$(CONFIG_MODE_TT) += tt/ obj-$(CONFIG_MODE_SKAS) += skas/ -user-objs-$(CONFIG_TTY_LOG) += tty_log.o +# This needs be compiled with frame pointers regardless of how the rest of the +# kernel is built. +CFLAGS_frame.o := -fno-omit-frame-pointer -USER_OBJS := $(filter %_user.o,$(obj-y)) $(user-objs-y) config.o helper.o \ - main.o process.o tempfile.o time.o tty_log.o umid.o user_util.o frame.o -USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) +user-objs-$(CONFIG_TTY_LOG) += tty_log.o -CFLAGS_frame.o := -fno-omit-frame-pointer +USER_OBJS := $(user-objs-y) config.o helper.o main.o process.o tempfile.o \ + time.o tty_log.o umid.o user_util.o frame.o -$(USER_OBJS) : %.o: %.c - $(CC) $(USER_CFLAGS) $(CFLAGS_$(notdir $@)) -c -o $@ $ +include arch/um/scripts/Makefile.rules targets += config.c diff -puN arch/um/kernel/skas/Makefile~uml-user-obj-cleanup arch/um/kernel/skas/Makefile --- linux-2.6.11/arch/um/kernel/skas/Makefile~uml-user-obj-cleanup 2005-03-21 15:25:50.0 +0100 +++ linux-2.6.11-paolo/arch/um/kernel/skas/Makefile 2005-03-21 15:25:51.0 +0100 @@ -6,10 +6,8 @@ obj-y := exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \ syscall_kern.o syscall_user.o time.o tlb.o trap_user.o uaccess.o \ -USER_OBJS = $(filter %_user.o,$(obj-y)) process.o time.o -USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) +subdir- := util -$(USER_OBJS) : %.o: %.c - $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $ +USER_OBJS := process.o time.o -subdir- := util +include arch/um/scripts/Makefile.rules diff -puN arch/um/kernel/tt/Makefile~uml-user-obj-cleanup arch/um/kernel/tt/Makefile --- linux-2.6.11/arch/um/kernel/tt/Makefile~uml-user-obj-cleanup 2005-03-21 15:25:51.0 +0100 +++ linux-2.6.11-paolo/arch/um/kernel/tt/Makefile 2005-03-21 15:25:51.0 +0100 @@ -12,17 +12,15 @@ obj-y = exec_kern.o exec_user.o gdb.o ks obj-$(CONFIG_PT_PROXY) += gdb_kern.o ptproxy/
[uml-devel] [patch 1/1] uml: fix cond. expr. as lvalues warning
From: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED] Gcc 3.4.3 (and probably any 3.4) emits some deprecation warnings currently about usages of CHOOSE_MODE, since the below syntax has been deprecated: (a ? foo: bar) = foobar; which often results from expansion of: CHOOSE_MODE(foo, bar) = foobar; So add an additional __CHOOSE_MODE syntax for users which need to get a lvalue, which uses (a ? foo : bar) inside a function, casts the result to the correct type and dereference the pointer, and use it where needed (i.e. in sysdep/ptrace.h) The patch builds and runs correctly (this has been tested on i386 only, not on x86_64), and removes all the warnings. Signed-off-by: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED] --- linux-2.6.11-paolo/arch/um/include/choose-mode.h |7 + linux-2.6.11-paolo/arch/um/include/sysdep-i386/ptrace.h | 36 linux-2.6.11-paolo/arch/um/include/sysdep-x86_64/ptrace.h | 58 +++--- 3 files changed, 54 insertions(+), 47 deletions(-) diff -puN arch/um/include/choose-mode.h~uml-fix-cond-expr-as-lvalues arch/um/include/choose-mode.h --- linux-2.6.11/arch/um/include/choose-mode.h~uml-fix-cond-expr-as-lvalues 2005-03-22 16:24:29.0 +0100 +++ linux-2.6.11-paolo/arch/um/include/choose-mode.h2005-03-22 16:24:29.0 +0100 @@ -21,6 +21,13 @@ #define CHOOSE_MODE_PROC(tt, skas, args...) \ CHOOSE_MODE(tt(args), skas(args)) +extern int mode_tt; +static inline void *__choose_mode(void *tt, void *skas) { + return mode_tt ? tt : skas; +} + +#define __CHOOSE_MODE(tt, skas) (*( (typeof(tt) *) __choose_mode((tt), (skas + #endif /* diff -puN arch/um/include/sysdep-i386/ptrace.h~uml-fix-cond-expr-as-lvalues arch/um/include/sysdep-i386/ptrace.h --- linux-2.6.11/arch/um/include/sysdep-i386/ptrace.h~uml-fix-cond-expr-as-lvalues 2005-03-22 16:25:12.0 +0100 +++ linux-2.6.11-paolo/arch/um/include/sysdep-i386/ptrace.h 2005-03-22 16:28:39.0 +0100 @@ -93,39 +93,39 @@ extern int mode_tt; #define UPT_SC(r) ((r)-tt.sc) #define UPT_IP(r) \ - CHOOSE_MODE(SC_IP(UPT_SC(r)), REGS_IP((r)-skas.regs)) + __CHOOSE_MODE(SC_IP(UPT_SC(r)), REGS_IP((r)-skas.regs)) #define UPT_SP(r) \ - CHOOSE_MODE(SC_SP(UPT_SC(r)), REGS_SP((r)-skas.regs)) + __CHOOSE_MODE(SC_SP(UPT_SC(r)), REGS_SP((r)-skas.regs)) #define UPT_EFLAGS(r) \ - CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)-skas.regs)) + __CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)-skas.regs)) #define UPT_EAX(r) \ - CHOOSE_MODE(SC_EAX(UPT_SC(r)), REGS_EAX((r)-skas.regs)) + __CHOOSE_MODE(SC_EAX(UPT_SC(r)), REGS_EAX((r)-skas.regs)) #define UPT_EBX(r) \ - CHOOSE_MODE(SC_EBX(UPT_SC(r)), REGS_EBX((r)-skas.regs)) + __CHOOSE_MODE(SC_EBX(UPT_SC(r)), REGS_EBX((r)-skas.regs)) #define UPT_ECX(r) \ - CHOOSE_MODE(SC_ECX(UPT_SC(r)), REGS_ECX((r)-skas.regs)) + __CHOOSE_MODE(SC_ECX(UPT_SC(r)), REGS_ECX((r)-skas.regs)) #define UPT_EDX(r) \ - CHOOSE_MODE(SC_EDX(UPT_SC(r)), REGS_EDX((r)-skas.regs)) + __CHOOSE_MODE(SC_EDX(UPT_SC(r)), REGS_EDX((r)-skas.regs)) #define UPT_ESI(r) \ - CHOOSE_MODE(SC_ESI(UPT_SC(r)), REGS_ESI((r)-skas.regs)) + __CHOOSE_MODE(SC_ESI(UPT_SC(r)), REGS_ESI((r)-skas.regs)) #define UPT_EDI(r) \ - CHOOSE_MODE(SC_EDI(UPT_SC(r)), REGS_EDI((r)-skas.regs)) + __CHOOSE_MODE(SC_EDI(UPT_SC(r)), REGS_EDI((r)-skas.regs)) #define UPT_EBP(r) \ - CHOOSE_MODE(SC_EBP(UPT_SC(r)), REGS_EBP((r)-skas.regs)) + __CHOOSE_MODE(SC_EBP(UPT_SC(r)), REGS_EBP((r)-skas.regs)) #define UPT_ORIG_EAX(r) \ - CHOOSE_MODE((r)-tt.syscall, (r)-skas.syscall) + __CHOOSE_MODE((r)-tt.syscall, (r)-skas.syscall) #define UPT_CS(r) \ - CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)-skas.regs)) + __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)-skas.regs)) #define UPT_SS(r) \ - CHOOSE_MODE(SC_SS(UPT_SC(r)), REGS_SS((r)-skas.regs)) + __CHOOSE_MODE(SC_SS(UPT_SC(r)), REGS_SS((r)-skas.regs)) #define UPT_DS(r) \ - CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)-skas.regs)) + __CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)-skas.regs)) #define UPT_ES(r) \ - CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)-skas.regs)) + __CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)-skas.regs)) #define UPT_FS(r) \ - CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)-skas.regs)) + __CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)-skas.regs)) #define UPT_GS(r) \ - CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)-skas.regs)) + __CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)-skas.regs)) #define UPT_SYSCALL_ARG1(r) UPT_EBX(r) #define UPT_SYSCALL_ARG2(r) UPT_ECX(r) @@ -222,7 +222,7 @@ struct syscall_args { REGS_SEGV_IS_FIXABLE(r-skas)) #define UPT_FAULT_ADDR(r) \ - CHOOSE_MODE(SC_FAULT_ADDR(UPT_SC(r)), REGS_FAULT_ADDR(r-skas)) + __CHOOSE_MODE(SC_FAULT_ADDR(UPT_SC(r)), REGS_FAULT_ADDR(r-skas)) #define UPT_FAULT_WRITE(r) \
[uml-devel] [patch 11/12] uml: real fix for __gcov_init symbols
From: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED] CC: Anton Altaparmakov [EMAIL PROTECTED] Correctly export __gcov_init for cases where it's needed, by adding a weak definition for the case when GCC does not define this symbol and letting it being overriden by the real definition when GCC defines it (recent ones). Can't be implemented as a test on GCC version because SuSE has a crippled GCC, declared as 3.3.4 but having a lot of backported features. Also, since gcc 3.4.3 requires profiling options even during linking, add profiling options to final link stage. Signed-off-by: Paolo 'Blaisorblade' Giarrusso [EMAIL PROTECTED] --- linux-2.6.11-paolo/arch/um/Makefile-skas | 10 ++ linux-2.6.11-paolo/arch/um/kernel/gmon_syms.c | 20 ++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff -puN arch/um/kernel/gmon_syms.c~uml-real-fix-gcov-symbols arch/um/kernel/gmon_syms.c --- linux-2.6.11/arch/um/kernel/gmon_syms.c~uml-real-fix-gcov-symbols 2005-03-22 11:06:13.0 +0100 +++ linux-2.6.11-paolo/arch/um/kernel/gmon_syms.c 2005-03-22 11:06:13.0 +0100 @@ -5,14 +5,22 @@ #include linux/module.h -#if __GNUC__ 3 || (__GNUC__ == 3 __GNUC_MINOR__ 3) || \ - (__GNUC__ == 3 __GNUC_MINOR__ == 3 __GNUC_PATCHLEVEL__ = 4) -extern void __gcov_init(void *); -EXPORT_SYMBOL(__gcov_init); -#else extern void __bb_init_func(void *); EXPORT_SYMBOL(__bb_init_func); -#endif + +/* This is defined (and referred to in profiling stub code) only by some GCC + * versions in libgcov. + * + * Since SuSE backported the fix, we cannot handle it depending on GCC version. + * So, unconditinally export it. But also give it a weak declaration, which will + * be overriden by any other one. + */ + +extern void __gcov_init(void *) __attribute__((weak)); +EXPORT_SYMBOL(__gcov_init); + +extern void __gcov_merge_add(void *) __attribute__((weak)); +EXPORT_SYMBOL(__gcov_merge_add); /* * Overrides for Emacs so that we follow Linus's tabbing style. diff -puN arch/um/Makefile-skas~uml-real-fix-gcov-symbols arch/um/Makefile-skas --- linux-2.6.11/arch/um/Makefile-skas~uml-real-fix-gcov-symbols 2005-03-22 11:06:13.0 +0100 +++ linux-2.6.11-paolo/arch/um/Makefile-skas2005-03-22 11:06:13.0 +0100 @@ -3,10 +3,12 @@ # Licensed under the GPL # -PROFILE += -pg +GPROF_OPT += -pg +GCOV_OPT += -fprofile-arcs -ftest-coverage -CFLAGS-$(CONFIG_GCOV) += -fprofile-arcs -ftest-coverage -CFLAGS-$(CONFIG_GPROF) += $(PROFILE) -LINK-$(CONFIG_GPROF) += $(PROFILE) +CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT) +CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT) +LINK-$(CONFIG_GCOV) += $(GCOV_OPT) +LINK-$(CONFIG_GPROF) += $(GPROF_OPT) GEN_HEADERS += $(ARCH_DIR)/include/skas_ptregs.h _ --- This SF.net email is sponsored by: 2005 Windows Mobile Application Contest Submit applications for Windows Mobile(tm)-based Pocket PCs or Smartphones for the chance to win $25,000 and application distribution. Enter today at http://ads.osdn.com/?ad_id=6882alloc_id=15148op=click ___ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] Re: [patch 03/12] uml: export getgid for hostfs
On Tue, Mar 22, 2005 at 05:21:23PM +0100, [EMAIL PROTECTED] wrote: Export this symbol which is not satisfied currently. The code using it has been merged, so please export this symbol. and it's still bogus, and you haven't replied when I mentioned it last time. --- This SF.net email is sponsored by: 2005 Windows Mobile Application Contest Submit applications for Windows Mobile(tm)-based Pocket PCs or Smartphones for the chance to win $25,000 and application distribution. Enter today at http://ads.osdn.com/?ad_id=6882alloc_id=15148op=click ___ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Re: [uml-devel] Re: Testing GCOV handling in -bk
On Monday 21 March 2005 11:49, Anton Altaparmakov wrote: On Sun, 2005-03-20 at 12:42 +0100, Blaisorblade wrote: Anton, would you test the current -bk tree for the CONFIG_GCOV problem and the patch I and Jeff put together? http://user-mode-linux.sourceforge.net/work/current/2.6/2.6.11-bk8/patche s/weak_gcov_init The above should fix the situation for you... for real 3.4 Gcc, however, the problems are bigger because it also requires to change link flags (and this interferes with some executables we build). I also get a link failure on __bb_fork_something..., which I haven't been able to solve until now. I would test it but UML in current -BK doesn't build at all. It stops with: CC kernel/signal.o kernel/signal.c: In function `get_signal_to_deliver': kernel/signal.c:1849: error: structure has no member named `eflags' kernel/signal.c:1849: error: `TF_MASK' undeclared (first use in this function) kernel/signal.c:1849: error: (Each undeclared identifier is reported only once kernel/signal.c:1849: error: for each function it appears in.) make[1]: *** [kernel/signal.o] Error 1 make: *** [kernel] Error 2 Best regards, Anton Ok, watch the patches I'm sending now. The one titled uml: fix compile fix the above problem, while the one named uml: real fix for __gcov_init symbols is what I'm merging for this problem (from your results I guess it should work well for you too). -- Paolo Giarrusso, aka Blaisorblade Linux registered user n. 292729 http://www.user-mode-linux.org/~blaisorblade --- This SF.net email is sponsored by: 2005 Windows Mobile Application Contest Submit applications for Windows Mobile(tm)-based Pocket PCs or Smartphones for the chance to win $25,000 and application distribution. Enter today at http://ads.osdn.com/?ad_id=6882alloc_id=15148op=click ___ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Re: [uml-devel] ptrace_test.c program on PPC
On Sunday 20 March 2005 20:25, ashwin tanugula wrote: Hi, I know that UML has to be ported to PPC. I want to resume that work. I just wanted to make sure that my PPC box can run uml.(because the first step in porting uml is to check that the ptrace_test.c file outputs two same pids). Since there have been working versions of the PPC port, it should be working well. I have set ORIG_EAX to 0. Is that correct or wrong? Hmm, actually this is wrong... by reading ptrace_test.c, which I just found on my HD, it should work almost out of the box. However, if you look at the source, what it puts inside the ORIG_EAX is the number of getppid(), not of getpid(), i.e. 64. You don't need to change the value IMHO. If you write 20 there it is perfectly expectable that the pids you get are different (as an exercise, try to understand why: if the child executes getpid() it gets its own PID, if it executes getppid() it gets the father's pid). That said, the problem you should get is that I don't expect ORIG_EAX to be accepted. From reading include/asm-ppc/unistd.h, it seems that the register to be changed is r0 (so the macro is PT_R0). Also, the ptrace_test.c requirement has been reduced a lot by SYSEMU introduction. Basically, ptrace_test.c uses a hack to avoid that the syscall is executed on the host, i.e. changing the syscall number to getpid. PTRACE_SYSEMU is a ptrace() option that says that the syscall invoked by the debugged thread must not be executed: we write the result from the UML execution of the syscall to the result register. Thanks, Ashwin. -- Paolo Giarrusso, aka Blaisorblade Linux registered user n. 292729 http://www.user-mode-linux.org/~blaisorblade #include stdio.h #include signal.h #include sys/wait.h #include sys/ptrace.h #include asm/ptrace.h #include asm/unistd.h static char stack[65536]; int child(void *arg) { if(ptrace(PTRACE_TRACEME, 0, 0, 0) 0){ perror(ptrace); exit(1); } kill(getpid(), SIGSTOP); while(1){ printf(getpid() returned %d\n, getpid()); sleep(3); } return(0); } int main(int argc, char **argv) { int pid, status, syscall; printf(Parent pid = %d\n, getpid()); if((pid = clone(child, stack[65532], SIGCHLD, NULL)) 0){ perror(clone); exit(1); } if((pid = waitpid(pid, status, WUNTRACED)) 0){ perror(Waiting for stop); exit(1); } if(ptrace(PTRACE_SYSCALL, pid, 0, 0) 0){ perror(continuing); exit(1); } while(1){ if((pid = waitpid(-1, status, WUNTRACED)) = 0){ perror(wait); exit(1); } if(WIFSTOPPED(status) (WSTOPSIG(status) == SIGTRAP)){ syscall = ptrace(PTRACE_PEEKUSER, pid, 4 * ORIG_EAX, 0); if(syscall == __NR_getpid){ if(ptrace(PTRACE_POKEUSER, pid, 4 * ORIG_EAX, __NR_getppid) 0){ perror(ptrace); exit(1); } } if(ptrace(PTRACE_SYSCALL, pid, 0, 0) 0){ perror(continuing); exit(1); } } else printf(wait failed - pid = %d, status = %d\n, pid, status); } }
Re: [uml-devel] Hostfs permission checks are all wonky.
On Tuesday 22 March 2005 02:19 pm, Blaisorblade wrote: On Sunday 20 March 2005 20:17, Rob Landley wrote: If I open a device like /dev/loop0 or /dev/console from a hostfs mount, I'll get the UML device, not the host device, right? Obviously right. So why are the permissions checks on hostfs devices done relative to the _host_ user? What is the result from ls -l that device? Does it look readable for root? Yes. sh-2.05b# ls -l /dev/loop0 brw-rw1 root disk 7, 0 Sep 15 2003 /dev/loop0 sh-2.05b# A side effect of this is that I have to chown console to belong to the user running UML in order to run ./linux rootfstype=hostfs rw init=/bin/sh, because otherwise it can't open /dev/console to get the initial console. (This is with the stdio console.) /dev/console has permissions 600. I'm not sure, however you could try the attached patch (there is also some whitespace cleanup, sorry), and if that does not work, then again I've not understood your scenario and you might answer the other questions in the email (I've first wrote the generic questions, then understood what is probably going on). Ok, I'm now seeing that UML uses access() (inside access_file()) to check permissions. See hostfs_permission - access_file - access. hostfs_permission (not access_file) should skip the access_file call in case its type is OS_TYPE_CHARDEV / OS_TYPE_BLOCKDEV / OS_TYPE_FIFO / OS_TYPE_SOCK. Look at init_inode() about how to see the file's type, but even better look at the cached information, i.e. inode-i_mode and the S_* access macro (look at init_special_inode about this). Yeah, that'd do it. I might not get to this tonight, but I'll try the patch tomorrow at the latest. If /dev/console doesn't belong to the current user, the system can't even open the initial console, despite the fact the output does NOT go to TTY1 if I'm running it an xterm. /dev/console and /dev/tty1 are entirely different. If you open a getty on /dev/console, Ctrl-C won't work there. I'm booting with init=/bin/sh (or a shellscript). It opens /dev/console for me behind the scenes, I don't make any special arrangements. You're right, ctrl-c doesn't work. It would be nice if it did... What I meant by not going to /dev/tty1 is that's where console output goes by default in the parent system, so if the thing were managing to write to the parent's /dev/console that's where all the output would wind up. But it's not, it's going to stdout like it's supposed to. Minus the wonky permissions check you noticed above... 1) Which version of UML are you using? If you are using the incrementals, they contain the hostfs rewrite which has all these problems... (with that, you can't even do a stat on a device you don't own, wrongly). 2.6.11 from kernel.org. 2) Which command line? I recall you run with hostfs as root fs, but I'm not really sure of this. Try it, it's easy. ./linux rootfstype=hostfs rootflags=/ rw init=/bin/sh If you run it from an xterm, that should work. If you run it from an ssh session, it probably won't because of the permissions on /dev/console discussed above. 3) When you have hostfs as your root fs, there is some special code to handle this which may be reconsidered. I.e., when you have a file on the host owned by the user running UML, that is seen as owned by root inside UML. Actually it's not related to your current problem, but if ever you notice any bugs, please let us know. You mean like this darn bug I've been seeing for weeks? io scheduler noop registered loop: loaded (max 8 devices) Initialized stdio console driver Console initialized on /dev/tty0 VFS: Mounted root (hostfs filesystem). idr_remove called for id=3 which is not allocated. Call Trace: a01fba48: [a007cbec] a01fba84: [a007cc13] a01fba9c: [a0085eaa] a01fbb04: [a0085697] a01fbb4c: [a00860a4] a01fbb68: [a007d09d] a01fbb74: [a004cc5e] a01fbb7c: [a004cdb6] a01fbb80: [a008e193] a01fbba8: [a004cd31] a01fbbc8: [a004526c] a01fbbe4: [a00451bf] a01fbc24: [a0045365] a01fbc38: [a0045445] a01fbc54: [a0011de9] a01fbcc0: [a0011e30] a01fbce4: [a0012d18] a01fbd14: [a0017887] a01fbd20: [a0097808] sh-2.05b# It does that all the time. (The id=? bit changes with each run.) Somewhere around here I've got a trace from when I built it with debug symbols, I can get that for you at the same time I try out your patch... Similarly, if /dev/loop0 is chmod 600 and I run UML as a normal user and try to do a mount -o loop, it says it can't find a loop device. Yet if I run UML as root, it doesn't allocate one of the parent's loop devices, UML does it internally... I'm told there's a major rewrite of hostfs underway. Is it worth me trying to patch the existing hostfs code, or should I go try to track down the new stuff and try it out? Well, the rewrite (currently in the incrementals) is waiting for more urgent work since a lot of time (it was started by the 2.4.24-2um