All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/i915: Forward all core DRM ioctls to core compat handling
@ 2015-07-14 10:13 ` Tvrtko Ursulin
  0 siblings, 0 replies; 7+ messages in thread
From: Tvrtko Ursulin @ 2015-07-14 10:13 UTC (permalink / raw)
  To: Intel-gfx; +Cc: Tvrtko Ursulin, Daniel Vetter, stable

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Previously only core DRM ioctls under the DRM_COMMAND_BASE were being
forwarded, but the drm.h header suggests (and reality confirms) ones
after (and including) DRM_COMMAND_END should be forwarded as well.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: stable@vger.kernel.org
---
 drivers/gpu/drm/i915/i915_ioc32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
index 176de6322e4d..23aa04cded6b 100644
--- a/drivers/gpu/drm/i915/i915_ioc32.c
+++ b/drivers/gpu/drm/i915/i915_ioc32.c
@@ -204,7 +204,7 @@ long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	drm_ioctl_compat_t *fn = NULL;
 	int ret;
 
-	if (nr < DRM_COMMAND_BASE)
+	if (nr < DRM_COMMAND_BASE || nr >= DRM_COMMAND_END)
 		return drm_compat_ioctl(filp, cmd, arg);
 
 	if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(i915_compat_ioctls))
-- 
2.4.2


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

* [PATCH 1/2] drm/i915: Forward all core DRM ioctls to core compat handling
@ 2015-07-14 10:13 ` Tvrtko Ursulin
  0 siblings, 0 replies; 7+ messages in thread
From: Tvrtko Ursulin @ 2015-07-14 10:13 UTC (permalink / raw)
  To: Intel-gfx; +Cc: Daniel Vetter, stable

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Previously only core DRM ioctls under the DRM_COMMAND_BASE were being
forwarded, but the drm.h header suggests (and reality confirms) ones
after (and including) DRM_COMMAND_END should be forwarded as well.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: stable@vger.kernel.org
---
 drivers/gpu/drm/i915/i915_ioc32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
index 176de6322e4d..23aa04cded6b 100644
--- a/drivers/gpu/drm/i915/i915_ioc32.c
+++ b/drivers/gpu/drm/i915/i915_ioc32.c
@@ -204,7 +204,7 @@ long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	drm_ioctl_compat_t *fn = NULL;
 	int ret;
 
-	if (nr < DRM_COMMAND_BASE)
+	if (nr < DRM_COMMAND_BASE || nr >= DRM_COMMAND_END)
 		return drm_compat_ioctl(filp, cmd, arg);
 
 	if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(i915_compat_ioctls))
-- 
2.4.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH 2/2] drm: Provide compat ioctl for addfb2.1
  2015-07-14 10:13 ` Tvrtko Ursulin
  (?)
@ 2015-07-14 10:13 ` Tvrtko Ursulin
  2015-07-14 10:26     ` Daniel Vetter
  2015-07-15  9:17     ` Tvrtko Ursulin
  -1 siblings, 2 replies; 7+ messages in thread
From: Tvrtko Ursulin @ 2015-07-14 10:13 UTC (permalink / raw)
  To: Intel-gfx
  Cc: Tvrtko Ursulin, dri-devel, Rob Clark, Daniel Stone, Daniel Vetter,
	stable

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Frame buffer modifiers extensions provided in;

  commit e3eb3250d84ef97b766312345774367b6a310db8
  Author: Rob Clark <robdclark@gmail.com>
  Date:   Thu Feb 5 14:41:52 2015 +0000

      drm: add support for tiled/compressed/etc modifier in addfb2

Missed the structure packing/alignment problem where 64-bit
members were added after the odd number of 32-bit ones. This
makes the compiler produce structures of different sizes under
32- and 64-bit x86 targets and makes the ioctl need explicit
compat handling.

v2: Removed the typedef. (Daniel Vetter)

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Cc: Rob Clark <robdclark@gmail.com>
Cc: Daniel Stone <daniels@collabora.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: stable@vger.kernel.org
---
 drivers/gpu/drm/drm_ioc32.c | 60 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
index 8dcfa76b09e6..40d18d6173d9 100644
--- a/drivers/gpu/drm/drm_ioc32.c
+++ b/drivers/gpu/drm/drm_ioc32.c
@@ -70,6 +70,8 @@
 
 #define DRM_IOCTL_WAIT_VBLANK32		DRM_IOWR(0x3a, drm_wait_vblank32_t)
 
+#define DRM_IOCTL_MODE_ADDFB232		DRM_IOWR(0xb8, drm_mode_fb_cmd232_t)
+
 typedef struct drm_version_32 {
 	int version_major;	  /**< Major version */
 	int version_minor;	  /**< Minor version */
@@ -1013,6 +1015,63 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
 	return 0;
 }
 
+struct drm_mode_fb_cmd232 {
+	u32 fb_id;
+	u32 width;
+	u32 height;
+	u32 pixel_format;
+	u32 flags;
+	u32 handles[4];
+	u32 pitches[4];
+	u32 offsets[4];
+	u64 modifier[4];
+} __attribute__((packed));
+
+static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
+				  unsigned long arg)
+{
+	struct drm_mode_fb_cmd232 __user *argp = (void __user *)arg;
+	struct drm_mode_fb_cmd232 req32;
+	struct drm_mode_fb_cmd2 __user *req64;
+	int i;
+	int err;
+
+	if (copy_from_user(&req32, argp, sizeof(req32)))
+		return -EFAULT;
+
+	req64 = compat_alloc_user_space(sizeof(*req64));
+
+	if (!access_ok(VERIFY_WRITE, req64, sizeof(*req64))
+	    || __put_user(req32.width, &req64->width)
+	    || __put_user(req32.height, &req64->height)
+	    || __put_user(req32.pixel_format, &req64->pixel_format)
+	    || __put_user(req32.flags, &req64->flags))
+		return -EFAULT;
+
+	for (i = 0; i < 4; i++) {
+		if (__put_user(req32.handles[i], &req64->handles[i]))
+			return -EFAULT;
+		if (__put_user(req32.pitches[i], &req64->pitches[i]))
+			return -EFAULT;
+		if (__put_user(req32.offsets[i], &req64->offsets[i]))
+			return -EFAULT;
+		if (__put_user(req32.modifier[i], &req64->modifier[i]))
+			return -EFAULT;
+	}
+
+	err = drm_ioctl(file, DRM_IOCTL_MODE_ADDFB2, (unsigned long)req64);
+	if (err)
+		return err;
+
+	if (__get_user(req32.fb_id, &req64->fb_id))
+		return -EFAULT;
+
+	if (copy_to_user(argp, &req32, sizeof(req32)))
+		return -EFAULT;
+
+	return 0;
+}
+
 static drm_ioctl_compat_t *drm_compat_ioctls[] = {
 	[DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
 	[DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
@@ -1045,6 +1104,7 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = {
 	[DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW32)] = compat_drm_update_draw,
 #endif
 	[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK32)] = compat_drm_wait_vblank,
+	[DRM_IOCTL_NR(DRM_IOCTL_MODE_ADDFB232)] = compat_drm_mode_addfb2,
 };
 
 /**
-- 
2.4.2


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

* Re: [Intel-gfx] [PATCH 2/2] drm: Provide compat ioctl for addfb2.1
  2015-07-14 10:13 ` [PATCH 2/2] drm: Provide compat ioctl for addfb2.1 Tvrtko Ursulin
@ 2015-07-14 10:26     ` Daniel Vetter
  2015-07-15  9:17     ` Tvrtko Ursulin
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2015-07-14 10:26 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: Intel-gfx, Daniel Stone, stable, dri-devel, Daniel Vetter

On Tue, Jul 14, 2015 at 11:13:08AM +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Frame buffer modifiers extensions provided in;
> 
>   commit e3eb3250d84ef97b766312345774367b6a310db8
>   Author: Rob Clark <robdclark@gmail.com>
>   Date:   Thu Feb 5 14:41:52 2015 +0000
> 
>       drm: add support for tiled/compressed/etc modifier in addfb2
> 
> Missed the structure packing/alignment problem where 64-bit
> members were added after the odd number of 32-bit ones. This
> makes the compiler produce structures of different sizes under
> 32- and 64-bit x86 targets and makes the ioctl need explicit
> compat handling.
> 
> v2: Removed the typedef. (Daniel Vetter)
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: dri-devel@lists.freedesktop.org
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Daniel Stone <daniels@collabora.com>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: stable@vger.kernel.org

Applied to topic/drm-fixes. I pulled in the i915 one (with cc:stable
added) already.

Thanks, Daniel
> ---
>  drivers/gpu/drm/drm_ioc32.c | 60 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 60 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
> index 8dcfa76b09e6..40d18d6173d9 100644
> --- a/drivers/gpu/drm/drm_ioc32.c
> +++ b/drivers/gpu/drm/drm_ioc32.c
> @@ -70,6 +70,8 @@
>  
>  #define DRM_IOCTL_WAIT_VBLANK32		DRM_IOWR(0x3a, drm_wait_vblank32_t)
>  
> +#define DRM_IOCTL_MODE_ADDFB232		DRM_IOWR(0xb8, drm_mode_fb_cmd232_t)
> +
>  typedef struct drm_version_32 {
>  	int version_major;	  /**< Major version */
>  	int version_minor;	  /**< Minor version */
> @@ -1013,6 +1015,63 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
>  	return 0;
>  }
>  
> +struct drm_mode_fb_cmd232 {
> +	u32 fb_id;
> +	u32 width;
> +	u32 height;
> +	u32 pixel_format;
> +	u32 flags;
> +	u32 handles[4];
> +	u32 pitches[4];
> +	u32 offsets[4];
> +	u64 modifier[4];
> +} __attribute__((packed));
> +
> +static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
> +				  unsigned long arg)
> +{
> +	struct drm_mode_fb_cmd232 __user *argp = (void __user *)arg;
> +	struct drm_mode_fb_cmd232 req32;
> +	struct drm_mode_fb_cmd2 __user *req64;
> +	int i;
> +	int err;
> +
> +	if (copy_from_user(&req32, argp, sizeof(req32)))
> +		return -EFAULT;
> +
> +	req64 = compat_alloc_user_space(sizeof(*req64));
> +
> +	if (!access_ok(VERIFY_WRITE, req64, sizeof(*req64))
> +	    || __put_user(req32.width, &req64->width)
> +	    || __put_user(req32.height, &req64->height)
> +	    || __put_user(req32.pixel_format, &req64->pixel_format)
> +	    || __put_user(req32.flags, &req64->flags))
> +		return -EFAULT;
> +
> +	for (i = 0; i < 4; i++) {
> +		if (__put_user(req32.handles[i], &req64->handles[i]))
> +			return -EFAULT;
> +		if (__put_user(req32.pitches[i], &req64->pitches[i]))
> +			return -EFAULT;
> +		if (__put_user(req32.offsets[i], &req64->offsets[i]))
> +			return -EFAULT;
> +		if (__put_user(req32.modifier[i], &req64->modifier[i]))
> +			return -EFAULT;
> +	}
> +
> +	err = drm_ioctl(file, DRM_IOCTL_MODE_ADDFB2, (unsigned long)req64);
> +	if (err)
> +		return err;
> +
> +	if (__get_user(req32.fb_id, &req64->fb_id))
> +		return -EFAULT;
> +
> +	if (copy_to_user(argp, &req32, sizeof(req32)))
> +		return -EFAULT;
> +
> +	return 0;
> +}
> +
>  static drm_ioctl_compat_t *drm_compat_ioctls[] = {
>  	[DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
>  	[DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
> @@ -1045,6 +1104,7 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = {
>  	[DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW32)] = compat_drm_update_draw,
>  #endif
>  	[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK32)] = compat_drm_wait_vblank,
> +	[DRM_IOCTL_NR(DRM_IOCTL_MODE_ADDFB232)] = compat_drm_mode_addfb2,
>  };
>  
>  /**
> -- 
> 2.4.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

* Re: [PATCH 2/2] drm: Provide compat ioctl for addfb2.1
@ 2015-07-14 10:26     ` Daniel Vetter
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2015-07-14 10:26 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: dri-devel, Daniel Vetter, Intel-gfx, Daniel Stone, stable

On Tue, Jul 14, 2015 at 11:13:08AM +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Frame buffer modifiers extensions provided in;
> 
>   commit e3eb3250d84ef97b766312345774367b6a310db8
>   Author: Rob Clark <robdclark@gmail.com>
>   Date:   Thu Feb 5 14:41:52 2015 +0000
> 
>       drm: add support for tiled/compressed/etc modifier in addfb2
> 
> Missed the structure packing/alignment problem where 64-bit
> members were added after the odd number of 32-bit ones. This
> makes the compiler produce structures of different sizes under
> 32- and 64-bit x86 targets and makes the ioctl need explicit
> compat handling.
> 
> v2: Removed the typedef. (Daniel Vetter)
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: dri-devel@lists.freedesktop.org
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Daniel Stone <daniels@collabora.com>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: stable@vger.kernel.org

Applied to topic/drm-fixes. I pulled in the i915 one (with cc:stable
added) already.

Thanks, Daniel
> ---
>  drivers/gpu/drm/drm_ioc32.c | 60 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 60 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
> index 8dcfa76b09e6..40d18d6173d9 100644
> --- a/drivers/gpu/drm/drm_ioc32.c
> +++ b/drivers/gpu/drm/drm_ioc32.c
> @@ -70,6 +70,8 @@
>  
>  #define DRM_IOCTL_WAIT_VBLANK32		DRM_IOWR(0x3a, drm_wait_vblank32_t)
>  
> +#define DRM_IOCTL_MODE_ADDFB232		DRM_IOWR(0xb8, drm_mode_fb_cmd232_t)
> +
>  typedef struct drm_version_32 {
>  	int version_major;	  /**< Major version */
>  	int version_minor;	  /**< Minor version */
> @@ -1013,6 +1015,63 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
>  	return 0;
>  }
>  
> +struct drm_mode_fb_cmd232 {
> +	u32 fb_id;
> +	u32 width;
> +	u32 height;
> +	u32 pixel_format;
> +	u32 flags;
> +	u32 handles[4];
> +	u32 pitches[4];
> +	u32 offsets[4];
> +	u64 modifier[4];
> +} __attribute__((packed));
> +
> +static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
> +				  unsigned long arg)
> +{
> +	struct drm_mode_fb_cmd232 __user *argp = (void __user *)arg;
> +	struct drm_mode_fb_cmd232 req32;
> +	struct drm_mode_fb_cmd2 __user *req64;
> +	int i;
> +	int err;
> +
> +	if (copy_from_user(&req32, argp, sizeof(req32)))
> +		return -EFAULT;
> +
> +	req64 = compat_alloc_user_space(sizeof(*req64));
> +
> +	if (!access_ok(VERIFY_WRITE, req64, sizeof(*req64))
> +	    || __put_user(req32.width, &req64->width)
> +	    || __put_user(req32.height, &req64->height)
> +	    || __put_user(req32.pixel_format, &req64->pixel_format)
> +	    || __put_user(req32.flags, &req64->flags))
> +		return -EFAULT;
> +
> +	for (i = 0; i < 4; i++) {
> +		if (__put_user(req32.handles[i], &req64->handles[i]))
> +			return -EFAULT;
> +		if (__put_user(req32.pitches[i], &req64->pitches[i]))
> +			return -EFAULT;
> +		if (__put_user(req32.offsets[i], &req64->offsets[i]))
> +			return -EFAULT;
> +		if (__put_user(req32.modifier[i], &req64->modifier[i]))
> +			return -EFAULT;
> +	}
> +
> +	err = drm_ioctl(file, DRM_IOCTL_MODE_ADDFB2, (unsigned long)req64);
> +	if (err)
> +		return err;
> +
> +	if (__get_user(req32.fb_id, &req64->fb_id))
> +		return -EFAULT;
> +
> +	if (copy_to_user(argp, &req32, sizeof(req32)))
> +		return -EFAULT;
> +
> +	return 0;
> +}
> +
>  static drm_ioctl_compat_t *drm_compat_ioctls[] = {
>  	[DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
>  	[DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
> @@ -1045,6 +1104,7 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = {
>  	[DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW32)] = compat_drm_update_draw,
>  #endif
>  	[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK32)] = compat_drm_wait_vblank,
> +	[DRM_IOCTL_NR(DRM_IOCTL_MODE_ADDFB232)] = compat_drm_mode_addfb2,
>  };
>  
>  /**
> -- 
> 2.4.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH 2/2 v3] drm: Provide compat ioctl for addfb2.1
  2015-07-14 10:13 ` [PATCH 2/2] drm: Provide compat ioctl for addfb2.1 Tvrtko Ursulin
@ 2015-07-15  9:17     ` Tvrtko Ursulin
  2015-07-15  9:17     ` Tvrtko Ursulin
  1 sibling, 0 replies; 7+ messages in thread
From: Tvrtko Ursulin @ 2015-07-15  9:17 UTC (permalink / raw)
  To: Intel-gfx
  Cc: Tvrtko Ursulin, dri-devel, Rob Clark, Daniel Stone, Daniel Vetter,
	stable

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Frame buffer modifiers extensions provided in;

  commit e3eb3250d84ef97b766312345774367b6a310db8
  Author: Rob Clark <robdclark@gmail.com>
  Date:   Thu Feb 5 14:41:52 2015 +0000

      drm: add support for tiled/compressed/etc modifier in addfb2

Missed the structure packing/alignment problem where 64-bit
members were added after the odd number of 32-bit ones. This
makes the compiler produce structures of different sizes under
32- and 64-bit x86 targets and makes the ioctl need explicit
compat handling.

v2: Removed the typedef. (Daniel Vetter)
v3: Failed to git add all changes when sending v2. (0day)

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Cc: dri-devel@lists.freedesktop.org
Cc: Rob Clark <robdclark@gmail.com>
Cc: Daniel Stone <daniels@collabora.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: stable@vger.kernel.org
---
 drivers/gpu/drm/drm_ioc32.c | 60 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
index 8dcfa76b09e6..7fdec8d1e059 100644
--- a/drivers/gpu/drm/drm_ioc32.c
+++ b/drivers/gpu/drm/drm_ioc32.c
@@ -70,6 +70,8 @@
 
 #define DRM_IOCTL_WAIT_VBLANK32		DRM_IOWR(0x3a, drm_wait_vblank32_t)
 
+#define DRM_IOCTL_MODE_ADDFB232		DRM_IOWR(0xb8, struct drm_mode_fb_cmd232)
+
 typedef struct drm_version_32 {
 	int version_major;	  /**< Major version */
 	int version_minor;	  /**< Minor version */
@@ -1013,6 +1015,63 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
 	return 0;
 }
 
+struct drm_mode_fb_cmd232 {
+	u32 fb_id;
+	u32 width;
+	u32 height;
+	u32 pixel_format;
+	u32 flags;
+	u32 handles[4];
+	u32 pitches[4];
+	u32 offsets[4];
+	u64 modifier[4];
+} __attribute__((packed));
+
+static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
+				  unsigned long arg)
+{
+	struct drm_mode_fb_cmd232 __user *argp = (void __user *)arg;
+	struct drm_mode_fb_cmd232 req32;
+	struct drm_mode_fb_cmd2 __user *req64;
+	int i;
+	int err;
+
+	if (copy_from_user(&req32, argp, sizeof(req32)))
+		return -EFAULT;
+
+	req64 = compat_alloc_user_space(sizeof(*req64));
+
+	if (!access_ok(VERIFY_WRITE, req64, sizeof(*req64))
+	    || __put_user(req32.width, &req64->width)
+	    || __put_user(req32.height, &req64->height)
+	    || __put_user(req32.pixel_format, &req64->pixel_format)
+	    || __put_user(req32.flags, &req64->flags))
+		return -EFAULT;
+
+	for (i = 0; i < 4; i++) {
+		if (__put_user(req32.handles[i], &req64->handles[i]))
+			return -EFAULT;
+		if (__put_user(req32.pitches[i], &req64->pitches[i]))
+			return -EFAULT;
+		if (__put_user(req32.offsets[i], &req64->offsets[i]))
+			return -EFAULT;
+		if (__put_user(req32.modifier[i], &req64->modifier[i]))
+			return -EFAULT;
+	}
+
+	err = drm_ioctl(file, DRM_IOCTL_MODE_ADDFB2, (unsigned long)req64);
+	if (err)
+		return err;
+
+	if (__get_user(req32.fb_id, &req64->fb_id))
+		return -EFAULT;
+
+	if (copy_to_user(argp, &req32, sizeof(req32)))
+		return -EFAULT;
+
+	return 0;
+}
+
 static drm_ioctl_compat_t *drm_compat_ioctls[] = {
 	[DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
 	[DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
@@ -1045,6 +1104,7 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = {
 	[DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW32)] = compat_drm_update_draw,
 #endif
 	[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK32)] = compat_drm_wait_vblank,
+	[DRM_IOCTL_NR(DRM_IOCTL_MODE_ADDFB232)] = compat_drm_mode_addfb2,
 };
 
 /**
-- 
2.4.2


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

* [PATCH 2/2 v3] drm: Provide compat ioctl for addfb2.1
@ 2015-07-15  9:17     ` Tvrtko Ursulin
  0 siblings, 0 replies; 7+ messages in thread
From: Tvrtko Ursulin @ 2015-07-15  9:17 UTC (permalink / raw)
  To: Intel-gfx; +Cc: Daniel Stone, stable, dri-devel, Daniel Vetter

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Frame buffer modifiers extensions provided in;

  commit e3eb3250d84ef97b766312345774367b6a310db8
  Author: Rob Clark <robdclark@gmail.com>
  Date:   Thu Feb 5 14:41:52 2015 +0000

      drm: add support for tiled/compressed/etc modifier in addfb2

Missed the structure packing/alignment problem where 64-bit
members were added after the odd number of 32-bit ones. This
makes the compiler produce structures of different sizes under
32- and 64-bit x86 targets and makes the ioctl need explicit
compat handling.

v2: Removed the typedef. (Daniel Vetter)
v3: Failed to git add all changes when sending v2. (0day)

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Cc: dri-devel@lists.freedesktop.org
Cc: Rob Clark <robdclark@gmail.com>
Cc: Daniel Stone <daniels@collabora.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: stable@vger.kernel.org
---
 drivers/gpu/drm/drm_ioc32.c | 60 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
index 8dcfa76b09e6..7fdec8d1e059 100644
--- a/drivers/gpu/drm/drm_ioc32.c
+++ b/drivers/gpu/drm/drm_ioc32.c
@@ -70,6 +70,8 @@
 
 #define DRM_IOCTL_WAIT_VBLANK32		DRM_IOWR(0x3a, drm_wait_vblank32_t)
 
+#define DRM_IOCTL_MODE_ADDFB232		DRM_IOWR(0xb8, struct drm_mode_fb_cmd232)
+
 typedef struct drm_version_32 {
 	int version_major;	  /**< Major version */
 	int version_minor;	  /**< Minor version */
@@ -1013,6 +1015,63 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
 	return 0;
 }
 
+struct drm_mode_fb_cmd232 {
+	u32 fb_id;
+	u32 width;
+	u32 height;
+	u32 pixel_format;
+	u32 flags;
+	u32 handles[4];
+	u32 pitches[4];
+	u32 offsets[4];
+	u64 modifier[4];
+} __attribute__((packed));
+
+static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
+				  unsigned long arg)
+{
+	struct drm_mode_fb_cmd232 __user *argp = (void __user *)arg;
+	struct drm_mode_fb_cmd232 req32;
+	struct drm_mode_fb_cmd2 __user *req64;
+	int i;
+	int err;
+
+	if (copy_from_user(&req32, argp, sizeof(req32)))
+		return -EFAULT;
+
+	req64 = compat_alloc_user_space(sizeof(*req64));
+
+	if (!access_ok(VERIFY_WRITE, req64, sizeof(*req64))
+	    || __put_user(req32.width, &req64->width)
+	    || __put_user(req32.height, &req64->height)
+	    || __put_user(req32.pixel_format, &req64->pixel_format)
+	    || __put_user(req32.flags, &req64->flags))
+		return -EFAULT;
+
+	for (i = 0; i < 4; i++) {
+		if (__put_user(req32.handles[i], &req64->handles[i]))
+			return -EFAULT;
+		if (__put_user(req32.pitches[i], &req64->pitches[i]))
+			return -EFAULT;
+		if (__put_user(req32.offsets[i], &req64->offsets[i]))
+			return -EFAULT;
+		if (__put_user(req32.modifier[i], &req64->modifier[i]))
+			return -EFAULT;
+	}
+
+	err = drm_ioctl(file, DRM_IOCTL_MODE_ADDFB2, (unsigned long)req64);
+	if (err)
+		return err;
+
+	if (__get_user(req32.fb_id, &req64->fb_id))
+		return -EFAULT;
+
+	if (copy_to_user(argp, &req32, sizeof(req32)))
+		return -EFAULT;
+
+	return 0;
+}
+
 static drm_ioctl_compat_t *drm_compat_ioctls[] = {
 	[DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
 	[DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
@@ -1045,6 +1104,7 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = {
 	[DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW32)] = compat_drm_update_draw,
 #endif
 	[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK32)] = compat_drm_wait_vblank,
+	[DRM_IOCTL_NR(DRM_IOCTL_MODE_ADDFB232)] = compat_drm_mode_addfb2,
 };
 
 /**
-- 
2.4.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2015-07-15  9:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14 10:13 [PATCH 1/2] drm/i915: Forward all core DRM ioctls to core compat handling Tvrtko Ursulin
2015-07-14 10:13 ` Tvrtko Ursulin
2015-07-14 10:13 ` [PATCH 2/2] drm: Provide compat ioctl for addfb2.1 Tvrtko Ursulin
2015-07-14 10:26   ` [Intel-gfx] " Daniel Vetter
2015-07-14 10:26     ` Daniel Vetter
2015-07-15  9:17   ` [PATCH 2/2 v3] " Tvrtko Ursulin
2015-07-15  9:17     ` Tvrtko Ursulin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.