Patch: fbcon generic memmove fix

From: Russell King (rmk@arm.linux.org.uk)
Date: Tue Aug 08 2000 - 16:30:58 EST


Linus,

The following patch fixes a problem in the generic fbcon memmove stuff.
It missed copying the first word in the area when src < dst. The
problem causes corruption of characters when the "insert character"
escape sequence is sent to a fbcon console (typically ending up with
half a character lost).

The patch is against test6-pre8.

diff -urN linux-orig/include/video/fbcon.h linux/include/video/fbcon.h
--- linux-orig/include/video/fbcon.h Sat Jul 15 00:10:39 2000
+++ linux/include/video/fbcon.h Fri Aug 4 22:09:56 2000
@@ -681,32 +681,37 @@
         while (count--)
             fb_writeb(fb_readb(src++), dst++);
     } else {
- dst = (unsigned long) d + count - 1;
- src = (unsigned long) s + count - 1;
+ dst = (unsigned long) d + count;
+ src = (unsigned long) s + count;
 
         if ((count < 8) || ((dst ^ src) & 3))
             goto restdown;
 
         if (dst & 1) {
- fb_writeb(fb_readb(src--), dst--);
+ src--;
+ dst--;
             count--;
+ fb_writeb(fb_readb(src), dst);
         }
         if (dst & 2) {
- fb_writew(fb_readw(src), dst);
             src -= 2;
             dst -= 2;
             count -= 2;
+ fb_writew(fb_readw(src), dst);
         }
         while (count > 3) {
- fb_writel(fb_readl(src), dst);
             src -= 4;
             dst -= 4;
             count -= 4;
+ fb_writel(fb_readl(src), dst);
         }
 
     restdown:
- while (count--)
- fb_writeb(fb_readb(src--), dst--);
+ while (count--) {
+ src--;
+ dst--;
+ fb_writeb(fb_readb(src), dst);
+ }
     }
 
     return d;
@@ -744,32 +749,37 @@
         while (count--)
             fb_writeb(fb_readb(src++), dst++);
     } else {
- dst = (unsigned long) d + count - 1;
- src = (unsigned long) s + count - 1;
+ dst = (unsigned long) d + count;
+ src = (unsigned long) s + count;
 
         if ((count < 8) || ((dst ^ src) & 3))
             goto restdown;
 
         if (dst & 1) {
- fb_writeb(fb_readb(src--), dst--);
+ src--;
+ dst--;
             count--;
+ fb_writeb(fb_readb(src), dst);
         }
         if (dst & 2) {
- fb_writew(fb_readw(src), dst);
             src -= 2;
             dst -= 2;
             count -= 2;
+ fb_writew(fb_readw(src), dst);
         }
         while (count > 3) {
- fb_writel(fb_readl(src), dst);
             src -= 4;
             dst -= 4;
             count -= 4;
+ fb_writel(fb_readl(src), dst);
         }
 
     restdown:
- while (count--)
- fb_writeb(fb_readb(src--), dst--);
+ while (count--) {
+ src--;
+ dst--;
+ fb_writeb(fb_readb(src), dst);
+ }
     }
 }
 

   _____
  |_____| ------------------------------------------------- ---+---+-
  | | Russell King rmk@arm.linux.org.uk --- ---
  | | | | http://www.arm.linux.org.uk/personal/aboutme.html / / |
  | +-+-+ --- -+-
  / | THE developer of ARM Linux |+| /|\
 / | | | --- |
    +-+-+ ------------------------------------------------- /\\\ |

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Aug 15 2000 - 21:00:16 EST