i915 driver fails on i686 userspace + x86_64 kernel
Pavel Roskin
proski at gnu.org
Wed Oct 16 02:08:57 CEST 2013
On Wed, 16 Oct 2013 00:39:34 +0100
Chris Wilson <chris at chris-wilson.co.uk> wrote:
> > However, I feel uneasy about that patch. I tried to debug the
> > problem, and it looked not as a data corruption, but as something
> > opposite. The kernel writes correct data to the userspace, but the
> > userspace gets the old value.
I added code to print addresses of structures and found that when X
fails, enc starts exactly at the address where conn ends. So it's not
like enc is too close to the stack pointer.
But for a 64-bit compiler that compiled the kernel, conn ends 4 bytes
later because it's 8-byte aligned. So enc.encoder_id sits in the same
place as the unused bytes of conn. That's risky. The compiler can
assume that conn is only changed by accessing its elements and not by
accessing any other structure or variable.
I see that the kernel is compiled with -fno-strict-aliasing, so it must
be something other that aliasing. Also, the kernel code doesn't know
where it would write the encoders, so I don't see how the compiler
could optimize it out. It must be some runtime optimization.
Even though I don't understand the mechanism, your patch doesn't seem
wrong anymore. Maybe it could be simplified by using the aligned
attribute or by other means. On the positive side, it's a change
entirely in userspace.
> For other structures we have taken great care to make sure that
> they are padded to 64-bit boundaries for exactly this abi
> incompatibility for 32-bit userspaces. To be strict we should do an
> ioc32 wrapper in the kernel.
I see. After all, the kernel fails to write the encoders at the
requested address, so perhaps it could be improved as well.
Thank you for the fix!
--
Regards,
Pavel Roskin
More information about the dri-devel
mailing list