Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

32bit DRM ioctls don't work on amd64 #166

Closed
jbeich opened this issue Aug 11, 2017 · 3 comments
Closed

32bit DRM ioctls don't work on amd64 #166

jbeich opened this issue Aug 11, 2017 · 3 comments

Comments

@jbeich
Copy link

jbeich commented Aug 11, 2017

32bit OpenGL/OpenCL apps (e.g., Wine) either crash, don't work or are very slow because device-specific DRI driver fails on DRM ioctls. Here's an example from Skylake GT2:

$ nm /boot/kernel/i915kms.ko | fgrep compat_ioctl
$ sysctl kern.conftxt | fgrep COMPAT_
options COMPAT_FREEBSD11
options COMPAT_FREEBSD10
options COMPAT_FREEBSD32

$ ABI=FreeBSD:12:i386 pkg install mesa-dri mesa-demos
$ LIBGL_DEBUG=verbose MESA_DEBUG=context glxgears
libGL: OpenDriver: trying /usr/local/lib/dri/i965_dri.so
Mesa warning: drm_i915_getparam: -14
i965_dri.so does not support the 0xffffffff PCI ID.
libGL error: failed to create dri screen
libGL error: failed to load driver: i965
libGL: OpenDriver: trying /usr/local/lib/dri/swrast_dri.so
libGL: Can't open configuration file /home/foo/.drirc: No such file or directory.
libGL: Can't open configuration file /home/foo/.drirc: No such file or directory.
602 frames in 5.0 seconds = 120.249 FPS
^C

drivers/gpu/drm/drm_os_config.h doesn't include opt_compat.h, otherwise build would fail like the following:

sys/dev/drm/i915/i915_drv.c:2576:3: error: field designator 'compat_ioctl' does not refer to any field in type 'const struct file_operations'
        .compat_ioctl = i915_compat_ioctl,
         ^
1 error generated.

which can be fixed by moving compat_ioctl out of #if 0 in sys/compat/linuxkpi/common/include/linux/fs.h except linuxkpi never calls .compat_ioctl.

@jbeich jbeich changed the title 32bit OpenGL isn't accelerated on amd64 32bit DRM ioctls don't work on amd64 Aug 11, 2017
@hselasky
Copy link

I think some defines are missing in the compilation process to turn on 32-bit support.

@valpackett
Copy link

valpackett commented Sep 21, 2017

linuxkpi never calls .compat_ioctl

This is fixable, just submitted 222504.

The harder problem is the usage of compat_alloc_user_space in *_ioc32.c files. I've tried to implement that function (which got a CVE back in the day, BTW :D) but failed. Well, that function "worked", the copyin/copyout (__put_user, __get_user) stuff didn't. I guess redefining compat_alloc_user_space as a normal allocation and __put_user/__get_user as normal copies could work… but I can't think of a way to insert the frees just by defining macros.

So I'm working on a terrible patch that replaces that allocation with just having the struct on the stack, just like this 2014 patch.

Already managed to run some GL applications on Wine :) Also Steam on Linuxulator now shows the login UI (but doesn't communicate with the network, net.cpp (1913) : Assertion Failed: Unable to set default socket options, error 22) instead of, well, not showing it.

@valpackett
Copy link

valpackett commented Sep 21, 2017

Also, the current version in linux doesn't use compat_alloc_user_space anymore, it's actually kinda more similar to what I'm doing, but it has new weirdness: compat_ptr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants