PMode call-opcode problem
PMode call-opcode problem
When I call something in PMode bochs gives me the error "running in bogus memory", which should mean that the eip pointer is in the never-never land. Maybe someone of you have an idea what can produce such a failure.
Re:PMode call-opcode problem
Ok, I found the problem it was the stack! But how have I to setup the stack right? I?ve written 0fffffh in esp and now 1000h. But how can I now control the stack, because now when there is a failure in my code it could overwrite my kernel.
Re:PMode call-opcode problem
you can control stack overflows/underflows by the paging mechanism. In fact you can put an unmapped page at the extremes of the stack, so when the stack go out of its boundaries a stack-fault exception occurs... and you can manage it in the opportune way.
Re:PMode call-opcode problem
..
Last edited by Perica on Sun Dec 03, 2006 8:35 pm, edited 1 time in total.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:PMode call-opcode problem
just keep in mind that C and most HLL will *require* that a stack offset can be used as data offset aswell (i.e. no special instruction should be involved to get &on_stack)Perica Senjak wrote: Or: You could make a Stack DataSelector in your GDT that maps the Area where you want your Stack to be! (In my Opinion, this is an easier solution -- And the one i am About to use: I just got to get around to implementing it ;D);
Re:PMode call-opcode problem
..
Last edited by Perica on Sun Dec 03, 2006 8:35 pm, edited 1 time in total.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:PMode call-opcode problem
what i mean is that *bases* will have to be aligned. limits, however, can differ. I use a no-limit (0xffff.ffff) data segment and a expand-down stack segment that guarantees a protection for stack overflows only (limit = max top-of-stack).
Any other scheme (and believe me, i've been trying a lot of them) will require a modification of the code generated by the C compiler. Only a few languages like Java and assembly will let you play with ss.base != ds.base.
Any other scheme (and believe me, i've been trying a lot of them) will require a modification of the code generated by the C compiler. Only a few languages like Java and assembly will let you play with ss.base != ds.base.