UML - More page fault path trimming
PATCH 2/5 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.
--
arch/um/include/os.h | 6 - arch/um/include/tlb.h | 8 - arch/um/kernel/physmem.c | 228 -------------------------------------- arch/um/kernel/skas/tlb.c | 21 +-- arch/um/kernel/tlb.c | 42 ++----- arch/um/os-Linux/skas/mem.c | 51 ++++---- arch/um/os-Linux/skas/process.c | 122 ++++++++++++-------- arch/um/os-Linux/skas/trap.c | 17 -- arch/um/sys-i386/user-offsets.c | 9 + arch/um/sys-x86_64/user-offsets.c | 5 include/asm-um/page.h | 3 include/asm-um/tlbflush.h | 24 ++-- 12 files changed, 158 insertions(+), 378 deletions(-)
arch/um/include/os.h +2 -4
@@ -300,13 +300,12 @@ extern long syscall_stub_data(struct mm_ 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, i/* 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);
arch/um/kernel/physmem.c +1 -227
244 lines not on this page · raw message
arch/um/os-Linux/skas/mem.c +29 -22
105 lines not on this page · raw message
arch/um/os-Linux/skas/process.c +74 -48
193 lines not on this page · raw message
arch/um/os-Linux/skas/trap.c +0 -17
@@ -64,20 +64,3 @@ void sig_handler_common_skas(int sig, vo errno = save_errno; r->skas.is_user = save_user; } - -extern int ptrace_faultinfo; - -void user_signal (int sig,union uml_pt_regs *regs,int pid) -{ -void (*handler)(int ,union uml_pt_regs *); -int segv = ((sig ==SIGFPE ) || (sig ==SIGSEGV ) || (sig ==SIGBUS ) || - (sig ==SIGILL ) || (sig ==SIGTRAP )); - -if (segv) -get_skas_faultinfo (pid, ®s->skas.faultinfo); - - handler = sig_info[sig]; -handler (sig, (union uml_pt_regs *) regs); - -unblock_signals (); -}
include/asm-um/page.h +0 -3
@@ -114,9 +114,6 @@ extern unsigned long uml_physmem;extern struct page *arch_validate (struct page *page,gfp_t mask,int order);#define HAVE_ARCH_VALIDATE -extern void arch_free_page (struct page *page,int order); -#define HAVE_ARCH_FREE_PAGE -#include <asm-generic/memory_model.h> #include <asm-generic/page.h>
arch/um/include/tlb.h +2 -6
@@ -14,9 +14,7 @@ struct host_vm_op {struct {unsigned long addr;unsigned long len; -unsigned int r:1 ; -unsigned int w:1 ; -unsigned int x:1 ; +unsigned int prot;int fd;__u64 offset; } mmap;
@@ -27,9 +25,7 @@ struct host_vm_op {struct {unsigned long addr;unsigned long len; -unsigned int r:1 ; -unsigned int w:1 ; -unsigned int x:1 ; +unsigned int prot; } mprotect; } u; };
arch/um/kernel/skas/tlb.c +11 -10
@@ -27,9 +27,9 @@ static int do_ops(union mm_context *mmu,switch (op->type){case MMAP : ret =map (&mmu->skas.id, op->u.mmap.addr, - op->u.mmap.len, op->u.mmap.r, op->u.mmap.w, - op->u.mmap.x, op->u.mmap.fd, - op->u.mmap.offset, finished, flush); + op->u.mmap.len, op->u.mmap.prot, + op->u.mmap.fd, op->u.mmap.offset, finished, + flush);break ;case MUNMAP : ret = unmap(&mmu->skas.id, op->u.munmap.addr,
@@ -37,8 +37,7 @@ static int do_ops(union mm_context *mmu,break ;case MPROTECT : ret =protect (&mmu->skas.id, op->u.mprotect.addr, - op->u.mprotect.len, op->u.mprotect.r, - op->u.mprotect.w, op->u.mprotect.x, + op->u.mprotect.len, op->u.mprotect.prot, finished, flush);break ;default :
@@ -102,10 +101,10 @@ void flush_tlb_page_skas(struct vm_area_pte_t *pte;struct mm_struct *mm = vma->vm_mm;void *flush =NULL ; -int r, w, x, err =0 ; +int r, w, x, prot, err =0 ;struct mm_id *mm_id; - pgd =pgd_offset (vma->vm_mm, address); + pgd =pgd_offset (mm, address);if (!pgd_present (*pgd)) goto kill;
@@ -130,19 +129,21 @@ void flush_tlb_page_skas(struct vm_area_ } mm_id = &mm->context.skas.id; + prot = ((r ?UM_PROT_READ :0 ) | (w ?UM_PROT_WRITE :0 ) | + (x ?UM_PROT_EXEC :0 ));if (pte_newpage (*pte)){if (pte_present (*pte)){unsigned long long offset;int fd; fd =phys_mapping (pte_val (*pte) &PAGE_MASK , &offset); - err =map (mm_id, address,PAGE_SIZE , r, w, x, fd, - offset,1 , &flush); + err =map (mm_id, address,PAGE_SIZE , prot, fd, offset, +1 , &flush); }else err =unmap (mm_id, address,PAGE_SIZE ,1 , &flush); }else if (pte_newprot (*pte)) - err =protect (mm_id, address,PAGE_SIZE , r, w, x,1 , &flush); + err =protect (mm_id, address,PAGE_SIZE , prot,1 , &flush);if (err) goto kill;
arch/um/kernel/tlb.c +14 -28
103 lines not on this page · raw message
arch/um/sys-i386/user-offsets.c +7 -2
@@ -1,9 +1,10 @@#include <stdio.h> +#include <stddef.h> #include <signal.h> +#include <sys/poll.h> +#include <sys/mman.h> #include <asm/ptrace.h> #include <asm/user.h> -#include <stddef.h> -#include <sys/poll.h> #define DEFINE (sym, val) \ asm volatile("\n->" #sym " %0 " #val : : "i" (val))
@@ -72,4 +73,8 @@ void foo(void)DEFINE (UM_POLLIN ,POLLIN );DEFINE (UM_POLLPRI ,POLLPRI );DEFINE (UM_POLLOUT ,POLLOUT ); + +DEFINE (UM_PROT_READ ,PROT_READ ); +DEFINE (UM_PROT_WRITE ,PROT_WRITE ); +DEFINE (UM_PROT_EXEC ,PROT_EXEC ); }
include/asm-um/tlbflush.h +13 -11
@@ -7,6 +7,7 @@#define __UM_TLBFLUSH_H#include <linux/mm.h> +#include "choose-mode.h" /* * TLB flushing:
@@ -24,6 +25,18 @@ extern void flush_tlb_all(void);extern void flush_tlb_mm (struct mm_struct *mm);extern void flush_tlb_range (struct vm_area_struct *vma,unsigned long start,unsigned long end); +extern void flush_tlb_page_skas (struct vm_area_struct *vma, +unsigned long address); + +static inline void flush_tlb_page (struct vm_area_struct *vma, +unsigned long address) +{ + address &=PAGE_MASK ; + +CHOOSE_MODE (flush_tlb_range (vma, address, address +PAGE_SIZE ), +flush_tlb_page_skas (vma, address)); +} +extern void flush_tlb_page (struct vm_area_struct *vma,unsigned long vmaddr);extern void flush_tlb_kernel_vm (void );extern void flush_tlb_kernel_range (unsigned long start,unsigned long end);
@@ -35,14 +48,3 @@ static inline void flush_tlb_pgtables(st }#endif - -/* -* Overrides for Emacs so that we follow Linus's tabbing style. -* Emacs will notice this stuff at the end of the file and automatically -* adjust the settings for this buffer only. This must remain at the end -* of the file. -* --------------------------------------------------------------------------- -* Local variables: -* c-file-style: "linux" -* End: -*/
arch/um/sys-x86_64/user-offsets.c +5 -0
@@ -2,6 +2,7 @@#include <stddef.h> #include <signal.h> #include <sys/poll.h> +#include <sys/mman.h> #define __FRAME_OFFSETS#include <asm/ptrace.h> #include <asm/types.h>
@@ -93,4 +94,8 @@ void foo(void)DEFINE (UM_POLLIN ,POLLIN );DEFINE (UM_POLLPRI ,POLLPRI );DEFINE (UM_POLLOUT ,POLLOUT ); + +DEFINE (UM_PROT_READ ,PROT_READ ); +DEFINE (UM_PROT_WRITE ,PROT_WRITE ); +DEFINE (UM_PROT_EXEC ,PROT_EXEC ); }
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel