Bug 4127 - cfbtile32.c on Sparc causes memory corruption when used with cfb32
Summary: cfbtile32.c on Sparc causes memory corruption when used with cfb32
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/General (show other bugs)
Version: git
Hardware: SPARC NetBSD
: high normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-17 07:11 UTC by Chris Gilbert
Modified: 2008-07-11 14:39 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Chris Gilbert 2005-08-17 07:11:17 UTC
cfbtile32.c contains the macro expand, which on sparc does some loop unrolling.

When using cfb32, in 32bit mode, PWSH is 0, while PGZB is 4, this causes the
following code:
# define Expand(left,right) {\
    int part = nlwMiddle & ((PGSZB*2)-1); \
    nlwMiddle >>= PWSH + 1; \

To become:
# define Expand(left,right) {\
    int part = nlwMiddle & (7); \
    nlwMiddle >>= 1; \

This causes a problem as the the loop following has unrolled the loop 8 times. 
This causes memory corruption as the loop runs *4 iterations more than it should.

The fix is probably to hardcode the numbers to allow for the 8 unroll
iterations, as the loop has nothing to do with pixels per a word.  However I'm
not sure what effect that would have on a 64bit version of the X server.

The fix is in the NetBSD tree:
http://cvsweb.netbsd.org/bsdweb.cgi/xsrc/xfree/xc/programs/Xserver/cfb/cfbtile32.c.diff?r1=1.1&r2=1.2&f=h

Thanks
Comment 1 Alan Coopersmith 2005-08-17 08:40:58 UTC
I don't know that it matters any more (I think all drivers in the Xorg tree have
now been converted from cfb to fb), but for what it's worth, the Xsun we ship in
Solaris uses 'nlwMiddle >>= 3' there, and has for over a decade.   
(It only supports 32-bit mode though.)

It was actually changed from 3 to PWSH + 1 when Xsun moved from X11R5 to X11R6,
but quickly changed back when it found that caused Netscape to crash Xsun.
Unfortunately it looks like the fix never got propogated back upstream to the
old X Consortium.
Comment 2 Mike A. Harris 2005-11-25 18:40:02 UTC
So...  if the fix is known, how about checking it into CVS?  ;o)
Comment 3 Erik Andren 2006-04-28 03:00:26 UTC
Ping! Any fix in the pipe?
Comment 4 Chris Gilbert 2006-09-21 03:16:22 UTC
Any update on this being checked in/fixed?  It's over a year old and the patch
is available.

Thanks,
Chris

Comment 5 Daniel Stone 2007-02-27 01:27:40 UTC
Sorry about the phenomenal bug spam, guys.  Adding xorg-team@ to the QA contact so bugs don't get lost in future.
Comment 6 Adam Jackson 2008-07-11 14:39:07 UTC
cfb32 unexists now, so I'm happy to call this fixed.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.