public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: From Eric Anholt:
       [not found] <200405112211.i4BMBQDZ006167@hera.kernel.org>
@ 2004-05-11 22:22 ` Greg KH
  2004-05-11 23:17   ` Dave Airlie
  2004-05-11 23:20   ` Dave Airlie
  0 siblings, 2 replies; 14+ messages in thread
From: Greg KH @ 2004-05-11 22:22 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: airlied

On Sat, Apr 10, 2004 at 04:32:02AM +0000, Linux Kernel Mailing List wrote:
> diff -Nru a/drivers/char/drm/drm.h b/drivers/char/drm/drm.h
> --- a/drivers/char/drm/drm.h	Tue May 11 15:11:32 2004
> +++ b/drivers/char/drm/drm.h	Tue May 11 15:11:32 2004
> @@ -580,6 +580,16 @@
>  	unsigned long handle;	/**< Used for mapping / unmapping */
>  } drm_scatter_gather_t;
>  
> +/**
> + * DRM_IOCTL_SET_VERSION ioctl argument type.
> + */
> +typedef struct drm_set_version {
> +	int drm_di_major;
> +	int drm_di_minor;
> +	int drm_dd_major;
> +	int drm_dd_minor;
> +} drm_set_version_t;
> +

Ick, you can't use "int" as an ioctl structure member, sorry.  Please
use the proper "__u16" or "__u32" value instead.

And what about kernels running in 64bit mode with 32bit userspace?  Care
to provide the proper thunking layer for them too?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: From Eric Anholt:
  2004-05-11 22:22 ` From Eric Anholt: Greg KH
@ 2004-05-11 23:17   ` Dave Airlie
  2004-05-11 23:20   ` Dave Airlie
  1 sibling, 0 replies; 14+ messages in thread
From: Dave Airlie @ 2004-05-11 23:17 UTC (permalink / raw)
  To: Greg KH; +Cc: Linux Kernel Mailing List


> >
> > +/**
> > + * DRM_IOCTL_SET_VERSION ioctl argument type.
> > + */
> > +typedef struct drm_set_version {
> > +	int drm_di_major;
> > +	int drm_di_minor;
> > +	int drm_dd_major;
> > +	int drm_dd_minor;
> > +} drm_set_version_t;
> > +
>
> Ick, you can't use "int" as an ioctl structure member, sorry.  Please
> use the proper "__u16" or "__u32" value instead.

okay I'll submit a fix to Linus rsn ...
>
> And what about kernels running in 64bit mode with 32bit userspace?  Care
> to provide the proper thunking layer for them too?

would love to don't have anyone on team that does 64-bit at the moment or
even has access to 64-bit hardware .. f someone provides the code I'll accept
it, anyway the DRM isn't completely 64-bit safe AFAIK, it has other
"issues",

Thanks,
Dave.

-- 
David Airlie, Software Engineer
http://www.skynet.ie/~airlied / airlied at skynet.ie
pam_smb / Linux DECstation / Linux VAX / ILUG person


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: From Eric Anholt:
  2004-05-11 22:22 ` From Eric Anholt: Greg KH
  2004-05-11 23:17   ` Dave Airlie
@ 2004-05-11 23:20   ` Dave Airlie
  2004-05-11 23:34     ` Valdis.Kletnieks
                       ` (2 more replies)
  1 sibling, 3 replies; 14+ messages in thread
From: Dave Airlie @ 2004-05-11 23:20 UTC (permalink / raw)
  To: Greg KH; +Cc: Linux Kernel Mailing List, dri-devel

>
> Ick, you can't use "int" as an ioctl structure member, sorry.  Please
> use the proper "__u16" or "__u32" value instead.

I just looked at drm.h and nearly all the ioctls use int, this file is
included in user-space applications also at the moment, I'm worried
changing all ints to __u32 will break some of these, anyone on DRI list
care to comment?

Dave.

 >
> And what about kernels running in 64bit mode with 32bit userspace?  Care
> to provide the proper thunking layer for them too?
>
> thanks,
>
> greg k-h
>

-- 
David Airlie, Software Engineer
http://www.skynet.ie/~airlied / airlied at skynet.ie
pam_smb / Linux DECstation / Linux VAX / ILUG person


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: From Eric Anholt:
  2004-05-11 23:20   ` Dave Airlie
@ 2004-05-11 23:34     ` Valdis.Kletnieks
  2004-05-11 23:43       ` Greg KH
                         ` (2 more replies)
  2004-05-12  1:07     ` Jon Smirl
  2004-05-12 22:32     ` Linus Torvalds
  2 siblings, 3 replies; 14+ messages in thread
From: Valdis.Kletnieks @ 2004-05-11 23:34 UTC (permalink / raw)
  To: Dave Airlie; +Cc: Greg KH, Linux Kernel Mailing List, dri-devel

[-- Attachment #1: Type: text/plain, Size: 466 bytes --]

On Wed, 12 May 2004 00:20:51 BST, Dave Airlie said:

> I just looked at drm.h and nearly all the ioctls use int, this file is
> included in user-space applications also at the moment, I'm worried
> changing all ints to __u32 will break some of these, anyone on DRI list
> care to comment?

Is this a case where somebody is *really* including kernel headers in userspace
and we need to smack them, or are they using a copy that's been sanitized
(and possibly fixed)?

[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: From Eric Anholt:
  2004-05-11 23:34     ` Valdis.Kletnieks
@ 2004-05-11 23:43       ` Greg KH
  2004-05-12  0:07         ` Daniel Jacobowitz
  2004-05-12  0:12         ` H. Peter Anvin
  2004-05-11 23:46       ` ioctls in drm.h Dave Airlie
  2004-05-13  1:39       ` From Eric Anholt: Eric Anholt
  2 siblings, 2 replies; 14+ messages in thread
From: Greg KH @ 2004-05-11 23:43 UTC (permalink / raw)
  To: Valdis.Kletnieks; +Cc: Dave Airlie, Linux Kernel Mailing List, dri-devel

On Tue, May 11, 2004 at 07:34:39PM -0400, Valdis.Kletnieks@vt.edu wrote:
> On Wed, 12 May 2004 00:20:51 BST, Dave Airlie said:
> 
> > I just looked at drm.h and nearly all the ioctls use int, this file is
> > included in user-space applications also at the moment, I'm worried
> > changing all ints to __u32 will break some of these, anyone on DRI list
> > care to comment?
> 
> Is this a case where somebody is *really* including kernel headers in userspace
> and we need to smack them, or are they using a copy that's been sanitized
> (and possibly fixed)?

Don't know, but how are you dealing with the issue that an "int" is
different for different kernel sizes (64 vs 32) and userspace too.
That's why you can't use it in an ioctl and expect things to work
properly.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 14+ messages in thread

* re: ioctls in drm.h
  2004-05-11 23:34     ` Valdis.Kletnieks
  2004-05-11 23:43       ` Greg KH
@ 2004-05-11 23:46       ` Dave Airlie
  2004-05-13  1:39       ` From Eric Anholt: Eric Anholt
  2 siblings, 0 replies; 14+ messages in thread
From: Dave Airlie @ 2004-05-11 23:46 UTC (permalink / raw)
  To: Valdis.Kletnieks; +Cc: Greg KH, Linux Kernel Mailing List, dri-devel

> > care to comment?
>
> Is this a case where somebody is *really* including kernel headers in userspace
> and we need to smack them, or are they using a copy that's been sanitized
> (and possibly fixed)?

hmm drm.h is used by all drm users and it hasn't really been sanitised..
we probably do need to look into what goes where.. are the rules for 32/64
user/kernel ioctls written down anywhere?

Dave.
>

-- 
David Airlie, Software Engineer
http://www.skynet.ie/~airlied / airlied at skynet.ie
pam_smb / Linux DECstation / Linux VAX / ILUG person


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: From Eric Anholt:
  2004-05-11 23:43       ` Greg KH
@ 2004-05-12  0:07         ` Daniel Jacobowitz
  2004-05-12  0:12           ` Greg KH
  2004-05-12  0:12         ` H. Peter Anvin
  1 sibling, 1 reply; 14+ messages in thread
From: Daniel Jacobowitz @ 2004-05-12  0:07 UTC (permalink / raw)
  To: Greg KH; +Cc: Valdis.Kletnieks, Dave Airlie, Linux Kernel Mailing List,
	dri-devel

On Tue, May 11, 2004 at 04:43:29PM -0700, Greg KH wrote:
> On Tue, May 11, 2004 at 07:34:39PM -0400, Valdis.Kletnieks@vt.edu wrote:
> > On Wed, 12 May 2004 00:20:51 BST, Dave Airlie said:
> > 
> > > I just looked at drm.h and nearly all the ioctls use int, this file is
> > > included in user-space applications also at the moment, I'm worried
> > > changing all ints to __u32 will break some of these, anyone on DRI list
> > > care to comment?
> > 
> > Is this a case where somebody is *really* including kernel headers in userspace
> > and we need to smack them, or are they using a copy that's been sanitized
> > (and possibly fixed)?
> 
> Don't know, but how are you dealing with the issue that an "int" is
> different for different kernel sizes (64 vs 32) and userspace too.
> That's why you can't use it in an ioctl and expect things to work
> properly.

I'm not disagreeing that it ought to use __u32, but are there any Linux
supported targets that don't have a 32-bit int?  It's long that tends
to change size.

-- 
Daniel Jacobowitz

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: From Eric Anholt:
  2004-05-11 23:43       ` Greg KH
  2004-05-12  0:07         ` Daniel Jacobowitz
@ 2004-05-12  0:12         ` H. Peter Anvin
  1 sibling, 0 replies; 14+ messages in thread
From: H. Peter Anvin @ 2004-05-12  0:12 UTC (permalink / raw)
  To: linux-kernel

Followup to:  <20040511234329.GA27242@kroah.com>
By author:    Greg KH <greg@kroah.com>
In newsgroup: linux.dev.kernel
> 
> Don't know, but how are you dealing with the issue that an "int" is
> different for different kernel sizes (64 vs 32) and userspace too.
> That's why you can't use it in an ioctl and expect things to work
> properly.
> 

On Linux, "int" should always be 32 bits.  "long", and "void *",
however, may be 32 or 64 bits.

	-hpa

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: From Eric Anholt:
  2004-05-12  0:07         ` Daniel Jacobowitz
@ 2004-05-12  0:12           ` Greg KH
  0 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2004-05-12  0:12 UTC (permalink / raw)
  To: Valdis.Kletnieks, Dave Airlie, Linux Kernel Mailing List,
	dri-devel

On Tue, May 11, 2004 at 08:07:09PM -0400, Daniel Jacobowitz wrote:
> On Tue, May 11, 2004 at 04:43:29PM -0700, Greg KH wrote:
> > On Tue, May 11, 2004 at 07:34:39PM -0400, Valdis.Kletnieks@vt.edu wrote:
> > > On Wed, 12 May 2004 00:20:51 BST, Dave Airlie said:
> > > 
> > > > I just looked at drm.h and nearly all the ioctls use int, this file is
> > > > included in user-space applications also at the moment, I'm worried
> > > > changing all ints to __u32 will break some of these, anyone on DRI list
> > > > care to comment?
> > > 
> > > Is this a case where somebody is *really* including kernel headers in userspace
> > > and we need to smack them, or are they using a copy that's been sanitized
> > > (and possibly fixed)?
> > 
> > Don't know, but how are you dealing with the issue that an "int" is
> > different for different kernel sizes (64 vs 32) and userspace too.
> > That's why you can't use it in an ioctl and expect things to work
> > properly.
> 
> I'm not disagreeing that it ought to use __u32, but are there any Linux
> supported targets that don't have a 32-bit int?  It's long that tends
> to change size.

I don't think so, but I am not sure.  That's why you should use __u32 to
keep people from guessing :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: From Eric Anholt:
  2004-05-11 23:20   ` Dave Airlie
  2004-05-11 23:34     ` Valdis.Kletnieks
@ 2004-05-12  1:07     ` Jon Smirl
  2004-05-12  1:15       ` Greg KH
  2004-05-12 22:32     ` Linus Torvalds
  2 siblings, 1 reply; 14+ messages in thread
From: Jon Smirl @ 2004-05-12  1:07 UTC (permalink / raw)
  To: Dave Airlie, Greg KH; +Cc: Linux Kernel Mailing List, dri-devel

Would int16_t and int32_t work? Those int's were in there before I started
working on it. __u16 and __u32 are Linux kernel defines that aren't always there
in user space.

I would much rather have one h file than two. When we had two the variable and
structure names, comments, etc had drifted over the years until they didn't even
look like the same file anymore. drm.h only defines the ioctls, no internal
kernel structures are exposed.

--- Dave Airlie <airlied@linux.ie> wrote:
> >
> > Ick, you can't use "int" as an ioctl structure member, sorry.  Please
> > use the proper "__u16" or "__u32" value instead.
> 
> I just looked at drm.h and nearly all the ioctls use int, this file is
> included in user-space applications also at the moment, I'm worried
> changing all ints to __u32 will break some of these, anyone on DRI list
> care to comment?
> 
> Dave.
> 
>  >
> > And what about kernels running in 64bit mode with 32bit userspace?  Care
> > to provide the proper thunking layer for them too?
> >
> > thanks,
> >
> > greg k-h
> >
> 
> -- 
> David Airlie, Software Engineer
> http://www.skynet.ie/~airlied / airlied at skynet.ie
> pam_smb / Linux DECstation / Linux VAX / ILUG person
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by Sleepycat Software
> Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to 
> deliver higher performing products faster, at low TCO.
> http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
> --
> _______________________________________________
> Dri-devel mailing list
> Dri-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dri-devel


=====
Jon Smirl
jonsmirl@yahoo.com


	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: From Eric Anholt:
  2004-05-12  1:07     ` Jon Smirl
@ 2004-05-12  1:15       ` Greg KH
  0 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2004-05-12  1:15 UTC (permalink / raw)
  To: Jon Smirl; +Cc: Dave Airlie, Linux Kernel Mailing List, dri-devel

On Tue, May 11, 2004 at 06:07:27PM -0700, Jon Smirl wrote:
> Would int16_t and int32_t work?

No, sorry.  See the lkml archives for why.

> Those int's were in there before I started working on it. __u16 and
> __u32 are Linux kernel defines that aren't always there in user space.

Don't share header files between userspace and the kernel.  End of
problem :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: From Eric Anholt:
  2004-05-11 23:20   ` Dave Airlie
  2004-05-11 23:34     ` Valdis.Kletnieks
  2004-05-12  1:07     ` Jon Smirl
@ 2004-05-12 22:32     ` Linus Torvalds
  2004-05-13 16:54       ` Egbert Eich
  2 siblings, 1 reply; 14+ messages in thread
From: Linus Torvalds @ 2004-05-12 22:32 UTC (permalink / raw)
  To: dri-devel; +Cc: Greg KH, Linux Kernel Mailing List



On Wed, 12 May 2004, Dave Airlie wrote:
> 
> I just looked at drm.h and nearly all the ioctls use int, this file is
> included in user-space applications also at the moment, I'm worried
> changing all ints to __u32 will break some of these, anyone on DRI list
> care to comment?

Right now, all architectures have "int" being 32-bit, so nothing should 
break. Apart from sign issues, of course.

If there are pointers and "long", then those should just not exist. Never
expose kernel pointers to user mode (and you really never should pass user
pointers back), and "long" should really just be "__u32" instead (since 
that is what it is on a 32-bit platform - and if it works there, then it 
should work on a 64-bit platform too).

		Linus

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: From Eric Anholt:
  2004-05-11 23:34     ` Valdis.Kletnieks
  2004-05-11 23:43       ` Greg KH
  2004-05-11 23:46       ` ioctls in drm.h Dave Airlie
@ 2004-05-13  1:39       ` Eric Anholt
  2 siblings, 0 replies; 14+ messages in thread
From: Eric Anholt @ 2004-05-13  1:39 UTC (permalink / raw)
  To: DRI; +Cc: Linux Kernel Mailing List

On Tue, 2004-05-11 at 16:34, Valdis.Kletnieks@vt.edu wrote:
> On Wed, 12 May 2004 00:20:51 BST, Dave Airlie said:
> 
> > I just looked at drm.h and nearly all the ioctls use int, this file is
> > included in user-space applications also at the moment, I'm worried
> > changing all ints to __u32 will break some of these, anyone on DRI list
> > care to comment?
> 
> Is this a case where somebody is *really* including kernel headers in userspace
> and we need to smack them, or are they using a copy that's been sanitized
> (and possibly fixed)?

These headers being discussed are what define the interface between
userland and kernel, and nothing else.  They are included by both
userland (libdrm, statically linked in the 3d drivers and in the X
server) and kernel.

-- 
Eric Anholt                                eta@lclark.edu          
http://people.freebsd.org/~anholt/         anholt@FreeBSD.org



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: From Eric Anholt:
  2004-05-12 22:32     ` Linus Torvalds
@ 2004-05-13 16:54       ` Egbert Eich
  0 siblings, 0 replies; 14+ messages in thread
From: Egbert Eich @ 2004-05-13 16:54 UTC (permalink / raw)
  To: dri-devel; +Cc: Greg KH, Linux Kernel Mailing List

Linus Torvalds writes:
 > 
 > 
 > On Wed, 12 May 2004, Dave Airlie wrote:
 > > 
 > > I just looked at drm.h and nearly all the ioctls use int, this file is
 > > included in user-space applications also at the moment, I'm worried
 > > changing all ints to __u32 will break some of these, anyone on DRI list
 > > care to comment?
 > 
 > Right now, all architectures have "int" being 32-bit, so nothing should 
 > break. Apart from sign issues, of course.
 > 
 > If there are pointers and "long", then those should just not exist. Never
 > expose kernel pointers to user mode (and you really never should pass user
 > pointers back), and "long" should really just be "__u32" instead (since 
 > that is what it is on a 32-bit platform - and if it works there, then it 
 > should work on a 64-bit platform too).
 > 

Unfortunately this is done in some places in DRM. Pointers are used as a 
simple 'handle' to point to areas that are to be mapped by mmap()
from user mode.
I've done some ioctl32() interfaces for DRM for a few drivers (mga, 
radeon, r128) to make 32bit software work on 64bit systems such as AMD64.
In most cases it was easy to work around the longs as they either did
not have to exist at all or could be replaced by something that's
platform independent.
I have plans to submit these ioctl32() interfaces to Mesa when I get
around to do it.
Anyway they are unnecessary kludges which should have been avoided
from the beginning.

Egbert.


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-05-13 16:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200405112211.i4BMBQDZ006167@hera.kernel.org>
2004-05-11 22:22 ` From Eric Anholt: Greg KH
2004-05-11 23:17   ` Dave Airlie
2004-05-11 23:20   ` Dave Airlie
2004-05-11 23:34     ` Valdis.Kletnieks
2004-05-11 23:43       ` Greg KH
2004-05-12  0:07         ` Daniel Jacobowitz
2004-05-12  0:12           ` Greg KH
2004-05-12  0:12         ` H. Peter Anvin
2004-05-11 23:46       ` ioctls in drm.h Dave Airlie
2004-05-13  1:39       ` From Eric Anholt: Eric Anholt
2004-05-12  1:07     ` Jon Smirl
2004-05-12  1:15       ` Greg KH
2004-05-12 22:32     ` Linus Torvalds
2004-05-13 16:54       ` Egbert Eich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox