Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/dist/drm/i915 Work around ioctl ABI mi...



details:   https://anonhg.NetBSD.org/src/rev/8022ea7e1a85
branches:  trunk
changeset: 366313:8022ea7e1a85
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 14:47:02 2018 +0000

description:
Work around ioctl ABI mistake in i915 drm.

A flags argument was added to the I915_GEM_MMAP ioctl.  The version
of xf86-video-intel we imported was compiled to use the new ioctl
structure including the flags argument, but without initializing the
flags argument, so it would be userland stack garbage causing
i915_gem_mmap_ioctl to fail.

Newer xf86-video-intel will query the mmap version first before
trying to use either the older ioctl structure, with the original
shorter argument and thus no stack garbage (which will be padded with
to the full length in the kernel by drm_ioctl), or the newer ioctl
structure, with the argument initialized.

libdrm does not appear to be affected by this -- it zeroes the longer
structure before passing it in.

Patch from mrg@, diagnosis and explanation by me.

diffstat:

 sys/external/bsd/drm2/dist/drm/i915/i915_dma.c |  7 +++++--
 sys/external/bsd/drm2/dist/drm/i915/i915_drv.h |  7 ++++++-
 sys/external/bsd/drm2/dist/drm/i915/i915_gem.c |  8 ++++++--
 3 files changed, 17 insertions(+), 5 deletions(-)

diffs (79 lines):

diff -r 42991133b5ef -r 8022ea7e1a85 sys/external/bsd/drm2/dist/drm/i915/i915_dma.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c    Mon Aug 27 14:46:38 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c    Mon Aug 27 14:47:02 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_dma.c,v 1.23 2018/08/27 13:43:39 riastradh Exp $  */
+/*     $NetBSD: i915_dma.c,v 1.24 2018/08/27 14:47:02 riastradh Exp $  */
 
 /* i915_dma.c -- DMA support for the I915 -*- linux-c -*-
  */
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_dma.c,v 1.23 2018/08/27 13:43:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_dma.c,v 1.24 2018/08/27 14:47:02 riastradh Exp $");
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
@@ -160,6 +160,9 @@
                value = 1;
                break;
        case I915_PARAM_MMAP_VERSION:
+#ifdef __NetBSD__
+               dev_priv->quirks |= QUIRK_NETBSD_VERSION_CALLED;
+#endif
                value = 1;
                break;
        case I915_PARAM_SUBSLICE_TOTAL:
diff -r 42991133b5ef -r 8022ea7e1a85 sys/external/bsd/drm2/dist/drm/i915/i915_drv.h
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h    Mon Aug 27 14:46:38 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h    Mon Aug 27 14:47:02 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_drv.h,v 1.23 2018/08/27 13:43:39 riastradh Exp $  */
+/*     $NetBSD: i915_drv.h,v 1.24 2018/08/27 14:47:02 riastradh Exp $  */
 
 /* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
  */
@@ -1042,6 +1042,11 @@
 #define QUIRK_PIPEB_FORCE (1<<4)
 #define QUIRK_PIN_SWIZZLED_PAGES (1<<5)
 
+#ifdef __NetBSD__
+/* NetBSD hack to note version was called and thus mmap flags valid. */
+#define QUIRK_NETBSD_VERSION_CALLED (1ul<<31)
+#endif
+
 struct intel_fbdev;
 struct intel_fbc_work;
 
diff -r 42991133b5ef -r 8022ea7e1a85 sys/external/bsd/drm2/dist/drm/i915/i915_gem.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c    Mon Aug 27 14:46:38 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c    Mon Aug 27 14:47:02 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem.c,v 1.51 2018/08/27 14:44:46 riastradh Exp $  */
+/*     $NetBSD: i915_gem.c,v 1.52 2018/08/27 14:47:02 riastradh Exp $  */
 
 /*
  * Copyright © 2008-2015 Intel Corporation
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem.c,v 1.51 2018/08/27 14:44:46 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem.c,v 1.52 2018/08/27 14:47:02 riastradh Exp $");
 
 #ifdef __NetBSD__
 #if 0                          /* XXX uvmhist option?  */
@@ -1930,7 +1930,11 @@
        struct drm_gem_object *obj;
        unsigned long addr;
 #ifdef __NetBSD__
+       struct drm_i915_private *dev_priv = dev->dev_private;
        int ret;
+
+       if ((dev_priv->quirks & QUIRK_NETBSD_VERSION_CALLED) == 0)
+               args->flags = 0;
 #endif
 
        if (args->flags & ~(I915_MMAP_WC))



Home | Main Index | Thread Index | Old Index