re: CVS commit: src/sys/kern

2014-04-12 Thread matthew green

> > btw, why do you keep adding 4 space idented { } ?
> 
> To narrow local var scopes.  They should go away eventually...

please do not commit these to the tree, keep them as local changes.


.mrg.


Re: CVS commit: src/sys/kern

2014-04-12 Thread Masao Uebayashi
On Sun, Apr 13, 2014 at 12:33 AM, Nick Hudson  wrote:
> On 04/12/14 16:08, Masao Uebayashi wrote:
>>
>> Module Name:src
>> Committed By:   uebayasi
>> Date:   Sat Apr 12 15:08:56 UTC 2014
>>
>> Modified Files:
>> src/sys/kern: kern_exec.c
>>
>> Log Message:
>> execve_runproc: Correct thinko in Rev. 1.386; the new SP always points to
>> after (higher adderss) argc/argv/env/aux/strings regardless of stack
>> growing
>> direction .
>
> Doesn't this mean that argc, etc will get overwritten on _rtld_start call
> for stack grows down machines?
>
> SP needs to point to the first available stack address. On stack grows down
> machines this is a lower value than argc, etc. On stack grows up machines
> this is a higher value.

http://www.netbsd.org/~uebayasi/execve-stack-growdown.pdf
http://www.netbsd.org/~uebayasi/execve-stack-growup.pdf

Initial SP points to STACK_GROW(minsaddr, ssize).  rtld can use the
given stack freely (contradicting obsolete comments found in
kern_exec.c).

stack-growing-up rtld has to figure out &argc.  This is possible by
(vaddr_t)ps_argvstr - (vaddr_t)sizeof(argc).  Note that argc on stack
is long (== char *), not int.  hppa's rtld assumes int, which has to
be fixed for hppa64.

http://nxr.netbsd.org/xref/src/libexec/ld.elf_so/arch/hppa/rtld_start.S#88

> btw, why do you keep adding 4 space idented { } ?

To narrow local var scopes.  They should go away eventually...


Re: CVS commit: src/sys/kern

2014-04-12 Thread Nick Hudson

On 04/12/14 16:08, Masao Uebayashi wrote:

Module Name:src
Committed By:   uebayasi
Date:   Sat Apr 12 15:08:56 UTC 2014

Modified Files:
src/sys/kern: kern_exec.c

Log Message:
execve_runproc: Correct thinko in Rev. 1.386; the new SP always points to
after (higher adderss) argc/argv/env/aux/strings regardless of stack growing
direction .


Doesn't this mean that argc, etc will get overwritten on _rtld_start 
call for stack grows down machines?


SP needs to point to the first available stack address. On stack grows 
down machines this is a lower value than argc, etc. On stack grows up 
machines this is a higher value.


btw, why do you keep adding 4 space idented { } ?

Nick



Re: CVS commit: src/sys/kern

2014-04-12 Thread Christos Zoulas
In article <20140412150856.b6ca...@cvs.netbsd.org>,
Masao Uebayashi  wrote:
>-=-=-=-=-=-
>-  /* setup new registers and do misc. setup. */
>-  (*epp->ep_esch->es_emul->e_setregs)(l, epp, data->ed_newstack);
>+{

No need for braces, we use c99 in the kernel.

christos