Subject: Ariadne panics: potential bugfix enclosed
To: None <port-amiga@NetBSD.ORG>
From: Ignatios Souvatzis <ignatios@theory.cs.uni-bonn.de>
List: port-amiga
Date: 03/09/1998 18:18:13
Hello,

if you're a victim of the Ariadne + 1.3 panic, please:

- apply the enclosed patch to /sys/arch/amiga/dev/if_le.c
- recompile your kernel
- test
- report if it works

Regards,
	-is


--- if_le.c-1.27	Sat Oct  4 14:03:05 1997
+++ if_le.c	Sat Mar  7 22:06:28 1998
@@ -463,20 +463,26 @@
 	int i;
 
 	if (len > 0 && isodd(boff)) {
+		/* adjust source pointer */
 		b1 = (u_short *)(a1 + 1);
+		/* compute aligned destination pointer */
 		b2 = (u_short *)(a2 + 1);
-		b2[-1] = (b2[-1] & 0xff00) | (b1[-1] & 0x00ff);
+		/* copy first unaligned byte to buf */
+		b2[-1] = (b2[-1] & 0xff00) | *a1;
 		--len;
 	} else {
+		/* destination is aligned or length is zero */
 		b1 = (u_short *)a1;
 		b2 = (u_short *)a2;
 	}
 
+	/* copy full words with aligned destination */
 	for (i = len >> 1; i > 0; i--)
 		*b2++ = *b1++;
 
+	/* copy remaining byte */
 	if (isodd(len))
-		*b2 = (*b2 & 0x00ff) | (*b1 & 0xff00);
+		*b2 = (*b2 & 0x00ff) | (*(u_char *)b1) << 8;
 }
 
 integrate void
@@ -492,20 +498,26 @@
 	int i;
 
 	if (len > 0 && isodd(boff)) {
-		b1 = (u_short *)(a1 + 1);
-		b2 = (u_short *)(a2 + 1);
-		b2[-1] = (b2[-1] & 0xff00) | (b1[-1] & 0x00ff);
+		/* compute aligned source pointer */
+		b1  = (u_short *)(a1 + 1);
+		/* adjust destination pointer (possibly unaligned) */
+		b2  = (u_short *)(a2 + 1);
+		/* copy first unaligned byte from buf */
+		*a2 = b1[-1];
 		--len;
 	} else {
+		/* source is aligned or length is zero */
 		b1 = (u_short *)a1;
 		b2 = (u_short *)a2;
 	}
 
+	/* copy full words with aligned source */
 	for (i = len >> 1; i > 0; i--)
 		*b2++ = *b1++;
 
+	/* copy remaining byte */
 	if (isodd(len))
-		*b2 = (*b2 & 0x00ff) | (*b1 & 0xff00);
+		*(u_char *)b2 = *b1 >> 8;
 }
 
 integrate void