From owner-freebsd-current Sun Jul 21 22:40:24 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4E36537B401; Sun, 21 Jul 2002 22:40:16 -0700 (PDT) Received: from rwcrmhc51.attbi.com (rwcrmhc51.attbi.com [204.127.198.38]) by mx1.FreeBSD.org (Postfix) with ESMTP id D990643E58; Sun, 21 Jul 2002 22:40:15 -0700 (PDT) (envelope-from julian@elischer.org) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc51.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020722054015.EZMC24728.rwcrmhc51.attbi.com@InterJet.elischer.org>; Mon, 22 Jul 2002 05:40:15 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id WAA02618; Sun, 21 Jul 2002 22:36:31 -0700 (PDT) Date: Sun, 21 Jul 2002 22:36:29 -0700 (PDT) From: Julian Elischer To: Mark Peek Cc: freebsd-current@freebsd.org, Alan Cox , julian@freebsd.org Subject: Re: Panic in -current when using i386_set_ioperm() In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 21 Jul 2002, Mark Peek wrote: > There is a reproducible panic in -current after using > i386_set_ioperm(). The extended pcb is attempted to be freed in > cpu_thread_exit() using kmem_free(). Via private mail, Alan Cox > explained it to me as such: > > "The problem runs deeper than Giant not being held: cpu_thread_exit() > really can't call kmem_free(). At the point of the call, a spin lock > is held. Acquiring the kernel_map lock can cause you to sleep. Thus, > the code could sleep with a spin lock held." > > The program and the panic trace is below. I figured I would post this > to -current to get some more people thinking about the right fix. > > Mark There is a problem with set/get ioperm and threads (any variety) Ioperms should be a per-process thing, but the ioperm is stored as part of the information which turned out to be thread_specific. I.e the ioperm map is stored as part of the extended PCB as the extension of the TSS. The TSS holds information that on my reading appears to be largly thread-specific. (though some items might be interpreted as process specific) (hense the mess). The ioperm information is defined by Intel to be an extension to the context information that is in the ext-PCB, which is currently thread specific in -current.C Thus, when we change it, we need to sto pall threads, change the ioperm information or all of them and restart them, as the each have their own.. A least that is the way I remember it wothout going and looking at the 1/ sources 2/ intel docs. :-/ the iomap is in the extended pcb as ext_iomap. The extended pcb includes several things that should probably be per thread, including a TSS. I'm not sure, but there is maybe a possibility that all the TSSs in a process could share the pages used for the iomap. thus it would look like multiple TSSs but if you updated one iomap you updated the iomap for all of them. I dunno....it's a mess.. ideas anyone.. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message