mesa/src/drm-shim
Alyssa Rosenzweig 38f39cc1e2 drm-shim: Support kernels with >4k pages
mmap requires its offset is page aligned, but the current code only
guarantees 4k alignment, causing drm-shim to break badly on kernels with
>4k page sizes. This fixes drm-shim on my Apple M1, running bare metal
Linux with 16k pages. It probably also fixes exotic PowerPC systems with
64k pages.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Zoltan Boszormenyi <zboszor@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12347>
2021-08-13 23:33:52 +00:00
..
README.md
device.c drm-shim: Support kernels with >4k pages 2021-08-13 23:33:52 +00:00
drm_shim.c drm-shim: implement stat/fstat when xstat variants are not there 2021-08-02 00:19:26 +00:00
drm_shim.h
meson.build

README.md

DRM shim - Fake GEM kernel drivers in userspace for CI

On CI systems where we don't control the kernel, it would be nice to be able to present either no-op GEM devices (for shader-db runs) or simulator-backed GEM devices (for testing against a software simulator or FPGA). This lets us do that by intercepting libc calls and exposing render nodes.

Limitations

  • Doesn't know how to handle DRM fds getting passed over the wire from X11 (Could we use kmsro to support the X11 case?).
  • libc interception is rather glibc-specific and fragile.
  • Can easily break gdb if the libc interceptor code is what's broken. (ulimit -c unlimited and doing gdb on the core after the fact can help)

Using

You choose the backend by setting LD_PRELOAD to the shim you want. Since this will effectively fake another DRM device to your system, you may need some work on your userspace to get your test application to use it if it's not the only DRM device present. Setting DRM_SHIM_DEBUG=1 in the environment will print out what path the shim initialized on.

For piglit tests, you can set:

PIGLIT_PLATFORM=gbm
WAFFLE_GBM_DEVICE=<path from DRM_SHIM_DEBUG>

See your drm-shim backend's README for details on how to use it.