Date: Thu, 01 Feb 1996 02:07:28 -0800 From: David Greenman <davidg@Root.COM> To: KATO Takenori <kato@eclogite.eps.nagoya-u.ac.jp> Cc: current@FreeBSD.org Subject: Re: TSS broken Message-ID: <199602011007.CAA01314@Root.COM> In-Reply-To: Your message of "Mon, 01 Jan 1996 11:50:18 %2B0900." <199601010250.LAA00929@marble.eps.nagoya-u.ac.jp>
next in thread | previous in thread | raw e-mail | index | archive | help
>In recent change of sys/i386/i386/swtch.s, the code > movl %esp,PCB_ESP(%ecx) >is changed into > leal 4(%esp),%eax > movl %eax,PCB_ESP(%ecx) >(in savectx). > >After this operation, the member tss_esp points not user stack >pointer, but the address of TSS. > >This may causes panic when swapper is activated. I don't think so. At the time of entry to this function, the stack pointer points to the return address of the caller that was saved on the stack when the call was made. The stack layout looks like this: ... address of caller (?) auto variables used in mi_switch arguments to cpu_switch (proc) address of caller (mi_switch) auto variables used in cpu_switch arguments to savectx (pcb) address of caller (cpu_switch) The instruction pointer that is saved is the caller of savectx(), which is in cpu_switch. When the new process is scheduled to run, it will start at the return address. Previously, the stack was not fixed up to remove the return address and the result was that it was off-by-four. If cpu_switch referenced any of it's auto variables when the child started, bad things would have happened. The messed up stack pointer wasn't normally a problem because none of the auto variables were referenced after 'returning' to cpu_switch and the frame pointer fixes up the stack before the return to mi_switch. -DG David Greenman Core Team/Principal Architect, The FreeBSD Project
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199602011007.CAA01314>