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: [EMAIL PROTECTED]
Department of Computer Science          Phone: (919) 660-6590





To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to