From owner-freebsd-current Mon May 4 04:02:32 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id EAA03767 for freebsd-current-outgoing; Mon, 4 May 1998 04:02:32 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from watermarkgroup.com (lor.watermarkgroup.com [207.202.73.33]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id EAA03749 for ; Mon, 4 May 1998 04:02:30 -0700 (PDT) (envelope-from luoqi@watermarkgroup.com) Received: by watermarkgroup.com (4.1/SMI-4.1) id AA13313; Mon, 4 May 98 07:02:01 EDT Date: Mon, 4 May 98 07:02:01 EDT From: luoqi@watermarkgroup.com (Luoqi Chen) Message-Id: <9805041102.AA13313@watermarkgroup.com> To: jb@cimlogic.com.au, luoqi@watermarkgroup.com Subject: Re: 'fatal trap 12' on boot (smp and up) Cc: current@FreeBSD.ORG Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > I think I made a mistake in my patch that cause the core dump. Try to > enclose the two lines in the patch that reset fs and gs inside > if (pcb == curpcb) {}. Without this, the code might trash fs & gs in > another process' context. Probably pcb->pcb_fs and pcb->pcb_gs need to be reset too. Please use the following patch (I've also sent it in a follow-up to the original PR i386/6219). -lq Index: machdep.c =================================================================== RCS file: /fun/cvs/src/sys/i386/i386/machdep.c,v retrieving revision 1.294 diff -u -r1.294 machdep.c --- machdep.c 1998/04/06 15:46:17 1.294 +++ machdep.c 1998/05/04 10:40:30 @@ -768,14 +768,15 @@ u_long stack; { struct trapframe *regs = p->p_md.md_regs; - -#ifdef USER_LDT struct pcb *pcb = &p->p_addr->u_pcb; +#ifdef USER_LDT /* was i386_user_cleanup() in NetBSD */ if (pcb->pcb_ldt) { - if (pcb == curpcb) - lldt(GSEL(GUSERLDT_SEL, SEL_KPL)); + if (pcb == curpcb) { + lldt(_default_ldt); + currentldt = _default_ldt; + } kmem_free(kernel_map, (vm_offset_t)pcb->pcb_ldt, pcb->pcb_ldt_len * sizeof(union descriptor)); pcb->pcb_ldt_len = (int)pcb->pcb_ldt = 0; @@ -790,6 +791,14 @@ regs->tf_ds = _udatasel; regs->tf_es = _udatasel; regs->tf_cs = _ucodesel; + + /* reset %fs and %gs as well */ + pcb->pcb_fs = _udatasel; + pcb->pcb_gs = _udatasel; + if (pcb == curpcb) { + __asm("mov %0,%%fs" : : "r" (_udatasel)); + __asm("mov %0,%%gs" : : "r" (_udatasel)); + } /* * Initialize the math emulator (if any) for the current process. Index: vm_machdep.c =================================================================== RCS file: /fun/cvs/src/sys/i386/i386/vm_machdep.c,v retrieving revision 1.105 diff -u -r1.105 vm_machdep.c --- vm_machdep.c 1998/03/23 19:52:42 1.105 +++ vm_machdep.c 1998/04/14 01:30:21 @@ -703,8 +703,10 @@ #endif #ifdef USER_LDT if (pcb->pcb_ldt != 0) { - if (pcb == curpcb) - lldt(GSEL(GUSERLDT_SEL, SEL_KPL)); + if (pcb == curpcb) { + lldt(_default_ldt); + currentldt = _default_ldt; + } kmem_free(kernel_map, (vm_offset_t)pcb->pcb_ldt, pcb->pcb_ldt_len * sizeof(union descriptor)); pcb->pcb_ldt_len = (int)pcb->pcb_ldt = 0; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message