Subject: Re: struct netbsd32_statvfs and packed attribute
To: None <firstname.lastname@example.org>
From: Christos Zoulas <email@example.com>
Date: 09/08/2007 17:20:49
In article <20070908132230.GK12249@snowdrop.l8s.co.uk>,
David Laight <firstname.lastname@example.org> wrote:
>On Fri, Sep 07, 2007 at 04:36:21PM -0700, Markus Mayer wrote:
>> I just noticed an issue with netbsd32_statvfs and the getvfsstat()
>> syscall. This is for a MIPS platform with 64 bit kernel and (some) 32
>> bit userland applications. However, I am assuming it'll affect other
>> platforms, as well.
>> I traced the problem to the attribute "packed" that is specified for
>> struct netbsd32_statvfs. netbsd32_statvfs is 2228 bytes in the kernel.
>> However, struct statvfs, which is not packed, is 2232 bytes in 32 bit
>IIRC the 'problem' is that struct statvfs has a 64bit integer that
>isn't (by default) aligned on an 8 byte boundary.
>On i386 (I'm not sure about sparc) 64bit types only have 4 byte alignment,
>so an amd64 kernel (where they have 8 byte alignment) incorrectly
>maps the statvfs structure.
>Adding 'base' types netbsd32_int64 and netbsd32_uint64 (which have 4byte
>alignemnt when needed) may be necessary. Packing the whole structure
>gives a massive performance penalty on cpus that can't do misaligned
Or version the struct and make new syscalls.