Skip to contentSkip to conversation

This patch adds initial user-virtualization support for the DRM (type 'd') IOCTLs in linux. With it and a corresponding architecture chroot (say aarch64), I am able to successfully run a few 2D and 3D applications with native graphics acceleration. Some notes/caveats are:

PATCH In review Timothy Pearson 2 participants 2 messages Jun 19, 2016 – Jun 20, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 4/7 This patch adds initial user-virtualization support for the DRM (type 'd') IOCTLs in linux. With it and a corresponding architecture chroot (say aarch64), I am able to successfully run a few 2D and 3D applications with native graphics acceleration. Some notes/caveats are:

1. It will only work with open drivers as their IOCTLs are documented.
2. i965+ is only supported. That is any haswell, ivybridge, etc. GPU will work.
3. X doesn't start yet, though this patch eliminates all the visible unsupported DRM IOCTL calls as observed by setting QEMU_STRACE=1.
4. Intel open drivers components except for Beignet are architecture independent AFAICT and compile cleanly in foreign architecture environments.
5. The DRM table provided is current as of linux-3.17-rc2, however, compiling it with older kernel headers might require conditional guards that this patch doesn't provide yet.
6. syscalls.c now includes <drm/*.h> files, which should be available in any valid linux-user build environment.

Using a Debian aarch64 chroot on ubuntu amd64, I have successfully run nexuiz and
compiled and run qemu-system-i386 with SDL emulation (+ patch for forcing OpenGL).

---
 linux-user/ioctls.h        | 137 ++++++++++
 linux-user/syscall.c       |   2 +
 linux-user/syscall_defs.h  | 139 ++++++++++
 linux-user/syscall_types.h | 651
+++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 929 insertions(+)
linux-user/ioctls.h +5 -0
index e672655..60bbe33 100644
@@ -386,3 +386,140 @@
                 MK_PTR(MK_STRUCT(STRUCT_rtentry)))
   IOCTL_SPECIAL(SIOCDELRT, IOC_W, do_ioctl_rt,
                 MK_PTR(MK_STRUCT(STRUCT_rtentry)))
+
+  IOCTL(DRM_IOCTL_VERSION, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_version)))
+  IOCTL(DRM_IOCTL_GET_UNIQUE, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_unique)))
+  IOCTL(DRM_IOCTL_GET_MAGIC, IOC_R, MK_PTR(MK_STRUCT(STRUCT_drm_auth)))
+  IOCTL(DRM_IOCTL_IRQ_BUSID, IOC_RW,

MK_PTR(MK_STRUCT(STRUCT_drm_irq_busid)))

+  IOCTL(DRM_IOCTL_GET_MAP, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_map)))
+  IOCTL(DRM_IOCTL_GET_CLIENT, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_client)))
+  IOCTL(DRM_IOCTL_GET_STATS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_drm_stats)))
+  IOCTL(DRM_IOCTL_SET_VERSION, IOC_RW,

MK_PTR(MK_STRUCT(STRUCT_drm_set_version)))
+ IOCTL(DRM_IOCTL_MODESET_CTL, IOC_W,
MK_PTR(MK_STRUCT(STRUCT_drm_modeset_ctl)))
+ IOCTL(DRM_IOCTL_GEM_CLOSE, IOC_W ,
MK_PTR(MK_STRUCT(STRUCT_drm_gem_close)))
+ IOCTL(DRM_IOCTL_GEM_FLINK, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_drm_gem_flink)))

+  IOCTL(DRM_IOCTL_GEM_OPEN, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_gem_open)))
+  IOCTL(DRM_IOCTL_GET_CAP, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_get_cap)))
+  IOCTL(DRM_IOCTL_SET_CLIENT_CAP, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_drm_set_client_cap)))
+  IOCTL(DRM_IOCTL_SET_UNIQUE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_unique)))
+  IOCTL(DRM_IOCTL_AUTH_MAGIC, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_auth)))
+  IOCTL(DRM_IOCTL_BLOCK, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_block)))
+  IOCTL(DRM_IOCTL_UNBLOCK, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_block)))
+  IOCTL(DRM_IOCTL_CONTROL, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_control)))
+  IOCTL(DRM_IOCTL_ADD_MAP, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_map)))
+  IOCTL(DRM_IOCTL_ADD_BUFS, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_buf_desc)))
+  IOCTL(DRM_IOCTL_MARK_BUFS, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_buf_desc)))
+  IOCTL(DRM_IOCTL_INFO_BUFS, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_drm_buf_info)))
+  IOCTL(DRM_IOCTL_MAP_BUFS, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_buf_map)))
+  IOCTL(DRM_IOCTL_FREE_BUFS, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_buf_free)))
+  IOCTL(DRM_IOCTL_RM_MAP, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_map)))
+  IOCTL(DRM_IOCTL_SET_SAREA_CTX, IOC_W,
MK_PTR(MK_STRUCT(STRUCT_drm_ctx_priv_map)))
+  IOCTL(DRM_IOCTL_GET_SAREA_CTX, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_drm_ctx_priv_map)))
+  IOCTL(DRM_IOCTL_SET_MASTER, 0, TYPE_NULL)
+  IOCTL(DRM_IOCTL_DROP_MASTER, 0, TYPE_NULL)
+  IOCTL(DRM_IOCTL_ADD_CTX, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_ctx)))
+  IOCTL(DRM_IOCTL_RM_CTX, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_ctx)))
+  IOCTL(DRM_IOCTL_MOD_CTX, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_ctx)))
+  IOCTL(DRM_IOCTL_GET_CTX, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_ctx)))
+  IOCTL(DRM_IOCTL_SWITCH_CTX, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_ctx)))
+  IOCTL(DRM_IOCTL_NEW_CTX, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_ctx)))
+  IOCTL(DRM_IOCTL_RES_CTX, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_ctx_res)))
+  IOCTL(DRM_IOCTL_ADD_DRAW, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_draw)))
+  IOCTL(DRM_IOCTL_RM_DRAW, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_draw)))
+  IOCTL(DRM_IOCTL_DMA, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_dma)))
+  IOCTL(DRM_IOCTL_LOCK, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_lock)))
+  IOCTL(DRM_IOCTL_UNLOCK, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_lock)))
+  IOCTL(DRM_IOCTL_FINISH, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_lock)))
+  IOCTL(DRM_IOCTL_PRIME_HANDLE_TO_FD, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_drm_prime_handle)))
+  IOCTL(DRM_IOCTL_PRIME_FD_TO_HANDLE, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_drm_prime_handle)))
+  IOCTL(DRM_IOCTL_AGP_ACQUIRE, 0, TYPE_NULL)
+  IOCTL(DRM_IOCTL_AGP_RELEASE, 0, TYPE_NULL)
+  IOCTL(DRM_IOCTL_AGP_ENABLE, IOC_W,

MK_PTR(MK_STRUCT(STRUCT_drm_agp_mode)))
+ IOCTL(DRM_IOCTL_AGP_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_drm_agp_info)))
+ IOCTL(DRM_IOCTL_AGP_ALLOC, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_agp_buffer)))
+ IOCTL(DRM_IOCTL_AGP_FREE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_agp_buffer)))
+ IOCTL(DRM_IOCTL_AGP_BIND, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_agp_binding)))
+ IOCTL(DRM_IOCTL_AGP_UNBIND, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_agp_binding)))
+ IOCTL(DRM_IOCTL_SG_ALLOC, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_scatter_gather)))
+ IOCTL(DRM_IOCTL_SG_FREE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_scatter_gather)))
+ IOCTL(DRM_IOCTL_WAIT_VBLANK, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_wait_vblank_reply)))
+ IOCTL(DRM_IOCTL_UPDATE_DRAW, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_update_draw)))
+ IOCTL(DRM_IOCTL_MODE_GETRESOURCES, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_card_res)))
+ IOCTL(DRM_IOCTL_MODE_GETCRTC, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_crtc)))
+ IOCTL(DRM_IOCTL_MODE_SETCRTC, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_crtc)))
+ IOCTL(DRM_IOCTL_MODE_CURSOR, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_cursor)))
+ IOCTL(DRM_IOCTL_MODE_GETGAMMA, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_crtc_lut)))
+ IOCTL(DRM_IOCTL_MODE_SETGAMMA, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_crtc_lut)))
+ IOCTL(DRM_IOCTL_MODE_GETENCODER, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_get_encoder)))
+ IOCTL(DRM_IOCTL_MODE_GETCONNECTOR, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_get_connector)))
+ IOCTL(DRM_IOCTL_MODE_ATTACHMODE, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_mode_cmd)))
+ IOCTL(DRM_IOCTL_MODE_DETACHMODE, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_mode_cmd)))
+ IOCTL(DRM_IOCTL_MODE_GETPROPERTY, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_get_property)))
+ IOCTL(DRM_IOCTL_MODE_SETPROPERTY, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_connector_set_property)))
+ IOCTL(DRM_IOCTL_MODE_GETPROPBLOB, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_get_blob)))
+ IOCTL(DRM_IOCTL_MODE_GETFB, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_fb_cmd)))
+ IOCTL(DRM_IOCTL_MODE_ADDFB, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_fb_cmd)))
+ IOCTL(DRM_IOCTL_MODE_RMFB, IOC_RW, TYPE_INT)
+ IOCTL(DRM_IOCTL_MODE_PAGE_FLIP, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_crtc_page_flip)))
+ IOCTL(DRM_IOCTL_MODE_DIRTYFB, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_fb_dirty_cmd)))
+ IOCTL(DRM_IOCTL_MODE_CREATE_DUMB, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_create_dumb)))
+ IOCTL(DRM_IOCTL_MODE_MAP_DUMB, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_map_dumb)))
+ IOCTL(DRM_IOCTL_MODE_DESTROY_DUMB, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_destroy_dumb)))
+ IOCTL(DRM_IOCTL_MODE_GETPLANERESOURCES, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_get_plane_res)))
+ IOCTL(DRM_IOCTL_MODE_GETPLANE, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_get_plane)))
+ IOCTL(DRM_IOCTL_MODE_SETPLANE, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_set_plane)))
+ IOCTL(DRM_IOCTL_MODE_ADDFB2, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_fb_cmd2)))
+ IOCTL(DRM_IOCTL_MODE_OBJ_GETPROPERTIES, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_obj_get_properties)))
+ IOCTL(DRM_IOCTL_MODE_OBJ_SETPROPERTY, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_obj_set_property)))
+ IOCTL(DRM_IOCTL_MODE_CURSOR2, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_mode_cursor2)))
+
+ IOCTL(DRM_IOCTL_I915_INIT, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_init_t)))

+  IOCTL(DRM_IOCTL_I915_FLUSH, 0, TYPE_NULL)
+  IOCTL(DRM_IOCTL_I915_FLIP, 0, TYPE_NULL)
+  IOCTL(DRM_IOCTL_I915_BATCHBUFFER, IOC_W,

MK_PTR(MK_STRUCT(STRUCT_drm_i915_batchbuffer_t)))
+ IOCTL(DRM_IOCTL_I915_IRQ_EMIT, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_irq_emit_t)))
+ IOCTL(DRM_IOCTL_I915_IRQ_WAIT, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_irq_wait_t)))
+ IOCTL(DRM_IOCTL_I915_GETPARAM, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_getparam_t)))
+ IOCTL(DRM_IOCTL_I915_SETPARAM, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_setparam_t)))
+ IOCTL(DRM_IOCTL_I915_ALLOC, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_mem_alloc_t)))
+ IOCTL(DRM_IOCTL_I915_FREE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_mem_free_t)))
+ IOCTL(DRM_IOCTL_I915_INIT_HEAP, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_mem_init_heap_t)))
+ IOCTL(DRM_IOCTL_I915_CMDBUFFER, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_cmdbuffer_t)))
+ IOCTL(DRM_IOCTL_I915_DESTROY_HEAP, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_mem_destroy_heap_t)))
+ IOCTL(DRM_IOCTL_I915_SET_VBLANK_PIPE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_vblank_pipe_t)))
+ IOCTL(DRM_IOCTL_I915_GET_VBLANK_PIPE, IOC_R, MK_PTR(MK_STRUCT(STRUCT_drm_i915_vblank_pipe_t)))
+ IOCTL(DRM_IOCTL_I915_VBLANK_SWAP , IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_vblank_swap_t)))
+ IOCTL(DRM_IOCTL_I915_HWS_ADDR, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_init)))
+ IOCTL(DRM_IOCTL_I915_GEM_INIT, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_init)))
+ IOCTL(DRM_IOCTL_I915_GEM_EXECBUFFER, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_execbuffer)))
+ IOCTL(DRM_IOCTL_I915_GEM_PIN, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_pin)))
+ IOCTL(DRM_IOCTL_I915_GEM_UNPIN, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_unpin)))
+ IOCTL(DRM_IOCTL_I915_GEM_BUSY, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_busy)))

+  IOCTL(DRM_IOCTL_I915_GEM_THROTTLE, 0, TYPE_NULL)
+  IOCTL(DRM_IOCTL_I915_GEM_ENTERVT, 0, TYPE_NULL)
+  IOCTL(DRM_IOCTL_I915_GEM_LEAVEVT, 0, TYPE_NULL)
+  IOCTL(DRM_IOCTL_I915_GEM_CREATE, IOC_RW,

MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_create)))
+ IOCTL(DRM_IOCTL_I915_GEM_PREAD, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_pread)))
+ IOCTL(DRM_IOCTL_I915_GEM_PWRITE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_pwrite)))
+ IOCTL(DRM_IOCTL_I915_GEM_MMAP, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_mmap)))
+ IOCTL(DRM_IOCTL_I915_GEM_MMAP_GTT, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_mmap_gtt)))
+ IOCTL(DRM_IOCTL_I915_GEM_SET_DOMAIN, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_set_domain)))
+ IOCTL(DRM_IOCTL_I915_GEM_SW_FINISH, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_sw_finish)))
+ IOCTL(DRM_IOCTL_I915_GEM_SET_TILING, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_set_tiling)))
+ IOCTL(DRM_IOCTL_I915_GEM_GET_TILING, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_get_tiling)))
+ IOCTL(DRM_IOCTL_I915_GEM_GET_APERTURE, IOC_R, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_get_aperture)))
+ IOCTL(DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_get_pipe_from_crtc_id)))
+ IOCTL(DRM_IOCTL_I915_GEM_MADVISE, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_madvise)))
+ IOCTL(DRM_IOCTL_I915_OVERLAY_PUT_IMAGE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_intel_overlay_put_image)))
+ IOCTL(DRM_IOCTL_I915_OVERLAY_ATTRS, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_intel_overlay_attrs)))
+ IOCTL(DRM_IOCTL_I915_GEM_EXECBUFFER2, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_execbuffer2)))
+ IOCTL(DRM_IOCTL_I915_SET_SPRITE_COLORKEY, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_intel_sprite_colorkey)))
+ IOCTL(DRM_IOCTL_I915_GET_SPRITE_COLORKEY, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_intel_sprite_colorkey)))
+ IOCTL(DRM_IOCTL_I915_GEM_WAIT, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_wait)))
+ IOCTL(DRM_IOCTL_I915_GEM_CONTEXT_CREATE, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_context_create)))
+ IOCTL(DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_context_destroy)))
+ IOCTL(DRM_IOCTL_I915_GEM_SET_CACHING, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_caching)))
+ IOCTL(DRM_IOCTL_I915_GEM_GET_CACHING, IOC_W, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_caching)))
+ IOCTL(DRM_IOCTL_I915_REG_READ, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_reg_read)))
+ IOCTL(DRM_IOCTL_I915_GET_RESET_STATS, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_reset_stats)))
+ IOCTL(DRM_IOCTL_I915_GEM_USERPTR, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_userptr))) \ No newline at end of file

linux-user/syscall.c +1 -0
index 644a490..96d285a 100644
@@ -82,6 +82,8 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
 #define tchars host_tchars /* same as target */
 #define ltchars host_ltchars /* same as target */
 +#include <libdrm/drm.h>
+#include <libdrm/i915_drm.h>
 #include <linux/termios.h>
 #include <linux/unistd.h>
 #include <linux/cdrom.h>
linux-user/syscall_defs.h +3 -0
index 6ee9251..275583a 100644
@@ -2604,3 +2604,142 @@ struct target_user_cap_data {
     uint32_t permitted;
     uint32_t inheritable;
 };
+
+/* drm defines */
+#define TARGET_DRM_IOCTL_VERSION                      TARGET_IOWR('d',

0x00, struct drm_version)
+#define TARGET_DRM_IOCTL_GET_UNIQUE TARGET_IOWR('d',
0x01, struct drm_unique)
+#define TARGET_DRM_IOCTL_GET_MAGIC TARGET_IOR('d',
0x02, struct drm_auth)
+#define TARGET_DRM_IOCTL_IRQ_BUSID TARGET_IOWR('d',
0x03, struct drm_irq_busid)
+#define TARGET_DRM_IOCTL_GET_MAP TARGET_IOWR('d',
0x04, struct drm_map)
+#define TARGET_DRM_IOCTL_GET_CLIENT TARGET_IOWR('d',
0x05, struct drm_client)
+#define TARGET_DRM_IOCTL_GET_STATS TARGET_IOR('d',
0x06, struct drm_stats)
+#define TARGET_DRM_IOCTL_SET_VERSION TARGET_IOWR('d',
0x07, struct drm_set_version)
+#define TARGET_DRM_IOCTL_MODESET_CTL TARGET_IOW('d',
0x08, struct drm_modeset_ctl)
+#define TARGET_DRM_IOCTL_GEM_CLOSE TARGET_IOW('d',
0x09, struct drm_gem_close)
+#define TARGET_DRM_IOCTL_GEM_FLINK TARGET_IOWR('d',
0x0a, struct drm_gem_flink)
+#define TARGET_DRM_IOCTL_GEM_OPEN TARGET_IOWR('d',
0x0b, struct drm_gem_open) +#define TARGET_DRM_IOCTL_GET_CAP

          TARGET_IOWR('d', 0x0c, struct drm_get_cap)

+#define TARGET_DRM_IOCTL_SET_CLIENT_CAP TARGET_IOWR('d',
0x0d, struct drm_set_client_cap)
+#define TARGET_DRM_IOCTL_SET_UNIQUE TARGET_IOW('d',
0x10, struct drm_unique)
+#define TARGET_DRM_IOCTL_AUTH_MAGIC
TARGET_IOW('d',0x11, struct drm_auth)
+#define TARGET_DRM_IOCTL_BLOCK TARGET_IOWR('d',
0x12, struct drm_block)
+#define TARGET_DRM_IOCTL_UNBLOCK TARGET_IOWR('d',
0x13, struct drm_block)
+#define TARGET_DRM_IOCTL_CONTROL TARGET_IOW('d',
0x14, struct drm_control)
+#define TARGET_DRM_IOCTL_ADD_MAP TARGET_IOWR('d',
0x15, struct drm_map)
+#define TARGET_DRM_IOCTL_ADD_BUFS TARGET_IOWR('d',
0x16, struct drm_buf_desc)
+#define TARGET_DRM_IOCTL_MARK_BUFS TARGET_IOW('d',
0x17, struct drm_buf_desc)
+#define TARGET_DRM_IOCTL_INFO_BUFS TARGET_IOWR('d',
0x18, struct drm_buf_info)
+#define TARGET_DRM_IOCTL_MAP_BUFS TARGET_IOWR('d',
0x19, struct drm_buf_map)
+#define TARGET_DRM_IOCTL_FREE_BUFS TARGET_IOW('d',
0x1a, struct drm_buf_free)
+#define TARGET_DRM_IOCTL_RM_MAP TARGET_IOW('d',
0x1b, struct drm_map)
+#define TARGET_DRM_IOCTL_SET_SAREA_CTX TARGET_IOW('d',
0x1c, struct drm_ctx_priv_map)
+#define TARGET_DRM_IOCTL_GET_SAREA_CTX TARGET_IOWR('d',
0x1d, struct drm_ctx_priv_map)

+#define TARGET_DRM_IOCTL_SET_MASTER                   TARGET_IO('d', 0x1e)
+#define TARGET_DRM_IOCTL_DROP_MASTER                  TARGET_IO('d', 0x1f)
+#define TARGET_DRM_IOCTL_ADD_CTX                      TARGET_IOWR('d',

0x20, struct drm_ctx)
+#define TARGET_DRM_IOCTL_RM_CTX TARGET_IOWR('d',
0x21, struct drm_ctx)
+#define TARGET_DRM_IOCTL_MOD_CTX TARGET_IOW('d',
0x22, struct drm_ctx)
+#define TARGET_DRM_IOCTL_GET_CTX TARGET_IOWR('d',
0x23, struct drm_ctx)
+#define TARGET_DRM_IOCTL_SWITCH_CTX TARGET_IOW('d',
0x24, struct drm_ctx)
+#define TARGET_DRM_IOCTL_NEW_CTX TARGET_IOW('d',
0x25, struct drm_ctx)
+#define TARGET_DRM_IOCTL_RES_CTX TARGET_IOWR('d',
0x26, struct drm_ctx_res)
+#define TARGET_DRM_IOCTL_ADD_DRAW TARGET_IOWR('d',
0x27, struct drm_draw)
+#define TARGET_DRM_IOCTL_RM_DRAW TARGET_IOWR('d',
0x28, struct drm_draw)
+#define TARGET_DRM_IOCTL_DMA TARGET_IOWR('d',
0x29, struct drm_dma)
+#define TARGET_DRM_IOCTL_LOCK TARGET_IOW('d',
0x2a, struct drm_lock)
+#define TARGET_DRM_IOCTL_UNLOCK TARGET_IOW('d',
0x2b, struct drm_lock)
+#define TARGET_DRM_IOCTL_FINISH TARGET_IOW('d',
0x2c, struct drm_lock)
+#define TARGET_DRM_IOCTL_PRIME_HANDLE_TO_FD TARGET_IOWR('d',
0x2d, struct drm_prime_handle)
+#define TARGET_DRM_IOCTL_PRIME_FD_TO_HANDLE TARGET_IOWR('d',
0x2e, struct drm_prime_handle)
+#define TARGET_DRM_IOCTL_AGP_ACQUIRE TARGET_IO('d',
0x30)
+#define TARGET_DRM_IOCTL_AGP_RELEASE TARGET_IO('d',
0x31)
+#define TARGET_DRM_IOCTL_AGP_ENABLE TARGET_IOW('d',
0x32, struct drm_agp_mode)
+#define TARGET_DRM_IOCTL_AGP_INFO TARGET_IOR('d',
0x33, struct drm_agp_info)
+#define TARGET_DRM_IOCTL_AGP_ALLOC TARGET_IOWR('d',
0x34, struct drm_agp_buffer)
+#define TARGET_DRM_IOCTL_AGP_FREE TARGET_IOW('d',
0x35, struct drm_agp_buffer)
+#define TARGET_DRM_IOCTL_AGP_BIND TARGET_IOW('d',
0x36, struct drm_agp_binding)
+#define TARGET_DRM_IOCTL_AGP_UNBIND TARGET_IOW('d',
0x37, struct drm_agp_binding)
+#define TARGET_DRM_IOCTL_SG_ALLOC TARGET_IOWR('d',
0x38, struct drm_scatter_gather)
+#define TARGET_DRM_IOCTL_SG_FREE TARGET_IOW('d',
0x39, struct drm_scatter_gather)
+#define TARGET_DRM_IOCTL_WAIT_VBLANK TARGET_IOWR('d',
0x3a, union drm_wait_vblank)
+#define TARGET_DRM_IOCTL_UPDATE_DRAW TARGET_IOW('d',
0x3f, struct drm_update_draw)
+#define TARGET_DRM_IOCTL_MODE_GETRESOURCES TARGET_IOWR('d',
0xa0, struct drm_mode_card_res)
+#define TARGET_DRM_IOCTL_MODE_GETCRTC TARGET_IOWR('d',
0xa1, struct drm_mode_crtc)
+#define TARGET_DRM_IOCTL_MODE_SETCRTC TARGET_IOWR('d',
0xa2, struct drm_mode_crtc)
+#define TARGET_DRM_IOCTL_MODE_CURSOR TARGET_IOWR('d',
0xa3, struct drm_mode_cursor)
+#define TARGET_DRM_IOCTL_MODE_GETGAMMA TARGET_IOWR('d',
0xa4, struct drm_mode_crtc_lut)
+#define TARGET_DRM_IOCTL_MODE_SETGAMMA TARGET_IOWR('d',
0xa5, struct drm_mode_crtc_lut)
+#define TARGET_DRM_IOCTL_MODE_GETENCODER TARGET_IOWR('d',
0xa6, struct drm_mode_get_encoder)
+#define TARGET_DRM_IOCTL_MODE_GETCONNECTOR TARGET_IOWR('d',
0xa7, struct drm_mode_get_connector)
+#define TARGET_DRM_IOCTL_MODE_ATTACHMODE TARGET_IOWR('d',
0xa8, struct drm_mode_mode_cmd)
+#define TARGET_DRM_IOCTL_MODE_DETACHMODE TARGET_IOWR('d',
0xa9, struct drm_mode_mode_cmd)
+#define TARGET_DRM_IOCTL_MODE_GETPROPERTY TARGET_IOWR('d',
0xaa, struct drm_mode_get_property)
+#define TARGET_DRM_IOCTL_MODE_SETPROPERTY TARGET_IOWR('d',
0xab, struct drm_mode_connector_set_property)
+#define TARGET_DRM_IOCTL_MODE_GETPROPBLOB TARGET_IOWR('d',
0xac, struct drm_mode_get_blob)
+#define TARGET_DRM_IOCTL_MODE_GETFB TARGET_IOWR('d',
0xad, struct drm_mode_fb_cmd)
+#define TARGET_DRM_IOCTL_MODE_ADDFB TARGET_IOWR('d',
0xae, struct drm_mode_fb_cmd)
+#define TARGET_DRM_IOCTL_MODE_RMFB TARGET_IOWR('d',
0xaf, unsigned int)
+#define TARGET_DRM_IOCTL_MODE_PAGE_FLIP TARGET_IOWR('d',
0xb0, struct drm_mode_crtc_page_flip)
+#define TARGET_DRM_IOCTL_MODE_DIRTYFB TARGET_IOWR('d',
0xb1, struct drm_mode_fb_dirty_cmd)
+#define TARGET_DRM_IOCTL_MODE_CREATE_DUMB TARGET_IOWR('d',
0xb2, struct drm_mode_create_dumb)
+#define TARGET_DRM_IOCTL_MODE_MAP_DUMB TARGET_IOWR('d',
0xb3, struct drm_mode_map_dumb)
+#define TARGET_DRM_IOCTL_MODE_DESTROY_DUMB TARGET_IOWR('d',
0xb4, struct drm_mode_destroy_dumb)
+#define TARGET_DRM_IOCTL_MODE_GETPLANERESOURCES TARGET_IOWR('d',
0xb5, struct drm_mode_get_plane_res)
+#define TARGET_DRM_IOCTL_MODE_GETPLANE TARGET_IOWR('d',
0xb6, struct drm_mode_get_plane)
+#define TARGET_DRM_IOCTL_MODE_SETPLANE TARGET_IOWR('d',
0xb7, struct drm_mode_set_plane)
+#define TARGET_DRM_IOCTL_MODE_ADDFB2 TARGET_IOWR('d',
0xb8, struct drm_mode_fb_cmd2)
+#define TARGET_DRM_IOCTL_MODE_OBJ_GETPROPERTIES TARGET_IOWR('d',
0xb9, struct drm_mode_obj_get_properties)
+#define TARGET_DRM_IOCTL_MODE_OBJ_SETPROPERTY TARGET_IOWR('d',
0xba, struct drm_mode_obj_set_property)
+#define TARGET_DRM_IOCTL_MODE_CURSOR2 TARGET_IOWR('d',
0xbb, struct drm_mode_cursor2)
+
+/* i915 drm defines */
+#define TARGET_DRM_IOCTL_I915_INIT TARGET_IOW('d',
0x40, drm_i915_init_t)

+#define TARGET_DRM_IOCTL_I915_FLUSH                   TARGET_IO('d',  0x41)
+#define TARGET_DRM_IOCTL_I915_FLIP                    TARGET_IO('d',  0x42)
+#define TARGET_DRM_IOCTL_I915_BATCHBUFFER             TARGET_IOW('d',

0x43, drm_i915_batchbuffer_t)
+#define TARGET_DRM_IOCTL_I915_IRQ_EMIT TARGET_IOWR('d',
0x44, drm_i915_irq_emit_t)
+#define TARGET_DRM_IOCTL_I915_IRQ_WAIT TARGET_IOW('d',
0x45, drm_i915_irq_wait_t)
+#define TARGET_DRM_IOCTL_I915_GETPARAM TARGET_IOWR('d',
0x46, drm_i915_getparam_t)
+#define TARGET_DRM_IOCTL_I915_SETPARAM TARGET_IOW('d',
0x47, drm_i915_setparam_t)
+#define TARGET_DRM_IOCTL_I915_ALLOC TARGET_IOWR('d',
0x48, drm_i915_mem_alloc_t)
+#define TARGET_DRM_IOCTL_I915_FREE TARGET_IOW('d',
0x49, drm_i915_mem_free_t)
+#define TARGET_DRM_IOCTL_I915_INIT_HEAP TARGET_IOW('d',
0x4a, drm_i915_mem_init_heap_t)
+#define TARGET_DRM_IOCTL_I915_CMDBUFFER TARGET_IOW('d',
0x4b, drm_i915_cmdbuffer_t)
+#define TARGET_DRM_IOCTL_I915_DESTROY_HEAP TARGET_IOW('d',
0x4c, drm_i915_mem_destroy_heap_t)
+#define TARGET_DRM_IOCTL_I915_SET_VBLANK_PIPE TARGET_IOW('d',
0x4d, drm_i915_vblank_pipe_t)
+#define TARGET_DRM_IOCTL_I915_GET_VBLANK_PIPE TARGET_IOR('d',
0x4e, drm_i915_vblank_pipe_t)
+#define TARGET_DRM_IOCTL_I915_VBLANK_SWAP TARGET_IOWR('d',
0x4f, drm_i915_vblank_swap_t)
+#define TARGET_DRM_IOCTL_I915_HWS_ADDR TARGET_IOW('d',
0x51, struct drm_i915_gem_init)
+#define TARGET_DRM_IOCTL_I915_GEM_INIT TARGET_IOW('d',
0x53, struct drm_i915_gem_init)
+#define TARGET_DRM_IOCTL_I915_GEM_EXECBUFFER TARGET_IOW('d',
0x54, struct drm_i915_gem_execbuffer)
+#define TARGET_DRM_IOCTL_I915_GEM_PIN TARGET_IOWR('d',
0x55, struct drm_i915_gem_pin)
+#define TARGET_DRM_IOCTL_I915_GEM_UNPIN TARGET_IOW('d',
0x56, struct drm_i915_gem_unpin)
+#define TARGET_DRM_IOCTL_I915_GEM_BUSY TARGET_IOWR('d',
0x57, struct drm_i915_gem_busy)

+#define TARGET_DRM_IOCTL_I915_GEM_THROTTLE            TARGET_IO('d',  0x58)
+#define TARGET_DRM_IOCTL_I915_GEM_ENTERVT             TARGET_IO('d', 0x59)
+#define TARGET_DRM_IOCTL_I915_GEM_LEAVEVT             TARGET_IO('d', 0x5a)
+#define TARGET_DRM_IOCTL_I915_GEM_CREATE              TARGET_IOWR('d',

0x5b, struct drm_i915_gem_create)
+#define TARGET_DRM_IOCTL_I915_GEM_PREAD TARGET_IOW('d',
0x5c, struct drm_i915_gem_pread)
+#define TARGET_DRM_IOCTL_I915_GEM_PWRITE TARGET_IOW('d',
0x5d, struct drm_i915_gem_pwrite)
+#define TARGET_DRM_IOCTL_I915_GEM_MMAP TARGET_IOWR('d',
0x5e, struct drm_i915_gem_mmap)
+#define TARGET_DRM_IOCTL_I915_GEM_SET_DOMAIN TARGET_IOW('d',
0x5f, struct drm_i915_gem_set_domain)
+#define TARGET_DRM_IOCTL_I915_GEM_SW_FINISH TARGET_IOW('d',
0x60, struct drm_i915_gem_sw_finish)
+#define TARGET_DRM_IOCTL_I915_GEM_SET_TILING TARGET_IOWR('d',
0x61, struct drm_i915_gem_set_tiling)
+#define TARGET_DRM_IOCTL_I915_GEM_GET_TILING TARGET_IOWR('d',
0x62, struct drm_i915_gem_get_tiling)
+#define TARGET_DRM_IOCTL_I915_GEM_GET_APERTURE TARGET_IOR('d',
0x63, struct drm_i915_gem_get_aperture)
+#define TARGET_DRM_IOCTL_I915_GEM_MMAP_GTT TARGET_IOWR('d',
0x64, struct drm_i915_gem_mmap_gtt)
+#define TARGET_DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID TARGET_IOWR('d',
0x65, struct drm_i915_get_pipe_from_crtc_id)
+#define TARGET_DRM_IOCTL_I915_GEM_MADVISE TARGET_IOWR('d',
0x66, struct drm_i915_gem_madvise)
+#define TARGET_DRM_IOCTL_I915_OVERLAY_PUT_IMAGE TARGET_IOW('d',0x67, struct drm_intel_overlay_put_image)
+#define TARGET_DRM_IOCTL_I915_OVERLAY_ATTRS TARGET_IOWR('d',
0x68, struct drm_intel_overlay_attrs)
+#define TARGET_DRM_IOCTL_I915_GEM_EXECBUFFER2 TARGET_IOW('d',
0x69, struct drm_i915_gem_execbuffer2)
+#define TARGET_DRM_IOCTL_I915_SET_SPRITE_COLORKEY TARGET_IOWR('d',
0x6a, struct drm_intel_sprite_colorkey)
+#define TARGET_DRM_IOCTL_I915_GET_SPRITE_COLORKEY TARGET_IOWR('d',
0x6b, struct drm_intel_sprite_colorkey)
+#define TARGET_DRM_IOCTL_I915_GEM_WAIT TARGET_IOWR('d',
0x6c, struct drm_i915_gem_wait)
+#define TARGET_DRM_IOCTL_I915_GEM_CONTEXT_CREATE TARGET_IOWR('d',
0x6d, struct drm_i915_gem_context_create)
+#define TARGET_DRM_IOCTL_I915_GEM_CONTEXT_DESTROY TARGET_IOW('d',
0x6e, struct drm_i915_gem_context_destroy)
+#define TARGET_DRM_IOCTL_I915_GEM_SET_CACHING TARGET_IOW('d',
0x6f, struct drm_i915_gem_caching)
+#define TARGET_DRM_IOCTL_I915_GEM_GET_CACHING TARGET_IOW('d',
0x70, struct drm_i915_gem_caching)
+#define TARGET_DRM_IOCTL_I915_REG_READ TARGET_IOWR('d',
0x71, struct drm_i915_reg_read)
+#define TARGET_DRM_IOCTL_I915_GET_RESET_STATS TARGET_IOWR('d',
0x72, struct drm_i915_reset_stats)
+#define TARGET_DRM_IOCTL_I915_GEM_USERPTR TARGET_IOWR('d',
0x73, struct drm_i915_gem_userptr)
\ No newline at end of file

linux-user/syscall_types.h +651 -0

655 lines not on this page · raw message

Signature · 1 line
2.1.4
#1 lore raw
Quoted 14 lines · Timothy Pearson

1. It will only work with open drivers as their IOCTLs are documented.
2. i965+ is only supported. That is any haswell, ivybridge, etc. GPU will work.
3. X doesn't start yet, though this patch eliminates all the visible unsupported DRM IOCTL calls as observed by setting QEMU_STRACE=1.
4. Intel open drivers components except for Beignet are architecture independent AFAICT and compile cleanly in foreign architecture environments.
5. The DRM table provided is current as of linux-3.17-rc2, however, compiling it with older kernel headers might require conditional guards that this patch doesn't provide yet.
6. syscalls.c now includes <drm/*.h> files, which should be available in any valid linux-user build environment.

Quoted 4 lines

Using a Debian aarch64 chroot on ubuntu amd64, I have successfully run nexuiz and
compiled and run qemu-system-i386 with SDL emulation (+ patch for forcing OpenGL).

Could you fix up the formatting on this commit message, please? The first line should be a brief summary subject.

You're also missing a signed-off-by line.

Quoted 7 lines
---
 linux-user/ioctls.h        | 137 ++++++++++
 linux-user/syscall.c       |   2 +
 linux-user/syscall_defs.h  | 139 ++++++++++
 linux-user/syscall_types.h | 651
+++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 929 insertions(+)

There's a lot of stuff being added to some of these files, I think they're worth splitting out into subfiles rather than having them get really huge.

Quoted 2 lines

MK_PTR(MK_STRUCT(STRUCT_drm_i915_gem_userptr)))
\ No newline at end of file

Make sure files end with a newline...

linux-user/syscall.c int __clone2(int (*fn)(void *), void *child_stack_base, · line 85

Quoted 9 lines
linux-user/syscall.c +1 -0
index 644a490..96d285a 100644
@@ -82,6 +82,8 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
 #define tchars host_tchars /* same as target */
 #define ltchars host_ltchars /* same as target */
 +#include <libdrm/drm.h>
+#include <libdrm/i915_drm.h>

We can't rely on /usr/include/libdrm being present so we should probably probe for this in configure if we need it.

Quoted 14 lines
linux-user/syscall.c +0 -0
 #include <linux/termios.h>
 #include <linux/unistd.h>
 #include <linux/cdrom.h>
linux-user/syscall_defs.h +3 -0
index 6ee9251..275583a 100644
@@ -2604,3 +2604,142 @@ struct target_user_cap_data {
     uint32_t permitted;
     uint32_t inheritable;
 };
+
+/* drm defines */
+#define TARGET_DRM_IOCTL_VERSION                      TARGET_IOWR('d',
Quoted 1 line

0x00, struct drm_version)

Structs like drm_version will differ in size between architectures (they include pointers or types like "long"), so the target ioctl number calculation needs to use the target's idea of the struct size, not the host's.

thanks
-- PMM