From b4ffb6ad8d8477b561377ca150bbbfc0db02da54 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Sun, 6 May 2007 14:50:59 -0700 Subject: 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 Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/include/os.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/um/include/os.h') diff --git a/arch/um/include/os.h b/arch/um/include/os.h index 5c74da41045..22666b4a8be 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h @@ -273,7 +273,7 @@ extern void stack_protections(unsigned long address); 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 */ -- cgit v1.2.3 From 24fa6c0832f4513ac897082d7d803970a40cc1b0 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Sun, 6 May 2007 14:51:09 -0700 Subject: uml: move remaining useful contents of user_util.h Rescue the useful contents of the soon-to-be-gone user-util.h. pty.c now gets ptsname from stdlib.h like it should have always done. CATCH_EINTR is now in os.h, although perhaps all usage should be under os-Linux at some point. get_pty is also in os.h. This patch restores the old definition of ARRAY_SIZE in user.h. This file is included only in userspace files, so there will be no conflict with the kernel's new ARRAY_SIZE. The copy of the kernel's ARRAY_SIZE and associated infrastructure is now gone. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/include/os.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'arch/um/include/os.h') diff --git a/arch/um/include/os.h b/arch/um/include/os.h index 22666b4a8be..394adcded0b 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h @@ -16,6 +16,8 @@ #include "sysdep/tls.h" #include "sysdep/archsetjmp.h" +#define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR)) + #define OS_TYPE_FILE 1 #define OS_TYPE_DIR 2 #define OS_TYPE_SYMLINK 3 @@ -341,6 +343,10 @@ extern void maybe_sigio_broken(int fd, int read); extern void sig_handler_common_skas(int sig, void *sc_ptr); extern void user_signal(int sig, union uml_pt_regs *regs, int pid); +/* sys-x86_64/prctl.c */ extern int os_arch_prctl(int pid, int code, unsigned long *addr); +/* tty.c */ +int get_pty(void); + #endif -- cgit v1.2.3 From 3d564047a5f45cb628ec72514f68076e532988f3 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Sun, 6 May 2007 14:51:32 -0700 Subject: uml: start fixing os_read_file and os_write_file This patch starts the removal of a very old, very broken piece of code. This stems from the problem of passing a userspace buffer into read() or write() on the host. If that buffer had not yet been faulted in, read and write will return -EFAULT. To avoid this problem, the solution was to fault the buffer in before the system call by touching the pages that hold the buffer by doing a copy-user of a byte to each page. This is obviously bogus, but it does usually work, in tt mode, since the kernel and process are in the same address space and userspace addresses can be accessed directly in the kernel. In skas mode, where the kernel and process are in separate address spaces, it is completely bogus because the userspace address, which is invalid in the kernel, is passed into the system call instead of the corresponding physical address, which would be valid. Here, it appears that this code, on every host read() or write(), tries to fault in a random process page. This doesn't seem to cause any correctness problems, but there is a performance impact. This patch, and the ones following, result in a 10-15% performance gain on a kernel build. This code can't be immediately tossed out because when it is, you can't log in. Apparently, there is some code in the console driver which depends on this somehow. However, we can start removing it by switching the code which does I/O using kernel addresses to using plain read() and write(). This patch introduces os_read_file_k and os_write_file_k for use with kernel buffers and converts all call locations which use obvious kernel buffers to use them. These include I/O using buffers which are local variables which are on the stack or kmalloc-ed. Later patches will handle the less obvious cases, followed by a mass conversion back to the original interface. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/include/os.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/um/include/os.h') diff --git a/arch/um/include/os.h b/arch/um/include/os.h index 394adcded0b..b463170a530 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h @@ -144,7 +144,9 @@ extern int os_mode_fd(int fd, int mode); extern int os_seek_file(int fd, __u64 offset); extern int os_open_file(char *file, struct openflags flags, int mode); extern int os_read_file(int fd, void *buf, int len); +extern int os_read_file_k(int fd, void *buf, int len); extern int os_write_file(int fd, const void *buf, int count); +extern int os_write_file_k(int fd, const void *buf, int len); extern int os_file_size(char *file, unsigned long long *size_out); extern int os_file_modtime(char *file, unsigned long *modtime); extern int os_pipe(int *fd, int stream, int close_on_exec); -- cgit v1.2.3 From 63843c265fd0e0c7894f713e0db5777560e756ae Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Sun, 6 May 2007 14:51:39 -0700 Subject: uml: dump core on panic Dump core after a panic. This will provide better debugging information than is currently available. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/include/os.h | 1 + 1 file changed, 1 insertion(+) (limited to 'arch/um/include/os.h') diff --git a/arch/um/include/os.h b/arch/um/include/os.h index b463170a530..901804db3c3 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h @@ -279,6 +279,7 @@ extern int raw(int fd); extern void setup_machinename(char *machine_out); extern void setup_hostinfo(char *buf, int len); extern int setjmp_wrapper(void (*proc)(void *, void *), ...); +extern void os_dump_core(void); /* time.c */ #define BILLION (1000 * 1000 * 1000) -- cgit v1.2.3 From a6ea4cceed18edebe1eb6001cb9e0f88cd741a6c Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Sun, 6 May 2007 14:51:43 -0700 Subject: uml: rename os_{read_write}_file_k back to os_{read_write}_file Rename os_{read_write}_file_k back to os_{read_write}_file, delete the originals and their bogus infrastructure, and fix all the callers. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/include/os.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'arch/um/include/os.h') diff --git a/arch/um/include/os.h b/arch/um/include/os.h index 901804db3c3..d6638090870 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h @@ -144,9 +144,7 @@ extern int os_mode_fd(int fd, int mode); extern int os_seek_file(int fd, __u64 offset); extern int os_open_file(char *file, struct openflags flags, int mode); extern int os_read_file(int fd, void *buf, int len); -extern int os_read_file_k(int fd, void *buf, int len); extern int os_write_file(int fd, const void *buf, int count); -extern int os_write_file_k(int fd, const void *buf, int len); extern int os_file_size(char *file, unsigned long long *size_out); extern int os_file_modtime(char *file, unsigned long *modtime); extern int os_pipe(int *fd, int stream, int close_on_exec); -- cgit v1.2.3 From 64f60841c096594b8073e408cd9b40d7d08dcfdd Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Sun, 6 May 2007 14:51:45 -0700 Subject: uml: speed page fault path Give the page fault code a specialized path. There is only one page to look at, so there's no point in going into the general page table walking code. There's only going to be one host operation, so there are no opportunities for merging. So, we go straight to the pte we want, figure out what needs doing, and do it. While I was in here, I fixed the wart where the address passed to unmap was a void *, but an unsigned long to map and protect. This gives me just under 10% on a kernel build. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/include/os.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/um/include/os.h') diff --git a/arch/um/include/os.h b/arch/um/include/os.h index d6638090870..e11bdcd8afc 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h @@ -302,7 +302,7 @@ extern long syscall_stub_data(struct mm_id * mm_idp, extern int map(struct mm_id * mm_idp, unsigned long virt, unsigned long len, int r, int w, int x, int phys_fd, unsigned long long offset, int done, void **data); -extern int unmap(struct mm_id * mm_idp, void *addr, unsigned long len, +extern int unmap(struct mm_id * mm_idp, unsigned long addr, unsigned long len, int done, void **data); extern int protect(struct mm_id * mm_idp, unsigned long addr, unsigned long len, int r, int w, int x, int done, -- cgit v1.2.3 From 16dd07bc6404c8da0bdfeb7a5cde4e4a63991c00 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Sun, 6 May 2007 14:51:48 -0700 Subject: uml: more page fault path trimming More trimming of the page fault path. Permissions are passed around in a single int rather than one bit per int. The permission values are copied from libc so that they can be passed to mmap and mprotect without any further conversion. The register sets used by do_syscall_stub and copy_context_skas0 are initialized once, at boot time, rather than once per call. wait_stub_done checks whether it is getting the signals it expects by comparing the wait status to a mask containing bits for the signals of interest rather than comparing individually to the signal numbers. It also has one check for a wait failure instead of two. The caller is expected to do the initial continue of the stub. This gets rid of an argument and some logic. The fname argument is gone, as that can be had from a stack trace. user_signal() is collapsed into userspace() as it is basically one or two lines of code afterwards. The physical memory remapping stuff is gone, as it is unused. flush_tlb_page is inlined. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/include/os.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'arch/um/include/os.h') diff --git a/arch/um/include/os.h b/arch/um/include/os.h index e11bdcd8afc..688d181b5f8 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h @@ -300,13 +300,12 @@ extern long syscall_stub_data(struct mm_id * mm_idp, unsigned long *data, int data_count, void **addr, void **stub_addr); extern int map(struct mm_id * mm_idp, unsigned long virt, - unsigned long len, int r, int w, int x, int phys_fd, + unsigned long len, int prot, int phys_fd, unsigned long long offset, int done, void **data); extern int unmap(struct mm_id * mm_idp, unsigned long addr, unsigned long len, int done, void **data); extern int protect(struct mm_id * mm_idp, unsigned long addr, - unsigned long len, int r, int w, int x, int done, - void **data); + unsigned long len, unsigned int prot, int done, void **data); /* skas/process.c */ extern int is_skas_winch(int pid, int fd, void *data); @@ -342,7 +341,6 @@ extern void maybe_sigio_broken(int fd, int read); /* skas/trap */ extern void sig_handler_common_skas(int sig, void *sc_ptr); -extern void user_signal(int sig, union uml_pt_regs *regs, int pid); /* sys-x86_64/prctl.c */ extern int os_arch_prctl(int pid, int code, unsigned long *addr); -- cgit v1.2.3