Subject: Re: kern/8945: Calling pwrite() from Linux application causes panic
To: None <netbsd-bugs@netbsd.org>
From: Dave Sainty <dave@dtsp.co.nz>
List: netbsd-bugs
Date: 12/05/1999 01:44:44
dave writes:

> >Number:         8945
> >Category:       kern
> >Synopsis:       Calling pwrite() from Linux application causes panic
> >Confidential:   no
> >Severity:       serious
> >Priority:       high
> >Responsible:    kern-bug-people (Kernel Bug People)
> >State:          open
> >Class:          sw-bug
> >Submitter-Id:   net
> >Arrival-Date:   Sat Dec  4 00:30:01 1999
> >Last-Modified:
> >Originator:     Dave Sainty
> >Organization:
> Dynamic Technology Services and Products Ltd (NZ)
> >Release:        Recent current
> 
> >Description:
> 
> 	pwrite() under linux emulation simply calls the NetBSD system call
> 	implementation.  linux_sysent.c contains:
> 
> 	{ 4, sizeof(struct sys_pwrite_args), sys_pwrite }, /* 181 = pwrite */
> 
> 	Now, sizeof(struct sys_pwrite_args) == 24, which presents a problem.
> >Fix:
> 
> Here is "a" patch that allowed me to get past the panic and
> determine the real problem.
> 
> I'm not sure if it is right though, does Linux use %ebp for the 7th
> block of 32 bits?  I chose it by a process of elimination (it was
> all that was left and

On second thoughts...

sys/sys/syscallargs.h:
struct sys_pwrite_args {
        syscallarg(int) fd;
        syscallarg(const void *) buf;
        syscallarg(size_t) nbyte;
        syscallarg(int) pad;
        syscallarg(off_t) offset;
};

I imagine Linux doesn't want padding in there, so the arguments will
fit in 6 registers, and I guess a conversion routine is the correct
fix for the pwrite() case (and the pread() case).

Maybe some DIAGNOSTIC code is called for that checks the Linux
argument table at boot time is called for...

Cheers,

Dave