Changeset 074c9bd in mainline
- Timestamp:
- 2010-07-15T10:39:23Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5c16ce7
- Parents:
- 41ce4d9 (diff), 4003861 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- kernel
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/include/asm.h
r41ce4d9 r074c9bd 435 435 GEN_WRITE_REG(dr7) 436 436 437 extern size_t interrupt_handler_size;438 extern void interrupt_handlers(void);439 440 437 extern void asm_delay_loop(uint32_t); 441 438 extern void asm_fake_loop(uint32_t); 442 439 440 extern uintptr_t int_0; 441 extern uintptr_t int_1; 442 extern uintptr_t int_2; 443 extern uintptr_t int_3; 444 extern uintptr_t int_4; 445 extern uintptr_t int_5; 446 extern uintptr_t int_6; 447 extern uintptr_t int_7; 448 extern uintptr_t int_8; 449 extern uintptr_t int_9; 450 extern uintptr_t int_10; 451 extern uintptr_t int_11; 452 extern uintptr_t int_12; 453 extern uintptr_t int_13; 454 extern uintptr_t int_14; 455 extern uintptr_t int_15; 456 extern uintptr_t int_16; 457 extern uintptr_t int_17; 458 extern uintptr_t int_18; 459 extern uintptr_t int_19; 460 extern uintptr_t int_20; 461 extern uintptr_t int_21; 462 extern uintptr_t int_22; 463 extern uintptr_t int_23; 464 extern uintptr_t int_24; 465 extern uintptr_t int_25; 466 extern uintptr_t int_26; 467 extern uintptr_t int_27; 468 extern uintptr_t int_28; 469 extern uintptr_t int_29; 470 extern uintptr_t int_30; 471 extern uintptr_t int_31; 472 extern uintptr_t int_32; 473 extern uintptr_t int_33; 474 extern uintptr_t int_34; 475 extern uintptr_t int_35; 476 extern uintptr_t int_36; 477 extern uintptr_t int_37; 478 extern uintptr_t int_38; 479 extern uintptr_t int_39; 480 extern uintptr_t int_40; 481 extern uintptr_t int_41; 482 extern uintptr_t int_42; 483 extern uintptr_t int_43; 484 extern uintptr_t int_44; 485 extern uintptr_t int_45; 486 extern uintptr_t int_46; 487 extern uintptr_t int_47; 488 extern uintptr_t int_48; 489 extern uintptr_t int_49; 490 extern uintptr_t int_50; 491 extern uintptr_t int_51; 492 extern uintptr_t int_52; 493 extern uintptr_t int_53; 494 extern uintptr_t int_54; 495 extern uintptr_t int_55; 496 extern uintptr_t int_56; 497 extern uintptr_t int_57; 498 extern uintptr_t int_58; 499 extern uintptr_t int_59; 500 extern uintptr_t int_60; 501 extern uintptr_t int_61; 502 extern uintptr_t int_62; 503 extern uintptr_t int_63; 504 443 505 #endif 444 506 -
kernel/arch/amd64/include/cpu.h
r41ce4d9 r074c9bd 45 45 #define RFLAGS_DF (1 << 10) 46 46 #define RFLAGS_OF (1 << 11) 47 #define RFLAGS_NT (1 << 14) 47 48 #define RFLAGS_RF (1 << 16) 48 49 -
kernel/arch/amd64/include/interrupt.h
r41ce4d9 r074c9bd 74 74 typedef struct istate { 75 75 uint64_t rax; 76 uint64_t rbx; 76 77 uint64_t rcx; 77 78 uint64_t rdx; 78 79 uint64_t rsi; 79 80 uint64_t rdi; 81 uint64_t rbp; 80 82 uint64_t r8; 81 83 uint64_t r9; 82 84 uint64_t r10; 83 85 uint64_t r11; 84 uint64_t rbp; 85 uint64_t error_word; 86 uint64_t r12; 87 uint64_t r13; 88 uint64_t r14; 89 uint64_t r15; 90 uint64_t alignment; /* align rbp_frame on multiple of 16 */ 91 uint64_t rbp_frame; /* imitation of frame pointer linkage */ 92 uint64_t rip_frame; /* imitation of return address linkage */ 93 uint64_t error_word; /* real or fake error word */ 86 94 uint64_t rip; 87 95 uint64_t cs; 88 96 uint64_t rflags; 89 uint64_t stack[]; /* Additional data on stack */ 97 uint64_t rsp; /* only if istate_t is from uspace */ 98 uint64_t ss; /* only if istate_t is from uspace */ 90 99 } istate_t; 91 100 -
kernel/arch/amd64/src/asm.S
r41ce4d9 r074c9bd 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 29 #define IREGISTER_SPACE 8030 31 #define IOFFSET_RAX 0x0032 #define IOFFSET_RCX 0x0833 #define IOFFSET_RDX 0x1034 #define IOFFSET_RSI 0x1835 #define IOFFSET_RDI 0x2036 #define IOFFSET_R8 0x2837 #define IOFFSET_R9 0x3038 #define IOFFSET_R10 0x3839 #define IOFFSET_R11 0x4040 #define IOFFSET_RBP 0x4841 42 /**43 * Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int44 * has no error word and 1 means interrupt with error word45 *46 */47 #define ERROR_WORD_INTERRUPT_LIST 0x00027D0048 28 49 29 #include <arch/pm.h> … … 174 154 ret 175 155 176 /** Push all volatile general purpose registers on stack 177 * 156 #define ISTATE_OFFSET_RAX 0 157 #define ISTATE_OFFSET_RBX 8 158 #define ISTATE_OFFSET_RCX 16 159 #define ISTATE_OFFSET_RDX 24 160 #define ISTATE_OFFSET_RSI 32 161 #define ISTATE_OFFSET_RDI 40 162 #define ISTATE_OFFSET_RBP 48 163 #define ISTATE_OFFSET_R8 56 164 #define ISTATE_OFFSET_R9 64 165 #define ISTATE_OFFSET_R10 72 166 #define ISTATE_OFFSET_R11 80 167 #define ISTATE_OFFSET_R12 88 168 #define ISTATE_OFFSET_R13 96 169 #define ISTATE_OFFSET_R14 104 170 #define ISTATE_OFFSET_R15 112 171 #define ISTATE_OFFSET_ALIGNMENT 120 172 #define ISTATE_OFFSET_RBP_FRAME 128 173 #define ISTATE_OFFSET_RIP_FRAME 136 174 #define ISTATE_OFFSET_ERROR_WORD 144 175 #define ISTATE_OFFSET_RIP 152 176 #define ISTATE_OFFSET_CS 160 177 #define ISTATE_OFFSET_RFLAGS 168 178 #define ISTATE_OFFSET_RSP 176 179 #define ISTATE_OFFSET_SS 184 180 181 /* 182 * Size of the istate structure without the hardware-saved part and without the 183 * error word. 178 184 */ 179 .macro save_all_gpr 180 movq %rax, IOFFSET_RAX(%rsp) 181 movq %rcx, IOFFSET_RCX(%rsp) 182 movq %rdx, IOFFSET_RDX(%rsp) 183 movq %rsi, IOFFSET_RSI(%rsp) 184 movq %rdi, IOFFSET_RDI(%rsp) 185 movq %r8, IOFFSET_R8(%rsp) 186 movq %r9, IOFFSET_R9(%rsp) 187 movq %r10, IOFFSET_R10(%rsp) 188 movq %r11, IOFFSET_R11(%rsp) 189 movq %rbp, IOFFSET_RBP(%rsp) 190 .endm 191 192 .macro restore_all_gpr 193 movq IOFFSET_RAX(%rsp), %rax 194 movq IOFFSET_RCX(%rsp), %rcx 195 movq IOFFSET_RDX(%rsp), %rdx 196 movq IOFFSET_RSI(%rsp), %rsi 197 movq IOFFSET_RDI(%rsp), %rdi 198 movq IOFFSET_R8(%rsp), %r8 199 movq IOFFSET_R9(%rsp), %r9 200 movq IOFFSET_R10(%rsp), %r10 201 movq IOFFSET_R11(%rsp), %r11 202 movq IOFFSET_RBP(%rsp), %rbp 203 .endm 204 205 #define INTERRUPT_ALIGN 128 206 207 /** Declare interrupt handlers 208 * 209 * Declare interrupt handlers for n interrupt 210 * vectors starting at vector i. 211 * 212 * The handlers call exc_dispatch(). 185 #define ISTATE_SOFT_SIZE 144 186 187 /** 188 * Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int 189 * has no error word and 1 means interrupt with error word 213 190 * 214 191 */ 215 .macro handler i n 216 192 #define ERROR_WORD_INTERRUPT_LIST 0x00027D00 193 194 .macro handler i 195 .global int_\i 196 int_\i: 197 217 198 /* 218 199 * Choose between version with error code and version without error 219 * code. Both versions have to be of the same size. amd64 assembly is, 220 * however, a little bit tricky. For instance, subq $0x80, %rsp and 221 * subq $0x78, %rsp can result in two instructions with different 222 * op-code lengths. 223 * Therefore we align the interrupt handlers. 200 * code. 224 201 */ 225 202 … … 229 206 * Version with error word. 230 207 */ 231 subq $I REGISTER_SPACE, %rsp208 subq $ISTATE_SOFT_SIZE, %rsp 232 209 .else 233 210 /* 234 * Version without error word ,211 * Version without error word. 235 212 */ 236 subq $(I REGISTER_SPACE + 8), %rsp213 subq $(ISTATE_SOFT_SIZE + 8), %rsp 237 214 .endif 238 215 .else 239 216 /* 240 * Version without error word ,217 * Version without error word. 241 218 */ 242 subq $(I REGISTER_SPACE + 8), %rsp219 subq $(ISTATE_SOFT_SIZE + 8), %rsp 243 220 .endif 244 221 245 save_all_gpr 222 /* 223 * Save the general purpose registers. 224 */ 225 movq %rax, ISTATE_OFFSET_RAX(%rsp) 226 movq %rbx, ISTATE_OFFSET_RBX(%rsp) 227 movq %rcx, ISTATE_OFFSET_RCX(%rsp) 228 movq %rdx, ISTATE_OFFSET_RDX(%rsp) 229 movq %rsi, ISTATE_OFFSET_RSI(%rsp) 230 movq %rdi, ISTATE_OFFSET_RDI(%rsp) 231 movq %rbp, ISTATE_OFFSET_RBP(%rsp) 232 movq %r8, ISTATE_OFFSET_R8(%rsp) 233 movq %r9, ISTATE_OFFSET_R9(%rsp) 234 movq %r10, ISTATE_OFFSET_R10(%rsp) 235 movq %r11, ISTATE_OFFSET_R11(%rsp) 236 movq %r12, ISTATE_OFFSET_R12(%rsp) 237 movq %r13, ISTATE_OFFSET_R13(%rsp) 238 movq %r14, ISTATE_OFFSET_R14(%rsp) 239 movq %r15, ISTATE_OFFSET_R15(%rsp) 240 241 /* 242 * Imitate a regular stack frame linkage. 243 * Stop stack traces here if we came from userspace. 244 */ 245 xorq %rdx, %rdx 246 cmpq $(gdtselector(KTEXT_DES)), ISTATE_OFFSET_CS(%rsp) 247 cmovnzq %rdx, %rbp 248 249 movq %rbp, ISTATE_OFFSET_RBP_FRAME(%rsp) 250 movq ISTATE_OFFSET_RIP(%rsp), %rax 251 movq %rax, ISTATE_OFFSET_RIP_FRAME(%rsp) 252 leaq ISTATE_OFFSET_RBP_FRAME(%rsp), %rbp 253 254 movq $(\i), %rdi /* pass intnum in the first argument */ 255 movq %rsp, %rsi /* pass istate address in the second argument */ 256 246 257 cld 247 248 /* 249 * Stop stack traces here if we came from userspace. 250 */ 251 movq %cs, %rax 252 xorq %rdx, %rdx 253 cmpq %rax, IREGISTER_SPACE+16(%rsp) 254 cmovneq %rdx, %rbp 255 256 movq $(\i), %rdi /* %rdi - first argument */ 257 movq %rsp, %rsi /* %rsi - pointer to istate */ 258 258 259 259 /* Call exc_dispatch(i, istate) */ 260 260 call exc_dispatch 261 262 restore_all_gpr 261 262 /* 263 * Restore all scratch registers and the preserved registers we have 264 * clobbered in this handler (i.e. RBP). 265 */ 266 movq ISTATE_OFFSET_RAX(%rsp), %rax 267 movq ISTATE_OFFSET_RCX(%rsp), %rcx 268 movq ISTATE_OFFSET_RDX(%rsp), %rdx 269 movq ISTATE_OFFSET_RSI(%rsp), %rsi 270 movq ISTATE_OFFSET_RDI(%rsp), %rdi 271 movq ISTATE_OFFSET_RBP(%rsp), %rbp 272 movq ISTATE_OFFSET_R8(%rsp), %r8 273 movq ISTATE_OFFSET_R9(%rsp), %r9 274 movq ISTATE_OFFSET_R10(%rsp), %r10 275 movq ISTATE_OFFSET_R11(%rsp), %r11 263 276 264 277 /* $8 = Skip error word */ 265 addq $(I REGISTER_SPACE + 8), %rsp278 addq $(ISTATE_SOFT_SIZE + 8), %rsp 266 279 iretq 267 268 .align INTERRUPT_ALIGN269 .if (\n - \i) - 1270 handler "(\i + 1)", \n271 .endif272 280 .endm 273 281 274 .align INTERRUPT_ALIGN 282 #define LIST_0_63 \ 283 0, 1, 2, 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,\ 284 28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,\ 285 53,54,55,56,57,58,59,60,61,62,63 286 275 287 interrupt_handlers: 276 h_start: 277 handler 0 IDT_ITEMS278 h_end: 288 .irp cnt, LIST_0_63 289 handler \cnt 290 .endr 279 291 280 292 /** Low-level syscall handler … … 309 321 movq %gs:8, %rsp /* set this thread's kernel RSP */ 310 322 311 /* Switch back to remain consistent */ 323 /* 324 * Note that the space needed for the imitated istate structure has been 325 * preallocated for us in thread_create_arch() and set in 326 * before_thread_runs_arch(). 327 */ 328 329 /* 330 * Save the general purpose registers and push the 7th argument (syscall 331 * number) onto the stack. Note that the istate structure has a layout 332 * which supports this. 333 */ 334 movq %rax, ISTATE_OFFSET_RAX(%rsp) /* 7th argument, passed on stack */ 335 movq %rbx, ISTATE_OFFSET_RBX(%rsp) /* observability */ 336 movq %rcx, ISTATE_OFFSET_RCX(%rsp) /* userspace RIP */ 337 movq %rdx, ISTATE_OFFSET_RDX(%rsp) /* 3rd argument, observability */ 338 movq %rsi, ISTATE_OFFSET_RSI(%rsp) /* 2nd argument, observability */ 339 movq %rdi, ISTATE_OFFSET_RDI(%rsp) /* 1st argument, observability */ 340 movq %rbp, ISTATE_OFFSET_RBP(%rsp) /* need to preserve userspace RBP */ 341 movq %r8, ISTATE_OFFSET_R8(%rsp) /* 5th argument, observability */ 342 movq %r9, ISTATE_OFFSET_R9(%rsp) /* 6th argument, observability */ 343 movq %r10, ISTATE_OFFSET_R10(%rsp) /* 4th argument, observability */ 344 movq %r11, ISTATE_OFFSET_R11(%rsp) /* low 32 bits userspace RFLAGS */ 345 movq %r12, ISTATE_OFFSET_R12(%rsp) /* observability */ 346 movq %r13, ISTATE_OFFSET_R13(%rsp) /* observability */ 347 movq %r14, ISTATE_OFFSET_R14(%rsp) /* observability */ 348 movq %r15, ISTATE_OFFSET_R15(%rsp) /* observability */ 349 350 /* 351 * Save the return address and the userspace stack on locations that 352 * would normally be taken by them. 353 */ 354 movq %gs:0, %rax 355 movq %rax, ISTATE_OFFSET_RSP(%rsp) 356 movq %rcx, ISTATE_OFFSET_RIP(%rsp) 357 358 /* 359 * Imitate a regular stack frame linkage. 360 */ 361 movq $0, ISTATE_OFFSET_RBP_FRAME(%rsp) 362 movq %rcx, ISTATE_OFFSET_RIP_FRAME(%rsp) 363 leaq ISTATE_OFFSET_RBP_FRAME(%rsp), %rbp 364 365 /* Switch back to normal %gs */ 312 366 swapgs 313 367 sti 314 368 315 pushq %rcx316 pushq %r11317 pushq %rbp318 319 xorq %rbp, %rbp /* stop the stack traces here */320 321 369 /* Copy the 4th argument where it is expected */ 322 370 movq %r10, %rcx 323 pushq %rax 324 371 372 /* 373 * Call syscall_handler() with the 7th argument passed on stack. 374 */ 325 375 call syscall_handler 326 376 327 addq $8, %rsp328 329 popq %rbp330 popq %r11331 popq %rcx332 333 377 cli 334 swapgs 335 336 /* Restore the user RSP */ 337 movq %gs:0, %rsp 338 swapgs 339 378 379 /* 380 * Restore registers needed for return via the SYSRET instruction and 381 * the clobbered preserved registers (i.e. RBP). 382 */ 383 movq ISTATE_OFFSET_RBP(%rsp), %rbp 384 movq ISTATE_OFFSET_RCX(%rsp), %rcx 385 movq ISTATE_OFFSET_R11(%rsp), %r11 386 movq ISTATE_OFFSET_RSP(%rsp), %rsp 387 340 388 sysretq 341 389 … … 484 532 ret 485 533 486 .data487 .global interrupt_handler_size488 489 interrupt_handler_size: .quad (h_end - h_start) / IDT_ITEMS -
kernel/arch/amd64/src/interrupt.c
r41ce4d9 r074c9bd 65 65 void istate_decode(istate_t *istate) 66 66 { 67 printf("error_word=%#llx\n", istate->error_word); 68 printf("cs =%#0.16llx\trflags=%#0.16llx\n", istate->cs, 69 istate->rflags); 70 printf("rax=%#0.16llx\trbx=%#0.16llx\trcx=%#0.16llx\n", istate->rax, 71 istate->rcx, istate->rdx); 72 printf("rsi=%#0.16llx\trdi=%#0.16llx\tr8 =%#0.16llx\n", istate->rsi, 73 istate->rdi, istate->r8); 74 printf("r9 =%#0.16llx\tr10=%#0.16llx\tr11=%#0.16llx\n", istate->r9, 75 istate->r10, istate->r11); 67 printf("cs =%p\trip=%p\trfl=%p\terr=%p\n", 68 istate->cs, istate->rip, istate->rflags, istate->error_word); 69 70 if (istate_from_uspace(istate)) 71 printf("ss =%p\n", istate->ss); 72 73 printf("rax=%p\trbx=%p\trcx=%p\trdx=%p\n", 74 istate->rax, istate->rbx, istate->rcx, istate->rdx); 75 printf("rsi=%p\trdi=%p\trbp=%p\trsp=%p\n", 76 istate->rsi, istate->rdi, istate->rbp, 77 istate_from_uspace(istate) ? istate->rsp : (uintptr_t)&istate->rsp); 78 printf("r8 =%p\tr9 =%p\tr10=%p\tr11=%p\n", 79 istate->r8, istate->r9, istate->r10, istate->r11); 80 printf("r12=%p\tr13=%p\tr14=%p\tr15=%p\n", 81 istate->r12, istate->r13, istate->r14, istate->r15); 76 82 } 77 83 -
kernel/arch/amd64/src/mm/page.c
r41ce4d9 r074c9bd 90 90 if (as_page_fault(page, access, istate) == AS_PF_FAULT) { 91 91 fault_if_from_uspace(istate, "Page fault: %#x.", page); 92 panic_memtrap(istate, access, page, "Page fault.");92 panic_memtrap(istate, access, page, NULL); 93 93 } 94 94 } -
kernel/arch/amd64/src/pm.c
r41ce4d9 r074c9bd 175 175 d->present = 1; 176 176 d->type = AR_INTERRUPT; /* masking interrupt */ 177 178 idt_setoffset(d, ((uintptr_t) interrupt_handlers) +179 i * interrupt_handler_size);180 177 } 178 179 d = &idt[0]; 180 idt_setoffset(d++, (uintptr_t) &int_0); 181 idt_setoffset(d++, (uintptr_t) &int_1); 182 idt_setoffset(d++, (uintptr_t) &int_2); 183 idt_setoffset(d++, (uintptr_t) &int_3); 184 idt_setoffset(d++, (uintptr_t) &int_4); 185 idt_setoffset(d++, (uintptr_t) &int_5); 186 idt_setoffset(d++, (uintptr_t) &int_6); 187 idt_setoffset(d++, (uintptr_t) &int_7); 188 idt_setoffset(d++, (uintptr_t) &int_8); 189 idt_setoffset(d++, (uintptr_t) &int_9); 190 idt_setoffset(d++, (uintptr_t) &int_10); 191 idt_setoffset(d++, (uintptr_t) &int_11); 192 idt_setoffset(d++, (uintptr_t) &int_12); 193 idt_setoffset(d++, (uintptr_t) &int_13); 194 idt_setoffset(d++, (uintptr_t) &int_14); 195 idt_setoffset(d++, (uintptr_t) &int_15); 196 idt_setoffset(d++, (uintptr_t) &int_16); 197 idt_setoffset(d++, (uintptr_t) &int_17); 198 idt_setoffset(d++, (uintptr_t) &int_18); 199 idt_setoffset(d++, (uintptr_t) &int_19); 200 idt_setoffset(d++, (uintptr_t) &int_20); 201 idt_setoffset(d++, (uintptr_t) &int_21); 202 idt_setoffset(d++, (uintptr_t) &int_22); 203 idt_setoffset(d++, (uintptr_t) &int_23); 204 idt_setoffset(d++, (uintptr_t) &int_24); 205 idt_setoffset(d++, (uintptr_t) &int_25); 206 idt_setoffset(d++, (uintptr_t) &int_26); 207 idt_setoffset(d++, (uintptr_t) &int_27); 208 idt_setoffset(d++, (uintptr_t) &int_28); 209 idt_setoffset(d++, (uintptr_t) &int_29); 210 idt_setoffset(d++, (uintptr_t) &int_30); 211 idt_setoffset(d++, (uintptr_t) &int_31); 212 idt_setoffset(d++, (uintptr_t) &int_32); 213 idt_setoffset(d++, (uintptr_t) &int_33); 214 idt_setoffset(d++, (uintptr_t) &int_34); 215 idt_setoffset(d++, (uintptr_t) &int_35); 216 idt_setoffset(d++, (uintptr_t) &int_36); 217 idt_setoffset(d++, (uintptr_t) &int_37); 218 idt_setoffset(d++, (uintptr_t) &int_38); 219 idt_setoffset(d++, (uintptr_t) &int_39); 220 idt_setoffset(d++, (uintptr_t) &int_40); 221 idt_setoffset(d++, (uintptr_t) &int_41); 222 idt_setoffset(d++, (uintptr_t) &int_42); 223 idt_setoffset(d++, (uintptr_t) &int_43); 224 idt_setoffset(d++, (uintptr_t) &int_44); 225 idt_setoffset(d++, (uintptr_t) &int_45); 226 idt_setoffset(d++, (uintptr_t) &int_46); 227 idt_setoffset(d++, (uintptr_t) &int_47); 228 idt_setoffset(d++, (uintptr_t) &int_48); 229 idt_setoffset(d++, (uintptr_t) &int_49); 230 idt_setoffset(d++, (uintptr_t) &int_50); 231 idt_setoffset(d++, (uintptr_t) &int_51); 232 idt_setoffset(d++, (uintptr_t) &int_52); 233 idt_setoffset(d++, (uintptr_t) &int_53); 234 idt_setoffset(d++, (uintptr_t) &int_54); 235 idt_setoffset(d++, (uintptr_t) &int_55); 236 idt_setoffset(d++, (uintptr_t) &int_56); 237 idt_setoffset(d++, (uintptr_t) &int_57); 238 idt_setoffset(d++, (uintptr_t) &int_58); 239 idt_setoffset(d++, (uintptr_t) &int_59); 240 idt_setoffset(d++, (uintptr_t) &int_60); 241 idt_setoffset(d++, (uintptr_t) &int_61); 242 idt_setoffset(d++, (uintptr_t) &int_62); 243 idt_setoffset(d++, (uintptr_t) &int_63); 181 244 } 182 245 -
kernel/arch/amd64/src/proc/scheduler.c
r41ce4d9 r074c9bd 38 38 #include <proc/thread.h> 39 39 #include <arch.h> 40 #include <arch/context.h>41 40 #include <arch/asm.h> 42 41 #include <print.h> … … 57 56 { 58 57 CPU->arch.tss->rsp0 = 59 (uintptr_t) &THREAD->kstack[THREAD_STACK_SIZE - SP_DELTA];58 (uintptr_t) &THREAD->kstack[THREAD_STACK_SIZE]; 60 59 61 60 /* -
kernel/arch/amd64/src/proc/thread.c
r41ce4d9 r074c9bd 34 34 35 35 #include <proc/thread.h> 36 #include <arch/interrupt.h> 36 37 37 38 /** Perform amd64 specific thread initialization. … … 49 50 */ 50 51 thread->arch.syscall_rsp[SYSCALL_KSTACK_RSP] = 51 (uintptr_t) &thread->kstack[PAGE_SIZE - sizeof( uint64_t)];52 (uintptr_t) &thread->kstack[PAGE_SIZE - sizeof(istate_t)]; 52 53 } 53 54 -
kernel/arch/amd64/src/syscall.c
r41ce4d9 r074c9bd 66 66 * - clear DF so that the string instructions operate in 67 67 * the right direction 68 * - clear NT to prevent a #GP should the flag proliferate to an IRET 68 69 */ 69 write_msr(AMD_MSR_SFMASK, RFLAGS_IF | RFLAGS_DF );70 write_msr(AMD_MSR_SFMASK, RFLAGS_IF | RFLAGS_DF | RFLAGS_NT); 70 71 } 71 72 -
kernel/arch/arm32/src/mm/page_fault.c
r41ce4d9 r074c9bd 183 183 if (ret == AS_PF_FAULT) { 184 184 fault_if_from_uspace(istate, "Page fault: %#x.", badvaddr); 185 panic_memtrap(istate, access, badvaddr, "Page fault.");185 panic_memtrap(istate, access, badvaddr, NULL); 186 186 } 187 187 } … … 198 198 199 199 if (ret == AS_PF_FAULT) { 200 panic_memtrap(istate, PF_ACCESS_EXEC, istate->pc, 201 "Page fault - prefetch_abort."); 200 fault_if_from_uspace(istate, 201 "Page fault - prefetch_abort: %#x.", istate->pc); 202 panic_memtrap(istate, PF_ACCESS_EXEC, istate->pc, NULL); 202 203 } 203 204 } -
kernel/arch/ia32/include/asm.h
r41ce4d9 r074c9bd 43 43 #include <trace.h> 44 44 45 extern uint32_t interrupt_handler_size;46 47 45 /** Halt CPU 48 46 * … … 429 427 extern void asm_delay_loop(uint32_t); 430 428 extern void asm_fake_loop(uint32_t); 429 430 extern uintptr_t int_syscall; 431 431 432 432 extern uintptr_t int_0; -
kernel/arch/ia32/include/cpu.h
r41ce4d9 r074c9bd 37 37 38 38 #define EFLAGS_IF (1 << 9) 39 #define EFLAGS_DF (1 << 10) 40 #define EFLAGS_NT (1 << 14) 39 41 #define EFLAGS_RF (1 << 16) 40 42 -
kernel/arch/ia32/include/pm.h
r41ce4d9 r074c9bd 67 67 #define AR_CODE (3 << 3) 68 68 #define AR_WRITABLE (1 << 1) 69 #define AR_INTERRUPT (0x0e) 70 #define AR_TSS (0x09) 69 #define AR_INTERRUPT (0xe) 70 #define AR_TRAP (0xf) 71 #define AR_TSS (0x9) 71 72 72 73 #define DPL_KERNEL (PL_KERNEL << 5) -
kernel/arch/ia32/src/asm.S
r41ce4d9 r074c9bd 1 1 /* 2 * Copyright (c) 20 01Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 31 31 */ 32 32 33 /**34 * Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int35 * has no error word and 1 means interrupt with error word36 *37 */38 #define ERROR_WORD_INTERRUPT_LIST 0x00027d0039 40 33 #include <arch/pm.h> 34 #include <arch/cpu.h> 41 35 #include <arch/mm/page.h> 42 36 … … 153 147 wrmsr 154 148 ret 155 156 /** Clear nested flag157 *158 */159 .macro CLEAR_NT_FLAG160 pushfl161 andl $0xffffbfff, (%esp)162 popfl163 .endm164 149 165 150 #define ISTATE_OFFSET_EDX 0 … … 190 175 191 176 /* 192 * Size of the entire istate structure including the error word and the193 * hardware-saved part.194 */195 #define ISTATE_REAL_SIZE (ISTATE_SOFT_SIZE + 24)196 197 /*198 177 * The SYSENTER syscall mechanism can be used for syscalls with 199 178 * four or fewer arguments. To pass these four arguments, we … … 206 185 .global sysenter_handler 207 186 sysenter_handler: 208 sti 209 subl $(ISTATE_REAL_SIZE), %esp 187 188 /* 189 * Note that the space needed for the istate structure has been 190 * preallocated on the stack by before_thread_runs_arch(). 191 */ 210 192 211 193 /* … … 243 225 * Switch to kernel selectors. 244 226 */ 245 movw $ 16, %ax227 movw $(gdtselector(KDATA_DES)), %ax 246 228 movw %ax, %ds 247 229 movw %ax, %es 248 230 249 cld 231 /* 232 * Sanitize EFLAGS. 233 * 234 * SYSENTER does not clear the NT flag, which could thus proliferate 235 * from here to the IRET instruction via a context switch and result 236 * in crash. 237 * 238 * SYSENTER does not clear DF, which the ABI assumes to be cleared. 239 * 240 * SYSENTER clears IF, which we would like to be set for syscalls. 241 * 242 */ 243 pushl $(EFLAGS_IF) /* specify EFLAGS bits that we want to set */ 244 popfl /* set bits from the mask, clear or ignore others */ 245 250 246 call syscall_handler 251 247 … … 262 258 movl ISTATE_OFFSET_ESP(%esp), %ecx 263 259 264 addl $(ISTATE_REAL_SIZE), %esp265 266 260 sysexit /* return to userspace */ 267 261 268 /** Declare interrupt handlers 269 * 270 * Declare interrupt handlers for n interrupt 271 * vectors starting at vector i. 272 * 273 */ 262 /* 263 * This is the legacy syscall handler using the interrupt mechanism. 264 */ 265 .global int_syscall 266 int_syscall: 267 subl $(ISTATE_SOFT_SIZE + 4), %esp 268 269 /* 270 * Push syscall arguments onto the stack 271 * 272 * NOTE: The idea behind the order of arguments passed 273 * in registers is to use all scratch registers 274 * first and preserved registers next. An optimized 275 * libc syscall wrapper can make use of this setup. 276 * The istate structure is arranged in the way to support 277 * this idea. 278 * 279 */ 280 movl %eax, ISTATE_OFFSET_EAX(%esp) 281 movl %ebx, ISTATE_OFFSET_EBX(%esp) 282 movl %ecx, ISTATE_OFFSET_ECX(%esp) 283 movl %edx, ISTATE_OFFSET_EDX(%esp) 284 movl %edi, ISTATE_OFFSET_EDI(%esp) 285 movl %esi, ISTATE_OFFSET_ESI(%esp) 286 movl %ebp, ISTATE_OFFSET_EBP(%esp) 287 288 /* 289 * Save the selector registers. 290 */ 291 movl %gs, %ecx 292 movl %fs, %edx 293 294 movl %ecx, ISTATE_OFFSET_GS(%esp) 295 movl %edx, ISTATE_OFFSET_FS(%esp) 296 297 movl %es, %ecx 298 movl %ds, %edx 299 300 movl %ecx, ISTATE_OFFSET_ES(%esp) 301 movl %edx, ISTATE_OFFSET_DS(%esp) 302 303 /* 304 * Switch to kernel selectors. 305 */ 306 movl $(gdtselector(KDATA_DES)), %eax 307 movl %eax, %ds 308 movl %eax, %es 309 310 movl $0, ISTATE_OFFSET_EBP_FRAME(%esp) 311 movl ISTATE_OFFSET_EIP(%esp), %eax 312 movl %eax, ISTATE_OFFSET_EIP_FRAME(%esp) 313 leal ISTATE_OFFSET_EBP_FRAME(%esp), %ebp 314 315 cld 316 317 /* Call syscall_handler(edx, ecx, ebx, esi, edi, ebp, eax) */ 318 call syscall_handler 319 320 /* 321 * Restore the selector registers. 322 */ 323 movl ISTATE_OFFSET_GS(%esp), %ecx 324 movl ISTATE_OFFSET_FS(%esp), %edx 325 326 movl %ecx, %gs 327 movl %edx, %fs 328 329 movl ISTATE_OFFSET_ES(%esp), %ecx 330 movl ISTATE_OFFSET_DS(%esp), %edx 331 332 movl %ecx, %es 333 movl %edx, %ds 334 335 /* 336 * Restore the preserved registers the handler cloberred itself 337 * (i.e. EBP). 338 */ 339 movl ISTATE_OFFSET_EBP(%esp), %ebp 340 341 addl $(ISTATE_SOFT_SIZE + 4), %esp 342 iret 343 344 /** 345 * Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int 346 * has no error word and 1 means interrupt with error word 347 * 348 */ 349 #define ERROR_WORD_INTERRUPT_LIST 0x00027d00 274 350 275 351 .macro handler i 276 352 .global int_\i 277 353 int_\i: 278 .ifeq \i - 0x30 279 /* Syscall handler */ 280 subl $(ISTATE_SOFT_SIZE + 4), %esp 281 282 /* 283 * Push syscall arguments onto the stack 284 * 285 * NOTE: The idea behind the order of arguments passed 286 * in registers is to use all scratch registers 287 * first and preserved registers next. An optimized 288 * libc syscall wrapper can make use of this setup. 289 * The istate structure is arranged in the way to support 290 * this idea. 291 * 292 */ 293 movl %eax, ISTATE_OFFSET_EAX(%esp) 294 movl %ebx, ISTATE_OFFSET_EBX(%esp) 295 movl %ecx, ISTATE_OFFSET_ECX(%esp) 296 movl %edx, ISTATE_OFFSET_EDX(%esp) 297 movl %edi, ISTATE_OFFSET_EDI(%esp) 298 movl %esi, ISTATE_OFFSET_ESI(%esp) 299 movl %ebp, ISTATE_OFFSET_EBP(%esp) 300 301 /* 302 * Save the selector registers. 303 */ 304 movl %gs, %ecx 305 movl %fs, %edx 306 307 movl %ecx, ISTATE_OFFSET_GS(%esp) 308 movl %edx, ISTATE_OFFSET_FS(%esp) 309 310 movl %es, %ecx 311 movl %ds, %edx 312 313 movl %ecx, ISTATE_OFFSET_ES(%esp) 314 movl %edx, ISTATE_OFFSET_DS(%esp) 315 316 /* 317 * Switch to kernel selectors. 318 */ 319 movl $16, %eax 320 movl %eax, %ds 321 movl %eax, %es 322 323 movl $0, ISTATE_OFFSET_EBP_FRAME(%esp) 324 movl ISTATE_OFFSET_EIP(%esp), %eax 325 movl %eax, ISTATE_OFFSET_EIP_FRAME(%esp) 326 leal ISTATE_OFFSET_EBP_FRAME(%esp), %ebp 327 328 cld 329 sti 330 331 /* Call syscall_handler(edx, ecx, ebx, esi, edi, ebp, eax) */ 332 call syscall_handler 333 334 CLEAR_NT_FLAG 335 336 /* 337 * Restore the selector registers. 338 */ 339 movl ISTATE_OFFSET_GS(%esp), %ecx 340 movl ISTATE_OFFSET_FS(%esp), %edx 341 342 movl %ecx, %gs 343 movl %edx, %fs 344 345 movl ISTATE_OFFSET_ES(%esp), %ecx 346 movl ISTATE_OFFSET_DS(%esp), %edx 347 348 movl %ecx, %es 349 movl %edx, %ds 350 351 /* 352 * Restore the preserved registers the handler cloberred itself 353 * (i.e. EBP). 354 */ 355 movl ISTATE_OFFSET_EBP(%esp), %ebp 356 357 addl $(ISTATE_SOFT_SIZE + 4), %esp 358 iret 359 354 /* 355 * This macro distinguishes between two versions of ia32 356 * exceptions. One version has error word and the other 357 * does not have it. The latter version fakes the error 358 * word on the stack so that the handlers and istate_t 359 * can be the same for both types. 360 */ 361 .iflt \i - 32 362 .if (1 << \i) & ERROR_WORD_INTERRUPT_LIST 363 /* 364 * Exception with error word. 365 */ 366 subl $ISTATE_SOFT_SIZE, %esp 367 .else 368 /* 369 * Exception without error word: fake up one 370 */ 371 subl $(ISTATE_SOFT_SIZE + 4), %esp 372 .endif 360 373 .else 361 374 /* 362 * This macro distinguishes between two versions of ia32 363 * exceptions. One version has error word and the other 364 * does not have it. The latter version fakes the error 365 * word on the stack so that the handlers and istate_t 366 * can be the same for both types. 375 * Interrupt: fake up an error word 367 376 */ 368 .iflt \i - 32 369 .if (1 << \i) & ERROR_WORD_INTERRUPT_LIST 370 /* 371 * Exception with error word: do nothing 372 */ 373 .else 374 /* 375 * Exception without error word: fake up one 376 */ 377 pushl $0 378 .endif 379 .else 380 /* 381 * Interrupt: fake up one 382 */ 383 pushl $0 384 .endif 385 386 subl $ISTATE_SOFT_SIZE, %esp 387 388 /* 389 * Save the general purpose registers. 390 */ 391 movl %eax, ISTATE_OFFSET_EAX(%esp) 392 movl %ebx, ISTATE_OFFSET_EBX(%esp) 393 movl %ecx, ISTATE_OFFSET_ECX(%esp) 394 movl %edx, ISTATE_OFFSET_EDX(%esp) 395 movl %edi, ISTATE_OFFSET_EDI(%esp) 396 movl %esi, ISTATE_OFFSET_ESI(%esp) 397 movl %ebp, ISTATE_OFFSET_EBP(%esp) 398 399 /* 400 * Save the selector registers. 401 */ 402 movl %gs, %eax 403 movl %fs, %ebx 404 movl %es, %ecx 405 movl %ds, %edx 406 407 movl %eax, ISTATE_OFFSET_GS(%esp) 408 movl %ebx, ISTATE_OFFSET_FS(%esp) 409 movl %ecx, ISTATE_OFFSET_ES(%esp) 410 movl %edx, ISTATE_OFFSET_DS(%esp) 411 412 /* 413 * Switch to kernel selectors. 414 */ 415 movl $16, %eax 416 movl %eax, %ds 417 movl %eax, %es 418 419 /* 420 * Imitate a regular stack frame linkage. 421 * Stop stack traces here if we came from userspace. 422 */ 423 cmpl $8, ISTATE_OFFSET_CS(%esp) 424 jz 0f 425 xorl %ebp, %ebp 426 427 0: 428 429 movl %ebp, ISTATE_OFFSET_EBP_FRAME(%esp) 430 movl ISTATE_OFFSET_EIP(%esp), %eax 431 movl %eax, ISTATE_OFFSET_EIP_FRAME(%esp) 432 leal ISTATE_OFFSET_EBP_FRAME(%esp), %ebp 433 434 cld 435 436 pushl %esp /* pass istate address */ 437 pushl $(\i) /* pass intnum */ 438 439 /* Call exc_dispatch(intnum, istate) */ 440 call exc_dispatch 441 442 addl $8, %esp /* clear arguments from the stack */ 443 444 CLEAR_NT_FLAG 445 446 /* 447 * Restore the selector registers. 448 */ 449 movl ISTATE_OFFSET_GS(%esp), %eax 450 movl ISTATE_OFFSET_FS(%esp), %ebx 451 movl ISTATE_OFFSET_ES(%esp), %ecx 452 movl ISTATE_OFFSET_DS(%esp), %edx 453 454 movl %eax, %gs 455 movl %ebx, %fs 456 movl %ecx, %es 457 movl %edx, %ds 458 459 /* 460 * Restore the scratch registers and the preserved 461 * registers the handler cloberred itself 462 * (i.e. EBX and EBP). 463 */ 464 movl ISTATE_OFFSET_EAX(%esp), %eax 465 movl ISTATE_OFFSET_EBX(%esp), %ebx 466 movl ISTATE_OFFSET_ECX(%esp), %ecx 467 movl ISTATE_OFFSET_EDX(%esp), %edx 468 movl ISTATE_OFFSET_EBP(%esp), %ebp 469 470 addl $(ISTATE_SOFT_SIZE + 4), %esp 471 iret 472 377 subl $(ISTATE_SOFT_SIZE + 4), %esp 473 378 .endif 379 380 /* 381 * Save the general purpose registers. 382 */ 383 movl %eax, ISTATE_OFFSET_EAX(%esp) 384 movl %ebx, ISTATE_OFFSET_EBX(%esp) 385 movl %ecx, ISTATE_OFFSET_ECX(%esp) 386 movl %edx, ISTATE_OFFSET_EDX(%esp) 387 movl %edi, ISTATE_OFFSET_EDI(%esp) 388 movl %esi, ISTATE_OFFSET_ESI(%esp) 389 movl %ebp, ISTATE_OFFSET_EBP(%esp) 390 391 /* 392 * Save the selector registers. 393 */ 394 movl %gs, %ecx 395 movl %fs, %edx 396 397 movl %ecx, ISTATE_OFFSET_GS(%esp) 398 movl %edx, ISTATE_OFFSET_FS(%esp) 399 400 movl %es, %ecx 401 movl %ds, %edx 402 403 movl %ecx, ISTATE_OFFSET_ES(%esp) 404 movl %edx, ISTATE_OFFSET_DS(%esp) 405 406 /* 407 * Switch to kernel selectors. 408 */ 409 movl $(gdtselector(KDATA_DES)), %eax 410 movl %eax, %ds 411 movl %eax, %es 412 413 /* 414 * Imitate a regular stack frame linkage. 415 * Stop stack traces here if we came from userspace. 416 */ 417 xorl %eax, %eax 418 cmpl $(gdtselector(KTEXT_DES)), ISTATE_OFFSET_CS(%esp) 419 cmovnzl %eax, %ebp 420 421 movl %ebp, ISTATE_OFFSET_EBP_FRAME(%esp) 422 movl ISTATE_OFFSET_EIP(%esp), %eax 423 movl %eax, ISTATE_OFFSET_EIP_FRAME(%esp) 424 leal ISTATE_OFFSET_EBP_FRAME(%esp), %ebp 425 426 cld 427 428 pushl %esp /* pass istate address */ 429 pushl $(\i) /* pass intnum */ 430 431 /* Call exc_dispatch(intnum, istate) */ 432 call exc_dispatch 433 434 addl $8, %esp /* clear arguments from the stack */ 435 436 /* 437 * Restore the selector registers. 438 */ 439 movl ISTATE_OFFSET_GS(%esp), %ecx 440 movl ISTATE_OFFSET_FS(%esp), %edx 441 442 movl %ecx, %gs 443 movl %edx, %fs 444 445 movl ISTATE_OFFSET_ES(%esp), %ecx 446 movl ISTATE_OFFSET_DS(%esp), %edx 447 448 movl %ecx, %es 449 movl %edx, %ds 450 451 /* 452 * Restore the scratch registers and the preserved 453 * registers the handler cloberred itself 454 * (i.e. EBP). 455 */ 456 movl ISTATE_OFFSET_EAX(%esp), %eax 457 movl ISTATE_OFFSET_ECX(%esp), %ecx 458 movl ISTATE_OFFSET_EDX(%esp), %edx 459 movl ISTATE_OFFSET_EBP(%esp), %ebp 460 461 addl $(ISTATE_SOFT_SIZE + 4), %esp 462 iret 474 463 .endm 475 464 -
kernel/arch/ia32/src/interrupt.c
r41ce4d9 r074c9bd 65 65 void istate_decode(istate_t *istate) 66 66 { 67 printf(" error_word=%p\n", istate->error_word);68 printf("eflags=%p\n", istate->eflags);69 70 printf(" cs =%p\tds =%p\tes =%p\n", istate->cs, istate->ds, istate->es);71 printf("fs =%p\tgs =%p", istate->fs, istate->gs);67 printf("cs =%p\teip=%p\tefl=%p\terr=%p\n", 68 istate->cs, istate->eip, istate->eflags, istate->error_word); 69 70 printf("ds =%p\tes =%p\tfs =%p\tgs =%p\n", 71 istate->ds, istate->es, istate->fs, istate->gs); 72 72 if (istate_from_uspace(istate)) 73 printf("\tss =%p\n", istate->ss); 74 else 75 printf("\n"); 76 77 printf("eax=%p\tebx=%p\tecx=%p\n", istate->eax, istate->ebx, 78 istate->ecx); 79 printf("edx=%p\tedi=%p\tesi=%p\n", istate->edx, istate->edi, 80 istate->esi); 81 printf("ebp=%p\tesp=%p\teip=%p\n", istate->ebp, 82 istate_from_uspace(istate) ? istate->esp : (uintptr_t) &istate->esp, 83 istate->eip); 73 printf("ss =%p\n", istate->ss); 74 75 printf("eax=%p\tebx=%p\tecx=%p\tedx=%p\n", 76 istate->eax, istate->ebx, istate->ecx, istate->edx); 77 printf("esi=%p\tedi=%p\tebp=%p\tesp=%p\n", 78 istate->esi, istate->edi, istate->ebp, 79 istate_from_uspace(istate) ? istate->esp : (uintptr_t)&istate->esp); 84 80 } 85 81 -
kernel/arch/ia32/src/mm/page.c
r41ce4d9 r074c9bd 115 115 if (as_page_fault(page, access, istate) == AS_PF_FAULT) { 116 116 fault_if_from_uspace(istate, "Page fault: %#x.", page); 117 panic_memtrap(istate, access, page, "Page fault.");117 panic_memtrap(istate, access, page, NULL); 118 118 } 119 119 } -
kernel/arch/ia32/src/pm.c
r41ce4d9 r074c9bd 130 130 d->selector = gdtselector(KTEXT_DES); 131 131 132 d->access = AR_PRESENT | AR_INTERRUPT; /* masking interrupt */133 134 132 if (i == VECTOR_SYSCALL) { 135 133 /* 136 * The syscall interrupt gate must be calleable from137 * userland. 134 * The syscall trap gate must be callable from 135 * userland. Interrupts will remain enabled. 138 136 */ 139 d->access |= DPL_USER; 137 d->access = AR_PRESENT | AR_TRAP | DPL_USER; 138 } else { 139 /* 140 * Other interrupts use interrupt gates which 141 * disable interrupts. 142 */ 143 d->access = AR_PRESENT | AR_INTERRUPT; 140 144 } 141 145 } … … 206 210 idt_setoffset(d++, (uintptr_t) &int_62); 207 211 idt_setoffset(d++, (uintptr_t) &int_63); 212 213 idt_setoffset(&idt[VECTOR_SYSCALL], (uintptr_t) &int_syscall); 208 214 } 209 215 -
kernel/arch/ia32/src/proc/scheduler.c
r41ce4d9 r074c9bd 38 38 #include <proc/thread.h> 39 39 #include <arch.h> 40 #include <arch/ context.h> /* SP_DELTA */40 #include <arch/interrupt.h> 41 41 #include <arch/pm.h> 42 42 #include <arch/asm.h> … … 58 58 void before_thread_runs_arch(void) 59 59 { 60 uintptr_t kstk = (uintptr_t) &THREAD->kstack[THREAD_STACK_SIZE - 61 SP_DELTA]; 60 uintptr_t kstk = (uintptr_t) &THREAD->kstack[THREAD_STACK_SIZE]; 62 61 63 62 if (CPU->arch.fi.bits.sep) { 64 63 /* Set kernel stack for CP3 -> CPL0 switch via SYSENTER */ 65 write_msr(IA32_MSR_SYSENTER_ESP, kstk );64 write_msr(IA32_MSR_SYSENTER_ESP, kstk - sizeof(istate_t)); 66 65 } 67 66 -
kernel/arch/ia64/src/mm/tlb.c
r41ce4d9 r074c9bd 500 500 if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) { 501 501 fault_if_from_uspace(istate, "Page fault at %p.", va); 502 panic_memtrap(istate, PF_ACCESS_EXEC, va, 503 "Page fault."); 502 panic_memtrap(istate, PF_ACCESS_EXEC, va, NULL); 504 503 } 505 504 } … … 622 621 if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { 623 622 fault_if_from_uspace(istate, "Page fault at %p.", va); 624 panic_memtrap(istate, PF_ACCESS_READ, va, 625 "Page fault."); 623 panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL); 626 624 } 627 625 } … … 671 669 if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) { 672 670 fault_if_from_uspace(istate, "Page fault at %p.", va); 673 panic_memtrap(istate, PF_ACCESS_WRITE, va, 674 "Page fault."); 671 panic_memtrap(istate, PF_ACCESS_WRITE, va, NULL); 675 672 } 676 673 } … … 708 705 if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) { 709 706 fault_if_from_uspace(istate, "Page fault at %p.", va); 710 panic_memtrap(istate, PF_ACCESS_EXEC, va, 711 "Page fault."); 707 panic_memtrap(istate, PF_ACCESS_EXEC, va, NULL); 712 708 } 713 709 } … … 745 741 if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { 746 742 fault_if_from_uspace(istate, "Page fault at %p.", va); 747 panic_memtrap(istate, PF_ACCESS_READ, va, 748 "Page fault."); 743 panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL); 749 744 } 750 745 } … … 778 773 if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) { 779 774 fault_if_from_uspace(istate, "Page fault at %p.", va); 780 panic_memtrap(istate, PF_ACCESS_WRITE, va, "Page fault.");775 panic_memtrap(istate, PF_ACCESS_WRITE, va, NULL); 781 776 } 782 777 page_table_unlock(AS, true); … … 818 813 if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { 819 814 fault_if_from_uspace(istate, "Page fault at %p.", va); 820 panic_memtrap(istate, PF_ACCESS_READ, va, 821 "Page fault."); 815 panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, NULL); 822 816 } 823 817 } -
kernel/arch/mips32/src/mm/tlb.c
r41ce4d9 r074c9bd 324 324 325 325 fault_if_from_uspace(istate, "TLB Refill Exception on %p.", va); 326 panic_memtrap(istate, PF_ACCESS_ READ, va, "TLB Refill Exception.");326 panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, "TLB Refill Exception."); 327 327 } 328 328 … … 333 333 334 334 fault_if_from_uspace(istate, "TLB Invalid Exception on %p.", va); 335 panic_memtrap(istate, PF_ACCESS_ READ, va, "TLB Invalid Exception.");335 panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, "TLB Invalid Exception."); 336 336 } 337 337 -
kernel/arch/ppc32/src/mm/tlb.c
r41ce4d9 r074c9bd 112 112 { 113 113 fault_if_from_uspace(istate, "PHT Refill Exception on %p.", badvaddr); 114 panic_memtrap(istate, PF_ACCESS_ READ, badvaddr,114 panic_memtrap(istate, PF_ACCESS_UNKNOWN, badvaddr, 115 115 "PHT Refill Exception."); 116 116 } -
kernel/arch/sparc64/src/mm/sun4u/tlb.c
r41ce4d9 r074c9bd 259 259 /* NULL access in kernel */ 260 260 do_fast_data_access_mmu_miss_fault(istate, tag, 261 "Dereferencing NULL pointer ");261 "Dereferencing NULL pointer."); 262 262 } else if (page_8k >= end_of_identity) { 263 263 /* … … 442 442 { 443 443 fault_if_from_uspace(istate, "%s, Address=%p.", str, va); 444 panic_memtrap(istate, PF_ACCESS_EXEC, va, "%s.",str);444 panic_memtrap(istate, PF_ACCESS_EXEC, va, str); 445 445 } 446 446 … … 453 453 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va, 454 454 tag.context); 455 panic_memtrap(istate, PF_ACCESS_ READ, va, "%s.", str);455 panic_memtrap(istate, PF_ACCESS_UNKNOWN, va, str); 456 456 } 457 457 … … 464 464 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va, 465 465 tag.context); 466 panic_memtrap(istate, PF_ACCESS_WRITE, va, "%s.",str);466 panic_memtrap(istate, PF_ACCESS_WRITE, va, str); 467 467 } 468 468 -
kernel/arch/sparc64/src/mm/sun4v/tlb.c
r41ce4d9 r074c9bd 359 359 { 360 360 fault_if_from_uspace(istate, "%s, Address=%p.", str, va); 361 panic_memtrap(istate, PF_ACCESS_EXEC, va, "%s.",str);361 panic_memtrap(istate, PF_ACCESS_EXEC, va, str); 362 362 } 363 363 … … 367 367 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, 368 368 DMISS_ADDRESS(page_and_ctx), DMISS_CONTEXT(page_and_ctx)); 369 panic_memtrap(istate, PF_ACCESS_ READ, DMISS_ADDRESS(page_and_ctx),370 "%s.");369 panic_memtrap(istate, PF_ACCESS_UNKNOWN, DMISS_ADDRESS(page_and_ctx), 370 str); 371 371 } 372 372 … … 377 377 DMISS_ADDRESS(page_and_ctx), DMISS_CONTEXT(page_and_ctx)); 378 378 panic_memtrap(istate, PF_ACCESS_WRITE, DMISS_ADDRESS(page_and_ctx), 379 "%s.");379 str); 380 380 } 381 381 -
kernel/generic/include/mm/as.h
r41ce4d9 r074c9bd 171 171 PF_ACCESS_READ, 172 172 PF_ACCESS_WRITE, 173 PF_ACCESS_EXEC 173 PF_ACCESS_EXEC, 174 PF_ACCESS_UNKNOWN 174 175 } pf_access_t; 175 176 -
kernel/generic/src/console/kconsole.c
r41ce4d9 r074c9bd 210 210 link_t *pos = NULL; 211 211 const char *hint; 212 char output[MAX_CMDLINE];212 char *output = malloc(MAX_CMDLINE, 0); 213 213 214 214 output[0] = 0; … … 235 235 str_cpy(input, size, output); 236 236 237 free(output); 237 238 return found; 238 239 } … … 245 246 wchar_t *current = history[history_pos]; 246 247 current[0] = 0; 248 char *tmp = malloc(STR_BOUNDS(MAX_CMDLINE), 0); 247 249 248 250 while (true) { … … 289 291 beg++; 290 292 291 char tmp[STR_BOUNDS(MAX_CMDLINE)];292 293 wstr_to_str(tmp, position - beg + 1, current + beg); 293 294 … … 415 416 } 416 417 418 free(tmp); 417 419 return current; 418 420 } … … 630 632 cmd->argv[i].vartype = ARG_TYPE_STRING; 631 633 } else { 632 printf("Wrong syn xtax.\n");634 printf("Wrong syntax.\n"); 633 635 error = true; 634 636 } … … 688 690 printf("Type \"exit\" to leave the console.\n"); 689 691 692 char *cmdline = malloc(STR_BOUNDS(MAX_CMDLINE), 0); 690 693 while (true) { 691 694 wchar_t *tmp = clever_readline((char *) prompt, stdin); … … 694 697 continue; 695 698 696 char cmdline[STR_BOUNDS(MAX_CMDLINE)];697 699 wstr_to_str(cmdline, STR_BOUNDS(MAX_CMDLINE), tmp); 698 700 … … 706 708 (void) cmd_info->func(cmd_info->argv); 707 709 } 710 free(cmdline); 708 711 } 709 712 -
kernel/generic/src/debug/panic.c
r41ce4d9 r074c9bd 61 61 } else if (cat == PANIC_BADTRAP) { 62 62 printf("BAD TRAP %ld.\n", address); 63 if (fmt) { 64 vprintf(fmt, args); 65 printf("\n"); 66 } 63 67 } else if (cat == PANIC_MEMTRAP) { 64 68 printf("A BAD MEMORY ACCESS WHILE "); … … 72 76 printf("REFERENCING"); 73 77 printf(" ADDRESS %p.\n", address); 78 if (fmt) { 79 vprintf(fmt, args); 80 printf("\n"); 81 } 74 82 } else { 75 83 printf("THE FOLLOWING REASON:\n"); 76 84 vprintf(fmt, args); 85 printf("\n"); 77 86 } 78 87 va_end(args);
Note:
See TracChangeset
for help on using the changeset viewer.