x86_64: kernel trap/interrupt handling
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 24 Jun 2013 22:12:31 +0000 (15:12 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 26 Jun 2013 05:19:03 +0000 (22:19 -0700)
Worked for breakpoint and a self-ipi.  Vcore stuff is turned off til I
get the kernel sorted.

kern/arch/x86/entry64.S
kern/arch/x86/process64.c
kern/arch/x86/ros/mmu64.h
kern/arch/x86/ros/trapframe64.h
kern/arch/x86/trap64.c
kern/arch/x86/trap64.h
kern/arch/x86/trapentry64.S
kern/src/init.c
user/parlib/include/x86/vcore64.h

index 1ca8bd0..876e840 100644 (file)
@@ -111,6 +111,13 @@ _start:
        ljmp    $0x08, $long_mode
 .code64
 long_mode:
+       # zero the data segments.  Not sure if this is legit or not.
+       xor     %rax, %rax
+       mov     %ax, %ds
+       mov     %ax, %es
+       mov     %ax, %ss
+       mov     %ax, %fs
+       mov     %ax, %gs
        # paging is on, and our code is still running at 0x00100000.
        # do some miscellaneous OS setup.  the coreid stuff is so we can call
        # core_id() before smp_boot. 
@@ -139,6 +146,7 @@ gdt64:
        SEG_CODE_64(3)          # user code segment
        SEG_NULL                        # these two nulls are a placeholder for the TSS
        SEG_NULL                        # these two nulls are a placeholder for the TSS
+       SEG_DATA_64                     # generic flat data segment (debugging for now)
 .globl gdt64desc
 gdt64desc:
        .word   (gdt64desc - gdt64 - 1)         # sizeof(gdt64) - 1
index 882c1e9..7c96bcb 100644 (file)
@@ -71,8 +71,8 @@ void proc_pop_ctx(struct user_context *ctx)
                 * so that we have a chance to change esp to a good value before
                 * interrupts are enabled.  The other option would be to throw away the
                 * eflags, but that's less desirable. */
-               tf->tf_eflags &= !FL_IF;
-               tf->tf_esp = read_sp();
+               tf->tf_rflags &= !FL_IF;
+               tf->tf_rsp = read_sp();
 //             asm volatile ("movl %0,%%esp;           "
 //                           "popal;                   "
 //                           "popl %%gs;               "
@@ -104,19 +104,17 @@ void proc_init_ctx(struct user_context *ctx, uint32_t vcoreid, uintptr_t entryp,
         * GD_UT is the user text segment selector (see inc/memlayout.h).
         * The low 2 bits of each segment register contains the
         * Requestor Privilege Level (RPL); 3 means user mode. */
-       tf->tf_ds = GD_UD | 3;
-       tf->tf_es = GD_UD | 3;
        tf->tf_ss = GD_UD | 3;
-       tf->tf_esp = stack_top-64;
+       tf->tf_rsp = stack_top-64;
        tf->tf_cs = GD_UT | 3;
        /* set the env's EFLAGSs to have interrupts enabled */
-       tf->tf_eflags |= 0x00000200; // bit 9 is the interrupts-enabled
+       tf->tf_rflags |= 0x00000200; // bit 9 is the interrupts-enabled
 
-       tf->tf_eip = entryp;
+       tf->tf_rip = entryp;
 
        /* Coupled closely with user's entry.S.  id is the vcoreid, which entry.S
         * uses to determine what to do.  vcoreid == 0 is the main core/context. */
-       tf->tf_regs.reg_eax = vcoreid;
+       tf->tf_rax = vcoreid;
 }
 
 /* TODO: handle both HW and SW contexts */
@@ -129,13 +127,11 @@ void proc_secure_ctx(struct user_context *ctx)
         * necessarily know what it ought to be (we could check, but that's a pain).
         * the code protecting the kernel from TLS related things ought to be able
         * to handle GPFs on popping gs. TODO: (TLSV) */
-       tf->tf_ds = GD_UD | 3;
-       tf->tf_es = GD_UD | 3;
-       tf->tf_fs = 0;
+       //tf->tf_fs = 0;
        //tf->tf_gs = whatevs.  ignoring this.
        tf->tf_ss = GD_UD | 3;
        tf->tf_cs ? GD_UT | 3 : 0; // can be 0 for sysenter TFs.
-       tf->tf_eflags |= 0x00000200; // bit 9 is the interrupts-enabled
+       tf->tf_rflags |= 0x00000200; // bit 9 is the interrupts-enabled
 }
 
 /* Called when we are currently running an address space on our core and want to
index c10fdcc..d61c2b9 100644 (file)
@@ -433,7 +433,7 @@ typedef struct taskstate {
        uint64_t                                        ts_rsv3;        /* reserved / ignored */
        uint16_t                                        ts_rsv4;        /* reserved / ignored */
        uint16_t                                        ts_iobm;        /* IO base map (offset) */
-} taskstate_t;
+} __attribute__((packed)) taskstate_t;
 
 /* 64 bit gate descriptors for interrupts and traps */
 typedef struct Gatedesc {
@@ -504,7 +504,7 @@ typedef struct Pseudodesc {
 #define STS_IG32       0xE             /* 64-bit Interrupt Gate */
 #define STS_TG32       0xF             /* 64-bit Trap Gate */
 
-#define SEG_COUNT      5               /* Number of GDT segments */
+#define SEG_COUNT      6               /* Number of GDT segments */
 /* TODO: Probably won't use this */
 #define LDT_SIZE       (8192 * sizeof(segdesc_t))
 
index d86e79a..125da6a 100644 (file)
@@ -5,38 +5,38 @@
 #error "Do not include include ros/arch/trapframe64.h directly"
 #endif
 
-typedef struct pushregs {
-       /* registers as pushed by pusha */
-       uint32_t reg_edi;
-       uint32_t reg_esi;
-       uint32_t reg_ebp; uint32_t reg_oesp;            /* Useless */
-       uint32_t reg_ebx;
-       uint32_t reg_edx;
-       uint32_t reg_ecx;
-       uint32_t reg_eax;
-} push_regs_t;
-
 struct hw_trapframe {
-       push_regs_t tf_regs;
+       uint64_t tf_rax;
+       uint64_t tf_rbx;
+       uint64_t tf_rcx;
+       uint64_t tf_rdx;
+       uint64_t tf_rbp;
+       uint64_t tf_rsi;
+       uint64_t tf_rdi;
+       uint64_t tf_r8;
+       uint64_t tf_r9;
+       uint64_t tf_r10;
+       uint64_t tf_r11;
+       uint64_t tf_r12;
+       uint64_t tf_r13;
+       uint64_t tf_r14;
+       uint64_t tf_r15;
+       uint32_t tf_trapno;
        uint16_t tf_gs;
-       uint16_t tf_padding1;
        uint16_t tf_fs;
-       uint16_t tf_padding2;
-       uint16_t tf_es;
-       uint16_t tf_padding3;
-       uint16_t tf_ds;
-       uint16_t tf_padding4;
-       uint32_t tf_trapno;
-       /* below here defined by x86 hardware */
+       /* below here defined by x86 hardware (error code optional) */
        uint32_t tf_err;
-       uintptr_t tf_eip;
+       uint32_t tf_padding4;
+       uint64_t tf_rip;
        uint16_t tf_cs;
-       uint16_t tf_padding5;
-       uint32_t tf_eflags;
-       /* below here only when crossing rings, such as from user to kernel */
-       uintptr_t tf_esp;
+       uint16_t tf_padding3;
+       uint32_t tf_padding2;
+       uint64_t tf_rflags;
+       /* unlike 32 bit, SS:RSP is always pushed, even when not changing rings */
+       uint64_t tf_rsp;
        uint16_t tf_ss;
-       uint16_t tf_padding6;
+       uint16_t tf_padding1;
+       uint32_t tf_padding0;
 };
 
 struct sw_trapframe {
index b8581b8..9f08438 100644 (file)
@@ -45,18 +45,6 @@ void pop_kernel_ctx(struct kernel_ctx *ctx)
        panic("ret failed");
 }
 
-static void print_regs(push_regs_t *regs)
-{
-       printk("  edi  0x%08x\n", regs->reg_edi);
-       printk("  esi  0x%08x\n", regs->reg_esi);
-       printk("  ebp  0x%08x\n", regs->reg_ebp);
-       printk("  oesp 0x%08x\n", regs->reg_oesp);
-       printk("  ebx  0x%08x\n", regs->reg_ebx);
-       printk("  edx  0x%08x\n", regs->reg_edx);
-       printk("  ecx  0x%08x\n", regs->reg_ecx);
-       printk("  eax  0x%08x\n", regs->reg_eax);
-}
-
 void print_trapframe(struct hw_trapframe *hw_tf)
 {
        static spinlock_t ptf_lock = SPINLOCK_INITIALIZER_IRQSAVE;
@@ -68,22 +56,31 @@ void print_trapframe(struct hw_trapframe *hw_tf)
        pcpui->__lock_depth_disabled++;
        spin_lock_irqsave(&ptf_lock);
        printk("TRAP frame at %p on core %d\n", hw_tf, core_id());
-       print_regs(&hw_tf->tf_regs);
-       printk("  gs   0x----%04x\n", hw_tf->tf_gs);
-       printk("  fs   0x----%04x\n", hw_tf->tf_fs);
-       printk("  es   0x----%04x\n", hw_tf->tf_es);
-       printk("  ds   0x----%04x\n", hw_tf->tf_ds);
-       printk("  trap 0x%08x %s\n",  hw_tf->tf_trapno,
-                                     x86_trapname(hw_tf->tf_trapno));
-       printk("  err  0x%08x\n",     hw_tf->tf_err);
-       printk("  eip  0x%08x\n",     hw_tf->tf_eip);
-       printk("  cs   0x----%04x\n", hw_tf->tf_cs);
-       printk("  flag 0x%08x\n",     hw_tf->tf_eflags);
-       /* Prevents us from thinking these mean something for nested interrupts. */
-       if (hw_tf->tf_cs != GD_KT) {
-               printk("  esp  0x%08x\n",     hw_tf->tf_esp);
-               printk("  ss   0x----%04x\n", hw_tf->tf_ss);
-       }
+       printk("  rax  0x%016lx\n",           hw_tf->tf_rax);
+       printk("  rbx  0x%016lx\n",           hw_tf->tf_rbx);
+       printk("  rcx  0x%016lx\n",           hw_tf->tf_rcx);
+       printk("  rdx  0x%016lx\n",           hw_tf->tf_rdx);
+       printk("  rbp  0x%016lx\n",           hw_tf->tf_rbp);
+       printk("  rsi  0x%016lx\n",           hw_tf->tf_rsi);
+       printk("  rdi  0x%016lx\n",           hw_tf->tf_rdi);
+       printk("  r8   0x%016lx\n",           hw_tf->tf_r8);
+       printk("  r9   0x%016lx\n",           hw_tf->tf_r9);
+       printk("  r10  0x%016lx\n",           hw_tf->tf_r10);
+       printk("  r11  0x%016lx\n",           hw_tf->tf_r11);
+       printk("  r12  0x%016lx\n",           hw_tf->tf_r12);
+       printk("  r13  0x%016lx\n",           hw_tf->tf_r13);
+       printk("  r14  0x%016lx\n",           hw_tf->tf_r14);
+       printk("  r15  0x%016lx\n",           hw_tf->tf_r15);
+       printk("  trap 0x%08x %s\n",          hw_tf->tf_trapno,
+                                             x86_trapname(hw_tf->tf_trapno));
+       printk("  gs   0x%04x\n",             hw_tf->tf_gs);
+       printk("  fs   0x%04x\n",             hw_tf->tf_fs);
+       printk("  err  0x--------%08x\n",     hw_tf->tf_err);
+       printk("  rip  0x%016lx\n",           hw_tf->tf_rip);
+       printk("  cs   0x------------%04x\n", hw_tf->tf_cs);
+       printk("  flag 0x%016lx\n",           hw_tf->tf_rflags);
+       printk("  rsp  0x%016lx\n",           hw_tf->tf_rsp);
+       printk("  ss   0x------------%04x\n", hw_tf->tf_ss);
        spin_unlock_irqsave(&ptf_lock);
        pcpui->__lock_depth_disabled--;
 }
@@ -108,15 +105,15 @@ void page_fault_handler(struct hw_trapframe *hw_tf)
                /* Destroy the faulting process */
                printk("[%08x] user %s fault va %08x ip %08x on core %d with err %d\n",
                       current->pid, prot & PROT_READ ? "READ" : "WRITE", fault_va,
-                      hw_tf->tf_eip, core_id(), err);
+                      hw_tf->tf_rip, core_id(), err);
                print_trapframe(hw_tf);
                /* Turn this on to help debug bad function pointers */
-               printd("esp %p\n\t 0(esp): %p\n\t 4(esp): %p\n\t 8(esp): %p\n"
-                      "\t12(esp): %p\n", hw_tf->tf_esp,
-                      *(uintptr_t*)(hw_tf->tf_esp +  0),
-                      *(uintptr_t*)(hw_tf->tf_esp +  4),
-                      *(uintptr_t*)(hw_tf->tf_esp +  8),
-                      *(uintptr_t*)(hw_tf->tf_esp + 12));
+               printd("rsp %p\n\t 0(rsp): %p\n\t 8(rsp): %p\n\t 16(rsp): %p\n"
+                      "\t24(rsp): %p\n", hw_tf->tf_rsp,
+                      *(uintptr_t*)(hw_tf->tf_rsp +  0),
+                      *(uintptr_t*)(hw_tf->tf_rsp +  8),
+                      *(uintptr_t*)(hw_tf->tf_rsp + 16),
+                      *(uintptr_t*)(hw_tf->tf_rsp + 24));
                proc_destroy(current);
        }
 }
index 88e3476..4098902 100644 (file)
@@ -43,21 +43,21 @@ static inline void save_kernel_ctx(struct kernel_ctx *ctx)
 
 static inline uintptr_t x86_get_ip_hw(struct hw_trapframe *hw_tf)
 {
-       return hw_tf->tf_eip;
+       return hw_tf->tf_rip;
 }
 
 static inline void x86_advance_ip(struct hw_trapframe *hw_tf, size_t bytes)
 {
-               hw_tf->tf_eip += bytes;
+               hw_tf->tf_rip += bytes;
 }
 
 static inline void x86_fake_rdtscp(struct hw_trapframe *hw_tf)
 {
        uint64_t tsc_time = read_tsc();
-       hw_tf->tf_eip += 3;
-       hw_tf->tf_regs.reg_eax = tsc_time & 0xffffffff;
-       hw_tf->tf_regs.reg_edx = tsc_time >> 32;
-       hw_tf->tf_regs.reg_ecx = core_id();
+       hw_tf->tf_rip += 3;
+       hw_tf->tf_rax = tsc_time & 0xffffffff;
+       hw_tf->tf_rdx = tsc_time >> 32;
+       hw_tf->tf_rcx = core_id();
 }
 
 static inline void x86_set_sysenter_stacktop(uintptr_t stacktop)
@@ -67,12 +67,12 @@ static inline void x86_set_sysenter_stacktop(uintptr_t stacktop)
 
 static inline long x86_get_sysenter_arg0(struct hw_trapframe *hw_tf)
 {
-       return hw_tf->tf_regs.reg_eax;
+       return hw_tf->tf_rax;   // XXX probably wrong
 }
 
 static inline long x86_get_sysenter_arg1(struct hw_trapframe *hw_tf)
 {
-       return hw_tf->tf_regs.reg_esi;
+       return hw_tf->tf_rsi;   // XXX probably wrong
 }
 
 static inline uintptr_t x86_get_stacktop_tss(struct taskstate *tss)
index 39b45f4..8bfc157 100644 (file)
@@ -1,7 +1,7 @@
 /* See COPYRIGHT for copyright information.
  * The two TRAP* macros (minus the .data parts) are from the JOS project.
  * Everything else:
- * Copyright (c) 2009 The Regents of the University of California
+ * Copyright (c) 2009, 2013 The Regents of the University of California
  * Barret Rhoden <brho@cs.berkeley.edu>
  * See LICENSE for details.
  */
@@ -32,8 +32,7 @@
 
 /* Use TRAPHANDLER_NOEC for traps where the CPU doesn't push an error code.
  * It pushes a 0 in place of the error code, so the trap frame has the same
- * format in either case.
- */
+ * format in either case.  */
 #define TRAPHANDLER_NOEC(name, num)            \
        .text;                                                          \
        .globl name;                                            \
        .quad name;                                                     \
        .long num
 
-/* Same as above, but takes a specific function to jump to.  See comments
- * below from _allirqs for details.
- */
-#define IRQ_HANDLER_SPEC(name, num, func)                                      \
-       .text;                                                                                                 \
-       .globl name;                                                                                   \
-       .type name, @function;                                                                 \
-       .align 2;                                                                                              \
-       name:                                                                                                  \
-       pushq $0;                                                                  \
-       pushq $(num);                                                              \
-       cld;                                                                       \
-       pushq %ds;                                                                 \
-       pushq %es;                                                                 \
-       pushq %fs;                                                                 \
-       pushq %gs;                                                                 \
-       # pushal;                                                                  \
-       movw $0, %ax;                                                              \
-       movw %ax, %gs;                                                             \
-       movw %ax, %fs;                                                             \
-       movw $GD_KD, %ax;                                                          \
-       movw %ax, %ds;                                                             \
-       movw %ax, %es;                                                             \
-       pushq %rsp;                                                                \
-       movq $0, %rbp;                                                             \
-       call (func);                                                               \
-       popq %rsp;                                                                 \
-       # popal;                                                                   \
-       popq %gs;                                                                  \
-       popq %fs;                                                                  \
-       popq %es;                                                                  \
-       popq %ds;                                                                  \
-       addl $0x8, %rsp;                                                           \
-       iret;                                                                      \
-       .data;                                                                     \
-       .quad name;                                                                \
-       .long num
-
 .data
 .globl trap_tbl
 trap_tbl:
@@ -186,59 +147,93 @@ TRAPHANDLER_NOEC(ISR_default, T_DEFAULT)
 trap_tbl_end:
 
 /* Keep the exit paths of _alltraps, _allirqs, and sysenter_handler in sync
- * with the corrrsponding pop_tf's.
- */
+ * with the corrrsponding pop_tf's.  */
 .text
 _alltraps:
        cld
-       # pushq %ds
-       # pushq %es
-       pushq %fs
-       pushq %gs
-       # pushal
-       movw $0, %ax;
-       movw %ax, %gs;
-       movw %ax, %fs;
-       movw $GD_KD, %ax                # data segments aren't accessible by default
-       pushq %rsp
+       /* trapno was pushed, taking up 64 bits.  we're using the upper 32 bits */
+       movw %gs, 0x4(%rsp)
+       movw %fs, 0x6(%rsp)
+       pushq %r15
+       pushq %r14
+       pushq %r13
+       pushq %r12
+       pushq %r11
+       pushq %r10
+       pushq %r9
+       pushq %r8
+       pushq %rdi
+       pushq %rsi
+       pushq %rbp
+       pushq %rdx
+       pushq %rcx
+       pushq %rbx
+       pushq %rax
        movq $0, %rbp                   # so we can backtrace to this point
+       movq %rsp, %rdi
        call trap
-       popq %rsp
-       # popal
-       popq %gs
-       popq %fs
-       # popq %es
-       # popq %ds
-       addq $0x8, %rsp                 # skip trapno and err
-       iret
+       popq %rax
+       popq %rbx
+       popq %rcx
+       popq %rdx
+       popq %rbp
+       popq %rsi
+       popq %rdi
+       popq %r8
+       popq %r9
+       popq %r10
+       popq %r11
+       popq %r12
+       popq %r13
+       popq %r14
+       popq %r15
+       movw 0x4(%rsp), %gs
+       movw 0x6(%rsp), %fs
+       addq $0x10, %rsp                        # skip gs, fs, trapno, and err
+       iretq
 
-/* will need to think about when we reenable interrupts.  right now, iret does it,
- * if the previous EFLAGS had interrupts enabled
- */
 _allirqs:
        cld
-       # pushq %ds
-       # pushq %es
-       pushq %fs
-       pushq %gs
-       # pushal
-       movw $0, %ax;
-       movw %ax, %gs;
-       movw %ax, %fs;
-       movw $GD_KD, %ax                # data segments aren't accessible by default
-       movw %ax, %ds
-       movw %ax, %es
-       pushq %rsp
+       /* trapno was pushed, taking up 64 bits.  we're using the upper 32 bits */
+       movw %gs, 0x4(%rsp)
+       movw %fs, 0x6(%rsp)
+       pushq %r15
+       pushq %r14
+       pushq %r13
+       pushq %r12
+       pushq %r11
+       pushq %r10
+       pushq %r9
+       pushq %r8
+       pushq %rdi
+       pushq %rsi
+       pushq %rbp
+       pushq %rdx
+       pushq %rcx
+       pushq %rbx
+       pushq %rax
        movq $0, %rbp                   # so we can backtrace to this point
+       movq %rsp, %rdi
        call irq_handler
-       popq %rsp
-       # popal
-       popq %gs
-       popq %fs
-       # popq %es
-       # popq %ds
-       addq $0x8, %rsp                 # skip IRQ number and err (which is 0)
-       iret
+       popq %rax
+       popq %rbx
+       popq %rcx
+       popq %rdx
+       popq %rbp
+       popq %rsi
+       popq %rdi
+       popq %r8
+       popq %r9
+       popq %r10
+       popq %r11
+       popq %r12
+       popq %r13
+       popq %r14
+       popq %r15
+       movw 0x4(%rsp), %gs
+       movw 0x6(%rsp), %fs
+       addq $0x10, %rsp                        # skip gs, fs, trapno, and err (which is 0)
+       iretq
 
 .globl sysenter_handler;
 .type sysenter_handler, @function;
index e61eb10..9bb4f25 100644 (file)
@@ -79,7 +79,12 @@ void kernel_init(multiboot_info_t *mboot_info)
        vfs_init();
        devfs_init();
        idt_init();
-
+       kernel_msg_init();
+       sysenter_init();
+       timer_init();
+       train_timing();
+       kb_buf_init(&cons_buf);
+       
 #ifdef CONFIG_X86_64
 monitor(0);
 printk("Halting/spinning...\n");
@@ -87,12 +92,6 @@ while (1)
        asm volatile("hlt");
 #endif
 
-       kernel_msg_init();
-       sysenter_init();
-       timer_init();
-       train_timing();
-       kb_buf_init(&cons_buf);
-       
        arch_init();
        block_init();
        enable_irq();
index 4f4d89e..5c60d99 100644 (file)
@@ -70,6 +70,7 @@ extern struct syscall vc_entry;       /* in x86/vcore.c */
 
 static inline void pop_hw_tf(struct hw_trapframe *tf, uint32_t vcoreid)
 {
+       #if 0
        struct restart_helper *rst;
        struct preempt_data *vcpd = &__procdata.vcore_preempt_data[vcoreid];
        if (!tf->tf_cs) { /* sysenter TF.  esp and eip are in other regs. */
@@ -87,7 +88,6 @@ static inline void pop_hw_tf(struct hw_trapframe *tf, uint32_t vcoreid)
        rst->eflags = tf->tf_eflags;
        rst->eip = tf->tf_eip;
 
-       #if 0
        asm volatile ("movl %0,%%esp;        " /* jump esp to the utf */
                      "popal;                " /* restore normal registers */
                      "addl $0x24,%%esp;     " /* move to the esp slot in the tf */
@@ -202,6 +202,7 @@ static inline void pop_user_ctx(struct user_context *ctx, uint32_t vcoreid)
  * interrupts a uthread that is in the process of disabling notifs. */
 static inline void pop_user_ctx_raw(struct user_context *ctx, uint32_t vcoreid)
 {
+       #if 0
        struct hw_trapframe *tf = &ctx->tf.hw_tf;
        assert(ctx->type == ROS_HW_CTX);
        struct restart_helper *rst;
@@ -219,7 +220,6 @@ static inline void pop_user_ctx_raw(struct user_context *ctx, uint32_t vcoreid)
        rst->eflags = tf->tf_eflags;
        rst->eip = tf->tf_eip;
 
-       #if 0
        asm volatile ("movl %0,%%esp;        " /* jump esp to the utf */
                      "popal;                " /* restore normal registers */
                      "addl $0x24,%%esp;     " /* move to the esp slot in the tf */
@@ -313,6 +313,7 @@ static inline void save_user_ctx_hw(struct user_context *ctx)
 static inline void init_user_ctx(struct user_context *ctx, uint32_t entry_pt,
                                  uint32_t stack_top)
 {
+       #if 0
        struct sw_trapframe *sw_tf = &ctx->tf.sw_tf;
        ctx->type = ROS_SW_CTX;
        /* No need to bother with setting the other GP registers; the called
@@ -321,6 +322,7 @@ static inline void init_user_ctx(struct user_context *ctx, uint32_t entry_pt,
        sw_tf->tf_eip = entry_pt;
        sw_tf->tf_mxcsr = 0x00001f80;   /* x86 default mxcsr */
        sw_tf->tf_fpucw = 0x037f;               /* x86 default FP CW */
+       #endif
 }
 
 // this is how we get our thread id on entry.
@@ -334,6 +336,7 @@ static inline void init_user_ctx(struct user_context *ctx, uint32_t entry_pt,
 #include <stdio.h>
 static void print_hw_tf(struct hw_trapframe *tf)
 {
+       #if 0
        printf("[user] HW TRAP frame %08p\n", tf);
        printf("  edi  0x%08x\n", tf->tf_regs.reg_edi);
        printf("  esi  0x%08x\n", tf->tf_regs.reg_esi);
@@ -354,10 +357,12 @@ static void print_hw_tf(struct hw_trapframe *tf)
        printf("  flag 0x%08x\n", tf->tf_eflags);
        printf("  esp  0x%08x\n", tf->tf_esp);
        printf("  ss   0x----%04x\n", tf->tf_ss);
+       #endif
 }
 
 static void print_sw_tf(struct sw_trapframe *sw_tf)
 {
+       #if 0
        printf("[user] SW TRAP frame %08p\n", sw_tf);
        printf("  ebp  0x%08x\n", sw_tf->tf_ebp);
        printf("  ebx  0x%08x\n", sw_tf->tf_ebx);
@@ -367,6 +372,7 @@ static void print_sw_tf(struct sw_trapframe *sw_tf)
        printf("  eip  0x%08x\n", sw_tf->tf_eip);
        printf(" mxcsr 0x%08x\n", sw_tf->tf_mxcsr);
        printf(" fpucw 0x----%04x\n", sw_tf->tf_fpucw);
+       #endif
 }
 
 static void print_user_context(struct user_context *ctx)