Re: [uml-devel] [PATCH] UML utrace support, step 1
> Below is the first step in your Fix-Your-Broken-Arch-HOWTO for UML. Great! Thanks for tackling this. > Do you want incremental patches as I go along, or replacement ones? The way I've organized my patch series is with the arch support split up along with the separate infrastructure patches in the series. That is, just asm/tracehook.h with no utrace_regset stuff in the first patch so that the kernel builds with only utrace-tracehook.patch; then the regset stuff but no arch_ptrace et al in another patch so that it builds with utrace-regset.patch but without the later patches; then arch_ptrace et al in the final arch patch. Your patch is mostly just the first of these (utrace-tracehook-um), but includes utrace_regset and arch_ptrace stubs that won't compile without the later infrastructure patches applied. If you want to divide things up this way, then I'd like just to see a replacement utrace-tracehook-um.patch followed by utrace-regset-um.patch and utrace-ptrace-compat-um.patch, replacing each one whole as needed until it's merged into my trees, and then I can take incremental changes after that. If you don't want to bother with dividing things so it compiles in between patches in the series, then just one big replacement patch is fine. > +const struct utrace_regset_view utrace_um_native = { > + .name = "um", This name wants to be the subarch name--it's usually the $ARCH or UTS_MACHINE, i.e. the canonical arch name (i386 not i686, but ppc64 or ppc, not powerpc). In fact, I'm sure you really want to define the utrace_regset_view structs separately somewhere in arch/um/sys-$SUBARCH. On biarch platforms you'll need more than one, as the native biarch platforms have. (But that is all part of the second step that isn't really tackled in this patch.) > +#define ARCH_HAS_SINGLE_STEP (1) Note you'll eventually want to define the block-step macro and functions depending on subarch. (ia64 supports it, and x86 one day will.) > +extern const struct utrace_regset_view utrace_um_native; > +static inline const struct utrace_regset_view * > +utrace_native_view(struct task_struct *tsk) > +{ > + return &utrace_um_native; > +} You probably just want an extern decl for utrace_native_view here, since what it really does with depend on the subarch. > BTW, UML runs on the utrace in -mm (i.e. utrace on the host), which it > didn't with several Fedora kernels. Oh, really? That's good, but are you sure? Have you tried a CONFIG_PREEMPT=y host? I reproduced a failure with the current code recently after Alexey Dobriyan reported the problem. But I didn't get anywhere debugging it and got busy with other work. I could use some help tracking down what ptrace does differently that broke UML, if it does indeed still come up. I have plenty of experience debugging ptrace and users of it, but I don't know much of anything about UML's usage pattern and got quickly lost in its code trying to tell what it expected to happen. Thanks, Roland - 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-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] x86_64: PTRACE_[GS]ET_THREAD_AREA should be accepted
This patch backports from 2.6.19 a fix to a 2.6.18 regression. Like for PTRACE_OLDSETOPTIONS, we should fix PTRACE_[GS]ET_THREAD_AREA. This had been done already for 2.6.19, so this is for 2.6.18-stable only. This was tested with UML/32bit as API consumer, both before and after this patch. Cc: Andi Kleen <[EMAIL PROTECTED]> Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]> Index: linux-2.6.18/arch/x86_64/ia32/ptrace32.c === --- linux-2.6.18.orig/arch/x86_64/ia32/ptrace32.c +++ linux-2.6.18/arch/x86_64/ia32/ptrace32.c @@ -241,6 +241,8 @@ asmlinkage long sys32_ptrace(long reques case PTRACE_SYSCALL: case PTRACE_OLDSETOPTIONS: case PTRACE_SETOPTIONS: + case PTRACE_SET_THREAD_AREA: + case PTRACE_GET_THREAD_AREA: return sys_ptrace(request, pid, addr, data); default: - 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-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Re: [uml-devel] [PATCH] UML utrace support, step 1
On Wed, Feb 21, 2007 at 03:12:28AM -0800, Roland McGrath wrote: > The way I've organized my patch series is with the arch support split up > along with the separate infrastructure patches in the series. That is, > just asm/tracehook.h with no utrace_regset stuff in the first patch so that > the kernel builds with only utrace-tracehook.patch; then the regset stuff > but no arch_ptrace et al in another patch so that it builds with > utrace-regset.patch but without the later patches; then arch_ptrace et al > in the final arch patch. OK, I'll do it this way. > If you want to divide things up this way, then I'd like just to see a > replacement utrace-tracehook-um.patch Below. > > +const struct utrace_regset_view utrace_um_native = { > > + .name = "um", > > This name wants to be the subarch name--it's usually the $ARCH or > UTS_MACHINE, i.e. the canonical arch name (i386 not i686, but ppc64 or ppc, > not powerpc). In fact, I'm sure you really want to define the > utrace_regset_view structs separately somewhere in arch/um/sys-$SUBARCH. Yup, I'll leave this here, with .name initialized as SUBARCH, with the regsets defined in sys-$(ARCH) somewhere. > > +#define ARCH_HAS_SINGLE_STEP (1) > > Note you'll eventually want to define the block-step macro and functions > depending on subarch. (ia64 supports it, and x86 one day will.) Fixed. block-step is hardware-trap-on-branch or something similar? > You probably just want an extern decl for utrace_native_view here, > since what it really does with depend on the subarch. I'm leaving it here, with pieces imported from the underlying arch. > > BTW, UML runs on the utrace in -mm (i.e. utrace on the host), which it > > didn't with several Fedora kernels. > > Oh, really? That's good, but are you sure? Yeah, it seems fine to me. It's been happily running a 64-way kernel build loop the last couple of days. The Fedora kernels I tried couldn't even boot UML. > Have you tried a CONFIG_PREEMPT=y host? No, this is with preempt off. > I have plenty of experience debugging ptrace and > users of it, but I don't know much of anything about UML's usage pattern > and got quickly lost in its code trying to tell what it expected to happen. I don't think UML's ptrace usage is too strange, just all the stuff around it might get in the way conceptually. If you want some help figuring things out, I'll be happy to help. Stop by #uml in irc.oftc.net. Jeff -- Work email - jdike at linux dot intel dot com Step 1 of utrace support. Add tracehooks.h plus enough other changes to get UML to build and run. Signed-off-by: Jeff Dike <[EMAIL PROTECTED]> -- arch/um/kernel/exec.c |1 arch/um/kernel/process.c|6 arch/um/kernel/ptrace.c | 333 +--- arch/um/kernel/signal.c |5 arch/um/kernel/skas/syscall.c |4 arch/um/sys-i386/signal.c |4 include/asm-um/ptrace-generic.h |3 include/asm-um/ptrace-i386.h|2 include/asm-um/ptrace-x86_64.h |2 include/asm-um/tracehook.h | 64 +++ 10 files changed, 117 insertions(+), 307 deletions(-) Index: linux-2.6.18-mm/arch/um/kernel/exec.c === --- linux-2.6.18-mm.orig/arch/um/kernel/exec.c 2007-02-21 12:53:38.0 -0500 +++ linux-2.6.18-mm/arch/um/kernel/exec.c 2007-02-21 12:53:50.0 -0500 @@ -51,7 +51,6 @@ static long execve1(char *file, char __u error = do_execve(file, argv, env, ¤t->thread.regs); if (error == 0){ task_lock(current); -current->ptrace &= ~PT_DTRACE; #ifdef SUBARCH_EXECVE1 SUBARCH_EXECVE1(¤t->thread.regs.regs); #endif Index: linux-2.6.18-mm/arch/um/kernel/process.c === --- linux-2.6.18-mm.orig/arch/um/kernel/process.c 2007-02-21 12:53:38.0 -0500 +++ linux-2.6.18-mm/arch/um/kernel/process.c2007-02-21 12:53:50.0 -0500 @@ -458,11 +458,11 @@ int singlestepping(void * t) { struct task_struct *task = t ? t : current; - if ( ! (task->ptrace & PT_DTRACE) ) - return(0); + if (!test_thread_flag(TIF_SINGLESTEP)) + return 0; if (task->thread.singlestep_syscall) - return(1); + return 1; return 2; } Index: linux-2.6.18-mm/arch/um/kernel/ptrace.c === --- linux-2.6.18-mm.orig/arch/um/kernel/ptrace.c2007-02-21 12:53:38.0 -0500 +++ linux-2.6.18-mm/arch/um/kernel/ptrace.c 2007-02-21 13:05:30.0 -0500 @@ -3,261 +3,29 @@ * Licensed under the GPL */ -#include "linux/sched.h" -#include "linux/mm.h" -#include "linux/errno.h" -#include "linux/smp_lock.h" -#include "linux/security.h" -#include "linux/ptrace.h" -#include "linux/audit.
[uml-devel] [PATCH 3/4] UML - host_info tidying
Move the host_info string from util.c to um_arch.c, where it is actually initialized and used. Also document its lack of locking. Signed-off-by: Jeff Dike <[EMAIL PROTECTED]> -- arch/um/include/os.h|2 +- arch/um/include/user_util.h |2 -- arch/um/kernel/um_arch.c|6 +- arch/um/os-Linux/util.c |8 +++- 4 files changed, 9 insertions(+), 9 deletions(-) Index: linux-2.6.17/arch/um/include/os.h === --- linux-2.6.17.orig/arch/um/include/os.h 2007-02-19 11:39:11.0 -0500 +++ linux-2.6.17/arch/um/include/os.h 2007-02-19 12:55:11.0 -0500 @@ -273,7 +273,7 @@ extern void stack_protections(unsigned l extern void task_protections(unsigned long address); extern int raw(int fd); extern void setup_machinename(char *machine_out); -extern void setup_hostinfo(void); +extern void setup_hostinfo(char *buf, int len); extern int setjmp_wrapper(void (*proc)(void *, void *), ...); /* time.c */ Index: linux-2.6.17/arch/um/include/user_util.h === --- linux-2.6.17.orig/arch/um/include/user_util.h 2007-02-19 12:52:22.0 -0500 +++ linux-2.6.17/arch/um/include/user_util.h2007-02-19 12:55:36.0 -0500 @@ -36,8 +36,6 @@ extern unsigned long end_vm; extern unsigned long start_vm; extern unsigned long long highmem; -extern char host_info[]; - extern char saved_command_line[]; extern unsigned long _stext, _etext, _sdata, _edata, __bss_start, _end; Index: linux-2.6.17/arch/um/kernel/um_arch.c === --- linux-2.6.17.orig/arch/um/kernel/um_arch.c 2007-02-19 12:53:54.0 -0500 +++ linux-2.6.17/arch/um/kernel/um_arch.c 2007-02-19 12:55:11.0 -0500 @@ -17,6 +17,7 @@ #include "linux/seq_file.h" #include "linux/delay.h" #include "linux/module.h" +#include "linux/utsname.h" #include "asm/page.h" #include "asm/pgtable.h" #include "asm/ptrace.h" @@ -68,6 +69,9 @@ unsigned long thread_saved_pc(struct tas task)); } +/* Changed in setup_arch, which is called in early boot */ +static char host_info[(__NEW_UTS_LEN + 1) * 5]; + static int show_cpuinfo(struct seq_file *m, void *v) { int index = 0; @@ -483,7 +487,7 @@ void __init setup_arch(char **cmdline_p) paging_init(); strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); *cmdline_p = command_line; - setup_hostinfo(); + setup_hostinfo(host_info, sizeof host_info); } void __init check_bugs(void) Index: linux-2.6.17/arch/um/os-Linux/util.c === --- linux-2.6.17.orig/arch/um/os-Linux/util.c 2007-02-19 11:39:09.0 -0500 +++ linux-2.6.17/arch/um/os-Linux/util.c2007-02-19 12:55:11.0 -0500 @@ -96,15 +96,13 @@ void setup_machinename(char *machine_out strcpy(machine_out, host.machine); } -char host_info[(_UTSNAME_LENGTH + 1) * 4 + _UTSNAME_NODENAME_LENGTH + 1]; - -void setup_hostinfo(void) +void setup_hostinfo(char *buf, int len) { struct utsname host; uname(&host); - sprintf(host_info, "%s %s %s %s %s", host.sysname, host.nodename, - host.release, host.version, host.machine); + snprintf(buf, len, "%s %s %s %s %s", host.sysname, host.nodename, +host.release, host.version, host.machine); } int setjmp_wrapper(void (*proc)(void *, void *), ...) - 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-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] [PATCH 4/4] UML - lock host ldt retrieval
Add some locking to host_ldt_entries to prevent racing when reading LDT information from the host. Also fixed some style violations. Signed-off-by: Jeff Dike <[EMAIL PROTECTED]> -- arch/um/sys-i386/ldt.c | 29 +++-- 1 file changed, 19 insertions(+), 10 deletions(-) Index: linux-2.6.18-mm/arch/um/sys-i386/ldt.c === --- linux-2.6.18-mm.orig/arch/um/sys-i386/ldt.c 2007-01-14 17:29:35.0 +1100 +++ linux-2.6.18-mm/arch/um/sys-i386/ldt.c 2007-01-15 17:03:25.0 +1100 @@ -7,6 +7,7 @@ #include "linux/slab.h" #include "linux/types.h" #include "linux/errno.h" +#include "linux/spinlock.h" #include "asm/uaccess.h" #include "asm/smp.h" #include "asm/ldt.h" @@ -386,15 +387,20 @@ static long do_modify_ldt_skas(int func, return ret; } -short dummy_list[9] = {0, -1}; -short * host_ldt_entries = NULL; +static DEFINE_SPINLOCK(host_ldt_lock); +static short dummy_list[9] = {0, -1}; +static short * host_ldt_entries = NULL; -void ldt_get_host_info(void) +static void ldt_get_host_info(void) { long ret; struct ldt_entry * ldt; int i, size, k, order; + spin_lock(&host_ldt_lock); + if(host_ldt_entries != NULL) + goto out_unlock; + host_ldt_entries = dummy_list+1; for(i = LDT_PAGES_MAX-1, order=0; i; i>>=1, order++); @@ -402,8 +408,9 @@ void ldt_get_host_info(void) ldt = (struct ldt_entry *) __get_free_pages(GFP_KERNEL|__GFP_ZERO, order); if(ldt == NULL) { - printk("ldt_get_host_info: couldn't allocate buffer for host ldt\n"); - return; + printk("ldt_get_host_info: couldn't allocate buffer for host " + "ldt\n"); + goto out_unlock; } ret = modify_ldt(0, ldt, (1
[uml-devel] [PATCH 1/4] UML - delete unused code
Get rid of a bunch of unused stuff - cpu_feature had no users linux_prog is little-used, so its declaration is moved to the user for easy deletion when the whole file goes away a long-unused debugging aid in helper.c is gone Signed-off-by: Jeff Dike <[EMAIL PROTECTED]> -- arch/um/include/kern_util.h |1 - arch/um/include/user_util.h |1 - arch/um/kernel/tt/gdb.c |2 ++ arch/um/os-Linux/helper.c | 11 --- arch/um/os-Linux/main.c |8 +--- arch/um/sys-i386/bugs.c | 23 --- arch/um/sys-x86_64/bugs.c | 23 --- 7 files changed, 3 insertions(+), 66 deletions(-) Index: linux-2.6.17/arch/um/include/user_util.h === --- linux-2.6.17.orig/arch/um/include/user_util.h 2007-02-19 11:39:11.0 -0500 +++ linux-2.6.17/arch/um/include/user_util.h2007-02-19 12:52:22.0 -0500 @@ -62,7 +62,6 @@ extern void kill_child_dead(int pid); extern int cont(int pid); extern void check_sigio(void); extern void arch_check_bugs(void); -extern int cpu_feature(char *what, char *buf, int len); extern int arch_handle_signal(int sig, union uml_pt_regs *regs); extern int arch_fixup(unsigned long address, void *sc_ptr); extern void arch_init_thread(void); Index: linux-2.6.17/arch/um/sys-i386/bugs.c === --- linux-2.6.17.orig/arch/um/sys-i386/bugs.c 2006-12-02 09:56:56.0 -0500 +++ linux-2.6.17/arch/um/sys-i386/bugs.c2007-02-19 12:52:22.0 -0500 @@ -79,29 +79,6 @@ static int find_cpuinfo_line(int fd, cha return(0); } -int cpu_feature(char *what, char *buf, int len) -{ - int fd, ret = 0; - - fd = os_open_file("/proc/cpuinfo", of_read(OPENFLAGS()), 0); - if(fd < 0){ - printk("Couldn't open /proc/cpuinfo, err = %d\n", -fd); - return(0); - } - - if(!find_cpuinfo_line(fd, what, buf, len)){ - printk("Couldn't find '%s' line in /proc/cpuinfo\n", what); - goto out_close; - } - - token(fd, buf, len, '\n'); - ret = 1; - - out_close: - os_close_file(fd); - return(ret); -} - static int check_cpu_flag(char *feature, int *have_it) { char buf[MAXTOKEN], c; Index: linux-2.6.17/arch/um/sys-x86_64/bugs.c === --- linux-2.6.17.orig/arch/um/sys-x86_64/bugs.c 2006-06-17 21:49:35.0 -0400 +++ linux-2.6.17/arch/um/sys-x86_64/bugs.c 2007-02-19 12:52:22.0 -0500 @@ -88,29 +88,6 @@ static int find_cpuinfo_line(int fd, cha return(0); } -int cpu_feature(char *what, char *buf, int len) -{ - int fd, ret = 0; - - fd = os_open_file("/proc/cpuinfo", of_read(OPENFLAGS()), 0); - if(fd < 0){ - printk("Couldn't open /proc/cpuinfo, err = %d\n", -fd); - return(0); - } - - if(!find_cpuinfo_line(fd, what, buf, len)){ - printk("Couldn't find '%s' line in /proc/cpuinfo\n", what); - goto out_close; - } - - token(fd, buf, len, '\n'); - ret = 1; - - out_close: - os_close_file(fd); - return(ret); -} - /* 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 Index: linux-2.6.17/arch/um/include/kern_util.h === --- linux-2.6.17.orig/arch/um/include/kern_util.h 2007-02-19 11:39:11.0 -0500 +++ linux-2.6.17/arch/um/include/kern_util.h2007-02-19 12:52:22.0 -0500 @@ -23,7 +23,6 @@ struct kern_handlers { extern const struct kern_handlers handlinfo_kern; extern int ncpus; -extern char *linux_prog; extern char *gdb_init; extern int kmalloc_ok; extern int jail; Index: linux-2.6.17/arch/um/kernel/tt/gdb.c === --- linux-2.6.17.orig/arch/um/kernel/tt/gdb.c 2006-06-17 21:49:35.0 -0400 +++ linux-2.6.17/arch/um/kernel/tt/gdb.c2007-02-19 12:52:22.0 -0500 @@ -115,6 +115,8 @@ struct gdb_data { int err; }; +extern char *linux_prog; + static void config_gdb_cb(void *arg) { struct gdb_data *data = arg; Index: linux-2.6.17/arch/um/os-Linux/main.c === --- linux-2.6.17.orig/arch/um/os-Linux/main.c 2007-02-19 11:39:08.0 -0500 +++ linux-2.6.17/arch/um/os-Linux/main.c2007-02-19 12:52:22.0 -0500 @@ -25,12 +25,7 @@ #include "os.h" #include "um_malloc.h" -/* Set in set_stklim, which is called from main and __wrap_malloc. - * __wrap_malloc only calls it if main hasn't started. - */ -unsigned long stacksizelim; - -/* Set in main */ +/*
[uml-devel] [PATCH 0/4] UML - more cleanups
These are 2.6.21 material, nothing urgent. Jeff - 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-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] [PATCH 2/4] UML - formatting fixes
Formatting fixes - style violations whitespace breakage emacs formatting comment removal Signed-off-by: Jeff Dike <[EMAIL PROTECTED]> -- arch/um/kernel/um_arch.c | 51 +-- arch/um/os-Linux/main.c | 11 + arch/um/sys-i386/bugs.c | 54 -- arch/um/sys-x86_64/bugs.c | 34 ++-- 4 files changed, 67 insertions(+), 83 deletions(-) Index: linux-2.6.17/arch/um/kernel/um_arch.c === --- linux-2.6.17.orig/arch/um/kernel/um_arch.c 2007-02-19 11:39:10.0 -0500 +++ linux-2.6.17/arch/um/kernel/um_arch.c 2007-02-19 12:53:54.0 -0500 @@ -64,8 +64,8 @@ struct cpuinfo_um boot_cpu_data = { unsigned long thread_saved_pc(struct task_struct *task) { - return(os_process_pc(CHOOSE_MODE_PROC(thread_pid_tt, thread_pid_skas, - task))); + return os_process_pc(CHOOSE_MODE_PROC(thread_pid_tt, thread_pid_skas, + task)); } static int show_cpuinfo(struct seq_file *m, void *v) @@ -87,7 +87,7 @@ static int show_cpuinfo(struct seq_file loops_per_jiffy/(50/HZ), (loops_per_jiffy/(5000/HZ)) % 100); - return(0); + return 0; } static void *c_start(struct seq_file *m, loff_t *pos) @@ -213,12 +213,12 @@ __uml_setup("debug", no_skas_debug_setup #ifdef CONFIG_SMP static int __init uml_ncpus_setup(char *line, int *add) { - if (!sscanf(line, "%d", &ncpus)) { - printf("Couldn't parse [%s]\n", line); - return -1; - } + if (!sscanf(line, "%d", &ncpus)) { + printf("Couldn't parse [%s]\n", line); + return -1; + } - return 0; + return 0; } __uml_setup("ncpus=", uml_ncpus_setup, @@ -235,7 +235,7 @@ static int force_tt = 0; static int __init mode_tt_setup(char *line, int *add) { force_tt = 1; - return(0); + return 0; } #else @@ -246,7 +246,7 @@ static int __init mode_tt_setup(char *li static int __init mode_tt_setup(char *line, int *add) { printf("CONFIG_MODE_TT disabled - 'mode=tt' ignored\n"); - return(0); + return 0; } #else @@ -257,7 +257,7 @@ static int __init mode_tt_setup(char *li static int __init mode_tt_setup(char *line, int *add) { printf("CONFIG_MODE_SKAS disabled - 'mode=tt' redundant\n"); - return(0); + return 0; } #endif @@ -275,16 +275,15 @@ int mode_tt = DEFAULT_TT; static int __init Usage(char *line, int *add) { - const char **p; + const char **p; printf(usage_string, init_utsname()->release); - p = &__uml_help_start; - while (p < &__uml_help_end) { - printf("%s", *p); - p++; - } + p = &__uml_help_start; + while (p < &__uml_help_end) { + printf("%s", *p); + p++; + } exit(0); - return 0; } @@ -380,8 +379,8 @@ int linux_main(int argc, char **argv) set_task_sizes_skas, &task_size); /* -* Setting up handlers to 'sig_info' struct -*/ +* Setting up handlers to 'sig_info' struct +*/ os_fill_handlinfo(handlinfo_kern); brk_start = (unsigned long) sbrk(0); @@ -408,7 +407,7 @@ int linux_main(int argc, char **argv) argv1_begin = argv[1]; argv1_end = &argv[1][strlen(argv[1])]; #endif - + highmem = 0; iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK; max_physmem = get_kmem_end() - uml_physmem - iomem_size - MIN_VMALLOC; @@ -450,12 +449,12 @@ int linux_main(int argc, char **argv) printf("Kernel virtual memory size shrunk to %lu bytes\n", virtmem_size); - uml_postsetup(); + uml_postsetup(); task_protections((unsigned long) &init_thread_info); os_flush_stdout(); - return(CHOOSE_MODE(start_uml_tt(), start_uml_skas())); + return CHOOSE_MODE(start_uml_tt(), start_uml_skas()); } extern int uml_exitcode; @@ -468,7 +467,7 @@ static int panic_exit(struct notifier_bl bust_spinlocks(0); uml_exitcode = 1; machine_halt(); - return(0); + return 0; } static struct notifier_block panic_exit_notifier = { @@ -483,14 +482,14 @@ void __init setup_arch(char **cmdline_p) &panic_exit_notifier); paging_init(); strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); - *cmdline_p = command_line; + *cmdline_p = command_line; setup_hostinfo(); } void __init check_bugs(void) { arch_check_bugs(); - os_check_bugs(); + os_check_bugs(); } void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
Re: [uml-devel] [PATCH 4/4] UML - lock host ldt retrieval
On Wednesday 21 February 2007 21:25, Jeff Dike wrote: > Add some locking to host_ldt_entries to prevent racing when reading > LDT information from the host. Please remove GFP_KERNEL allocation under spin_lock - simplest way is using a mutex unless this can be important for performance. > @@ -386,15 +387,20 @@ static long do_modify_ldt_skas(int func, > return ret; > } > > -short dummy_list[9] = {0, -1}; > -short * host_ldt_entries = NULL; > +static DEFINE_SPINLOCK(host_ldt_lock); > +static short dummy_list[9] = {0, -1}; > +static short * host_ldt_entries = NULL; > > -void ldt_get_host_info(void) > +static void ldt_get_host_info(void) > { > long ret; > struct ldt_entry * ldt; > int i, size, k, order; > > + spin_lock(&host_ldt_lock); > + if(host_ldt_entries != NULL) > + goto out_unlock; > + > host_ldt_entries = dummy_list+1; > > for(i = LDT_PAGES_MAX-1, order=0; i; i>>=1, order++); > @@ -402,8 +408,9 @@ void ldt_get_host_info(void) > ldt = (struct ldt_entry *) > __get_free_pages(GFP_KERNEL|__GFP_ZERO, order); > if(ldt == NULL) { > - printk("ldt_get_host_info: couldn't allocate buffer for host > ldt\n"); > - return; > + printk("ldt_get_host_info: couldn't allocate buffer for host " > +"ldt\n"); > + goto out_unlock; > } > > ret = modify_ldt(0, ldt, (1< @@ -428,7 +435,8 @@ void ldt_get_host_info(void) > size = (size + 1) * sizeof(dummy_list[0]); > host_ldt_entries = kmalloc(size, GFP_KERNEL); > if(host_ldt_entries == NULL) { > - printk("ldt_get_host_info: couldn't allocate host ldt > list\n"); > + printk("ldt_get_host_info: couldn't allocate host ldt " > +"list\n"); > goto out_free; > } > } > @@ -442,6 +450,8 @@ void ldt_get_host_info(void) > > out_free: > free_pages((unsigned long)ldt, order); > +out_unlock: > + spin_unlock(&host_ldt_lock); > } > > long init_new_ldt(struct mmu_context_skas * new_mm, > @@ -480,8 +490,7 @@ long init_new_ldt(struct mmu_context_ska >* inherited from the host. All ldt-entries found >* will be reset in the following loop >*/ > - if(host_ldt_entries == NULL) > - ldt_get_host_info(); > + ldt_get_host_info(); > for(num_p=host_ldt_entries; *num_p != -1; num_p++){ > desc.entry_number = *num_p; > err = write_ldt_entry(&new_mm->id, 1, &desc, > @@ -560,6 +569,6 @@ void free_ldt(struct mmu_context_skas * > > int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount) > { > - return(CHOOSE_MODE_PROC(do_modify_ldt_tt, do_modify_ldt_skas, func, > - ptr, bytecount)); > + return CHOOSE_MODE_PROC(do_modify_ldt_tt, do_modify_ldt_skas, func, > + ptr, bytecount); > } > > > - > 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-devel mailing list > User-mode-linux-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel -- Inform me of my mistakes, so I can add them to my list! Paolo Giarrusso, aka Blaisorblade http://www.user-mode-linux.org/~blaisorblade Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com - 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-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] When opening /tmp/uml.ctl fails, what do we get?
I started uml_daemon as root by mistake, so /tmp/uml.ctl even if /dev/net/tun was world-readable. Ok, I did it. This is the result (after trying many times to do 'ifconfig eth0 up' inside UML): [42949710.29] Choosing a random ethernet address for device eth0 [42949710.29] Netdevice 0 (3a:9d:6f:12:83:b2) : daemon backend (uml_switch version 3) - unix:/tmp/uml.ctl [42949710.29] daemon_open : control connect failed, errno = 13 (13 = EPERM) [42949720.36] Registering fd 0 twice [42949720.36] Irqs : 2, 5 [42949720.36] Ids : 0x61a795f8, 0x61d181c0 [42949720.36] uml_net_open: failed to get irq(-12) (-12 is -ENOMEM, not -13 + 1, but is caused by 'registering XXX twice'). [42949720.36] Registering fd 0 twice [42949720.36] Irqs : 2, 5 [42949720.36] Ids : 0x61a795f8, 0x61d181c0 [42949720.36] uml_net_open: failed to get irq(-12) Looking into the code, I saw that: 1) daemon_user_init is confusing because it saved any error into pri->fd, instead of returning it to the caller. Also, it would make sense to move this into daemon_open. 2) connect_to_switch uses the same errno twice - it shouldn't, and we're hitting this. um_interrupt is called with fd => 0 because errno is cleared after printk (verified under debugging, I did not trace it fully to where it's changing but it's sufficient for a patch anyway). -- Inform me of my mistakes, so I can add them to my list! Paolo Giarrusso, aka Blaisorblade http://www.user-mode-linux.org/~blaisorblade Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com - 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-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Re: [uml-devel] [PATCH 2/3] UML - x86_64 thread fixes
On Thursday 08 February 2007 22:57, Jeff Dike wrote: > x86_64 needs some TLS fixes. What was missing was remembering the > child thread id during clone and stuffing it into the child during > each context switch. > > The %fs value is stored separately in the thread structure since the > host controls what effect it has on the actual register file. The > host also needs to store it in its own thread struct, so we need the > value kept outside the register file. Is there any reason for avoiding this treatment to %gs, apart that TLS code usually does not need it, even if the API allows for it to exist? I _do_ believe this patch fixes bug which can be tested (not verified everything), even if I wonder why you didn't look at the patch I sent to you time ago (I hadn't finished it, in truth, but there was most stuff - it had problems I couldn't debug at that time). -- Inform me of my mistakes, so I can add them to my list! Paolo Giarrusso, aka Blaisorblade http://www.user-mode-linux.org/~blaisorblade Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com - 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-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Re: [uml-devel] [PATCH] UML - Fix 2.6.20 hang
On Thursday 15 February 2007 18:07, Jeff Dike wrote: > Signed-off-by: Jeff Dike <[EMAIL PROTECTED]> [...] > @@ -331,10 +334,9 @@ void maybe_sigio_broken(int fd, int read > > sigio_lock(); > err = need_poll(&all_sigio_fds, all_sigio_fds.used + 1); > - if(err){ > - printk("maybe_sigio_broken - failed to add pollfd\n"); > + if(err) > goto out; > - } > + > all_sigio_fds.poll[all_sigio_fds.used++] = > ((struct pollfd) { .fd = fd, > .events = read ? POLLIN : POLLOUT, > Was that removal wanted or it happened by mistake? That way, err is completely lost. -- Inform me of my mistakes, so I can add them to my list! Paolo Giarrusso, aka Blaisorblade http://www.user-mode-linux.org/~blaisorblade Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com - 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-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel