[RFC PATCH] Address spaces as independent objects
Below is a patch which allows address spaces to be created, manipulated, and destroyed independently of processes. The additions are two system calls, new_mm and switch_mm /proc//mm PTRACE_SWITCH_MM new_mm() returns a file descriptor referencing a new address space which is a copy of the current one. switch_mm(fd, save_regs, new_regs, ip, sp) switches the current process to the address space referenced by fd. If save_regs is non-NULL, then the current registers are saved there. It must be a userspace pointer that's valid in the current address space. If new_regs is non-NULL, the registers are restored from there. It must be a userspace pointer valid in the new address space. If new_regs is NULL, then ip and sp will be used to initialize the instruction pointer and stack pointer, respectively. Opening /proc//mm gives you a descriptor referencing the address space of the given process. If you are switching temporarily to another address space and want to come back to the current one, then you need to open /proc/self/mm and use that descriptor to return. PTRACE_SWITCH_MM takes a file descriptor in data and makes the child process switch to the address space referenced by it. If you're familiar with UML, you'll recognize this stuff as what's in the host SKAS3 patch, except with a different interface. The purpose behind this is to allow UML to run more efficiently. With this patch, plus a PTRACE_GETSIGINFO extension, I get kernel build performance in the 82% - 83% range compared to native on i386. Internal interface changes - I made some previously static functions global: dup_mm - address space duplication getreg, putreg, getreg32, putreg32 - save and restore process register state The guts of this are in mm/mmfs.c, which implements a little filesystem sitting behind /proc//mm and new_mm(). Architecture support is there for 32 and 64-bit x86 and 32 bit compat on 64-bit. I want this to go into mainline, so I'd like to see it take a spin in -mm during 2.6.24 and then go into 2.6.25 if there no major problems with it. TODO - The architecture support needs work Register saving and restoring should include the FP registers Need to add /proc//task/mm In order to play with this, you'll need either this patch, which is a rolled-up patch containing both host and guest support: http://marc.info/?l=user-mode-linux-devel=120223043225099=raw or this broken-out series, of which the patch below is number 7: http://marc.info/?l=user-mode-linux-devel=120223042625081=raw http://marc.info/?l=user-mode-linux-devel=120223044925151=raw http://marc.info/?l=user-mode-linux-devel=120223040825042=raw http://marc.info/?l=user-mode-linux-devel=120223001024082=raw http://marc.info/?l=user-mode-linux-devel=120223003824164=raw http://marc.info/?l=user-mode-linux-devel=120223038325000=raw http://marc.info/?l=user-mode-linux-devel=120223005224218=raw http://marc.info/?l=user-mode-linux-devel=120223003124139=raw http://marc.info/?l=user-mode-linux-devel=120223045825168=raw http://marc.info/?l=user-mode-linux-devel=120223046325197=raw http://marc.info/?l=user-mode-linux-devel=120223005624238=raw These are against 2.6.24. Build both host and guest from this tree. Jeff -- Work email - jdike at linux dot intel dot com commit 8ebb7e2d1636f0fca44caaab936e9bfe21ae515b Author: Jeff Dike <[EMAIL PROTECTED]> Date: Mon Feb 4 15:38:02 2008 -0500 Host get_mm and switch_mm This is the new_mm, switch_mm, and /proc//mm implementation for 32- and 64-bit x86 and UML, plus 32-bit support on 64-bit x86. diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/skas_ptrace.h index cd2327d..6b55c52 100644 --- a/arch/um/include/skas_ptrace.h +++ b/arch/um/include/skas_ptrace.h @@ -7,7 +7,9 @@ #define __SKAS_PTRACE_H #define PTRACE_FAULTINFO 52 -#define PTRACE_SWITCH_MM 55 +#ifndef OLD_PTRACE_SWITCH_MM +#define OLD_PTRACE_SWITCH_MM 55 +#endif #include "sysdep/skas_ptrace.h" diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c index 47b57b4..25721bf 100644 --- a/arch/um/kernel/ptrace.c +++ b/arch/um/kernel/ptrace.c @@ -192,7 +192,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) } #endif #ifdef CONFIG_PROC_MM - case PTRACE_SWITCH_MM: { + case OLD_PTRACE_SWITCH_MM: { struct mm_struct *old = child->mm; struct mm_struct *new = proc_mm_get_mm(data); @@ -292,3 +292,14 @@ void syscall_trace(struct uml_pt_regs *regs, int entryexit) current->exit_code = 0; } } + +int ptrace_to_pt_regs(struct pt_regs *to, struct user_regs __user *from) +{ + memcpy(to, >regs, sizeof(from->regs)); + return 0; +} + +int pt_regs_to_ptrace(struct user_regs __user *to, struct pt_regs *from) +{ + return
[RFC PATCH] Address spaces as independent objects
Below is a patch which allows address spaces to be created, manipulated, and destroyed independently of processes. The additions are two system calls, new_mm and switch_mm /proc/pid/mm PTRACE_SWITCH_MM new_mm() returns a file descriptor referencing a new address space which is a copy of the current one. switch_mm(fd, save_regs, new_regs, ip, sp) switches the current process to the address space referenced by fd. If save_regs is non-NULL, then the current registers are saved there. It must be a userspace pointer that's valid in the current address space. If new_regs is non-NULL, the registers are restored from there. It must be a userspace pointer valid in the new address space. If new_regs is NULL, then ip and sp will be used to initialize the instruction pointer and stack pointer, respectively. Opening /proc/pid/mm gives you a descriptor referencing the address space of the given process. If you are switching temporarily to another address space and want to come back to the current one, then you need to open /proc/self/mm and use that descriptor to return. PTRACE_SWITCH_MM takes a file descriptor in data and makes the child process switch to the address space referenced by it. If you're familiar with UML, you'll recognize this stuff as what's in the host SKAS3 patch, except with a different interface. The purpose behind this is to allow UML to run more efficiently. With this patch, plus a PTRACE_GETSIGINFO extension, I get kernel build performance in the 82% - 83% range compared to native on i386. Internal interface changes - I made some previously static functions global: dup_mm - address space duplication getreg, putreg, getreg32, putreg32 - save and restore process register state The guts of this are in mm/mmfs.c, which implements a little filesystem sitting behind /proc/pid/mm and new_mm(). Architecture support is there for 32 and 64-bit x86 and 32 bit compat on 64-bit. I want this to go into mainline, so I'd like to see it take a spin in -mm during 2.6.24 and then go into 2.6.25 if there no major problems with it. TODO - The architecture support needs work Register saving and restoring should include the FP registers Need to add /proc/pid/task/mm In order to play with this, you'll need either this patch, which is a rolled-up patch containing both host and guest support: http://marc.info/?l=user-mode-linux-develm=120223043225099q=raw or this broken-out series, of which the patch below is number 7: http://marc.info/?l=user-mode-linux-develm=120223042625081q=raw http://marc.info/?l=user-mode-linux-develm=120223044925151q=raw http://marc.info/?l=user-mode-linux-develm=120223040825042q=raw http://marc.info/?l=user-mode-linux-develm=120223001024082q=raw http://marc.info/?l=user-mode-linux-develm=120223003824164q=raw http://marc.info/?l=user-mode-linux-develm=120223038325000q=raw http://marc.info/?l=user-mode-linux-develm=120223005224218q=raw http://marc.info/?l=user-mode-linux-develm=120223003124139q=raw http://marc.info/?l=user-mode-linux-develm=120223045825168q=raw http://marc.info/?l=user-mode-linux-develm=120223046325197q=raw http://marc.info/?l=user-mode-linux-develm=120223005624238q=raw These are against 2.6.24. Build both host and guest from this tree. Jeff -- Work email - jdike at linux dot intel dot com commit 8ebb7e2d1636f0fca44caaab936e9bfe21ae515b Author: Jeff Dike [EMAIL PROTECTED] Date: Mon Feb 4 15:38:02 2008 -0500 Host get_mm and switch_mm This is the new_mm, switch_mm, and /proc/pid/mm implementation for 32- and 64-bit x86 and UML, plus 32-bit support on 64-bit x86. diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/skas_ptrace.h index cd2327d..6b55c52 100644 --- a/arch/um/include/skas_ptrace.h +++ b/arch/um/include/skas_ptrace.h @@ -7,7 +7,9 @@ #define __SKAS_PTRACE_H #define PTRACE_FAULTINFO 52 -#define PTRACE_SWITCH_MM 55 +#ifndef OLD_PTRACE_SWITCH_MM +#define OLD_PTRACE_SWITCH_MM 55 +#endif #include sysdep/skas_ptrace.h diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c index 47b57b4..25721bf 100644 --- a/arch/um/kernel/ptrace.c +++ b/arch/um/kernel/ptrace.c @@ -192,7 +192,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) } #endif #ifdef CONFIG_PROC_MM - case PTRACE_SWITCH_MM: { + case OLD_PTRACE_SWITCH_MM: { struct mm_struct *old = child-mm; struct mm_struct *new = proc_mm_get_mm(data); @@ -292,3 +292,14 @@ void syscall_trace(struct uml_pt_regs *regs, int entryexit) current-exit_code = 0; } } + +int ptrace_to_pt_regs(struct pt_regs *to, struct user_regs __user *from) +{ + memcpy(to, from-regs, sizeof(from-regs)); + return 0; +} + +int pt_regs_to_ptrace(struct user_regs __user *to, struct
[RFC PATCH] Address spaces as independent objects
Below is a patch which allows address spaces to be created, manipulated, and destroyed independently of processes. The additions are two system calls, new_mm and switch_mm /proc//mm PTRACE_SWITCH_MM new_mm() returns a file descriptor referencing a new address space which is a copy of the current one. switch_mm(fd, flags, new_regs, save_regs) switches the current process to the address space referenced by fd. flags describes how the registers should be initialized once in the other address space. MM_ALL_REGS initializes all of the registers from new_regs. MM_SP_IP initialize only the instruction pointer and stack pointer from new_regs. If save is non-NULL, then the current registers are saved there. It must be a userspace pointer that's valid in the new address space. Opening /proc//mm gives you a descriptor referencing the address space of the given process. If you are switching temporarily to another address space and want to come back to the current one, then you need to open /proc/self/mm and use that descriptor to return. PTRACE_SWITCH_MM takes a file descriptor in data and makes the child process switch to the address space referenced by it. If you're familiar with UML, you'll recognize this stuff as what's in the host SKAS3 patch, except with a different interface. The purpose behind this is to allow UML to run more efficiently. With this patch, plus a PTRACE_GETSIGINFO extension, I get kernel build performance in the 82% - 83% range compared to native on i386. Internal interface changes - I made some previously static functions global: dup_mm - address space duplication getreg, putreg, getreg32, putreg32 - save and restore process register state The guts of this are in mm/mmfs.c, which implements a little filesystem sitting behind /proc//mm and new_mm(). Architecture support is there for 32 and 64-bit x86 and 32 bit compat on 64-bit. I want this to go into mainline, so I'd like to see it take a spin in -mm during 2.6.24 and then go into 2.6.25 if there no major problems with it. TODO - The architecture support needs work Register saving and restoring should include the FP registers Registers should be saved in the current address space Need to add /proc//task/mm In order to play with this, you'll need either this patch, which is a rolled-up patch containing both host and guest support: http://marc.info/?l=user-mode-linux-devel=120155633500396=raw or this broken-out series, of which the patch below is number 7: http://marc.info/?l=user-mode-linux-devel=120155631600315=raw http://marc.info/?l=user-mode-linux-devel=120155631700323=raw http://marc.info/?l=user-mode-linux-devel=120155634000413=raw http://marc.info/?l=user-mode-linux-devel=120155631900336=raw http://marc.info/?l=user-mode-linux-devel=120155634200425=raw http://marc.info/?l=user-mode-linux-devel=120155632800373=raw http://marc.info/?l=user-mode-linux-devel=120155635600462=raw http://marc.info/?l=user-mode-linux-devel=120155633100382=raw http://marc.info/?l=user-mode-linux-devel=120155634600430=raw http://marc.info/?l=user-mode-linux-devel=120155636000474=raw These are against 2.6.24. Build both host and guest from this tree. Jeff -- Work email - jdike at linux dot intel dot com diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/skas_ptrace.h index cd2327d..6b55c52 100644 --- a/arch/um/include/skas_ptrace.h +++ b/arch/um/include/skas_ptrace.h @@ -7,7 +7,9 @@ #define __SKAS_PTRACE_H #define PTRACE_FAULTINFO 52 -#define PTRACE_SWITCH_MM 55 +#ifndef OLD_PTRACE_SWITCH_MM +#define OLD_PTRACE_SWITCH_MM 55 +#endif #include "sysdep/skas_ptrace.h" diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c index 47b57b4..913037e 100644 --- a/arch/um/kernel/ptrace.c +++ b/arch/um/kernel/ptrace.c @@ -192,7 +192,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) } #endif #ifdef CONFIG_PROC_MM - case PTRACE_SWITCH_MM: { + case OLD_PTRACE_SWITCH_MM: { struct mm_struct *old = child->mm; struct mm_struct *new = proc_mm_get_mm(data); @@ -292,3 +292,19 @@ void syscall_trace(struct uml_pt_regs *regs, int entryexit) current->exit_code = 0; } } + +int copyin_user_regs(struct user_regs *to, unsigned long __user *from) +{ + return copy_from_user(>regs, from, sizeof(to->regs)); +} + +int ptrace_to_pt_regs(struct pt_regs *to, struct user_regs *from) +{ + memcpy(to, >regs, sizeof(from->regs)); + return 0; +} + +int pt_regs_to_ptrace(unsigned long __user *to, struct pt_regs *from) +{ + return copy_to_user(to, >regs.gp, sizeof(from->regs.gp)); +} diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 82a0780..522d0f1 100644 --- a/arch/um/os-Linux/skas/process.c
[RFC PATCH] Address spaces as independent objects
Below is a patch which allows address spaces to be created, manipulated, and destroyed independently of processes. The additions are two system calls, new_mm and switch_mm /proc/pid/mm PTRACE_SWITCH_MM new_mm() returns a file descriptor referencing a new address space which is a copy of the current one. switch_mm(fd, flags, new_regs, save_regs) switches the current process to the address space referenced by fd. flags describes how the registers should be initialized once in the other address space. MM_ALL_REGS initializes all of the registers from new_regs. MM_SP_IP initialize only the instruction pointer and stack pointer from new_regs. If save is non-NULL, then the current registers are saved there. It must be a userspace pointer that's valid in the new address space. Opening /proc/pid/mm gives you a descriptor referencing the address space of the given process. If you are switching temporarily to another address space and want to come back to the current one, then you need to open /proc/self/mm and use that descriptor to return. PTRACE_SWITCH_MM takes a file descriptor in data and makes the child process switch to the address space referenced by it. If you're familiar with UML, you'll recognize this stuff as what's in the host SKAS3 patch, except with a different interface. The purpose behind this is to allow UML to run more efficiently. With this patch, plus a PTRACE_GETSIGINFO extension, I get kernel build performance in the 82% - 83% range compared to native on i386. Internal interface changes - I made some previously static functions global: dup_mm - address space duplication getreg, putreg, getreg32, putreg32 - save and restore process register state The guts of this are in mm/mmfs.c, which implements a little filesystem sitting behind /proc/pid/mm and new_mm(). Architecture support is there for 32 and 64-bit x86 and 32 bit compat on 64-bit. I want this to go into mainline, so I'd like to see it take a spin in -mm during 2.6.24 and then go into 2.6.25 if there no major problems with it. TODO - The architecture support needs work Register saving and restoring should include the FP registers Registers should be saved in the current address space Need to add /proc/pid/task/mm In order to play with this, you'll need either this patch, which is a rolled-up patch containing both host and guest support: http://marc.info/?l=user-mode-linux-develm=120155633500396q=raw or this broken-out series, of which the patch below is number 7: http://marc.info/?l=user-mode-linux-develm=120155631600315q=raw http://marc.info/?l=user-mode-linux-develm=120155631700323q=raw http://marc.info/?l=user-mode-linux-develm=120155634000413q=raw http://marc.info/?l=user-mode-linux-develm=120155631900336q=raw http://marc.info/?l=user-mode-linux-develm=120155634200425q=raw http://marc.info/?l=user-mode-linux-develm=120155632800373q=raw http://marc.info/?l=user-mode-linux-develm=120155635600462q=raw http://marc.info/?l=user-mode-linux-develm=120155633100382q=raw http://marc.info/?l=user-mode-linux-develm=120155634600430q=raw http://marc.info/?l=user-mode-linux-develm=120155636000474q=raw These are against 2.6.24. Build both host and guest from this tree. Jeff -- Work email - jdike at linux dot intel dot com diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/skas_ptrace.h index cd2327d..6b55c52 100644 --- a/arch/um/include/skas_ptrace.h +++ b/arch/um/include/skas_ptrace.h @@ -7,7 +7,9 @@ #define __SKAS_PTRACE_H #define PTRACE_FAULTINFO 52 -#define PTRACE_SWITCH_MM 55 +#ifndef OLD_PTRACE_SWITCH_MM +#define OLD_PTRACE_SWITCH_MM 55 +#endif #include sysdep/skas_ptrace.h diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c index 47b57b4..913037e 100644 --- a/arch/um/kernel/ptrace.c +++ b/arch/um/kernel/ptrace.c @@ -192,7 +192,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) } #endif #ifdef CONFIG_PROC_MM - case PTRACE_SWITCH_MM: { + case OLD_PTRACE_SWITCH_MM: { struct mm_struct *old = child-mm; struct mm_struct *new = proc_mm_get_mm(data); @@ -292,3 +292,19 @@ void syscall_trace(struct uml_pt_regs *regs, int entryexit) current-exit_code = 0; } } + +int copyin_user_regs(struct user_regs *to, unsigned long __user *from) +{ + return copy_from_user(to-regs, from, sizeof(to-regs)); +} + +int ptrace_to_pt_regs(struct pt_regs *to, struct user_regs *from) +{ + memcpy(to, from-regs, sizeof(from-regs)); + return 0; +} + +int pt_regs_to_ptrace(unsigned long __user *to, struct pt_regs *from) +{ + return copy_to_user(to, from-regs.gp, sizeof(from-regs.gp)); +} diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 82a0780..522d0f1 100644 ---