From owner-p4-projects Fri May 31 10:40:27 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B4EF537B400; Fri, 31 May 2002 10:40:12 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from rwcrmhc54.attbi.com (rwcrmhc54.attbi.com [216.148.227.87]) by hub.freebsd.org (Postfix) with ESMTP id 45B5337B405; Fri, 31 May 2002 10:40:11 -0700 (PDT) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc54.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020531174010.RRHU13253.rwcrmhc54.attbi.com@InterJet.elischer.org>; Fri, 31 May 2002 17:40:10 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id KAA29025; Fri, 31 May 2002 10:23:20 -0700 (PDT) Date: Fri, 31 May 2002 10:23:19 -0700 (PDT) From: Julian Elischer To: Jake Burkholder Cc: Julian Elischer , Perforce Change Reviews Subject: Re: PERFORCE change 12179 for review In-Reply-To: <20020531130656.T62759@locore.ca> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 31 May 2002, Jake Burkholder wrote: > Apparently, On Thu, May 30, 2002 at 10:57:02PM -0700, > Julian Elischer said words to the effect of; > > > http://people.freebsd.org/~peter/p4db/chv.cgi?CH=12179 > > > > Change 12179 by julian@julian_ref on 2002/05/30 22:56:19 > > > > Use fuword and suword instead of copyin/copyout > > when setting up thread completion mailboxes. > > needs fptr and sptr, which I will add soon. > > Please do not add these without discussing it first. fuword and > suword take a long as their argument/return value, which works > fine. except that you have to cast the results.. It'd be nice if there was one guaranteed to return a (void *) preferably at a second argument so that a success value can be given as well. (I decided not to add it myself unilaterally but rather to lobby for it amongst types such as yourself..) There is no guarantee that on every imaginable architecture that the same long<->pointer conversion is correct, and anyhow the casting is wrong.. it wouldn't take much to make a retval = fptr(addr, &target) call. > > > > > Affected files ... > > > > ... //depot/projects/kse/sys/i386/i386/trap.c#43 edit > > ... //depot/projects/kse/sys/kern/kern_thread.c#50 edit > > > > Differences ... > > > > ==== //depot/projects/kse/sys/i386/i386/trap.c#43 (text+ko) ==== > > > > @@ -955,10 +955,10 @@ > > * possibility that we could do this lazily (in sleep()), > > * but for now do it every time. > > */ > > - error = copyin((caddr_t)td->td_kse->ke_mailbox + > > - offsetof(struct kse_mailbox, current_thread), > > - &td->td_mailbox, sizeof(void *)); > > - if (error || td->td_mailbox == NULL) { > > + td->td_mailbox = fuword((caddr_t)td->td_kse->ke_mailbox + > > + offsetof(struct kse_mailbox, current_thread)); > > + if ((td->td_mailbox == NULL) || > > + (td->td_mailbox == (viod *)-1)) { > > td->td_mailbox = NULL; /* single thread it.. */ > > td->td_flags &= ~TDF_UNBOUND; > > } else { > > > > ==== //depot/projects/kse/sys/kern/kern_thread.c#50 (text+ko) ==== > > > > @@ -251,7 +251,7 @@ > > thread_export_context(struct thread *td) > > { > > struct kse *ke; > > - void *td2_mbx; > > + uint td2_mbx; /* XXXKSE */ > > sigh. sizeof(uint) != sizeof(void *). Use uintptr_t. That's one reason the XXXKSE is there.. I wasn't sure what to use... I'll fix it now.. > > > void *addr1; > > void *addr2; > > int error; > > @@ -266,11 +266,17 @@ > > + offsetof(struct thread_mailbox , next_completed); > > /* Then link it into it's KSE's list of completed threads. */ > > if (!error) > > - error = copyin( addr1, &td2_mbx, sizeof(void *)); > > + error = td2_mbx = fuword(addr1); > > + if (error == -1) > > + error = EFAULT; > > + else > > + error = 0; > > if (!error) > > - error = copyout(&td2_mbx, addr2, sizeof(void *)); > > + error = suword(addr2, td2_mbx); > > if (!error) > > - error = copyout(&td->td_mailbox, addr1, sizeof(void *)); > > + error = suword(addr1, (uint)td->td_mailbox); > > + if (error == -1) > > + error = EFAULT; > > return (error); > > } > > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message