Re: need type to carry kernel pointers to user space

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Wed Jan 19 2000 - 16:16:29 EST


On Wed, 19 Jan 2000, Mitchell Blank Jr wrote:

> Richard B. Johnson wrote:
> > > Recently, we had a discussion on the linux-atm list about the best approach
> > > for passing kernel pointers to user space, and back. The idea is as follows:
> > [SNIPPED...]
> >
> > A pointer in user space is not a pointer in kernel space! Kernel data
> > is referenced by a discriptor, referenced as KERNEL_DS, which is not
> > accessible from user-mode privilege.
>
> Yes, we (the linux-atm folks) of course know that. The pointer is
> treated as an opaque descriptor in user space, just like a file
> descriptor is passed back from open(). We just need a type
> that is garaunteed to hold a kernel-mode pointer given weird cases
> like sparc64 (suppose mips64 and hppa64 will be similar when support
> for them arrives)
>
> Personally, I'm advocating __u64. Note that no long-long calculations
> need to be done on 32-bit archs - the kernel will cast it down to
> "unsigned long" first thing - so all those unpleasantries don't
> come into play.

Okay. I get it. The "catch-all" which will work on every architecture,
including those which have not been invented yet, is a (don't laugh)
character array. Think about it. Simple casts+dereference gets to/from
anything you want. Sixteen bytes per element, with the start aligned
properly, will store anything up to 128 bits in length.

Cheers,
Dick Johnson

Penguin : Linux version 2.3.39 on an i686 machine (800.63 BogoMips).

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Jan 23 2000 - 21:00:21 EST