unaligned access sin sys_swapon()

From: Thorsten Kranzkowski (th@Marvin.DL8BCU.ampr.org)
Date: Fri Apr 14 2000 - 20:11:36 EST


Hello!
This is an Alpha AXPpxi33, ev4
gcc 2.96 (egcs-20000410)
kernel 2.3.99-pre5

I get an unaligned access in sys_swapon():

[from /proc/cpuinfo]:
kernel unaligned acc : 10 (pc=fffffc0000346384,va=fffffc0007c8fff6)

[from System.map]:
fffffc0000345bc0 T get_swaparea_info
fffffc0000345e10 T is_swap_partition
fffffc0000345e80 T sys_swapon
fffffc00003468c0 T si_swapinfo
fffffc00003469d0 T swap_duplicate

[gcc invocation]:
gcc -D__KERNEL__ -I/usr/src/linux-2.3.99-pre5-work/include -Wall
-Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strict-aliasing
-pipe -mno-fp-regs -ffixed-8 -mcpu=ev4 -Wa,-mev6
-c -o swapfile.o swapfile.c

[disassembled from swapfile.o]:

    16e8: 1f 04 ff 47 nop
    16ec: 00 00 e0 2f unop
/usr/src/linux-2.3.99-pre5-work/mm/swapfile.c:700
    16f0: fa 1f ef b3 stl zero,8186(fp)
/usr/src/linux-2.3.99-pre5-work/mm/swapfile.c:704
    16f4: 01 00 ff 24 ldah t6,1(zero)
/usr/src/linux-2.3.99-pre5-work/mm/swapfile.c:700
    16f8: fc 1f 2f a0 ldl t0,8188(fp)
/usr/src/linux-2.3.99-pre5-work/mm/swapfile.c:701
    16fc: 11 04 ff 47 clr a1
/usr/src/linux-2.3.99-pre5-work/mm/swapfile.c:704
    1700: 01 00 bf 20 lda t4,1(zero)
/usr/src/linux-2.3.99-pre5-work/mm/swapfile.c:700
    1704: f6 1f ef b3 stl zero,8182(fp) <-------- this is the
                                                             unaligned access
/usr/src/linux-2.3.99-pre5-work/mm/swapfile.c:704
    1708: ff ff e7 20 lda t6,-1(t6)
/usr/src/linux-2.3.99-pre5-work/mm/swapfile.c:700
    170c: 21 76 3e 48 zapnot t0,0xf3,t0
    1710: fc 1f 2f b0 stl t0,8188(fp)
/usr/src/linux-2.3.99-pre5-work/mm/swapfile.c:702
    1714: 20 00 e9 b3 stl zero,32(s0)
/usr/src/linux-2.3.99-pre5-work/mm/swapfile.c:703
    1718: 24 00 e9 b3 stl zero,36(s0)
    171c: 00 00 e0 2f unop

[from swapfile.c]:
698: switch (swap_header_version) {
699: case 1:
700: memset(((char *) swap_header)+PAGE_SIZE-10,0,10);
701: j = 0;
702: p->lowest_bit = 0;
703: p->highest_bit = 0;
704: for (i = 1 ; i < 8*PAGE_SIZE ; i++) {
705: if (test_bit(i,(char *) swap_header)) {

So memset tries to fill the last 10 bytes of a page with '0'. But 2 of the
3 stl insns use an unaligned address!

                                      ...this page... | ...next page...
[0] [1] .... [8176] [8180] [8184] [8188]| [8192]
0123 4567 .... 0123 4567 89ab cdef | 0123
                                                      |
16f0:: WW WW unaligned write
16f8:: RRRR aligned read
1704:: WW WW unaligned write
1710:: ..WW aligned write

>From asm-alpha/string.h it appears thet memset is in fact __builtin_memset
in this case. Is this a gcc problem or did I miss something?

Bye,
Thorsten

-- 
| Thorsten Kranzkowski        Internet: dl8bcu@gmx.net                        |
| Mobile: ++49 170 1876134       Snail: Niemannsweg 30, 49201 Dissen, Germany |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, dl8bcu@marvin.dl8bcu.ampr.org [44.130.8.19] |



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:29 EST