Changes in / [a7f7ed12:1f7753a] in mainline
- Files:
-
- 2 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
abi/include/mm/as.h
ra7f7ed12 r1f7753a 37 37 38 38 /** Address space area flags. */ 39 #define AS_AREA_READ 0x01 40 #define AS_AREA_WRITE 0x02 41 #define AS_AREA_EXEC 0x04 42 #define AS_AREA_CACHEABLE 0x08 43 #define AS_AREA_GUARD 0x10 39 #define AS_AREA_READ 0x01 40 #define AS_AREA_WRITE 0x02 41 #define AS_AREA_EXEC 0x04 42 #define AS_AREA_CACHEABLE 0x08 43 #define AS_AREA_GUARD 0x10 44 #define AS_AREA_LATE_RESERVE 0x20 44 45 45 46 /** Address space area info exported to uspace. */ -
boot/arch/ia64/src/main.c
ra7f7ed12 r1f7753a 48 48 49 49 #define DEFAULT_MEMORY_BASE 0x4000000ULL 50 #define DEFAULT_MEMORY_SIZE 0x4000000ULL50 #define DEFAULT_MEMORY_SIZE (256 * 1024 * 1024) 51 51 #define DEFAULT_LEGACY_IO_BASE 0x00000FFFFC000000ULL 52 52 #define DEFAULT_LEGACY_IO_SIZE 0x4000000ULL -
contrib/conf/ski.conf
ra7f7ed12 r1f7753a 1 load HelenOS/image.boot1 load image.boot -
kernel/arch/ia64/include/mm/as.h
ra7f7ed12 r1f7753a 43 43 #define USER_ADDRESS_SPACE_END_ARCH UINT64_C(0xdfffffffffffffff) 44 44 45 #define USTACK_ADDRESS_ARCH UINT64_C(0x0000000ff0000000)46 47 45 typedef struct { 48 46 } as_arch_t; -
kernel/arch/ia64/src/mm/tlb.c
ra7f7ed12 r1f7753a 113 113 va = page; 114 114 115 rr.word = rr_read(VA2VRN( va));116 if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN( va))))) {115 rr.word = rr_read(VA2VRN(page)); 116 if ((restore_rr = (rr.map.rid != ASID2RID(asid, VA2VRN(page))))) { 117 117 /* 118 118 * The selected region register does not contain required RID. … … 122 122 123 123 rr0 = rr; 124 rr0.map.rid = ASID2RID(asid, VA2VRN( va));125 rr_write(VA2VRN( va), rr0.word);124 rr0.map.rid = ASID2RID(asid, VA2VRN(page)); 125 rr_write(VA2VRN(page), rr0.word); 126 126 srlz_d(); 127 127 srlz_i(); … … 139 139 case 1: /* cnt 4 - 15 */ 140 140 ps = PAGE_WIDTH + 2; 141 va &= ~((1 << ps) - 1);141 va &= ~((1UL << ps) - 1); 142 142 break; 143 143 case 2: /* cnt 16 - 63 */ 144 144 ps = PAGE_WIDTH + 4; 145 va &= ~((1 << ps) - 1);145 va &= ~((1UL << ps) - 1); 146 146 break; 147 147 case 3: /* cnt 64 - 255 */ 148 148 ps = PAGE_WIDTH + 6; 149 va &= ~((1 << ps) - 1);149 va &= ~((1UL << ps) - 1); 150 150 break; 151 151 case 4: /* cnt 256 - 1023 */ 152 152 ps = PAGE_WIDTH + 8; 153 va &= ~((1 << ps) - 1);153 va &= ~((1UL << ps) - 1); 154 154 break; 155 155 case 5: /* cnt 1024 - 4095 */ 156 156 ps = PAGE_WIDTH + 10; 157 va &= ~((1 << ps) - 1);157 va &= ~((1UL << ps) - 1); 158 158 break; 159 159 case 6: /* cnt 4096 - 16383 */ 160 160 ps = PAGE_WIDTH + 12; 161 va &= ~((1 << ps) - 1);161 va &= ~((1UL << ps) - 1); 162 162 break; 163 163 case 7: /* cnt 16384 - 65535 */ 164 164 case 8: /* cnt 65536 - (256K - 1) */ 165 165 ps = PAGE_WIDTH + 14; 166 va &= ~((1 << ps) - 1);166 va &= ~((1UL << ps) - 1); 167 167 break; 168 168 default: 169 169 ps = PAGE_WIDTH + 18; 170 va &= ~((1 << ps) - 1);170 va &= ~((1UL << ps) - 1); 171 171 break; 172 172 } 173 173 174 for (; va < (page + cnt * PAGE_SIZE); va += (1 << ps))174 for (; va < (page + cnt * PAGE_SIZE); va += (1UL << ps)) 175 175 asm volatile ( 176 176 "ptc.l %[va], %[ps] ;;" … … 183 183 184 184 if (restore_rr) { 185 rr_write(VA2VRN( va), rr.word);185 rr_write(VA2VRN(page), rr.word); 186 186 srlz_d(); 187 187 srlz_i(); -
kernel/genarch/src/mm/page_ht.c
ra7f7ed12 r1f7753a 209 209 pte->frame = ALIGN_DOWN(frame, FRAME_SIZE); 210 210 211 /* 212 * Make sure that a concurrent ht_mapping_find() will see the 213 * new entry only after it is fully initialized. 214 */ 211 215 write_barrier(); 212 216 -
kernel/genarch/src/mm/page_pt.c
ra7f7ed12 r1f7753a 89 89 PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | 90 90 PAGE_WRITE); 91 /* 92 * Make sure that a concurrent hardware page table walk or 93 * pt_mapping_find() will see the new PTL1 only after it is 94 * fully initialized. 95 */ 91 96 write_barrier(); 92 97 SET_PTL1_PRESENT(ptl0, PTL0_INDEX(page)); … … 103 108 PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | 104 109 PAGE_WRITE); 110 /* 111 * Make the new PTL2 visible only after it is fully initialized. 112 */ 105 113 write_barrier(); 106 114 SET_PTL2_PRESENT(ptl1, PTL1_INDEX(page)); … … 117 125 PAGE_NOT_PRESENT | PAGE_USER | PAGE_EXEC | PAGE_CACHEABLE | 118 126 PAGE_WRITE); 127 /* 128 * Make the new PTL3 visible only after it is fully initialized. 129 */ 119 130 write_barrier(); 120 131 SET_PTL3_PRESENT(ptl2, PTL2_INDEX(page)); … … 125 136 SET_FRAME_ADDRESS(ptl3, PTL3_INDEX(page), frame); 126 137 SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), flags | PAGE_NOT_PRESENT); 138 /* 139 * Make the new mapping visible only after it is fully initialized. 140 */ 127 141 write_barrier(); 128 142 SET_FRAME_PRESENT(ptl3, PTL3_INDEX(page)); … … 296 310 297 311 #if (PTL1_ENTRIES != 0) 312 /* 313 * Always read ptl2 only after we are sure it is present. 314 */ 298 315 read_barrier(); 299 316 #endif … … 304 321 305 322 #if (PTL2_ENTRIES != 0) 323 /* 324 * Always read ptl3 only after we are sure it is present. 325 */ 306 326 read_barrier(); 307 327 #endif -
kernel/generic/include/config.h
ra7f7ed12 r1f7753a 44 44 #define STACK_FRAMES TWO_FRAMES 45 45 #define STACK_SIZE ((1 << STACK_FRAMES) << PAGE_WIDTH) 46 47 #define STACK_SIZE_USER (1 * 1024 * 1024) 46 48 47 49 #define CONFIG_INIT_TASKS 32 -
kernel/generic/include/mm/as.h
ra7f7ed12 r1f7753a 61 61 #define USER_ADDRESS_SPACE_END USER_ADDRESS_SPACE_END_ARCH 62 62 63 #ifdef USTACK_ADDRESS_ARCH64 #define USTACK_ADDRESS USTACK_ADDRESS_ARCH65 #else66 #define USTACK_ADDRESS (USER_ADDRESS_SPACE_END - (STACK_SIZE - 1))67 #endif68 69 63 /** Kernel address space. */ 70 64 #define FLAG_AS_KERNEL (1 << 0) … … 224 218 void (* destroy)(as_area_t *); 225 219 220 bool (* is_resizable)(as_area_t *); 221 bool (* is_shareable)(as_area_t *); 222 226 223 int (* page_fault)(as_area_t *, uintptr_t, pf_access_t); 227 224 void (* frame_free)(as_area_t *, uintptr_t, uintptr_t); -
kernel/generic/include/proc/task.h
ra7f7ed12 r1f7753a 134 134 uint64_t ucycles; 135 135 uint64_t kcycles; 136 137 /** If true, do not attempt to print a verbose kill message. */ 138 bool silent_kill; 136 139 } task_t; 137 140 -
kernel/generic/src/interrupt/interrupt.c
ra7f7ed12 r1f7753a 168 168 static NO_TRACE void fault_from_uspace_core(istate_t *istate, const char *fmt, va_list args) 169 169 { 170 printf("Task %s (%" PRIu64 ") killed due to an exception at " 171 "program counter %p.\n", TASK->name, TASK->taskid, 172 (void *) istate_get_pc(istate)); 173 174 istate_decode(istate); 175 stack_trace_istate(istate); 176 177 printf("Kill message: "); 178 vprintf(fmt, args); 179 printf("\n"); 170 if (!TASK->silent_kill) { 171 printf("Task %s (%" PRIu64 ") killed due to an exception at " 172 "program counter %p.\n", TASK->name, TASK->taskid, 173 (void *) istate_get_pc(istate)); 174 175 istate_decode(istate); 176 stack_trace_istate(istate); 177 178 printf("Kill message: "); 179 vprintf(fmt, args); 180 printf("\n"); 181 } 180 182 181 183 task_kill_self(true); -
kernel/generic/src/main/kinit.c
ra7f7ed12 r1f7753a 172 172 #endif /* CONFIG_KCONSOLE */ 173 173 174 /* 175 * Store the default stack size in sysinfo so that uspace can create 176 * stack with this default size. 177 */ 178 sysinfo_set_item_val("default.stack_size", NULL, STACK_SIZE_USER); 179 174 180 interrupts_enable(); 175 181 -
kernel/generic/src/mm/as.c
ra7f7ed12 r1f7753a 426 426 /* 427 427 * So far, the area does not conflict with other areas. 428 * Check if it doesn't conflict with kerneladdress space.428 * Check if it is contained in the user address space. 429 429 */ 430 430 if (!KERNEL_ADDRESS_SPACE_SHADOWED) { 431 return !overlaps(addr, P2SZ(count), KERNEL_ADDRESS_SPACE_START, 432 KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START); 431 return iswithin(USER_ADDRESS_SPACE_START, 432 (USER_ADDRESS_SPACE_END - USER_ADDRESS_SPACE_START) + 1, 433 addr, P2SZ(count)); 433 434 } 434 435 … … 696 697 return ENOENT; 697 698 } 698 699 if (area->backend == &phys_backend) { 700 /* 701 * Remapping of address space areas associated 702 * with memory mapped devices is not supported. 699 700 if (!area->backend->is_resizable(area)) { 701 /* 702 * The backend does not support resizing for this area. 703 703 */ 704 704 mutex_unlock(&area->lock); … … 1057 1057 } 1058 1058 1059 if ((!src_area->backend) || (!src_area->backend->share)) { 1060 /* 1061 * There is no backend or the backend does not 1062 * know how to share the area. 1059 if (!src_area->backend->is_shareable(src_area)) { 1060 /* 1061 * The backend does not permit sharing of this area. 1063 1062 */ 1064 1063 mutex_unlock(&src_area->lock); -
kernel/generic/src/mm/backend_anon.c
ra7f7ed12 r1f7753a 59 59 static void anon_destroy(as_area_t *); 60 60 61 static bool anon_is_resizable(as_area_t *); 62 static bool anon_is_shareable(as_area_t *); 63 61 64 static int anon_page_fault(as_area_t *, uintptr_t, pf_access_t); 62 65 static void anon_frame_free(as_area_t *, uintptr_t, uintptr_t); … … 68 71 .destroy = anon_destroy, 69 72 73 .is_resizable = anon_is_resizable, 74 .is_shareable = anon_is_shareable, 75 70 76 .page_fault = anon_page_fault, 71 77 .frame_free = anon_frame_free, … … 74 80 bool anon_create(as_area_t *area) 75 81 { 82 if (area->flags & AS_AREA_LATE_RESERVE) 83 return true; 84 76 85 return reserve_try_alloc(area->pages); 77 86 } … … 79 88 bool anon_resize(as_area_t *area, size_t new_pages) 80 89 { 90 if (area->flags & AS_AREA_LATE_RESERVE) 91 return true; 92 81 93 if (new_pages > area->pages) 82 94 return reserve_try_alloc(new_pages - area->pages); … … 100 112 ASSERT(mutex_locked(&area->as->lock)); 101 113 ASSERT(mutex_locked(&area->lock)); 114 ASSERT(!(area->flags & AS_AREA_LATE_RESERVE)); 102 115 103 116 /* … … 139 152 void anon_destroy(as_area_t *area) 140 153 { 154 if (area->flags & AS_AREA_LATE_RESERVE) 155 return; 156 141 157 reserve_free(area->pages); 142 158 } 143 159 160 bool anon_is_resizable(as_area_t *area) 161 { 162 return true; 163 } 164 165 bool anon_is_shareable(as_area_t *area) 166 { 167 return !(area->flags & AS_AREA_LATE_RESERVE); 168 } 144 169 145 170 /** Service a page fault in the anonymous memory address space area. … … 225 250 * the different causes 226 251 */ 252 253 if (area->flags & AS_AREA_LATE_RESERVE) { 254 /* 255 * Reserve the memory for this page now. 256 */ 257 if (!reserve_try_alloc(1)) { 258 printf("Killing task %" PRIu64 " due to a " 259 "failed late reservation request.\n", 260 TASK->taskid); 261 TASK->silent_kill = true; 262 return AS_PF_FAULT; 263 } 264 } 265 227 266 kpage = km_temporary_page_get(&frame, FRAME_NO_RESERVE); 228 267 memsetb((void *) kpage, PAGE_SIZE, 0); … … 255 294 ASSERT(mutex_locked(&area->lock)); 256 295 257 frame_free_noreserve(frame); 296 if (area->flags & AS_AREA_LATE_RESERVE) { 297 /* 298 * In case of the late reserve areas, physical memory will not 299 * be unreserved when the area is destroyed so we need to use 300 * the normal unreserving frame_free(). 301 */ 302 frame_free(frame); 303 } else { 304 /* 305 * The reserve will be given back when the area is destroyed or 306 * resized, so use the frame_free_noreserve() which does not 307 * manipulate the reserve or it would be given back twice. 308 */ 309 frame_free_noreserve(frame); 310 } 258 311 } 259 312 -
kernel/generic/src/mm/backend_elf.c
ra7f7ed12 r1f7753a 58 58 static void elf_destroy(as_area_t *); 59 59 60 static bool elf_is_resizable(as_area_t *); 61 static bool elf_is_shareable(as_area_t *); 62 60 63 static int elf_page_fault(as_area_t *, uintptr_t, pf_access_t); 61 64 static void elf_frame_free(as_area_t *, uintptr_t, uintptr_t); … … 66 69 .share = elf_share, 67 70 .destroy = elf_destroy, 71 72 .is_resizable = elf_is_resizable, 73 .is_shareable = elf_is_shareable, 68 74 69 75 .page_fault = elf_page_fault, … … 213 219 } 214 220 221 bool elf_is_resizable(as_area_t *area) 222 { 223 return true; 224 } 225 226 bool elf_is_shareable(as_area_t *area) 227 { 228 return true; 229 } 230 231 215 232 /** Service a page fault in the ELF backend address space area. 216 233 * -
kernel/generic/src/mm/backend_phys.c
ra7f7ed12 r1f7753a 52 52 static void phys_destroy(as_area_t *); 53 53 54 static bool phys_is_resizable(as_area_t *); 55 static bool phys_is_shareable(as_area_t *); 56 57 54 58 static int phys_page_fault(as_area_t *, uintptr_t, pf_access_t); 55 59 … … 59 63 .share = phys_share, 60 64 .destroy = phys_destroy, 65 66 .is_resizable = phys_is_resizable, 67 .is_shareable = phys_is_shareable, 61 68 62 69 .page_fault = phys_page_fault, … … 87 94 /* Nothing to do. */ 88 95 } 96 97 bool phys_is_resizable(as_area_t *area) 98 { 99 return false; 100 } 101 102 bool phys_is_shareable(as_area_t *area) 103 { 104 return true; 105 } 106 89 107 90 108 /** Service a page fault in the address space area backed by physical memory. -
kernel/generic/src/mm/km.c
ra7f7ed12 r1f7753a 233 233 * @param[inout] framep Pointer to a variable which will receive the physical 234 234 * address of the allocated frame. 235 * @param[in] flags Frame allocation flags. FRAME_NONE or FRAME_NO_RESERVE. 235 * @param[in] flags Frame allocation flags. FRAME_NONE, FRAME_NO_RESERVE 236 * and FRAME_ATOMIC bits are allowed. 236 237 * @return Virtual address of the allocated frame. 237 238 */ … … 243 244 ASSERT(THREAD); 244 245 ASSERT(framep); 245 ASSERT(!(flags & ~ FRAME_NO_RESERVE));246 ASSERT(!(flags & ~(FRAME_NO_RESERVE | FRAME_ATOMIC))); 246 247 247 248 /* … … 255 256 ASSERT(page); // FIXME 256 257 } else { 257 frame = (uintptr_t) frame_alloc_noreserve(ONE_FRAME, 258 FRAME_LOWMEM); 258 frame = (uintptr_t) frame_alloc(ONE_FRAME, 259 FRAME_LOWMEM | flags); 260 if (!frame) 261 return (uintptr_t) NULL; 259 262 page = PA2KA(frame); 260 263 } -
kernel/generic/src/proc/program.c
ra7f7ed12 r1f7753a 79 79 * Create the stack address space area. 80 80 */ 81 uintptr_t virt = USTACK_ADDRESS; 81 uintptr_t virt = (uintptr_t) -1; 82 uintptr_t bound = USER_ADDRESS_SPACE_END - (STACK_SIZE_USER - 1); 83 84 /* Adjust bound to create space for the desired guard page. */ 85 bound -= PAGE_SIZE; 86 82 87 as_area_t *area = as_area_create(as, 83 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, 84 STACK_SIZE, AS_AREA_ATTR_NONE, &anon_backend, NULL, &virt, 0); 88 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD | 89 AS_AREA_LATE_RESERVE, STACK_SIZE_USER, AS_AREA_ATTR_NONE, 90 &anon_backend, NULL, &virt, bound); 85 91 if (!area) { 86 92 task_destroy(prg->task); … … 93 99 kernel_uarg->uspace_entry = (void *) entry_addr; 94 100 kernel_uarg->uspace_stack = (void *) virt; 95 kernel_uarg->uspace_stack_size = STACK_SIZE ;101 kernel_uarg->uspace_stack_size = STACK_SIZE_USER; 96 102 kernel_uarg->uspace_thread_function = NULL; 97 103 kernel_uarg->uspace_thread_arg = NULL; -
kernel/generic/src/proc/task.c
ra7f7ed12 r1f7753a 196 196 task->ucycles = 0; 197 197 task->kcycles = 0; 198 199 task->silent_kill = false; 198 200 199 201 task->ipc_info.call_sent = 0; -
uspace/lib/c/Makefile
ra7f7ed12 r1f7753a 140 140 generic/net/socket_client.c \ 141 141 generic/net/socket_parse.c \ 142 generic/stack.c \ 142 143 generic/stacktrace.c \ 143 144 generic/arg_parse.c \ -
uspace/lib/c/generic/fibril.c
ra7f7ed12 r1f7753a 37 37 #include <fibril.h> 38 38 #include <thread.h> 39 #include <stack.h> 39 40 #include <tls.h> 40 41 #include <malloc.h> 42 #include <abi/mm/as.h> 43 #include <as.h> 41 44 #include <unistd.h> 42 45 #include <stdio.h> … … 46 49 #include <assert.h> 47 50 #include <async.h> 48 49 #ifndef FIBRIL_INITIAL_STACK_PAGES_NO50 #define FIBRIL_INITIAL_STACK_PAGES_NO 151 #endif52 51 53 52 /** … … 195 194 * stack member filled. 196 195 */ 197 free(stack);196 as_area_destroy(stack); 198 197 } 199 198 fibril_teardown(srcf->clean_after_me); … … 269 268 return 0; 270 269 271 fibril->stack = 272 (char *) malloc(FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize()); 273 if (!fibril->stack) { 270 size_t stack_size = stack_size_get(); 271 fibril->stack = as_area_create((void *) -1, stack_size, 272 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD | 273 AS_AREA_LATE_RESERVE); 274 if (fibril->stack == (void *) -1) { 274 275 fibril_teardown(fibril); 275 276 return 0; … … 281 282 context_save(&fibril->ctx); 282 283 context_set(&fibril->ctx, FADDR(fibril_main), fibril->stack, 283 FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize(), fibril->tcb);284 stack_size, fibril->tcb); 284 285 285 286 return (fid_t) fibril; … … 298 299 fibril_t *fibril = (fibril_t *) fid; 299 300 300 free(fibril->stack);301 as_area_destroy(fibril->stack); 301 302 fibril_teardown(fibril); 302 303 } -
uspace/lib/c/generic/thread.c
ra7f7ed12 r1f7753a 39 39 #include <abi/proc/uarg.h> 40 40 #include <fibril.h> 41 #include <stack.h> 41 42 #include <str.h> 42 43 #include <async.h> … … 44 45 #include <as.h> 45 46 #include "private/thread.h" 46 47 #ifndef THREAD_INITIAL_STACK_PAGES48 #define THREAD_INITIAL_STACK_PAGES 249 #endif50 47 51 48 /** Main thread function. … … 101 98 return ENOMEM; 102 99 103 size_t stack_size = getpagesize() * THREAD_INITIAL_STACK_PAGES;100 size_t stack_size = stack_size_get(); 104 101 void *stack = as_area_create(AS_AREA_ANY, stack_size, 105 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE); 102 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD | 103 AS_AREA_LATE_RESERVE); 106 104 if (stack == AS_MAP_FAILED) { 107 105 free(uarg);
Note:
See TracChangeset
for help on using the changeset viewer.