aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorBodo Stroesser <bstroesser@fujitsu-siemens.com>2006-01-18 20:42:39 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-18 22:20:18 -0500
commit12919aa6e015dd85170fc3b1a3e10a5dfd116c72 (patch)
tree07072818e5155f55f7c9867d216725f1261ec009 /arch/um
parentea1eae75eb596e0628dc5e01d32c78b1f6b257fb (diff)
[PATCH] uml: move LDT creation
s390 doesn't have a LDT. So MM_COPY_SEGMENTS will not be supported on s390. The only user of MM_COPY_SEGMENTS is new_mm(), but that's no longer useful, as arch/sys-i386/ldt.c defines init_new_ldt(), which is called immediately after new_mm(). So we should copy host's LDT in init_new_ldt(), if /proc/mm is available, to have this subarch specific call in subarch code. Signed-off-by: Bodo Stroesser <bstroesser@fujitsu-siemens.com> Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/kernel/skas/include/skas.h2
-rw-r--r--arch/um/kernel/skas/mmu.c8
-rw-r--r--arch/um/kernel/skas/process_kern.c16
-rw-r--r--arch/um/sys-i386/ldt.c26
4 files changed, 29 insertions, 23 deletions
diff --git a/arch/um/kernel/skas/include/skas.h b/arch/um/kernel/skas/include/skas.h
index 01d489de3986..a7f7cd556f1f 100644
--- a/arch/um/kernel/skas/include/skas.h
+++ b/arch/um/kernel/skas/include/skas.h
@@ -33,7 +33,7 @@ extern int protect(struct mm_id * mm_idp, unsigned long addr,
33 unsigned long len, int r, int w, int x, int done, 33 unsigned long len, int r, int w, int x, int done,
34 void **data); 34 void **data);
35extern void user_signal(int sig, union uml_pt_regs *regs, int pid); 35extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
36extern int new_mm(int from, unsigned long stack); 36extern int new_mm(unsigned long stack);
37extern int start_userspace(unsigned long stub_stack); 37extern int start_userspace(unsigned long stub_stack);
38extern int copy_context_skas0(unsigned long stack, int pid); 38extern int copy_context_skas0(unsigned long stack, int pid);
39extern void get_skas_faultinfo(int pid, struct faultinfo * fi); 39extern void get_skas_faultinfo(int pid, struct faultinfo * fi);
diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c
index 677871f1b37c..c5c9885a8297 100644
--- a/arch/um/kernel/skas/mmu.c
+++ b/arch/um/kernel/skas/mmu.c
@@ -78,7 +78,7 @@ int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
78 struct mmu_context_skas *from_mm = NULL; 78 struct mmu_context_skas *from_mm = NULL;
79 struct mmu_context_skas *to_mm = &mm->context.skas; 79 struct mmu_context_skas *to_mm = &mm->context.skas;
80 unsigned long stack = 0; 80 unsigned long stack = 0;
81 int from_fd, ret = -ENOMEM; 81 int ret = -ENOMEM;
82 82
83 if(skas_needs_stub){ 83 if(skas_needs_stub){
84 stack = get_zeroed_page(GFP_KERNEL); 84 stack = get_zeroed_page(GFP_KERNEL);
@@ -108,11 +108,7 @@ int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
108 from_mm = &current->mm->context.skas; 108 from_mm = &current->mm->context.skas;
109 109
110 if(proc_mm){ 110 if(proc_mm){
111 if(from_mm) 111 ret = new_mm(stack);
112 from_fd = from_mm->id.u.mm_fd;
113 else from_fd = -1;
114
115 ret = new_mm(from_fd, stack);
116 if(ret < 0){ 112 if(ret < 0){
117 printk("init_new_context_skas - new_mm failed, " 113 printk("init_new_context_skas - new_mm failed, "
118 "errno = %d\n", ret); 114 "errno = %d\n", ret);
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c
index dc41c6dc2f34..fcddee76c7c0 100644
--- a/arch/um/kernel/skas/process_kern.c
+++ b/arch/um/kernel/skas/process_kern.c
@@ -20,7 +20,6 @@
20#include "tlb.h" 20#include "tlb.h"
21#include "kern.h" 21#include "kern.h"
22#include "mode.h" 22#include "mode.h"
23#include "proc_mm.h"
24#include "registers.h" 23#include "registers.h"
25 24
26void switch_to_skas(void *prev, void *next) 25void switch_to_skas(void *prev, void *next)
@@ -125,25 +124,14 @@ int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp,
125 124
126extern void map_stub_pages(int fd, unsigned long code, 125extern void map_stub_pages(int fd, unsigned long code,
127 unsigned long data, unsigned long stack); 126 unsigned long data, unsigned long stack);
128int new_mm(int from, unsigned long stack) 127int new_mm(unsigned long stack)
129{ 128{
130 struct proc_mm_op copy; 129 int fd;
131 int n, fd;
132 130
133 fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0); 131 fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0);
134 if(fd < 0) 132 if(fd < 0)
135 return(fd); 133 return(fd);
136 134
137 if(from != -1){
138 copy = ((struct proc_mm_op) { .op = MM_COPY_SEGMENTS,
139 .u =
140 { .copy_segments = from } } );
141 n = os_write_file(fd, &copy, sizeof(copy));
142 if(n != sizeof(copy))
143 printk("new_mm : /proc/mm copy_segments failed, "
144 "err = %d\n", -n);
145 }
146
147 if(skas_needs_stub) 135 if(skas_needs_stub)
148 map_stub_pages(fd, CONFIG_STUB_CODE, CONFIG_STUB_DATA, stack); 136 map_stub_pages(fd, CONFIG_STUB_CODE, CONFIG_STUB_DATA, stack);
149 137
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
index 17746b4c08ff..0cdfd4481d5e 100644
--- a/arch/um/sys-i386/ldt.c
+++ b/arch/um/sys-i386/ldt.c
@@ -16,6 +16,8 @@
16#include "choose-mode.h" 16#include "choose-mode.h"
17#include "kern.h" 17#include "kern.h"
18#include "mode_kern.h" 18#include "mode_kern.h"
19#include "proc_mm.h"
20#include "os.h"
19 21
20extern int modify_ldt(int func, void *ptr, unsigned long bytecount); 22extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
21 23
@@ -456,13 +458,14 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
456 int i; 458 int i;
457 long page, err=0; 459 long page, err=0;
458 void *addr = NULL; 460 void *addr = NULL;
461 struct proc_mm_op copy;
459 462
460 memset(&desc, 0, sizeof(desc));
461 463
462 if(!ptrace_ldt) 464 if(!ptrace_ldt)
463 init_MUTEX(&new_mm->ldt.semaphore); 465 init_MUTEX(&new_mm->ldt.semaphore);
464 466
465 if(!from_mm){ 467 if(!from_mm){
468 memset(&desc, 0, sizeof(desc));
466 /* 469 /*
467 * We have to initialize a clean ldt. 470 * We have to initialize a clean ldt.
468 */ 471 */
@@ -494,8 +497,26 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
494 } 497 }
495 } 498 }
496 new_mm->ldt.entry_count = 0; 499 new_mm->ldt.entry_count = 0;
500
501 goto out;
497 } 502 }
498 else if (!ptrace_ldt) { 503
504 if(proc_mm){
505 /* We have a valid from_mm, so we now have to copy the LDT of
506 * from_mm to new_mm, because using proc_mm an new mm with
507 * an empty/default LDT was created in new_mm()
508 */
509 copy = ((struct proc_mm_op) { .op = MM_COPY_SEGMENTS,
510 .u =
511 { .copy_segments =
512 from_mm->id.u.mm_fd } } );
513 i = os_write_file(new_mm->id.u.mm_fd, &copy, sizeof(copy));
514 if(i != sizeof(copy))
515 printk("new_mm : /proc/mm copy_segments failed, "
516 "err = %d\n", -i);
517 }
518
519 if(!ptrace_ldt) {
499 /* Our local LDT is used to supply the data for 520 /* Our local LDT is used to supply the data for
500 * modify_ldt(READLDT), if PTRACE_LDT isn't available, 521 * modify_ldt(READLDT), if PTRACE_LDT isn't available,
501 * i.e., we have to use the stub for modify_ldt, which 522 * i.e., we have to use the stub for modify_ldt, which
@@ -524,6 +545,7 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
524 up(&from_mm->ldt.semaphore); 545 up(&from_mm->ldt.semaphore);
525 } 546 }
526 547
548 out:
527 return err; 549 return err;
528} 550}
529 551