aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2018-12-18 21:32:37 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-12-19 12:19:17 +0100
commit020ef045e0df09bc2f664d8d6e4b6600da53b41a (patch)
treee52dd5930d8c931123062d83012102cdfad86e0d /nx-X11/programs/Xserver
parent8d6a4a9b7bfabcf949ec80f552bd1f0707bf8c63 (diff)
downloadnx-libs-020ef045e0df09bc2f664d8d6e4b6600da53b41a.tar.gz
nx-libs-020ef045e0df09bc2f664d8d6e4b6600da53b41a.tar.bz2
nx-libs-020ef045e0df09bc2f664d8d6e4b6600da53b41a.zip
fb: Fix memcpy abuse
Fixes ArcticaProject/nx-libs#750 Backport of this commit: commit e32cc0b4c85c78cd8743a6e1680dcc79054b57ce Author: Adam Jackson <ajax@redhat.com> Date: Thu Apr 21 16:37:11 2011 -0400 fb: Fix memcpy abuse The memcpy fast path implicitly assumes that the copy walks left-to-right. That's not something memcpy guarantees, and newer glibc on some processors will indeed break that assumption. Since we walk a line at a time, check the source and destination against the width of the blit to determine whether we can be sloppy enough to allow memcpy. (Having done this, we can remove the check for !reverse as well.) On an Intel Core i7-2630QM with an NVIDIA GeForce GTX 460M running in NoAccel, the broken code and various fixes for -copywinwin{10,100,500} gives (edited to fit in 80 columns): 1: Disable the fastpath entirely 2: Replace memcpy with memmove 3: This fix 4: The code before this fix 1 2 3 4 Operation ------ --------------- --------------- --------------- ------------ 258000 269000 ( 1.04) 544000 ( 2.11) 552000 ( 2.14) Copy 10x10 21300 23000 ( 1.08) 43700 ( 2.05) 47100 ( 2.21) Copy 100x100 960 962 ( 1.00) 1990 ( 2.09) 1990 ( 2.07) Copy 500x500 So it's a modest performance hit, but correctness demands it, and it's probably worth keeping the 2x speedup from having the fast path in the first place. Signed-off-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'nx-X11/programs/Xserver')
-rw-r--r--nx-X11/programs/Xserver/fb/fbblt.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/nx-X11/programs/Xserver/fb/fbblt.c b/nx-X11/programs/Xserver/fb/fbblt.c
index e820a85eb..acec23bf2 100644
--- a/nx-X11/programs/Xserver/fb/fbblt.c
+++ b/nx-X11/programs/Xserver/fb/fbblt.c
@@ -67,6 +67,7 @@ fbBlt (FbBits *srcLine,
int n, nmiddle;
Bool destInvarient;
int startbyte, endbyte;
+ int careful;
FbDeclareMergeRop ();
#ifdef FB_24BIT
@@ -78,7 +79,11 @@ fbBlt (FbBits *srcLine,
}
#endif
- if (alu == GXcopy && pm == FB_ALLONES && !reverse &&
+ careful = !((srcLine < dstLine && srcLine + width * (bpp>>3) > dstLine) ||
+ (dstLine < srcLine && dstLine + width * (bpp>>3) > srcLine)) ||
+ (bpp & 7);
+
+ if (alu == GXcopy && pm == FB_ALLONES && !careful &&
!(srcX & 7) && !(dstX & 7) && !(width & 7)) {
int i;
CARD8 *src = (CARD8 *) srcLine;