From owner-freebsd-hackers Mon Dec 6 13:41:26 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from duke.cs.duke.edu (duke.cs.duke.edu [152.3.140.1]) by hub.freebsd.org (Postfix) with ESMTP id 99C2514D37 for ; Mon, 6 Dec 1999 13:41:20 -0800 (PST) (envelope-from gallatin@cs.duke.edu) Received: from grasshopper.cs.duke.edu (grasshopper.cs.duke.edu [152.3.145.30]) by duke.cs.duke.edu (8.9.1/8.9.1) with ESMTP id QAA11369 for ; Mon, 6 Dec 1999 16:41:19 -0500 (EST) Received: (from gallatin@localhost) by grasshopper.cs.duke.edu (8.9.3/8.9.1) id QAA86355; Mon, 6 Dec 1999 16:40:49 -0500 (EST) (envelope-from gallatin@cs.duke.edu) From: Andrew Gallatin MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 6 Dec 1999 16:40:49 -0500 (EST) To: freebsd-hackers@freebsd.org Subject: Is part of user stack always mapped? X-Mailer: VM 6.43 under 20.4 "Emerald" XEmacs Lucid Message-ID: <14412.10798.476867.196687@grasshopper.cs.duke.edu> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I've been getting the osf1ulator (alpha/osf1 abi ported from NetBSD over a year ago) on its feet again after this fall's signal changes. When looking closely at the emulators which are currently in the tree, I notice that they are they directly dereferencing memory which was allocated on the user's stack via stackgap_alloc() from within the kernel. stackgap_init() { #define szsigcode (*(curproc->p_sysent->sv_szsigcode)) return (caddr_t)(((caddr_t)PS_STRINGS) - szsigcode - SPARE_USRSPACE); } static __inline void * stackgap_alloc(sgp, sz) caddr_t *sgp; size_t sz; { void *p = (void *) *sgp; *sgp += ALIGN(sz); return p; } <...> sigset_t *set; caddr_t sg; sg = stackgap_init(); set = stackgap_alloc(&sg, sizeof(sigset_t)); *set = p->p_sigmask; <..> I was under the impression that this was a no-no & one should use copyin/copout & friends to access memory on users's stacks. Although this appears to work on the i386, if I try this on the alpha I take a fatal trap when accessing *set. So -- how does this work on the i386? Is the user's stack always mappeped into the kernel's address space? Should it also work on the alpha? Apologies for wasting your time if I'm missing something obvious, ------------------------------------------------------------------------------ Andrew Gallatin, Sr Systems Programmer http://www.cs.duke.edu/~gallatin Duke University Email: gallatin@cs.duke.edu Department of Computer Science Phone: (919) 660-6590 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message