Changeset e3c762cd in mainline
- Timestamp:
- 2006-05-05T11:59:19Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- de07bcf
- Parents:
- 22cf454d
- Files:
-
- 2 added
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
r22cf454d re3c762cd 129 129 generic/src/proc/the.c \ 130 130 generic/src/syscall/syscall.c \ 131 generic/src/syscall/copy.c \ 131 132 generic/src/mm/buddy.c \ 132 133 generic/src/mm/frame.c \ -
arch/amd64/include/interrupt.h
r22cf454d re3c762cd 87 87 }; 88 88 89 static inline void istate_set_retaddr(istate_t *istate, __address retaddr) 90 { 91 istate->rip = retaddr; 92 } 93 89 94 extern void (* disable_irqs_function)(__u16 irqmask); 90 95 extern void (* enable_irqs_function)(__u16 irqmask); -
arch/amd64/src/asm_utils.S
r22cf454d re3c762cd 61 61 jmp printf 62 62 63 .global memcpy64 memcpy:65 jmp _memcpy66 67 63 .global cpuid 68 64 .global has_cpuid … … 70 66 .global read_efer_flag 71 67 .global set_efer_flag 72 68 .global memcpy 69 .global memcpy_from_uspace 70 .global memcpy_to_uspace 71 .global memcpy_from_uspace_failover_address 72 .global memcpy_to_uspace_failover_address 73 74 #define MEMCPY_DST %rdi 75 #define MEMCPY_SRC %rsi 76 #define MEMCPY_SIZE %rdx 77 78 /** 79 * Copy memory from/to userspace. 80 * 81 * This is almost conventional memcpy(). 82 * The difference is that there is a failover part 83 * to where control is returned from a page fault if 84 * the page fault occurs during copy_from_uspace() 85 * or copy_to_uspace(). 86 * 87 * @param MEMCPY_DST Destination address. 88 * @param MEMCPY_SRC Source address. 89 * @param MEMCPY_SIZE Number of bytes to copy. 90 * 91 * @retrun MEMCPY_SRC on success, 0 on failure. 92 */ 93 memcpy: 94 memcpy_from_uspace: 95 memcpy_to_uspace: 96 movq MEMCPY_SRC, %rax 97 98 movq MEMCPY_SIZE, %rcx 99 shrq $3, %rcx /* size / 8 */ 100 101 rep movsq /* copy as much as possible word by word */ 102 103 movq MEMCPY_SIZE, %rcx 104 andq $7, %rcx /* size % 8 */ 105 jz 0f 106 107 rep movsb /* copy the rest byte by byte */ 108 109 0: 110 ret /* return MEMCPY_SRC, success */ 111 112 memcpy_from_uspace_failover_address: 113 memcpy_to_uspace_failover_address: 114 xorq %rax, %rax /* return 0, failure */ 115 ret 116 73 117 ## Determine CPUID support 74 118 # -
arch/amd64/src/mm/page.c
r22cf454d re3c762cd 167 167 168 168 page = read_cr2(); 169 if ( !as_page_fault(page)) {169 if (as_page_fault(page, istate) == AS_PF_FAULT) { 170 170 print_info_errcode(n, istate); 171 171 printf("Page fault address: %llX\n", page); -
arch/ia32/include/interrupt.h
r22cf454d re3c762cd 84 84 }; 85 85 86 static inline void istate_set_retaddr(istate_t *istate, __address retaddr) 87 { 88 istate->eip = retaddr; 89 } 90 86 91 extern void (* disable_irqs_function)(__u16 irqmask); 87 92 extern void (* enable_irqs_function)(__u16 irqmask); -
arch/ia32/src/asm.S
r22cf454d re3c762cd 38 38 .global enable_l_apic_in_msr 39 39 .global interrupt_handlers 40 .global memcpy 41 .global memcpy_from_uspace 42 .global memcpy_from_uspace_failover_address 43 .global memcpy_to_uspace 44 .global memcpy_to_uspace_failover_address 45 46 47 #define MEMCPY_DST 4 48 #define MEMCPY_SRC 8 49 #define MEMCPY_SIZE 12 50 51 /** Copy memory to/from userspace. 52 * 53 * This is almost conventional memcpy(). 54 * The difference is that there is a failover part 55 * to where control is returned from a page fault 56 * if the page fault occurs during copy_from_uspace() 57 * or copy_to_uspace(). 58 * 59 * @param MEMCPY_DST(%esp) Destination address. 60 * @param MEMCPY_SRC(%esp) Source address. 61 * @param MEMCPY_SIZE(%esp) Size. 62 * 63 * @return MEMCPY_SRC(%esp) on success and 0 on failure. 64 */ 65 memcpy: 66 memcpy_from_uspace: 67 memcpy_to_uspace: 68 movl %edi, %edx /* save %edi */ 69 movl %esi, %eax /* save %esi */ 70 71 movl MEMCPY_SIZE(%esp), %ecx 72 shrl $2, %ecx /* size / 4 */ 73 74 movl MEMCPY_DST(%esp), %edi 75 movl MEMCPY_SRC(%esp), %esi 76 77 rep movsl /* copy as much as possible word by word */ 78 79 movl MEMCPY_SIZE(%esp), %ecx 80 andl $3, %ecx /* size % 4 */ 81 jz 0f 82 83 rep movsb /* copy the rest byte by byte */ 84 85 0: 86 movl %edx, %edi 87 movl %eax, %esi 88 movl MEMCPY_SRC(%esp), %eax /* MEMCPY_SRC(%esp), success */ 89 ret 90 91 /* 92 * We got here from as_page_fault() after the memory operations 93 * above had caused a page fault. 94 */ 95 memcpy_from_uspace_failover_address: 96 memcpy_to_uspace_failover_address: 97 movl %edx, %edi 98 movl %eax, %esi 99 xorl %eax, %eax /* return 0, failure */ 100 ret 40 101 41 102 ## Turn paging on -
arch/ia32/src/boot/boot.S
r22cf454d re3c762cd 35 35 #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) 36 36 37 38 39 40 41 42 43 44 45 37 .section K_TEXT_START, "ax" 46 38 … … 436 428 #endif 437 429 438 439 440 430 .section K_DATA_START, "aw", @progbits 441 442 443 431 444 432 .align 4096 -
arch/ia32/src/interrupt.c
r22cf454d re3c762cd 145 145 146 146 page = read_cr2(); 147 if ( !as_page_fault(page)) {147 if (as_page_fault(page, istate) == AS_PF_FAULT) { 148 148 PRINT_INFO_ERRCODE(istate); 149 149 printf("page fault address: %#x\n", page); -
arch/ia64/include/interrupt.h
r22cf454d re3c762cd 107 107 }; 108 108 109 static inline void istate_set_retaddr(istate_t *istate, __address retaddr) 110 { 111 /* TODO */ 112 } 113 109 114 extern void *ivt; 110 115 -
arch/ia64/src/asm.S
r22cf454d re3c762cd 31 31 .text 32 32 33 /** Copy memory from/to userspace. 34 * 35 * @param in0 Destination address. 36 * @param in1 Source address. 37 * @param in2 Number of byte to copy. 38 */ 33 39 .global memcpy 40 .global memcpy_from_uspace 41 .global memcpy_to_uspace 42 .global memcpy_from_uspace_failover_address 43 .global memcpy_to_uspace_failover_address 34 44 memcpy: 45 memcpy_from_uspace: 46 memcpy_to_uspace: 35 47 br _memcpy 48 49 memcpy_from_uspace_failover_address: 50 memcpy_to_uspace_failover_address: 51 br memcpy_from_uspace_failover_address 36 52 37 53 .global memsetb -
arch/ia64/src/mm/tlb.c
r22cf454d re3c762cd 448 448 */ 449 449 page_table_unlock(AS, true); 450 if ( !as_page_fault(va)) {450 if (as_page_fault(va, istate) == AS_PF_FAULT) { 451 451 panic("%s: va=%p, rid=%d, iip=%p\n", __FUNCTION__, istate->cr_ifa, rr.map.rid, istate->cr_iip); 452 452 } … … 494 494 */ 495 495 page_table_unlock(AS, true); 496 if ( !as_page_fault(va)) {496 if (as_page_fault(va, istate) == AS_PF_FAULT) { 497 497 panic("%s: va=%p, rid=%d, iip=%p\n", __FUNCTION__, va, rid, istate->cr_iip); 498 498 } … … 609 609 } else { 610 610 page_table_unlock(AS, true); 611 if ( !as_page_fault(va)) {611 if (as_page_fault(va, istate) == AS_PF_FAULT) { 612 612 panic("%s: va=%p, rid=%d\n", __FUNCTION__, va, rr.map.rid); 613 613 } -
arch/mips32/include/exception.h
r22cf454d re3c762cd 94 94 }; 95 95 96 static inline void istate_set_retaddr(istate_t *istate, __address retaddr) 97 { 98 /* TODO */ 99 } 100 96 101 extern void exception(istate_t *istate); 97 102 extern void tlb_refill_entry(void); -
arch/mips32/src/asm.S
r22cf454d re3c762cd 58 58 nop 59 59 60 60 61 .global memcpy 62 .global memcpy_from_uspace 63 .global memcpy_to_uspace 64 .global memcpy_from_uspace_failover_address 65 .global memcpy_to_uspace_failover_address 61 66 memcpy: 67 memcpy_from_uspace: 68 memcpy_to_uspace: 62 69 j _memcpy 63 70 nop 71 72 memcpy_from_uspace_failover_address: 73 memcpy_to_uspace_failover_address: 74 j memcpy_from_uspace_failover_address 75 nop 76 77 64 78 65 79 .macro fpu_gp_save reg ctx -
arch/mips32/src/mm/tlb.c
r22cf454d re3c762cd 45 45 static void tlb_modified_fail(istate_t *istate); 46 46 47 static pte_t *find_mapping_and_check(__address badvaddr );47 static pte_t *find_mapping_and_check(__address badvaddr, istate_t *istate, int *pfrc); 48 48 49 49 static void prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, __address pfn); … … 92 92 __address badvaddr; 93 93 pte_t *pte; 94 int pfrc; 94 95 95 96 badvaddr = cp0_badvaddr_read(); … … 101 102 page_table_lock(AS, true); 102 103 103 pte = find_mapping_and_check(badvaddr); 104 if (!pte) 105 goto fail; 104 pte = find_mapping_and_check(badvaddr, istate, &pfrc); 105 if (!pte) { 106 switch (pfrc) { 107 case AS_PF_FAULT: 108 goto fail; 109 break; 110 case AS_PF_DEFER: 111 /* 112 * The page fault came during copy_from_uspace() 113 * or copy_to_uspace(). 114 */ 115 page_table_unlock(AS, true); 116 return; 117 default: 118 panic("unexpected pfrc (%d)\n", pfrc); 119 } 120 } 106 121 107 122 /* … … 149 164 entry_hi_t hi; 150 165 pte_t *pte; 166 int pfrc; 151 167 152 168 badvaddr = cp0_badvaddr_read(); … … 171 187 } 172 188 173 pte = find_mapping_and_check(badvaddr); 174 if (!pte) 175 goto fail; 189 pte = find_mapping_and_check(badvaddr, istate, &pfrc); 190 if (!pte) { 191 switch (pfrc) { 192 case AS_PF_FAULT: 193 goto fail; 194 break; 195 case AS_PF_DEFER: 196 /* 197 * The page fault came during copy_from_uspace() 198 * or copy_to_uspace(). 199 */ 200 page_table_unlock(AS, true); 201 return; 202 default: 203 panic("unexpected pfrc (%d)\n", pfrc); 204 } 205 } 176 206 177 207 /* … … 218 248 entry_hi_t hi; 219 249 pte_t *pte; 250 int pfrc; 220 251 221 252 badvaddr = cp0_badvaddr_read(); … … 240 271 } 241 272 242 pte = find_mapping_and_check(badvaddr); 243 if (!pte) 244 goto fail; 273 pte = find_mapping_and_check(badvaddr, istate, &pfrc); 274 if (!pte) { 275 switch (pfrc) { 276 case AS_PF_FAULT: 277 goto fail; 278 break; 279 case AS_PF_DEFER: 280 /* 281 * The page fault came during copy_from_uspace() 282 * or copy_to_uspace(). 283 */ 284 page_table_unlock(AS, true); 285 return; 286 default: 287 panic("unexpected pfrc (%d)\n", pfrc); 288 } 289 } 245 290 246 291 /* … … 322 367 * 323 368 * @param badvaddr Faulting virtual address. 369 * @param istate Pointer to interrupted state. 370 * @param pfrc Pointer to variable where as_page_fault() return code will be stored. 324 371 * 325 372 * @return PTE on success, NULL otherwise. 326 373 */ 327 pte_t *find_mapping_and_check(__address badvaddr )374 pte_t *find_mapping_and_check(__address badvaddr, istate_t *istate, int *pfrc) 328 375 { 329 376 entry_hi_t hi; … … 351 398 return pte; 352 399 } else { 400 int rc; 401 353 402 /* 354 403 * Mapping not found in page tables. … … 356 405 */ 357 406 page_table_unlock(AS, true); 358 if (as_page_fault(badvaddr)) { 407 switch (rc = as_page_fault(badvaddr, istate)) { 408 case AS_PF_OK: 359 409 /* 360 410 * The higher-level page fault handler succeeded, … … 365 415 ASSERT(pte && pte->p); 366 416 return pte; 367 } else { 417 break; 418 case AS_PF_DEFER: 419 page_table_lock(AS, true); 420 *pfrc = AS_PF_DEFER; 421 return NULL; 422 break; 423 case AS_PF_FAULT: 368 424 page_table_lock(AS, true); 369 425 printf("Page fault.\n"); 426 *pfrc = AS_PF_FAULT; 370 427 return NULL; 428 break; 429 default: 430 panic("unexpected rc (%d)\n", rc); 371 431 } 372 432 -
arch/ppc32/include/exception.h
r22cf454d re3c762cd 77 77 }; 78 78 79 static inline void istate_set_retaddr(istate_t *istate, __address retaddr) 80 { 81 /* TODO */ 82 } 83 79 84 #endif -
arch/ppc32/include/interrupt.h
r22cf454d re3c762cd 30 30 #define __ppc32_INTERRUPT_H__ 31 31 32 #include <arch/exception.h> 33 32 34 #define IRQ_COUNT 1 33 35 #define IVT_ITEMS 15 -
arch/ppc32/src/asm.S
r22cf454d re3c762cd 36 36 .global memsetb 37 37 .global memcpy 38 .global memcpy_from_uspace 39 .global memcpy_to_uspace 40 .global memcpy_from_uspace_failover_address 41 .global memcpy_to_uspace_failover_address 38 42 39 43 userspace_asm: … … 234 238 235 239 memcpy: 240 memcpy_from_uspace: 241 memcpy_to_uspace: 242 236 243 srwi. r7, r5, 3 237 244 addi r6, r3, -4 … … 294 301 mtctr r7 295 302 b 1b 303 304 memcpy_from_uspace_failover_address: 305 memcpy_to_uspace_failover_address: 306 b memcpy_from_uspace_failover_address -
arch/ppc32/src/mm/tlb.c
r22cf454d re3c762cd 69 69 * 70 70 * @param badvaddr Faulting virtual address. 71 * @param istate Pointer to interrupted state. 72 * @param pfrc Pointer to variable where as_page_fault() return code will be stored. 71 73 * @return PTE on success, NULL otherwise. 72 74 * 73 75 */ 74 static pte_t *find_mapping_and_check(__address badvaddr )76 static pte_t *find_mapping_and_check(__address badvaddr, istate_t *istate, int *pfcr) 75 77 { 76 78 /* … … 85 87 return pte; 86 88 } else { 89 int rc; 90 87 91 /* 88 92 * Mapping not found in page tables. … … 90 94 */ 91 95 page_table_unlock(AS, true); 92 if (as_page_fault(badvaddr)) { 96 switch (rc = as_page_fault(badvaddr, istate)) { 97 case AS_PF_OK: 93 98 /* 94 99 * The higher-level page fault handler succeeded, … … 99 104 ASSERT((pte) && (pte->p)); 100 105 return pte; 101 } else { 106 break; 107 case AS_PF_DEFER: 108 page_table_lock(AS, true); 109 *pfcr = rc; 110 return NULL; 111 break; 112 case AS_PF_FAULT: 102 113 page_table_lock(AS, true); 103 114 printf("Page fault.\n"); 115 *pfcr = rc; 104 116 return NULL; 105 } 106 117 break; 118 default: 119 panic("unexpected rc (%d)\n", rc); 120 break; 121 } 107 122 } 108 123 } … … 140 155 __u32 hash; 141 156 __u32 i; 157 int pfcr; 142 158 143 159 if (data) { … … 155 171 page_table_lock(AS, true); 156 172 157 pte = find_mapping_and_check(badvaddr); 158 if (!pte) 159 goto fail; 173 pte = find_mapping_and_check(badvaddr, istate, &pfcr); 174 if (!pte) { 175 switch (pfcr) { 176 case AS_PF_FAULT: 177 goto fail; 178 break; 179 case AS_PF_DEFER: 180 /* 181 * The page fault came during copy_from_uspace() 182 * or copy_to_uspace(). 183 */ 184 page_table_unlock(AS, true); 185 return; 186 default: 187 panic("Unexpected pfrc (%d)\n", pfcr); 188 break; 189 } 190 } 160 191 161 192 /* Record access to PTE */ -
arch/sparc64/include/interrupt.h
r22cf454d re3c762cd 31 31 32 32 #include <typedefs.h> 33 #include <arch/types.h> 33 34 34 35 #define IRQ_COUNT 1 /* TODO */ … … 44 45 #define trap_virtual_eoi() 45 46 47 struct istate { 48 }; 49 50 static inline void istate_set_retaddr(istate_t *istate, __address retaddr) 51 { 52 /* TODO */ 53 } 54 46 55 extern void interrupt_register(int n, const char *name, iroutine f); 47 56 -
arch/sparc64/src/asm.S
r22cf454d re3c762cd 30 30 31 31 .global memcpy 32 .global memcpy_from_uspace 33 .global memcpy_to_uspace 34 .global memcpy_from_uspace_failover_address 35 .global memcpy_to_uspace_failover_address 32 36 .global memsetb 33 37 34 38 memcpy: 39 memcpy_from_uspace: 40 memcpy_to_uspace: 41 35 42 b _memcpy 43 nop 44 45 memcpy_from_uspace_failover_address: 46 memcpy_to_uspace_failover_address: 47 b memcpy_from_uspace_failover_address 36 48 nop 37 49 -
generic/include/interrupt.h
r22cf454d re3c762cd 32 32 #include <arch/interrupt.h> 33 33 #include <typedefs.h> 34 #include <arch/types.h> 34 35 35 36 #ifndef IVT_ITEMS -
generic/include/mm/as.h
r22cf454d re3c762cd 64 64 #define AS_AREA_ATTR_PARTIAL 1 /* Not fully initialized area. */ 65 65 66 #define AS_PF_FAULT 0 /**< The page fault was not resolved by asp_page_fault(). */ 67 #define AS_PF_OK 1 /**< The page fault was resolved by as_page_fault(). */ 68 #define AS_PF_DEFER 2 /**< The page fault was caused by memcpy_from_uspace(). */ 69 66 70 /** Address space area structure. 67 71 * … … 122 126 int as_area_send(task_id_t dst_id, __address base); 123 127 extern void as_set_mapping(as_t *as, __address page, __address frame); 124 extern int as_page_fault(__address page );128 extern int as_page_fault(__address page, istate_t *istate); 125 129 extern void as_switch(as_t *old, as_t *new); 126 130 extern void as_free(as_t *as); -
generic/include/mm/page.h
r22cf454d re3c762cd 61 61 #define PAGE_GLOBAL (1<<PAGE_GLOBAL_SHIFT) 62 62 63 /* TODO - check that userspace is OK, platform specific functions etc */64 static inline void copy_to_uspace(void *dst, void *src, count_t cnt)65 {66 memcpy(dst, src, cnt);67 }68 69 static inline void copy_from_uspace(void *dst, void *src, count_t cnt)70 {71 memcpy(dst, src, cnt);72 }73 74 63 /** Operations to manipulate page mappings. */ 75 64 struct page_mapping_operations { -
generic/include/proc/thread.h
r22cf454d re3c762cd 92 92 volatile int timeout_pending; /**< Flag signalling sleep timeout in progress. */ 93 93 94 /** True if this thread is executing copy_from_uspace(). False otherwise. */ 95 bool in_copy_from_uspace; 96 /** True if this thread is executing copy_to_uspace(). False otherwise. */ 97 bool in_copy_to_uspace; 98 99 94 100 fpu_context_t *saved_fpu_context; 95 101 int fpu_context_exists; -
generic/src/ddi/ddi.c
r22cf454d re3c762cd 41 41 #include <security/cap.h> 42 42 #include <mm/frame.h> 43 #include <mm/page.h>44 43 #include <mm/as.h> 45 44 #include <synch/spinlock.h> 45 #include <syscall/copy.h> 46 46 #include <arch.h> 47 47 #include <align.h> … … 184 184 { 185 185 ddi_memarg_t arg; 186 187 copy_from_uspace(&arg, uspace_mem_arg, sizeof(ddi_memarg_t)); 186 int rc; 187 188 rc = copy_from_uspace(&arg, uspace_mem_arg, sizeof(ddi_memarg_t)); 189 if (rc != 0) 190 return (__native) rc; 191 188 192 return (__native) ddi_physmem_map((task_id_t) arg.task_id, ALIGN_DOWN((__address) arg.phys_base, FRAME_SIZE), 189 193 ALIGN_DOWN((__address) arg.virt_base, PAGE_SIZE), (count_t) arg.pages, … … 200 204 { 201 205 ddi_ioarg_t arg; 202 203 copy_from_uspace(&arg, uspace_io_arg, sizeof(ddi_ioarg_t)); 206 int rc; 207 208 rc = copy_from_uspace(&arg, uspace_io_arg, sizeof(ddi_ioarg_t)); 209 if (rc != 0) 210 return (__native) rc; 211 204 212 return (__native) ddi_iospace_enable((task_id_t) arg.task_id, (__address) arg.ioaddr, (size_t) arg.size); 205 213 } -
generic/src/ipc/irq.c
r22cf454d re3c762cd 48 48 #include <ipc/irq.h> 49 49 #include <atomic.h> 50 #include <syscall/copy.h> 50 51 51 52 typedef struct { … … 121 122 irq_code_t *code; 122 123 irq_cmd_t *ucmds; 124 int rc; 123 125 124 126 code = malloc(sizeof(*code), 0); 125 copy_from_uspace(code, ucode, sizeof(*code)); 127 rc = copy_from_uspace(code, ucode, sizeof(*code)); 128 if (rc != 0) { 129 free(code); 130 return NULL; 131 } 126 132 127 133 if (code->cmdcount > IRQ_MAX_PROG_SIZE) { … … 131 137 ucmds = code->cmds; 132 138 code->cmds = malloc(sizeof(code->cmds[0]) * (code->cmdcount), 0); 133 copy_from_uspace(code->cmds, ucmds, sizeof(code->cmds[0]) * (code->cmdcount)); 139 rc = copy_from_uspace(code->cmds, ucmds, sizeof(code->cmds[0]) * (code->cmdcount)); 140 if (rc != 0) { 141 free(code->cmds); 142 free(code); 143 return NULL; 144 } 134 145 135 146 return code; -
generic/src/ipc/sysipc.c
r22cf454d re3c762cd 29 29 #include <arch.h> 30 30 #include <proc/task.h> 31 31 #include <proc/thread.h> 32 32 #include <errno.h> 33 #include <mm/page.h>34 33 #include <memstr.h> 35 34 #include <debug.h> … … 39 38 #include <ipc/ipcrsc.h> 40 39 #include <arch/interrupt.h> 41 42 40 #include <print.h> 43 #include <arch.h> 44 #include <proc/thread.h> 41 #include <syscall/copy.h> 45 42 46 43 #define GET_CHECK_PHONE(phone,phoneid,err) { \ … … 229 226 phone_t *phone; 230 227 int res; 228 int rc; 231 229 232 230 ipc_call_static_init(&call); 233 copy_from_uspace(&call.data.args, &question->args, sizeof(call.data.args)); 231 rc = copy_from_uspace(&call.data.args, &question->args, sizeof(call.data.args)); 232 if (rc != 0) 233 return (__native) rc; 234 234 235 235 GET_CHECK_PHONE(phone, phoneid, return ENOENT); … … 241 241 IPC_SET_RETVAL(call.data, res); 242 242 243 STRUCT_TO_USPACE(&reply->args, &call.data.args); 243 rc = STRUCT_TO_USPACE(&reply->args, &call.data.args); 244 if (rc != 0) 245 return rc; 244 246 245 247 return 0; … … 298 300 phone_t *phone; 299 301 int res; 302 int rc; 300 303 301 304 if (check_call_limit()) … … 305 308 306 309 call = ipc_call_alloc(0); 307 copy_from_uspace(&call->data.args, &data->args, sizeof(call->data.args)); 310 rc = copy_from_uspace(&call->data.args, &data->args, sizeof(call->data.args)); 311 if (rc != 0) 312 return (__native) rc; 308 313 if (!(res=request_preprocess(call))) 309 314 ipc_call(phone, call); … … 394 399 ipc_data_t saved_data; 395 400 int saveddata = 0; 401 int rc; 396 402 397 403 call = get_call(callid); … … 403 409 saveddata = 1; 404 410 } 405 copy_from_uspace(&call->data.args, &data->args,411 rc = copy_from_uspace(&call->data.args, &data->args, 406 412 sizeof(call->data.args)); 413 if (rc != 0) 414 return rc; 407 415 408 416 answer_preprocess(call, saveddata ? &saved_data : NULL); -
generic/src/mm/as.c
r22cf454d re3c762cd 58 58 #include <adt/btree.h> 59 59 #include <proc/task.h> 60 #include <proc/thread.h> 60 61 #include <arch/asm.h> 61 62 #include <panic.h> … … 69 70 #include <arch/types.h> 70 71 #include <typedefs.h> 72 #include <syscall/copy.h> 73 #include <arch/interrupt.h> 71 74 72 75 as_operations_t *as_operations = NULL; … … 478 481 * 479 482 * @param page Faulting page. 480 * 481 * @return 0 on page fault, 1 on success. 482 */ 483 int as_page_fault(__address page) 483 * @param istate Pointer to interrupted state. 484 * 485 * @return 0 on page fault, 1 on success or 2 if the fault was caused by copy_to_uspace() or copy_from_uspace(). 486 */ 487 int as_page_fault(__address page, istate_t *istate) 484 488 { 485 489 pte_t *pte; … … 497 501 */ 498 502 spinlock_unlock(&AS->lock); 499 return 0;503 goto page_fault; 500 504 } 501 505 … … 507 511 spinlock_unlock(&area->lock); 508 512 spinlock_unlock(&AS->lock); 509 return 0;513 goto page_fault; 510 514 } 511 515 … … 555 559 spinlock_unlock(&area->lock); 556 560 spinlock_unlock(&AS->lock); 557 return 1; 561 return AS_PF_OK; 562 563 page_fault: 564 if (!THREAD) 565 return AS_PF_FAULT; 566 567 if (THREAD->in_copy_from_uspace) { 568 THREAD->in_copy_from_uspace = false; 569 istate_set_retaddr(istate, (__address) &memcpy_from_uspace_failover_address); 570 } else if (THREAD->in_copy_to_uspace) { 571 THREAD->in_copy_to_uspace = false; 572 istate_set_retaddr(istate, (__address) &memcpy_to_uspace_failover_address); 573 } else { 574 return AS_PF_FAULT; 575 } 576 577 return AS_PF_DEFER; 558 578 } 559 579 … … 885 905 { 886 906 as_area_acptsnd_arg_t arg; 887 888 copy_from_uspace(&arg, uspace_accept_arg, sizeof(as_area_acptsnd_arg_t)); 907 int rc; 908 909 rc = copy_from_uspace(&arg, uspace_accept_arg, sizeof(as_area_acptsnd_arg_t)); 910 if (rc != 0) 911 return rc; 889 912 890 913 if (!arg.size) … … 907 930 { 908 931 as_area_acptsnd_arg_t arg; 909 910 copy_from_uspace(&arg, uspace_send_arg, sizeof(as_area_acptsnd_arg_t)); 932 int rc; 933 934 rc = copy_from_uspace(&arg, uspace_send_arg, sizeof(as_area_acptsnd_arg_t)); 935 if (rc != 0) 936 return rc; 911 937 912 938 if (!arg.size) -
generic/src/mm/slab.c
r22cf454d re3c762cd 176 176 slab = data + fsize - sizeof(*slab); 177 177 } 178 178 179 179 /* Fill in slab structures */ 180 180 for (i=0; i < (1 << cache->order); i++) … … 278 278 /* Allow recursion and reclaiming 279 279 * - this should work, as the slab control structures 280 * are small and do not need to alloc te with anything281 * other t en frame_alloc when they are allocating,280 * are small and do not need to allocate with anything 281 * other than frame_alloc when they are allocating, 282 282 * that's why we should get recursion at most 1-level deep 283 283 */ … … 880 880 881 881 ASSERT(_slab_initialized); 882 ASSERT( 882 ASSERT(size && size <= (1 << SLAB_MAX_MALLOC_W)); 883 883 884 884 if (size < (1 << SLAB_MIN_MALLOC_W)) … … 890 890 } 891 891 892 893 892 void free(void *obj) 894 893 { -
generic/src/printf/vsnprintf.c
r22cf454d re3c762cd 40 40 41 41 /** Write string to given buffer. 42 * Write at most data->size characters including trailing zero. According to C99 has snprintfto return number42 * Write at most data->size characters including trailing zero. According to C99, snprintf() has to return number 43 43 * of characters that would have been written if enough space had been available. Hence the return value is not 44 * number of really printed characters but size of input string. Number of really used characters44 * number of really printed characters but size of the input string. Number of really used characters 45 45 * is stored in data->len. 46 46 * @param str source string to print … … 91 91 return printf_core(fmt, &ps, ap); 92 92 } 93 94 -
generic/src/proc/task.c
r22cf454d re3c762cd 49 49 #include <print.h> 50 50 #include <elf.h> 51 51 #include <syscall/copy.h> 52 52 53 53 #ifndef LOADED_PROG_STACK_PAGES_NO … … 171 171 * @param uspace_task_id Userspace address of 8-byte buffer where to store current task ID. 172 172 * 173 * @return Always returns 0.173 * @return 0 on success or an error code from @ref errno.h. 174 174 */ 175 175 __native sys_task_get_id(task_id_t *uspace_task_id) … … 179 179 * remains constant for the lifespan of the task. 180 180 */ 181 copy_to_uspace(uspace_task_id, &TASK->taskid, sizeof(TASK->taskid)); 182 183 return 0; 181 return (__native) copy_to_uspace(uspace_task_id, &TASK->taskid, sizeof(TASK->taskid)); 184 182 } 185 183 -
generic/src/proc/thread.c
r22cf454d re3c762cd 61 61 #include <debug.h> 62 62 #include <main/uinit.h> 63 #include <syscall/copy.h> 64 #include <errno.h> 63 65 64 66 char *thread_states[] = {"Invalid", "Running", "Sleeping", "Ready", "Entering", "Exiting"}; /**< Thread states */ … … 304 306 t->sleep_queue = NULL; 305 307 t->timeout_pending = 0; 308 309 t->in_copy_from_uspace = false; 310 t->in_copy_to_uspace = false; 306 311 307 312 t->rwlock_holder_type = RWLOCK_NONE; … … 463 468 uspace_arg_t *kernel_uarg; 464 469 __u32 tid; 465 466 copy_from_uspace(namebuf, uspace_name, THREAD_NAME_BUFLEN); 470 int rc; 471 472 rc = copy_from_uspace(namebuf, uspace_name, THREAD_NAME_BUFLEN); 473 if (rc != 0) 474 return (__native) rc; 467 475 468 476 kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0); 469 copy_from_uspace(kernel_uarg, uspace_uarg, sizeof(uspace_arg_t)); 477 rc = copy_from_uspace(kernel_uarg, uspace_uarg, sizeof(uspace_arg_t)); 478 if (rc != 0) { 479 free(kernel_uarg); 480 return (__native) rc; 481 } 470 482 471 483 if ((t = thread_create(uinit, kernel_uarg, TASK, 0, namebuf))) { … … 477 489 } 478 490 479 return (__native) -1;491 return (__native) ENOMEM; 480 492 } 481 493 -
generic/src/smp/ipi.c
r22cf454d re3c762cd 44 44 * @param ipi Message to broadcast. 45 45 * 46 * @bug sThe decision whether to actually send the IPI must be based47 * 48 * 49 * 46 * @bug The decision whether to actually send the IPI must be based 47 * on a different criterion. The current version has 48 * problems when some of the detected CPUs are marked 49 * disabled in machine configuration. 50 50 */ 51 51 void ipi_broadcast(int ipi) -
generic/src/synch/waitq.c
r22cf454d re3c762cd 31 31 * @brief Wait queue. 32 32 * 33 * Wait queue is the basic synchronization primitive upon all33 * Wait queue is the basic synchronization primitive upon which all 34 34 * other synchronization primitives build. 35 35 *
Note:
See TracChangeset
for help on using the changeset viewer.