Re: Interesting code in exec_setregs

From: Jon Passki <cykyc_at_yahoo.com>
Date: Sun, 26 Sep 2004 07:46:32 -0700 (PDT)
--- 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
Received on Sun Sep 26 2004 - 12:46:33 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:14 UTC