AXP egcs-1.1.2 bug ?

Harald Koenig (koenig@tat.physik.uni-tuebingen.de)
Tue, 12 Oct 1999 17:53:37 -0400


sometimes I can't read a 16bit word from memory and only get the 8 LSBs.
it doesn't seem to be a kernel problem since the kernel doesn't show
_any_ unaligned access traps.

the sample program below should show ` 7 908' in line 7 and ` 3 504'
as last line (as you can see if defining `OK'). but using

gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
on
Red Hat Linux release 6.0 (Hedwig)

I get the following output

0 201
1 302
2 403
3 504
4 605
5 706
6 807
7 8
8 a09
9 b0a
10 c0b
11 d0c
12 e0d
13 f0e
14 100f
15 10
16 1211
17 1312
18 1413

3 4

note the lines starting with 7, 15, and 3...

CPU info:
cpu : Alpha
cpu model : EV56
cpu variation : 0
cpu revision : 0
cpu serial number : Linux_is_Great!
system type : EB164
system variation : SX164

repeat by:
-------------------------------------------------------------------------------
struct __una_u16 { unsigned short x __attribute__((packed)); };

static __inline__ unsigned long ldw_u(unsigned short * r11)
{
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 91
const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
return ptr->x;
#else
unsigned long r1,r2;
__asm__("ldq_u %0,%3\n\t"
"ldq_u %1,%4\n\t"
"extwl %0,%2,%0\n\t"
"extwh %1,%2,%1"
:"=&r" (r1), "=&r" (r2)
:"r" (r11),
"m" (*r11),
"m" (*(const unsigned long *)(1+(char *) r11)));
return r1 | r2;
#endif
}

main()
{
unsigned char a[] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
typedef unsigned short u16;
u16 val;
int i;
for(i=0; i<19;i++) {
#ifdef OK
val = ldw_u(a + i);
#else
val = *(u16*)(a + i);
#endif
printf("%2d %4x\n",i,val);
}

#ifdef OK
val = ldw_u(a + 3);
#else
val = *(u16*)(a + 3);
#endif
printf("\n%2d %4x\n",3,val);
}
-------------------------------------------------------------------------------

Harald

--
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^

- 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/