Interesting code in exec_setregs

Jon Passki cykyc at yahoo.com
Sun Sep 26 07:46:33 PDT 2004


--- David Xu <davidxu at freebsd.org> wrote:

> I found following code in  sys/i386/i386/machdep.c:
> function exec_setregs:
> 
>  bzero((char *)regs, sizeof(struct trapframe));
>  regs->tf_eip = entry;
>  regs->tf_esp = stack;
>  regs->tf_eflags = PSL_USER | (regs->tf_eflags & PSL_T);
> 
> the regs is cleared to zero, why do we bother to test it
> again ? regs->tf_eflags & PSL_T  is useless code.
> 
> AMD64 also has this, I also found it in releng_4, why ?

FYI, it's first incarnation was in v1.87 [1] (1994-11-06):

        !           864:        bzero(regs, sizeof(struct
trapframe));
        !           865:        regs[tEIP] = entry;
        !           866:        regs[tESP] = stack;
        !           867:        regs[tEFLAGS] = PSL_USERSET |
(regs[tEFLAGS] & PSL_T);
        !           868:        regs[tSS] = _udatasel;
        !           869:        regs[tDS] = _udatasel;
        !           870:        regs[tES] = _udatasel;
        !           871:        regs[tCS] = _ucodesel;

Same issue, it seems.

Jon

[1] http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/i386/i386/machdep.c?annotate=1.87&only_with_tag=MAIN


		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail


More information about the freebsd-current mailing list