Subject: Re: CVS commit: syssrc
To: None <source-changes@netbsd.org, manu@netbsd.org>
From: Wolfgang Solfrank <ws@tools.de>
List: source-changes
Date: 03/15/2001 20:40:35
Hi,

> Module Name:	syssrc
> Committed By:	manu
> Date:		Thu Mar 15 19:18:21 UTC 2001
> 
> Modified Files:
> 	syssrc/sys/compat/linux/common: linux_emuldata.h linux_exec.c
> 	    linux_misc.c
> 
> Log Message:
> Fixed brk() emulation. We now keep track of the processes' idea of the
> break value. See http://mail-index.netbsd.org/tech-kern/2001/03/15/0000.html
> for more details.

Hmm, I thought the consensus was to try a change on linux_sys_brk more
along the lines of the following:

int
linux_sys_brk(p, v, retval)
	struct proc *p;
	void *v;
	register_t *retval;
{
	struct linux_sys_brk_args /* {
		syscallarg(char *) nsize;
	} */ *uap = v;
	char *nbrk = round_page(SCARG(uap, nsize));
	struct sys_obreak_args oba;
	struct vmspace *vm = p->p_vmspace;
	caddr_t oldbrk;

	oldbrk = round_page(vm->vm_daddr + ctob(vm->vm_dsize));

	SCARG(&oba, nsize) = nbrk;

	/*
	 * Linux always returns at least the old brk value.
	 */
	if ((caddr_t) nbrk > oldbrk && sys_obreak(p, &oba, retval) == 0)
		retval[0] = (register_t)nbrk;
	else
		retval[0] = (register_t)oldbrk;

	return 0;
}

I.e. to page align everything (and while here, to make the code comply to
the comment).  Note that I don't have any real data on whether linux really
does forbid the truncation of the data area.

Ciao,
Wolfgang
-- 
ws@TooLs.DE     Wolfgang Solfrank, TooLs GmbH 	+49-228-985800