Skip to contentSkip to conversation

um: fix UML_LIB_PATH

PATCH In review Richard Weinberger 3 participants 10 messages May 22, 2011 – May 24, 2011

Subsystems (3)
lore
Share & tools
lore

Richard Weinberger

author maintainer
#0 lore raw

PATCH 1/7 um: fix UML_LIB_PATH

UML_LIB_PATH is hardcoded to /usr/lib/uml/,
on 64bit systems UML_LIB_PATH needs to be /usr/lib64/uml/.

---
 arch/um/drivers/xterm.c     |    2 +-
 arch/um/include/shared/os.h |    6 ++++++
 arch/um/os-Linux/main.c     |    2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)
arch/um/drivers/xterm.c +1 -1
index da2caa5..8ac7146 100644
@@ -90,7 +90,7 @@ static int xterm_open(int input, int output, int primary, void *d,
 	int pid, fd, new, err;
 	char title[256], file[] = "/tmp/xterm-pipeXXXXXX";
 	char *argv[] = { terminal_emulator, title_switch, title, exec_switch,
-			 "/usr/lib/uml/port-helper", "-uml-socket",
+			 OS_LIB_PATH "/uml/port-helper", "-uml-socket",
 			 file, NULL };
 
 	if (access(argv[4], X_OK) < 0)
arch/um/include/shared/os.h +6 -0
index c4617ba..f06a5da 100644
@@ -29,6 +29,12 @@
 #define OS_ACC_R_OK    4       /* Test for read permission.  */
 #define OS_ACC_RW_OK   (OS_ACC_W_OK | OS_ACC_R_OK) /* Test for RW permission */
 
+#ifdef CONFIG_64BIT
+#define OS_LIB_PATH	"/usr/lib64/"
+#else
+#define OS_LIB_PATH	"/usr/lib/"
+#endif
+
 /*
  * types taken from stat_file() in hostfs_user.c
  * (if they are wrong here, they are wrong there...).
arch/um/os-Linux/main.c +1 -1
index eee69b9..39613ea 100644
@@ -78,7 +78,7 @@ static void install_fatal_handler(int sig)
 	}
 }
 
-#define UML_LIB_PATH	":/usr/lib/uml"
+#define UML_LIB_PATH	":" OS_LIB_PATH "/uml"
 
 static void setup_env_path(void)
 {
Signature · 1 line
1.7.4.2
author maintainer
#1 lore raw

PATCH 2/7 um: remove SIGHUP handler

The UML kernel ignores SIGHUP anyway.
This handler is in vain.

---
 arch/um/os-Linux/main.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
arch/um/os-Linux/main.c +0 -1
index 39613ea..fb2a97a 100644
@@ -142,7 +142,6 @@ int __init main(int argc, char **argv, char **envp)
 	 */
 	install_fatal_handler(SIGINT);
 	install_fatal_handler(SIGTERM);
-	install_fatal_handler(SIGHUP);
 
 	scan_elf_aux(envp);
 
Signature · 13 lines
1.7.4.2


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
author maintainer
#2 lore raw

PATCH 3/7 um: add earlyprintk support

In reply to Richard Weinberger

User Mode Linux can also benefit from earlyprintk. UML's earlyprintk writes kernel messages directly to stdout.

---
 arch/um/Kconfig.debug         |   10 ++++++++++
 arch/um/include/shared/os.h   |    1 +
 arch/um/kernel/Makefile       |    1 +
 arch/um/kernel/early_printk.c |   33 +++++++++++++++++++++++++++++++++
 arch/um/os-Linux/util.c       |    5 +++++
 5 files changed, 50 insertions(+), 0 deletions(-)
 create mode 100644 arch/um/kernel/early_printk.c
arch/um/Kconfig.debug +10 -0
index 8fce5e5..85c86edd 100644
@@ -37,4 +37,14 @@ config DEBUG_STACK_USAGE
 	  stack seen so far.
 
 	  This option will slow down process creation and destruction somewhat.
+
+config EARLY_PRINTK
+	bool "Early printk"
+	default y
+	---help---
+	  Write kernel log output directly to stdout.
+
+	  This is useful for kernel debugging when your machine crashes very
+	  early before the console code is initialized.
+
 endmenu
arch/um/include/shared/os.h +1 -0
index f06a5da..83c7c2e 100644
@@ -244,6 +244,7 @@ extern int raw(int fd);
 extern void setup_machinename(char *machine_out);
 extern void setup_hostinfo(char *buf, int len);
 extern void os_dump_core(void) __attribute__ ((noreturn));
+extern void um_early_printk(const char *s, unsigned int n);
 
 /* time.c */
 extern void idle_sleep(unsigned long long nsecs);
arch/um/kernel/Makefile +1 -0
index 1119233..c4491c1 100644
@@ -17,6 +17,7 @@ obj-y = config.o exec.o exitcode.o init_task.o irq.o ksyms.o mem.o \
 obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
 obj-$(CONFIG_GPROF)	+= gprof_syms.o
 obj-$(CONFIG_GCOV)	+= gmon_syms.o
+obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
 
 USER_OBJS := config.o
 
arch/um/kernel/early_printk.c new file +33 -0
new file mode 100644
index 0000000..ec649bf
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 Richard Weinberger <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/console.h>
+#include <linux/init.h>
+#include "os.h"
+
+static void early_console_write(struct console *con, const char *s, unsigned int n)
+{
+	um_early_printk(s, n);
+}
+
+static struct console early_console = {
+	.name = "earlycon",
+	.write = early_console_write,
+	.flags = CON_BOOT,
+	.index = -1,
+};
+
+static int __init setup_early_printk(char *buf)
+{
+	register_console(&early_console);
+
+	return 0;
+}
+
+early_param("earlyprintk", setup_early_printk);
arch/um/os-Linux/util.c +5 -0
index 42827ca..5803b18 100644
@@ -139,3 +139,8 @@ void os_dump_core(void)
 
 	uml_abort();
 }
+
+void um_early_printk(const char *s, unsigned int n)
+{
+	printf("%.*s", n, s);
+}
Signature · 13 lines
1.7.4.2


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
author maintainer
#3 lore raw

PATCH 4/7 um: add ucast ethernet transport.

In reply to Richard Weinberger

From: Nolan Leake <[email protected]>

The ucast transport is similar to the mcast transport (and, in fact, shares most of its code), only it uses UDP unicast to move packets.

Obviously this is only useful for point-to-point connections between virtual ethernet devices.

---
 Documentation/virtual/uml/UserModeLinux-HOWTO.txt |   10 +
 arch/um/drivers/Makefile                          |    4 +-
 arch/um/drivers/mcast.h                           |   24 ---
 arch/um/drivers/mcast_kern.c                      |  120 -------------
 arch/um/drivers/mcast_user.c                      |  165 ------------------
 arch/um/drivers/umcast.h                          |   27 +++
 arch/um/drivers/umcast_kern.c                     |  188 +++++++++++++++++++++
 arch/um/drivers/umcast_user.c                     |  186 ++++++++++++++++++++
 8 files changed, 413 insertions(+), 311 deletions(-)
 delete mode 100644 arch/um/drivers/mcast.h
 delete mode 100644 arch/um/drivers/mcast_kern.c
 delete mode 100644 arch/um/drivers/mcast_user.c
 create mode 100644 arch/um/drivers/umcast.h
 create mode 100644 arch/um/drivers/umcast_kern.c
 create mode 100644 arch/um/drivers/umcast_user.c
Documentation/virtual/uml/UserModeLinux-HOWTO.txt +10 -0
index 9b7e190..5d0fc8b 100644
@@ -1182,6 +1182,16 @@
   forge.net/>  and explains these in detail, as well as
   some other issues.
 
+  There is also a related point-to-point only "ucast" transport.
+  This is useful when your network does not support multicast, and
+  all network connections are simple point to point links.
+
+  The full set of command line options for this transport are
+
+
+       ethn=ucast,ethernet address,remote address,listen port,remote port
+
+
 
 
   66..66..  TTUUNN//TTAAPP wwiitthh tthhee uummll__nneett hheellppeerr
arch/um/drivers/Makefile +2 -2
index 1d9b6ae..e7582e1 100644
@@ -9,7 +9,7 @@
 slip-objs := slip_kern.o slip_user.o
 slirp-objs := slirp_kern.o slirp_user.o
 daemon-objs := daemon_kern.o daemon_user.o
-mcast-objs := mcast_kern.o mcast_user.o
+umcast-objs := umcast_kern.o umcast_user.o
 net-objs := net_kern.o net_user.o
 mconsole-objs := mconsole_kern.o mconsole_user.o
 hostaudio-objs := hostaudio_kern.o
@@ -44,7 +44,7 @@ obj-$(CONFIG_UML_NET_SLIP) += slip.o slip_common.o
 obj-$(CONFIG_UML_NET_SLIRP) += slirp.o slip_common.o
 obj-$(CONFIG_UML_NET_DAEMON) += daemon.o 
 obj-$(CONFIG_UML_NET_VDE) += vde.o
-obj-$(CONFIG_UML_NET_MCAST) += mcast.o 
+obj-$(CONFIG_UML_NET_MCAST) += umcast.o
 obj-$(CONFIG_UML_NET_PCAP) += pcap.o
 obj-$(CONFIG_UML_NET) += net.o 
 obj-$(CONFIG_MCONSOLE) += mconsole.o
arch/um/drivers/mcast.h deleted +0 -24
deleted file mode 100644
index 6fa282e..0000000
@@ -1,24 +0,0 @@
-/* 
- * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
- * Licensed under the GPL
- */
-
-#ifndef __DRIVERS_MCAST_H
-#define __DRIVERS_MCAST_H
-
-#include "net_user.h"
-
-struct mcast_data {
-	char *addr;
-	unsigned short port;
-	void *mcast_addr;
-	int ttl;
-	void *dev;
-};
-
-extern const struct net_user_info mcast_user_info;
-
-extern int mcast_user_write(int fd, void *buf, int len, 
-			    struct mcast_data *pri);
-
-#endif
arch/um/drivers/mcast_kern.c deleted +0 -120

120 lines not on this page · raw message

arch/um/drivers/mcast_user.c deleted +0 -165

165 lines not on this page · raw message

arch/um/drivers/umcast.h new file +27 -0
new file mode 100644
index 0000000..6f8c0fe
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
+ * Licensed under the GPL
+ */
+
+#ifndef __DRIVERS_UMCAST_H
+#define __DRIVERS_UMCAST_H
+
+#include "net_user.h"
+
+struct umcast_data {
+	char *addr;
+	unsigned short lport;
+	unsigned short rport;
+	void *listen_addr;
+	void *remote_addr;
+	int ttl;
+	int unicast;
+	void *dev;
+};
+
+extern const struct net_user_info umcast_user_info;
+
+extern int umcast_user_write(int fd, void *buf, int len,
+			     struct umcast_data *pri);
+
+#endif
arch/um/drivers/umcast_kern.c new file +188 -0

188 lines not on this page · raw message

arch/um/drivers/umcast_user.c new file +186 -0

186 lines not on this page · raw message

Signature · 13 lines
1.7.4.2


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
author maintainer
#4 lore raw

PATCH 5/7 um: print info about fatal segfaults

In reply to Richard Weinberger

Print a short info about fatal segfaults like other archs do.

---
 arch/um/kernel/trap.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
arch/um/kernel/trap.c +24 -0
index 637c650..8c7b882 100644
@@ -113,6 +113,27 @@ out_of_memory:
 	return 0;
 }
 
+static void show_segv_info(struct uml_pt_regs *regs)
+{
+	struct task_struct *tsk = current;
+	struct faultinfo *fi = UPT_FAULTINFO(regs);
+
+	if (!unhandled_signal(tsk, SIGSEGV))
+		return;
+
+	if (!printk_ratelimit())
+		return;
+
+	printk("%s%s[%d]: segfault at %lx ip %p sp %p error %x",
+		task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG,
+		tsk->comm, task_pid_nr(tsk), FAULT_ADDRESS(*fi),
+		(void *)UPT_IP(regs), (void *)UPT_SP(regs),
+		fi->error_code);
+
+	print_vma_addr(KERN_CONT " in ", UPT_IP(regs));
+	printk(KERN_CONT "\n");
+}
+
 static void bad_segv(struct faultinfo fi, unsigned long ip)
 {
 	struct siginfo si;
@@ -141,6 +162,7 @@ void segv_handler(int sig, struct uml_pt_regs *regs)
 	struct faultinfo * fi = UPT_FAULTINFO(regs);
 
 	if (UPT_IS_USER(regs) && !SEGV_IS_FIXABLE(fi)) {
+		show_segv_info(regs);
 		bad_segv(*fi, UPT_IP(regs));
 		return;
 	}
@@ -202,6 +224,8 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
 		      address, ip);
 	}
 
+	show_segv_info(regs);
+
 	if (err == -EACCES) {
 		si.si_signo = SIGBUS;
 		si.si_errno = 0;
Signature · 13 lines
1.7.4.2


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#5 lore raw

Re: [PATCH 5/7] um: print info about fatal segfaults

Quoted 10 lines · On Sun, 22 May 2011 16:48:34 +0200 Richard Weinberger <[email protected]> wrote:
arch/um/kernel/trap.c +10 -0
+static void show_segv_info(struct uml_pt_regs *regs)
+{
+	struct task_struct *tsk = current;
+	struct faultinfo *fi = UPT_FAULTINFO(regs);
+
+	if (!unhandled_signal(tsk, SIGSEGV))
+		return;
+
+	if (!printk_ratelimit())
+		return;

arch/um/kernel/trap.c out_of_memory: · line 135

Quoted 10 lines
arch/um/kernel/trap.c +10 -0
+
+	printk("%s%s[%d]: segfault at %lx ip %p sp %p error %x",
+		task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG,
+		tsk->comm, task_pid_nr(tsk), FAULT_ADDRESS(*fi),
+		(void *)UPT_IP(regs), (void *)UPT_SP(regs),
+		fi->error_code);
+
+	print_vma_addr(KERN_CONT " in ", UPT_IP(regs));
+	printk(KERN_CONT "\n");
+}

Please see the nice comment in printk.h

/*
* Please don't use printk_ratelimit(), because it shares ratelimiting state
* with all other unrelated printk_ratelimit() callsites. Instead use
* printk_ratelimited() or plain old __ratelimit().
*/

I thought we had a checkpatch rule for this but apparently I dreamed it.

maintainer
#6 lore raw

PATCH 1/1 checkpatch: Add warning for uses of printk_ratelimit

Warn about uses of printk_ratelimit because it uses a global state and can hide subsequent useful messages.

---
 scripts/checkpatch.pl |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
scripts/checkpatch.pl +5 -0
index d867081..d1a9adc 100755
@@ -1943,6 +1943,11 @@ sub process {
 			WARN("LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr);
 		}
 
+# check for uses of printk_ratelimit
+		if ($line =~ /\bprintk_ratelimit\s*\(/) {
+			WARN("Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr);
+		}
+
 # printk should use KERN_* levels.  Note that follow on printk's on the
 # same line do not need a level, so we use the current block context
 # to try and find and validate the current printk.  In summary the current
author maintainer
#7 lore raw

Re: [PATCH 5/7] um: print info about fatal segfaults

In reply to Andrew Morton

Am Dienstag 24 Mai 2011, 21:34:33 schrieb Andrew Morton:

Quoted 10 lines

Please see the nice comment in printk.h

/*
* Please don't use printk_ratelimit(), because it shares ratelimiting
state * with all other unrelated printk_ratelimit() callsites. Instead use * printk_ratelimited() or plain old __ratelimit().
*/

I thought we had a checkpatch rule for this but apparently I dreamed it.

Hmm, it seems I'm not the only one who doesn't know that. :-\
rw@raccoon:/media/data1/linux-2.6 (master)> grep * -R -e "printk_ratelimit()" | wc -l 243

Anyway, will resend...

Thanks,
//richard

author maintainer
#8 lore raw

PATCH 6/7 um: include linux/prefetch.h

In reply to Richard Weinberger

Fix build failures on UML.

---
 arch/um/include/asm/processor-generic.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/um/include/asm/processor-generic.h +2 -0
index d1d1b0d..98d01bc 100644
@@ -14,6 +14,8 @@ struct task_struct;
 #include "registers.h"
 #include "sysdep/archsetjmp.h"
 
+#include <linux/prefetch.h>
+
 struct mm_struct;
 
 struct thread_struct {
Signature · 13 lines
1.7.4.2


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
author maintainer
#9 lore raw

PATCH 7/7 um: fix crash while os_dump_core()

In reply to Richard Weinberger

os_dump_core() emits SIGTERM to terminate all UML processes. Kernel threads have to exit on SIGTERM instead of calling last_ditch_exit().
Multiple calls to last_ditch_exit() can cause a crash.

---
 arch/um/os-Linux/process.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/um/os-Linux/process.c +1 -0
index e0477c3..0c45dc8 100644
@@ -253,6 +253,7 @@ void init_new_thread_signals(void)
 		    SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGALRM,
 		    SIGVTALRM, -1);
 	signal(SIGWINCH, SIG_IGN);
+	signal(SIGTERM, SIG_DFL);
 }
 
 int run_kernel_thread(int (*fn)(void *), void *arg, jmp_buf **jmp_ptr)
Signature · 13 lines
1.7.4.2


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel