Commit 12919aa6 authored by Bodo Stroesser's avatar Bodo Stroesser Committed by Linus Torvalds

[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: default avatarBodo Stroesser <bstroesser@fujitsu-siemens.com>
Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ea1eae75
...@@ -33,7 +33,7 @@ extern int protect(struct mm_id * mm_idp, unsigned long addr, ...@@ -33,7 +33,7 @@ extern int protect(struct mm_id * mm_idp, unsigned long addr,
unsigned long len, int r, int w, int x, int done, unsigned long len, int r, int w, int x, int done,
void **data); void **data);
extern void user_signal(int sig, union uml_pt_regs *regs, int pid); extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
extern int new_mm(int from, unsigned long stack); extern int new_mm(unsigned long stack);
extern int start_userspace(unsigned long stub_stack); extern int start_userspace(unsigned long stub_stack);
extern int copy_context_skas0(unsigned long stack, int pid); extern int copy_context_skas0(unsigned long stack, int pid);
extern void get_skas_faultinfo(int pid, struct faultinfo * fi); extern void get_skas_faultinfo(int pid, struct faultinfo * fi);
......
...@@ -78,7 +78,7 @@ int init_new_context_skas(struct task_struct *task, struct mm_struct *mm) ...@@ -78,7 +78,7 @@ int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
struct mmu_context_skas *from_mm = NULL; struct mmu_context_skas *from_mm = NULL;
struct mmu_context_skas *to_mm = &mm->context.skas; struct mmu_context_skas *to_mm = &mm->context.skas;
unsigned long stack = 0; unsigned long stack = 0;
int from_fd, ret = -ENOMEM; int ret = -ENOMEM;
if(skas_needs_stub){ if(skas_needs_stub){
stack = get_zeroed_page(GFP_KERNEL); stack = get_zeroed_page(GFP_KERNEL);
...@@ -108,11 +108,7 @@ int init_new_context_skas(struct task_struct *task, struct mm_struct *mm) ...@@ -108,11 +108,7 @@ int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
from_mm = &current->mm->context.skas; from_mm = &current->mm->context.skas;
if(proc_mm){ if(proc_mm){
if(from_mm) ret = new_mm(stack);
from_fd = from_mm->id.u.mm_fd;
else from_fd = -1;
ret = new_mm(from_fd, stack);
if(ret < 0){ if(ret < 0){
printk("init_new_context_skas - new_mm failed, " printk("init_new_context_skas - new_mm failed, "
"errno = %d\n", ret); "errno = %d\n", ret);
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "tlb.h" #include "tlb.h"
#include "kern.h" #include "kern.h"
#include "mode.h" #include "mode.h"
#include "proc_mm.h"
#include "registers.h" #include "registers.h"
void switch_to_skas(void *prev, void *next) void 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,25 +124,14 @@ int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp,
extern void map_stub_pages(int fd, unsigned long code, extern void map_stub_pages(int fd, unsigned long code,
unsigned long data, unsigned long stack); unsigned long data, unsigned long stack);
int new_mm(int from, unsigned long stack) int new_mm(unsigned long stack)
{ {
struct proc_mm_op copy; int fd;
int n, fd;
fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0); fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0);
if(fd < 0) if(fd < 0)
return(fd); return(fd);
if(from != -1){
copy = ((struct proc_mm_op) { .op = MM_COPY_SEGMENTS,
.u =
{ .copy_segments = from } } );
n = os_write_file(fd, &copy, sizeof(copy));
if(n != sizeof(copy))
printk("new_mm : /proc/mm copy_segments failed, "
"err = %d\n", -n);
}
if(skas_needs_stub) if(skas_needs_stub)
map_stub_pages(fd, CONFIG_STUB_CODE, CONFIG_STUB_DATA, stack); map_stub_pages(fd, CONFIG_STUB_CODE, CONFIG_STUB_DATA, stack);
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "choose-mode.h" #include "choose-mode.h"
#include "kern.h" #include "kern.h"
#include "mode_kern.h" #include "mode_kern.h"
#include "proc_mm.h"
#include "os.h"
extern int modify_ldt(int func, void *ptr, unsigned long bytecount); extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
...@@ -456,13 +458,14 @@ long init_new_ldt(struct mmu_context_skas * new_mm, ...@@ -456,13 +458,14 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
int i; int i;
long page, err=0; long page, err=0;
void *addr = NULL; void *addr = NULL;
struct proc_mm_op copy;
memset(&desc, 0, sizeof(desc));
if(!ptrace_ldt) if(!ptrace_ldt)
init_MUTEX(&new_mm->ldt.semaphore); init_MUTEX(&new_mm->ldt.semaphore);
if(!from_mm){ if(!from_mm){
memset(&desc, 0, sizeof(desc));
/* /*
* We have to initialize a clean ldt. * We have to initialize a clean ldt.
*/ */
...@@ -494,8 +497,26 @@ long init_new_ldt(struct mmu_context_skas * new_mm, ...@@ -494,8 +497,26 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
} }
} }
new_mm->ldt.entry_count = 0; new_mm->ldt.entry_count = 0;
goto out;
} }
else if (!ptrace_ldt) {
if(proc_mm){
/* We have a valid from_mm, so we now have to copy the LDT of
* from_mm to new_mm, because using proc_mm an new mm with
* an empty/default LDT was created in new_mm()
*/
copy = ((struct proc_mm_op) { .op = MM_COPY_SEGMENTS,
.u =
{ .copy_segments =
from_mm->id.u.mm_fd } } );
i = os_write_file(new_mm->id.u.mm_fd, &copy, sizeof(copy));
if(i != sizeof(copy))
printk("new_mm : /proc/mm copy_segments failed, "
"err = %d\n", -i);
}
if(!ptrace_ldt) {
/* Our local LDT is used to supply the data for /* Our local LDT is used to supply the data for
* modify_ldt(READLDT), if PTRACE_LDT isn't available, * modify_ldt(READLDT), if PTRACE_LDT isn't available,
* i.e., we have to use the stub for modify_ldt, which * 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,6 +545,7 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
up(&from_mm->ldt.semaphore); up(&from_mm->ldt.semaphore);
} }
out:
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment