From owner-p4-projects@FreeBSD.ORG Tue Apr 8 14:11:30 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1B5D337B404; Tue, 8 Apr 2003 14:11:30 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AF2A337B401 for ; Tue, 8 Apr 2003 14:11:29 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2D74F43F93 for ; Tue, 8 Apr 2003 14:11:29 -0700 (PDT) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h38LBT0U090768 for ; Tue, 8 Apr 2003 14:11:29 -0700 (PDT) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h38LBS1V090761 for perforce@freebsd.org; Tue, 8 Apr 2003 14:11:28 -0700 (PDT) Date: Tue, 8 Apr 2003 14:11:28 -0700 (PDT) Message-Id: <200304082111.h38LBS1V090761@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 28564 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Apr 2003 21:11:31 -0000 http://perforce.freebsd.org/chv.cgi?CH=28564 Change 28564 by peter@peter_daintree on 2003/04/08 14:10:38 add a double fault handler. I'm not sure how useful this will be though since we didn't get a %cr3 reload. The hardware task switch stuff is gone in 64 bit mode. Remove leftovers. clean up setidt() args. Connect doublefault handler on ist1. Affected files ... .. //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#54 edit .. //depot/projects/hammer/sys/x86_64/x86_64/trap.c#23 edit Differences ... ==== //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#54 (text+ko) ==== @@ -111,9 +111,7 @@ #include extern void hammer_time(void); -#if 0 extern void dblfault_handler(void); -#endif #if 0 extern void printcpuinfo(void); /* XXX header file */ @@ -552,16 +550,16 @@ static struct gate_descriptor idt0[NIDT]; struct gate_descriptor *idt = &idt0[0]; /* interrupt descriptor table */ -#if 0 -static struct x86_64tss dblfault_tss; static char dblfault_stack[PAGE_SIZE]; -#endif /* * Nasty hack to arrange internal longword alignment. - * Probably not necessary. + * What were they thinking?? */ -static struct aligned_tss common_tss; +static struct { + u_int32_t pad; + struct x86_64tss tss __packed; +} common_tss; /* software prototypes -- in more palatable form */ @@ -612,38 +610,27 @@ 0, /* long */ 0, /* default 32 vs 16 bit size */ 0 /* limit granularity (byte/page units)*/ }, -#if 0 -/* GPANIC_SEL 4 Panic Tss Descriptor */ -{ (int) &dblfault_tss, /* segment base address */ - sizeof(struct x86_64tss)-1,/* length - all address space */ - SDT_SYSTSS, /* segment type */ - 0, /* segment descriptor priority level */ - 1, /* segment descriptor present */ - 0, /* long */ - 0, /* unused - default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, -#endif }; void -setidt(idx, func, typ, dpl, selec) +setidt(idx, func, typ, ist) int idx; inthand_t *func; int typ; - int dpl; - int selec; + int ist; { struct gate_descriptor *ip; ip = idt + idx; ip->gd_looffset = (uintptr_t)func; - ip->gd_selector = selec; - ip->gd_ist = 0; + ip->gd_selector = GSEL(GCODE_SEL, SEL_KPL); + ip->gd_ist = ist; ip->gd_xx = 0; ip->gd_type = typ; - ip->gd_dpl = dpl; + ip->gd_dpl = SEL_KPL; ip->gd_p = 1; ip->gd_hioffset = ((uintptr_t)func)>>16 ; +printf("setidt: idx:%2d 0x%08x 0x%08x 0x%08x 0x%08x\n", idx, ((u_int32_t *)ip)[0], ((u_int32_t *)ip)[1], ((u_int32_t *)ip)[2], ((u_int32_t *)ip)[3]); } #define IDTVEC(name) __CONCAT(X,name) @@ -1200,51 +1187,28 @@ /* exceptions */ for (x = 0; x < NIDT; x++) - setidt(x, &IDTVEC(rsvd), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(0, &IDTVEC(div), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(1, &IDTVEC(dbg), SDT_SYSIGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(2, &IDTVEC(nmi), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(3, &IDTVEC(bpt), SDT_SYSIGT, SEL_UPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(4, &IDTVEC(ofl), SDT_SYSTGT, SEL_UPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(5, &IDTVEC(bnd), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(6, &IDTVEC(ill), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(7, &IDTVEC(dna), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); -#if 0 - setidt(8, 0, SDT_SYSTASKGT, SEL_KPL, GSEL(GPANIC_SEL, SEL_KPL)); -#endif - setidt(9, &IDTVEC(fpusegm), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(10, &IDTVEC(tss), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(11, &IDTVEC(missing), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(12, &IDTVEC(stk), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(13, &IDTVEC(prot), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(14, &IDTVEC(page), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(15, &IDTVEC(rsvd), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(16, &IDTVEC(fpu), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(17, &IDTVEC(align), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(18, &IDTVEC(mchk), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(19, &IDTVEC(xmm), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(0x80, &IDTVEC(int0x80_syscall), SDT_SYSTGT, SEL_UPL, - GSEL(GCODE_SEL, SEL_KPL)); + setidt(x, &IDTVEC(rsvd), SDT_SYSTGT, 0); + setidt(0, &IDTVEC(div), SDT_SYSTGT, 0); + setidt(1, &IDTVEC(dbg), SDT_SYSIGT, 0); + setidt(2, &IDTVEC(nmi), SDT_SYSTGT, 0); + setidt(3, &IDTVEC(bpt), SDT_SYSIGT, 0); + setidt(4, &IDTVEC(ofl), SDT_SYSTGT, 0); + setidt(5, &IDTVEC(bnd), SDT_SYSTGT, 0); + setidt(6, &IDTVEC(ill), SDT_SYSTGT, 0); + setidt(7, &IDTVEC(dna), SDT_SYSTGT, 0); + setidt(8, (inthand_t *)dblfault_handler, SDT_SYSIGT, 1); + setidt(9, &IDTVEC(fpusegm), SDT_SYSTGT, 0); + setidt(10, &IDTVEC(tss), SDT_SYSTGT, 0); + setidt(11, &IDTVEC(missing), SDT_SYSTGT, 0); + setidt(12, &IDTVEC(stk), SDT_SYSTGT, 0); + setidt(13, &IDTVEC(prot), SDT_SYSTGT, 0); + setidt(14, &IDTVEC(page), SDT_SYSTGT, 0); + setidt(15, &IDTVEC(rsvd), SDT_SYSTGT, 0); + setidt(16, &IDTVEC(fpu), SDT_SYSTGT, 0); + setidt(17, &IDTVEC(align), SDT_SYSTGT, 0); + setidt(18, &IDTVEC(mchk), SDT_SYSTGT, 0); + setidt(19, &IDTVEC(xmm), SDT_SYSTGT, 0); + setidt(0x80, &IDTVEC(int0x80_syscall), SDT_SYSTGT, 0); r_idt.rd_limit = sizeof(idt0) - 1; r_idt.rd_base = (long) idt; @@ -1268,36 +1232,22 @@ #if 0 finishidentcpu(); /* Final stage of CPU initialization */ #endif - setidt(6, &IDTVEC(ill), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); - setidt(13, &IDTVEC(prot), SDT_SYSTGT, SEL_KPL, - GSEL(GCODE_SEL, SEL_KPL)); + setidt(6, &IDTVEC(ill), SDT_SYSTGT, 0); + setidt(13, &IDTVEC(prot), SDT_SYSTGT, 0); #if 0 initializecpu(); /* Initialize CPU registers */ #endif /* make an initial tss so cpu can get interrupt stack on syscall! */ common_tss.tss.tss_rsp0 = thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE - sizeof(struct pcb); + common_tss.tss.tss_rsp1 = common_tss.tss.tss_rsp0; + common_tss.tss.tss_rsp2 = common_tss.tss.tss_rsp0; + /* doublefault stack space, runs on ist1 */ + common_tss.tss.tss_ist1 = (long)&dblfault_stack[sizeof(dblfault_stack)]; gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); ltr(gsel_tss); -#if 0 - dblfault_tss.tss_esp = dblfault_tss.tss_esp0 = dblfault_tss.tss_esp1 = - dblfault_tss.tss_esp2 = (int)&dblfault_stack[sizeof(dblfault_stack)]; - dblfault_tss.tss_ss = dblfault_tss.tss_ss0 = dblfault_tss.tss_ss1 = - dblfault_tss.tss_ss2 = GSEL(GDATA_SEL, SEL_KPL); -#ifdef PAE - dblfault_tss.tss_cr3 = IdlePDPT; -#else - dblfault_tss.tss_cr3 = IdlePTD; -#endif - dblfault_tss.tss_eip = (int)dblfault_handler; - dblfault_tss.tss_rflags = PSL_KERNEL; - dblfault_tss.tss_ds = dblfault_tss.tss_es = dblfault_tss.tss_fs = - dblfault_tss.tss_gs = GSEL(GDATA_SEL, SEL_KPL); - dblfault_tss.tss_cs = GSEL(GCODE_SEL, SEL_KPL); -#endif getmemsize(kmdp, physfree); init_param2(physmem); ==== //depot/projects/hammer/sys/x86_64/x86_64/trap.c#23 (text+ko) ==== @@ -651,29 +651,18 @@ panic("unknown/reserved trap"); } -#if 0 /* * Double fault handler. Called when a fault occurs while writing * a frame for a trap/exception onto the stack. This usually occurs * when the stack overflows (such is the case with infinite recursion, * for example). - * - * XXX Note that the current PTD gets replaced by IdlePTD when the - * task switch occurs. This means that the stack that was active at - * the time of the double fault is not available at unless - * the machine was idle when the double fault occurred. The downside - * of this is that "trace " in ddb won't work. */ void dblfault_handler() { - printf("\nFatal double fault:\n"); - printf("eip = 0x%x\n", common_tss.tss_rip); - printf("esp = 0x%x\n", common_tss.tss_rsp); - printf("ebp = 0x%x\n", common_tss.tss_rbp); + printf("\nFatal double fault\n"); panic("double fault"); } -#endif /* * syscall - system call request C handler