Re: [Etherboot-developers] Adding real-mode stack for prot_to_real
Brought to you by:
marty_connor,
stefanhajnoczi
|
From: Eric W B. <ebi...@ln...> - 2002-09-21 04:43:10
|
Marc Singer <el...@bu...> writes: > On Fri, Sep 20, 2002 at 05:12:04PM -0600, Eric W Biederman wrote: > > I have a confirmation for you. mknbi fails to setup it's own stack > > and then behaves badly if etherboot doesn't give it a stack. > > > > I have triggered this bug in the development version by relocating > > etherboot. > > > > If you have the time to change mknbi to setup it's own stack 1K should > > be sufficient, it would be appreciated. > > > > The problem triggers in prot_to_real && real_to_prot. > > > > If I understand it correctly, the problem is that the stack etherboot > uses is greater than 64KiB away from the base address of mknbi. So, > when prot_to_real substracts $RELOC from the %esp and installs the > real-mode %ss, the stack has moved and is probably trouncing something > interesting. We also need to load the GDT, and segment registers with the values mknbi assumes are in use. A protected mode entry point can only sanely assume a flat 32bit address space with a base address of 0. I have played with the former and checked it into the developer etherboot CVS tree. But I had not identified the remaing stack issue. The stack moving and trouncing something interesting is less of a problem. > Now we could make real-mode %ss behave and leave the > stack where it is, or we could setup a real-mode stack for the benefit > of BIOS calls. I would suggest making the protected mode stack behave. We don't need to touch it unless we return to etherboot. > I've made a patch that I expect would work, but it doesn't. This is > against mknbi-1.2-7. The behavior is a hard crash before I see > anything from first32.c. I've put the real_stack in .code32 and in > .data with no change in behavior. The odd thing is that if I only > change the stack pointer to 0x00090000 before calling first() then > I'll see the logon messages. It must be something simple that I'm not > noticing. > > Ideas? I am not totally familiar with the usages in mknbi, but in etherboot I seem to recall some of the callers passing values on the stack through real_to_prot, and prot_to_real. So switching stack may not work. > BTW, I am aware that this won't work when we start in real-mode and > first to protected mode first. I think all we need to do is push an > initial 32 bit stack pointer before the first call to real_to_prot and > all should be good. Starting in real mode actually appears to behave better, some better in the existing cases. A real mode stack at a semi random location is less deadly than getting your segment registers wrong. Eric |