Skip to contentSkip to conversation

Support for Intel GPU

Qemu-devel Allan Sandfeld Jensen 1 participant 1 message Nov 29, 2018

lore
Share & tools
lore
#0 lore raw

I have attached a patch that enables support for direct use of Intel GPUs in QEMU. With this you can build the libdrm and mesa on for instance an AArch64 emulated system and have native OpenGL support inside QEMU.

The code has been sitting around on my drive for a year, and isn't quite as polished as I would like it to be, but I thought it would better to get it out there and see what people think.

I have other patches for Radeon drivers, but it untested, and many of the other DRM drivers are must harder to support as they have their own subcommand systems on top of IOCTL that makes it hard to support with existing IOCTL mapping in QEMU. I can share those too if there is interest, I am just starting with the one I have tested and know works at least for me.

Best regards
'Allan

Quoted 1 line

From 2ce0dc997c1ebc7a63dbd3ba3b7638b3a5f8432e Mon Sep 17 00:00:00 2001

From: Allan Sandfeld Jensen <[email protected]>
Date: Thu, 22 Feb 2018 12:42:13 +0100
Subject: [PATCH 1/2] Add support for drm ioctls

Tested with mesa on i915. Support for other drivers missing.

---
 configure                  |  19 +++
 linux-user/ioctls.h        |  60 ++++++++
 linux-user/syscall.c       |   5 +
 linux-user/syscall_defs.h  |  84 +++++++++++
 linux-user/syscall_types.h | 292 +++++++++++++++++++++++++++++++++++++
 5 files changed, 460 insertions(+)
configure +19 -0
index 0a3c6a72c3..b67cd624bb 100755
@@ -5386,6 +5386,20 @@ if compile_prog "" "" ; then
     have_rtnetlink=yes
 fi
 
+##########################################
+# check if we have libdrm available
+have_libdrm=no
+cat > $TMPC << EOF
+#include <libdrm/drm.h>
+#include <libdrm/i915_drm.h>
+int main(void) {
+  return DRM_IOCTL_PRIME_FD_TO_HANDLE | DRM_IOCTL_I915_GET_RESET_STATS;
+}
+EOF
+if compile_prog "" "" ; then
+    have_libdrm=yes
+fi
+
 ##########################################
 # check for usable AF_VSOCK environment
 have_af_vsock=no
@@ -6027,6 +6041,7 @@ echo "PIE               $pie"
 echo "vde support       $vde"
 echo "netmap support    $netmap"
 echo "Linux AIO support $linux_aio"
+echo "Linux drm support (i915) $have_libdrm"
 echo "ATTR/XATTR support $attr"
 echo "Install blobs     $blobs"
 echo "KVM support       $kvm"
@@ -6813,6 +6828,10 @@ if test "$libxml2" = "yes" ; then
   echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
 fi
 
+if test "$have_libdrm" = "yes" ; then
+  echo "CONFIG_LIBDRM=y" >> $config_host_mak
+fi
+
 if test "$replication" = "yes" ; then
   echo "CONFIG_REPLICATION=y" >> $config_host_mak
 fi
linux-user/ioctls.h +60 -0

63 lines not on this page · raw message

linux-user/syscall.c +5 -0
index 280137da8c..695ab0251c 100644
@@ -109,6 +109,11 @@
 #include "linux_loop.h"
 #include "uname.h"
 
+#ifdef CONFIG_LIBDRM
+#include <libdrm/drm.h>
+#include <libdrm/i915_drm.h>
+#endif
+
 #include "qemu.h"
 #include "fd-trans.h"
 
linux-user/syscall_defs.h +84 -0

88 lines not on this page · raw message

linux-user/syscall_types.h +292 -0

295 lines not on this page · raw message

Signature · 1 line
2.20.0.rc1