All of lore.kernel.org
 help / color / mirror / Atom feed
From: matthieu castet <castet.matthieu@free.fr>
To: linux-wireless@vger.kernel.org
Subject: b43 : unaligned access on mips
Date: Mon, 01 Jun 2009 23:54:33 +0200	[thread overview]
Message-ID: <4A244E19.7090501@free.fr> (raw)

Hi,

b43_generate_plcp_hdr generate unaligned access on mips with gcc [1] 
from openwrt.

A small testcase [2] show that &plcp->data is access as a 32 bit aligned 
variable (see the "lw      $2,0($4)" and "sw      $2,0($4)").
I don't know enough mips to know if it is a gcc bug (ignoring the packed 
attribute) or something missing in b43 code.


Matthieu



[1]
mipsel-openwrt-linux-uclibc-gcc -v
Using built-in specs.
Target: mipsel-openwrt-linux-uclibc
Configured with: 
/mnt/data/routeur/trunk/build_dir/toolchain-mipsel_gcc-4.1.2_uClibc-0.9.29/gcc-4.1.2/configure 
--prefix=/mnt/data/routeur/trunk/staging_dir/toolchain-mipsel_gcc-4.1.2_uClibc-0.9.29/usr 
--build=i486-linux-gnu --host=i486-linux-gnu 
--target=mipsel-openwrt-linux-uclibc --with-gnu-ld 
--enable-target-optspace --disable-libgomp --disable-libmudflap 
--disable-multilib --disable-nls --disable-libssp --disable-__cxa_atexit 
--enable-languages=c,c++ --enable-shared --enable-threads 
--with-slibdir=/mnt/data/routeur/trunk/staging_dir/toolchain-mipsel_gcc-4.1.2_uClibc-0.9.29/lib
Thread model: posix
gcc version 4.1.2

[2]
$cat test.c
#define __le32 unsigned int
#define u32 unsigned int
#define __u8 unsigned char
#define u8 unsigned char
#define u16 unsigned short
#define cpu_to_le32(x) (x)

#define _b43_declare_plcp_hdr(size) \
         struct b43_plcp_hdr##size {             \
                 union {                         \
                         __le32 data;            \
                         __u8 raw[size];         \
                 } __attribute__((__packed__));  \
         } __attribute__((__packed__))

/* struct b43_plcp_hdr4 */
_b43_declare_plcp_hdr(4);

void b43_generate_plcp_hdr(struct b43_plcp_hdr4 *plcp,
                                const u16 octets, const u8 bitrate)
{
                 u32 plen;
             __le32 *data = &(plcp->data);
                 plen = octets * 16 / bitrate;
                 *data |= cpu_to_le32(plen << 16);
}

$mipsel-openwrt-linux-uclibc-gcc test.c -Os -S
$cat test.s
         .file   1 "test.c"
         .section .mdebug.abi32
         .previous
         .abicalls
         .text
         .align  2
         .globl  b43_generate_plcp_hdr
         .ent    b43_generate_plcp_hdr
         .type   b43_generate_plcp_hdr, @function
b43_generate_plcp_hdr:
         .frame  $sp,0,$31               # vars= 0, regs= 0/0, args= 0, 
gp= 0
         .mask   0x00000000,0
         .fmask  0x00000000,0
         .set    noreorder
         .set    nomacro

         andi    $5,$5,0xffff
         sll     $5,$5,4
         andi    $6,$6,0x00ff
         bne     $6,$0,1f
         div     $0,$5,$6
         break   7
1:
         lw      $2,0($4)
         mflo    $5
         sll     $5,$5,16
         or      $2,$2,$5
         j       $31
         sw      $2,0($4)

         .set    macro
         .set    reorder
         .end    b43_generate_plcp_hdr
         .ident  "GCC: (GNU) 4.1.2"

             reply	other threads:[~2009-06-01 21:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-01 21:54 matthieu castet [this message]
2009-06-01 22:00 ` b43 : unaligned access on mips matthieu castet
2009-06-02  7:46   ` Johannes Berg
2009-06-02 15:20   ` Michael Buesch
2009-06-02 18:17     ` matthieu castet
2009-06-02 18:27       ` Michael Buesch
2009-06-04 19:51         ` matthieu castet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A244E19.7090501@free.fr \
    --to=castet.matthieu@free.fr \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.