Linux wireless drivers development
 help / color / mirror / Atom feed
From: Masakazu Mokuno <mokuno@sm.sony.co.jp>
To: linux-wireless@vger.kernel.org
Cc: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>,
	geoffrey.levand@am.sony.com
Subject: alignment issue between 32bit userland and 64bit kernel
Date: Mon, 09 Jul 2007 21:00:16 +0900	[thread overview]
Message-ID: <20070709201037.D02C.MOKUNO@sm.sony.co.jp> (raw)

	Hi,

While developing the wireless support for PS3, I'd noticed there were alignment
issues if we issued some wireless ioctl from 32bit userland to 64bit
kernel (ppc64 PS3 does have). 

 - IW_EV_LCP_LEN in 32bit userland and 64bit kernel differ
 - offsetof(struct iw_point, length) differ

The former issue could be fixed if we added 'packed' attribute to
iw_event structure, but it would break existing 64bit userland.  I have
no idea to resolve latter issue because the first member of struct
iw_point is a pointer.

Does anyone have idea to fix these issues?
(except compiling all userland apps in 64bit mode...)

The following is the output from a test code on my PS3.

> # cat test.c
> #include <stdio.h>
> #include <netdb.h>
> #include <linux/wireless.h>
> /* packed version */
> struct iw_event_p {
>   __u16         len;
>   __u16         cmd;
>   union iwreq_data      u;
> } __attribute__((packed));
> 
> int main(void)
> {
>   printf("IW_EV_LCP_LEN=%d offset=%d,%d\n",
>          IW_EV_LCP_LEN,
>          offsetof(struct iw_event, u),
>          offsetof(struct iw_event_p, u));
>   printf("iw_event=%d iw_event_p=%d iwreq_data=%d\n",
>          sizeof(struct iw_event),
>          sizeof(struct iw_event_p),
>          sizeof(union iwreq_data));
> 
>   /* --- */
> 
>   printf("iw_point=%d length=%d flags=%d\n",
>          sizeof(struct iw_point),
>          offsetof(struct iw_point, length),
>          offsetof(struct iw_point, flags));
>   return 0;
> }
> # cc -m64 -o test_64 test.c; cc -o test_32  test.c
> # ./test_64
> IW_EV_LCP_LEN=8 offset=8,4
> iw_event=24 iw_event_p=20 iwreq_data=16
> iw_point=16 length=8 flags=10
> # ./test_32
> IW_EV_LCP_LEN=4 offset=4,4
> iw_event=20 iw_event_p=20 iwreq_data=16
> iw_point=8 length=4 flags=6
> # 

regards

--
Masakazu MOKUNO


             reply	other threads:[~2007-07-09 12:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-09 12:00 Masakazu Mokuno [this message]
2007-07-09 12:03 ` alignment issue between 32bit userland and 64bit kernel Johannes Berg
2007-07-09 16:46   ` Jean Tourrilhes
2007-07-10  7:13     ` Masakazu Mokuno

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=20070709201037.D02C.MOKUNO@sm.sony.co.jp \
    --to=mokuno@sm.sony.co.jp \
    --cc=Geert.Uytterhoeven@sonycom.com \
    --cc=geoffrey.levand@am.sony.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox