Re: compat_netbsd32 swapctl

2014-01-30 Thread Martin Husemann
On Thu, Jan 30, 2014 at 03:43:31PM +1100, matthew green wrote: ... which is basically what dsl was suggesting, but with more useful details. Yes, David is right, it is all already there: just use netbsd32_dev_t for the definition of netbsd32_swapent. This uses NETBSD32_INT64_ALIGN, which on

compat_netbsd32 swapctl

2014-01-29 Thread Emmanuel Dreyfus
Hi swapctl() netbsd32 emulation breaks for SWAP_STATS if there are multiple swaps to report. The reason is that compiler padding is different on i386 and amd64: struct swapent is 1049 bytes long, and it gets padded to 1052 on i386 (4 bytes alignement) and 1056 on amd64 (8 bytes alignement) The

Re: compat_netbsd32 swapctl

2014-01-29 Thread Martin Husemann
On Wed, Jan 29, 2014 at 10:42:14AM +, Emmanuel Dreyfus wrote: The solution is for netbsd32_swapctl() to call sys_swapctl() for each individual record, but it needs to know the i386 size for struct swapent. I suspect there is a macro for that. Someone knows? Tricky. You could define

Re: compat_netbsd32 swapctl

2014-01-29 Thread Martin Husemann
On Wed, Jan 29, 2014 at 11:54:29AM +0100, Martin Husemann wrote: You could define swapent32 with se_dev split into two 32bit halves and do full conversion back and forth, but better check what alignment mips and sparc would require here first. I verified i386 uses 4 byte, sparc uses 8 byte. I

Re: compat_netbsd32 swapctl

2014-01-29 Thread Martin Husemann
On Wed, Jan 29, 2014 at 12:06:39PM +0100, Martin Husemann wrote: On Wed, Jan 29, 2014 at 11:54:29AM +0100, Martin Husemann wrote: You could define swapent32 with se_dev split into two 32bit halves and do full conversion back and forth, but better check what alignment mips and sparc would

Re: compat_netbsd32 swapctl

2014-01-29 Thread Emmanuel Dreyfus
Martin Husemann mar...@duskware.de wrote: So: please fix it only for amd64/i386, it aint broken for the others. There is no way to discover the alignment used from within the code? I can only define a magic number? -- Emmanuel Dreyfus http://hcpnet.free.fr/pubz m...@netbsd.org

Re: compat_netbsd32 swapctl

2014-01-29 Thread Martin Husemann
On Wed, Jan 29, 2014 at 01:40:42PM +0100, Emmanuel Dreyfus wrote: There is no way to discover the alignment used from within the code? I can only define a magic number? You can find out how much the current compiler (amd64) aligns, but I don't know of a way to find that out about the 32bit

Re: compat_netbsd32 swapctl

2014-01-29 Thread Emmanuel Dreyfus
On Wed, Jan 29, 2014 at 01:48:35PM +0100, Martin Husemann wrote: My vote for this special case: hard code it #ifdef __x86_64__. If we run into other instances, we can add a define (like: DEV_T_ALIGN_32). Here is a patch that fixes the problem. Index: sys/compat/netbsd32/netbsd32_netbsd.c

Re: compat_netbsd32 swapctl

2014-01-29 Thread David Holland
On Wed, Jan 29, 2014 at 03:37:13PM +, Emmanuel Dreyfus wrote: +panic(unexpected cmd = %d, SCARG(ua, cmd)); panic on garbage from userland really isn't the ticket. -- David A. Holland dholl...@netbsd.org

Re: compat_netbsd32 swapctl

2014-01-29 Thread David Holland
On Wed, Jan 29, 2014 at 05:45:51PM +, David Holland wrote: On Wed, Jan 29, 2014 at 03:37:13PM +, Emmanuel Dreyfus wrote: + panic(unexpected cmd = %d, SCARG(ua, cmd)); panic on garbage from userland really isn't the ticket. ok, so that is actually checked

Re: compat_netbsd32 swapctl

2014-01-29 Thread David Laight
On Wed, Jan 29, 2014 at 11:54:29AM +0100, Martin Husemann wrote: On Wed, Jan 29, 2014 at 10:42:14AM +, Emmanuel Dreyfus wrote: The solution is for netbsd32_swapctl() to call sys_swapctl() for each individual record, but it needs to know the i386 size for struct swapent. I suspect there

Re: compat_netbsd32 swapctl

2014-01-29 Thread David Holland
On Wed, Jan 29, 2014 at 06:26:14PM +, David Laight wrote: There is a 64bit integer type that has an alignment requirement of 8. If that is used instead of a normal 64bit type then the structure alignement under amd64 matches that of i386. Also, if nothing else, the structure should be

Re: compat_netbsd32 swapctl

2014-01-29 Thread Paul_Koning
On Wed, Jan 29, 2014 at 06:26:14PM +, David Laight wrote: There is a 64bit integer type that has an alignment requirement of 8. If that is used instead of a normal 64bit type then the structure alignement under amd64 matches that of i386. The easiest way to get such alignment is to ask for

Re: compat_netbsd32 swapctl

2014-01-29 Thread David Laight
On Wed, Jan 29, 2014 at 06:38:06PM +, paul_kon...@dell.com wrote: On Wed, Jan 29, 2014 at 06:26:14PM +, David Laight wrote: There is a 64bit integer type that has an alignment requirement of 8. If that is used instead of a normal 64bit type then the structure alignement under amd64

Re: compat_netbsd32 swapctl

2014-01-29 Thread Christos Zoulas
In article 20140129153713.gl5...@homeworld.netbsd.org, Emmanuel Dreyfus m...@netbsd.org wrote: On Wed, Jan 29, 2014 at 01:48:35PM +0100, Martin Husemann wrote: My vote for this special case: hard code it #ifdef __x86_64__. If we run into other instances, we can add a define (like:

re: compat_netbsd32 swapctl

2014-01-29 Thread matthew green
this is gross. all those magic numbers turn my stomach. can you please define a compat structure using appropriately placed __packed members to force the correct values, and then use these structures as necessary. thanks, .mrg.

re: compat_netbsd32 swapctl

2014-01-29 Thread matthew green
this is gross. all those magic numbers turn my stomach. can you please define a compat structure using appropriately placed __packed members to force the correct values, and then use these structures as necessary. ... which is basically what dsl was suggesting, but with more useful

Re: compat_netbsd32 swapctl

2014-01-29 Thread Emmanuel Dreyfus
On Wed, Jan 29, 2014 at 03:37:13PM +, Emmanuel Dreyfus wrote: On Wed, Jan 29, 2014 at 01:48:35PM +0100, Martin Husemann wrote: My vote for this special case: hard code it #ifdef __x86_64__. If we run into other instances, we can add a define (like: DEV_T_ALIGN_32). Here is a patch that