Skip to contentSkip to conversation

Other important UML fixes for 2.6.14

PATCH New Blaisorblade 1 participant 6 messages Sep 29, 2005 User-mode Linux (UML)

lore
Share & tools
lore
#0 lore raw

cover Other important UML fixes for 2.6.14

This is what I've currently in my tree for 2.6.14. It's not enough to fix all regressions (there are still some problems on which Jeff is working right now, namely UBD and x86-64 without frame pointers).

This includes the critical fixes for my UML fault handler breakage - this time I ran a kernel compile under each UML running mode (last time I couldn't test SKAS3) with these patches.

Signature · 23 lines
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


	

	
		
___________________________________ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#1 lore raw

PATCH 1/5 Uml: fix build dependencies with KBUILD OUTPUT

From: Paolo 'Blaisorblade' Giarrusso <[email protected]>

When doing "make ARCH=um O=<path>", where <path> only contains .config, the build failed, because <path>/include2 hadn't been created. It's not supposed to work like this, at all. Since I never saw this (even with massively parallel builds - I'm accustomed to test often -j50, given that I use ccache), I suppose that after doing "make ARCH=um O=<path> *config" this wouldn't happen.

Turns out that the UML "archprepare" target failed - it depends on prepare1 which in turn would cause include2 to be created, but the failing target was listed as dependency of archprepare. And there's no specific order among dependencies, so add another dependency.

Btw, fix some clutter I found (duplicate assignments).
And add $(Q) to an ln invocation, since this patch (don't ask me why) causes $(SYMLINK_HEADERS) to be rebuilt at each "make" call.

---

 arch/um/Makefile        |    6 +++++-
 arch/um/Makefile-i386   |    2 --
 arch/um/Makefile-x86_64 |    3 ---
 3 files changed, 5 insertions(+), 6 deletions(-)
arch/um/Makefile +5 -1
@@ -111,6 +111,10 @@ else
 $(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch)
 endif
 
+# archprepare depends on prepare1. But we need that all these are made *after* prepare1.
+# Otherwise, for instance, we may miss include2.
+$(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS): prepare1
+
 archprepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS)
 
 LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
@@ -161,7 +165,7 @@ archclean:
 $(SYMLINK_HEADERS):
 	@echo '  SYMLINK $@'
 ifneq ($(KBUILD_SRC),)
-	ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@
+	$(Q)ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@
 else
 	$(Q)cd $(TOPDIR)/$(dir $@) ; \
 	ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@)
arch/um/Makefile-i386 +0 -2
@@ -36,8 +36,6 @@ endif
 SYS_UTIL_DIR	:= $(ARCH_DIR)/sys-i386/util
 SYS_HEADERS	:= $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h
 
-prepare: $(SYS_HEADERS)
-
 $(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc
 	$(call filechk,gen_header)
 
arch/um/Makefile-x86_64 +0 -3
@@ -14,12 +14,9 @@ ELF_ARCH := i386:x86-64
 ELF_FORMAT := elf64-x86-64
 
 SYS_UTIL_DIR := $(ARCH_DIR)/sys-x86_64/util
-SYS_DIR := $(ARCH_DIR)/include/sysdep-x86_64
 
 SYS_HEADERS = $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h
 
-prepare: $(SYS_HEADERS)
-
 $(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc
 	$(call filechk,gen_header)
 

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#2 lore raw

PATCH 2/5 uml: fix page faults in SKAS3 mode.

In reply to Blaisorblade

From: Paolo 'Blaisorblade' Giarrusso <[email protected]>

I hadn't been running a SKAS3 host when testing the "uml: fix hang in TT mode on fault" patch (commit 546fe1cbf91d4d62e3849517c31a2327c992e5c5), and I didn't think enough to the missing trap_no in SKAS3 mode.

In fact, the resulting kernel doesn't work at all in SKAS3 mode.

---

 arch/um/include/sysdep-i386/sigcontext.h   |   10 +++++++++-
 arch/um/include/sysdep-x86_64/sigcontext.h |    5 ++++-
 arch/um/kernel/trap_kern.c                 |    5 ++++-
 3 files changed, 17 insertions(+), 3 deletions(-)
arch/um/include/sysdep-i386/sigcontext.h +9 -1
@@ -6,6 +6,7 @@
 #ifndef __SYS_SIGCONTEXT_I386_H
 #define __SYS_SIGCONTEXT_I386_H
 
+#include "uml-config.h"
 #include <sysdep/sc.h>
 
 #define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
@@ -26,7 +27,14 @@
 #define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0)
 
 /* This is Page Fault */
-#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
+#define SEGV_IS_FIXABLE(fi)	((fi)->trap_no == 14)
+
+/* SKAS3 has no trap_no on i386, but get_skas_faultinfo() sets it to 0. */
+#ifdef UML_CONFIG_MODE_SKAS
+#define SEGV_MAYBE_FIXABLE(fi)	((fi)->trap_no == 0 && ptrace_faultinfo)
+#else
+#define SEGV_MAYBE_FIXABLE(fi)	0
+#endif
 
 extern unsigned long *sc_sigmask(void *sc_ptr);
 extern int sc_get_fpregs(unsigned long buf, void *sc_ptr);
arch/um/include/sysdep-x86_64/sigcontext.h +4 -1
@@ -31,7 +31,10 @@
 #define SC_START_SYSCALL(sc) do SC_RAX(sc) = -ENOSYS; while(0)
 
 /* This is Page Fault */
-#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
+#define SEGV_IS_FIXABLE(fi)	((fi)->trap_no == 14)
+
+/* No broken SKAS API, which doesn't pass trap_no, here. */
+#define SEGV_MAYBE_FIXABLE(fi)	0
 
 extern unsigned long *sc_sigmask(void *sc_ptr);
 
arch/um/kernel/trap_kern.c +4 -1
@@ -26,6 +26,9 @@
 #include "mconsole_kern.h"
 #include "mem.h"
 #include "mem_kern.h"
+#ifdef CONFIG_MODE_SKAS
+#include "skas.h"
+#endif
 
 /* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */
 int handle_page_fault(unsigned long address, unsigned long ip, 
@@ -134,7 +137,7 @@ unsigned long segv(struct faultinfo fi, 
 	else if(current->mm == NULL)
 		panic("Segfault with no mm");
 
-	if (SEGV_IS_FIXABLE(&fi))
+	if (SEGV_IS_FIXABLE(&fi) || SEGV_MAYBE_FIXABLE(&fi))
 		err = handle_page_fault(address, ip, is_write, is_user, &si.si_code);
 	else {
 		err = -EFAULT;

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#3 lore raw

PATCH 3/5 uml: clear SKAS0/3 flags when running in TT mode

In reply to Blaisorblade

From: Paolo 'Blaisorblade' Giarrusso <[email protected]>

SEGV_MAYBE_FIXABLE tests ptrace_faultinfo, and depends on it being 1 only in SKAS3 mode, while currently when running with mode=tt it will be 1 anyway. Fix this, and do the same for proc_mm.

---

 arch/um/include/os.h     |    4 ++++
 arch/um/kernel/um_arch.c |    2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)
arch/um/include/os.h +4 -0
@@ -157,6 +157,10 @@ extern int os_lock_file(int fd, int excl
 extern void os_early_checks(void);
 extern int can_do_skas(void);
 
+/* Make sure they are clear when running in TT mode. Required by
+ * SEGV_MAYBE_FIXABLE */
+#define clear_can_do_skas() do { ptrace_faultinfo = proc_mm = 0; } while (0)
+
 /* mem.c */
 extern int create_mem_file(unsigned long len);
 
arch/um/kernel/um_arch.c +2 -0
@@ -334,6 +334,8 @@ int linux_main(int argc, char **argv)
 		add_arg(DEFAULT_COMMAND_LINE);
 
 	os_early_checks();
+	if (force_tt)
+		clear_can_do_skas();
 	mode_tt = force_tt ? 1 : !can_do_skas();
 #ifndef CONFIG_MODE_TT
 	if (mode_tt) {

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#4 lore raw

PATCH 4/5 uml: revert "run mconsole "sysrq" in process context"

In reply to Blaisorblade

From: Paolo 'Blaisorblade' Giarrusso <[email protected]>

Revert commit 12ebcd73e40e09f0dfddf89e465cc0541e0ff8b1, i.e. [PATCH] uml: run mconsole "sysrq" in process context on request from Jeff Dike.

a) sysrq may be run when the scheduler is non-functioning

b) the warning I wanted to fix actually came from the fault handler run in atomic context. But I fixed that not to take the semaphore in a separate patch.

c) the fault handler is run because of a fault, and that fault was unaffected by this patch.

---

 arch/um/drivers/mconsole_user.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/um/drivers/mconsole_user.c +1 -1
@@ -23,7 +23,7 @@ static struct mconsole_command commands[
 	{ "reboot", mconsole_reboot, MCONSOLE_PROC },
 	{ "config", mconsole_config, MCONSOLE_PROC },
 	{ "remove", mconsole_remove, MCONSOLE_PROC },
-	{ "sysrq", mconsole_sysrq, MCONSOLE_PROC },
+	{ "sysrq", mconsole_sysrq, MCONSOLE_INTR },
 	{ "help", mconsole_help, MCONSOLE_INTR },
 	{ "cad", mconsole_cad, MCONSOLE_INTR },
 	{ "stop", mconsole_stop, MCONSOLE_PROC },

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#5 lore raw

PATCH 5/5 uml: remove empty hostfs_truncate method

In reply to Blaisorblade

From: Paolo 'Blaisorblade' Giarrusso <[email protected]>

Calling truncate() on hostfs spits a kernel warning "Something isn't implemented here", but it still works fine.

Indeed, hostfs i_op->truncate doesn't do anything. But hostfs_setattr() -> set_attr() correctly detects ATTR_SIZE and calls truncate() on the host. So we should be safe (using ftruncate() may be better, in case the file is unlinked on the host, but we aren't sure to have the file open for writing, and reopening it would cause the same races; plus nobody should expect UML to be so careful).

So, the warning is wrong, because the current implementation is working. Al, am I correct, and can the warning be therefore dropped?

---

 fs/hostfs/hostfs_kern.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
fs/hostfs/hostfs_kern.c +0 -7
@@ -793,11 +793,6 @@ int hostfs_rename(struct inode *from_ino
 	return(err);
 }
 
-void hostfs_truncate(struct inode *ino)
-{
-	not_implemented();
-}
-
 int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd)
 {
 	char *name;
@@ -894,7 +889,6 @@ static struct inode_operations hostfs_io
 	.rmdir		= hostfs_rmdir,
 	.mknod		= hostfs_mknod,
 	.rename		= hostfs_rename,
-	.truncate	= hostfs_truncate,
 	.permission	= hostfs_permission,
 	.setattr	= hostfs_setattr,
 	.getattr	= hostfs_getattr,
@@ -910,7 +904,6 @@ static struct inode_operations hostfs_di
 	.rmdir		= hostfs_rmdir,
 	.mknod		= hostfs_mknod,
 	.rename		= hostfs_rename,
-	.truncate	= hostfs_truncate,
 	.permission	= hostfs_permission,
 	.setattr	= hostfs_setattr,
 	.getattr	= hostfs_getattr,

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel