Skip to contentSkip to conversation

2.6.20 unaligned accesses

DISCUSSION Andrew Walrond 3 participants 6 messages Feb 23, 2007 – Feb 26, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

On a Sun T1000 running 2.6.20 I'm seeing lots of these:

Kernel unaligned access at TPC[63d47c] Kernel unaligned access at TPC[63d47c] Kernel unaligned access at TPC[63d47c] aoenet_rcv+0xa4/0x190

aoenet_rcv+0xa4/0x190
aoenet_rcv+0xa4/0x190

Kernel unaligned access at TPC[63d47c] Kernel unaligned access at TPC[63d47c] Kernel unaligned access at TPC[63d47c] aoenet_rcv+0xa4/0x190 aoenet_rcv+0xa4/0x190

Google found similar reports and fixes by David Miller (cc'ed), suggesting that more agressive structure packing by gcc 4.1.1 was exposing buggy code, so perhaps this is a similar case? (I am also using gcc-4.1.1)

Is this just an 'unaligned accesses are slower' issue, or simething more serious?

Let me know if I can do anything to further diagnose or test.

Andrew Walrond

#1 lore raw
Quoted 10 lines · Andrew Walrond

On a Sun T1000 running 2.6.20 I'm seeing lots of these:

Kernel unaligned access at TPC[63d47c] Kernel unaligned access at TPC[63d47c] Kernel unaligned access at TPC[63d47c] aoenet_rcv+0xa4/0x190

aoenet_rcv+0xa4/0x190
aoenet_rcv+0xa4/0x190

Kernel unaligned access at TPC[63d47c] Kernel unaligned access at TPC[63d47c] Kernel unaligned access at TPC[63d47c] aoenet_rcv+0xa4/0x190 aoenet_rcv+0xa4/0x190

I have discovered that these only appear when running a kernel with

CONFIG_CC_OPTIMIZE_FOR_SIZE=y

Nevertheless, I guess it needs fixing.

Andrew Walrond

#2 lore raw
In reply to Andrew Walrond

From: Andrew Walrond <[email protected]>
Date: Mon, 26 Feb 2007 10:12:32 +0000

Quoted 5 lines

I have discovered that these only appear when running a kernel with

CONFIG_CC_OPTIMIZE_FOR_SIZE=y

Nevertheless, I guess it needs fixing.

Let me know if this fixes the bug for you:

drivers/block/aoe/aoecmd.c +6 -6
index bb022ed..8d17d8d 100644
@@ -530,7 +530,7 @@ aoecmd_ata_rsp(struct sk_buff *skb)
 	u16 aoemajor;
 
 	hin = (struct aoe_hdr *) skb->mac.raw;
-	aoemajor = be16_to_cpu(hin->major);
+	aoemajor = be16_to_cpu(get_unaligned(&hin->major));
 	d = aoedev_by_aoeaddr(aoemajor, hin->minor);
 	if (d = NULL) {
 		snprintf(ebuf, sizeof ebuf, "aoecmd_ata_rsp: ata response "
@@ -542,7 +542,7 @@ aoecmd_ata_rsp(struct sk_buff *skb)
 
 	spin_lock_irqsave(&d->lock, flags);
 
-	n = be32_to_cpu(hin->tag);
+	n = be32_to_cpu(get_unaligned(&hin->tag));
 	f = getframe(d, n);
 	if (f = NULL) {
 		calc_rttavg(d, -tsince(n));
@@ -550,9 +550,9 @@ aoecmd_ata_rsp(struct sk_buff *skb)
 		snprintf(ebuf, sizeof ebuf,
 			"%15s e%d.%d    tag=%08x@%08lx\n",
 			"unexpected rsp",
-			be16_to_cpu(hin->major),
+			be16_to_cpu(get_unaligned(&hin->major)),
 			hin->minor,
-			be32_to_cpu(hin->tag),
+			be32_to_cpu(get_unaligned(&hin->tag)),
 			jiffies);
 		aoechr_error(ebuf);
 		return;
@@ -631,7 +631,7 @@ aoecmd_ata_rsp(struct sk_buff *skb)
 			printk(KERN_INFO
 				"aoe: unrecognized ata command %2.2Xh for %d.%d\n",
 				ahout->cmdstat,
-				be16_to_cpu(hin->major),
+				be16_to_cpu(get_unaligned(&hin->major)),
 				hin->minor);
 		}
 	}
@@ -733,7 +733,7 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
 	 * Enough people have their dip switches set backwards to
 	 * warrant a loud message for this special case.
 	 */
-	aoemajor = be16_to_cpu(h->major);
+	aoemajor = be16_to_cpu(get_unaligned(&h->major));
 	if (aoemajor = 0xfff) {
 		printk(KERN_ERR "aoe: Warning: shelf address is all ones.  "
 			"Check shelf dip switches.\n");
drivers/block/aoe/aoenet.c +3 -2
index 9626e0f..5b85c0a 100644
@@ -8,6 +8,7 @@
 #include <linux/blkdev.h>
 #include <linux/netdevice.h>
 #include <linux/moduleparam.h>
+#include <asm/unaligned.h>
 #include "aoe.h"
 
 #define NECODES 5
@@ -123,7 +124,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
 	skb_push(skb, ETH_HLEN);	/* (1) */
 
 	h = (struct aoe_hdr *) skb->mac.raw;
-	n = be32_to_cpu(h->tag);
+	n = be32_to_cpu(get_unaligned(&h->tag));
 	if ((h->verfl & AOEFL_RSP) = 0 || (n & 1<<31))
 		goto exit;
 
@@ -133,7 +134,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
 			n = 0;
 		if (net_ratelimit())
 			printk(KERN_ERR "aoe: error packet from %d.%d; ecode=%d '%s'\n",
-			       be16_to_cpu(h->major), h->minor, 
+			       be16_to_cpu(get_unaligned(&h->major)), h->minor, 
 			       h->err, aoe_errlist[n]);
 		goto exit;
 	}
#3 lore raw
In reply to Andrew Walrond

Hello,

Quoted 4 lines · Andrew Walrond

On a Sun T1000 running 2.6.20 I'm seeing lots of these:

Kernel unaligned access at TPC[63d47c] Kernel unaligned access at TPC[63d47c] Kernel unaligned access at TPC[63d47c] aoenet_rcv+0xa4/0x190

[...]

On a Sun Blade 2000 I got this one every time I load eth1394:
Kernel unaligned access at TPC[101880c8] ether1394_reset_priv+0x2c/0xb8 [eth1394]

I got rid of the message with the following patch:

ieee1394/eth1394.c 2007-02-26 23:58:57.000000000 +0100 renamed from ieee1394/eth1394.c.old 2007-02-26 23:07:21.000000000 +0100 +2 -1
@@ -65,6 +65,7 @@
 #include <asm/uaccess.h>
 #include <asm/delay.h>
 #include <asm/semaphore.h>
+#include <asm/unaligned.h>
 #include <net/arp.h>
 
 #include "csr1212.h"
@@ -491,7 +492,7 @@
        int i;
        struct eth1394_priv *priv = netdev_priv(dev);
        struct hpsb_host *host = priv->host;
-       u64 guid = *((u64*)&(host->csr.rom->bus_info_data[3]));
+       u64 guid = get_unaligned(&(host->csr.rom->bus_info_data[3]));
        u16 maxpayload = 1 << (host->csr.max_rec + 1);
        int max_speed = IEEE1394_SPEED_MAX;
 

ciao,
ema

#4 lore raw
In reply to Andrew Walrond

From: Emanuele Rocca <[email protected]>
Date: Tue, 27 Feb 2007 00:14:49 +0100

Quoted 5 lines

Hello,

Quoted 2 lines · Andrew Walrond

On a Sun T1000 running 2.6.20 I'm seeing lots of these:

Quoted 8 lines
Quoted 2 lines

Kernel unaligned access at TPC[63d47c] Kernel unaligned access at TPC[63d47c] Kernel unaligned access at TPC[63d47c] aoenet_rcv+0xa4/0x190

[...]

On a Sun Blade 2000 I got this one every time I load eth1394:
Kernel unaligned access at TPC[101880c8] ether1394_reset_priv+0x2c/0xb8 [eth1394]

I got rid of the message with the following patch:

That is a different bug, and the current 2.6.x tree already has that fix applied so you shouldn't need to apply that patch to the vanilla tree.

#5 lore raw
In reply to Andrew Walrond
Quoted 10 lines · David Miller

From: Emanuele Rocca <[email protected]>

Quoted 4 lines

On a Sun Blade 2000 I got this one every time I load eth1394:
Kernel unaligned access at TPC[101880c8] ether1394_reset_priv+0x2c/0xb8 [eth1394]

I got rid of the message with the following patch:

That is a different bug, and the current 2.6.x tree already has that fix applied so you shouldn't need to apply that patch to the vanilla tree.

Ah, nice. linux-source 2.6.18.dfsg.1-11 (Debian unstable) is affected by the bug, so maybe we could add the patch?

Thanks.
ciao,
ema