karekare0 wrote:Oh my <insert diety here>...
@Ready4Dis: The NULL selector is not free space! It is reserved, and must be set to zero!!!
that is not correct, it's a NULL descriptor because it is used to catch NULL exceptions, not because it must remain NULL. Please read up on it before calling me a liar, I use this in my OS which runs on many hardware configs without issue, and all the intel documents agree. Please do some research before calling people out on things that you don't know, just because some guy said one time that it's a NULL descriptor and to set everything to NULL doesn't make it right (just as me telling you that it's ok to use is right, do the research yourself and find the answer, but I can tell you, I did my own research and I'm right
.
And please, did you read his code man? He's not doing a far call, why on earth would a near return cause a GPF? Even if he DID a far call, and a near return, it would just waste 4-bytes of his stack and cause no ill side effects, please learn how these things work before making assumptions. Stop calling my information unreliable, then spatting off crap and read up some more. Let me walk you through why my 'not so reliable suggestion' is more reliable than you think:
Directly from his code (did you even read it before responding?):
Code: Select all
init_gdt:
lgdt [gdt_begin]
mov ax,0x10
mov ds,ax
mov es,ax
mov gs,ax
mov fs,ax
mov ss,ax
jmp 0x08:gdt_return
gdt_return:
ret
Where in the world do you see a far call there? It looks like a regular call, not a callf, nor a call 0x08:init_gdt. It's a plain jain, 32-bit function call, it pushes EIP on the stack, and EIP only. A normal return is all that's required, and Even if, for some god for saken reason, it decided to push a random value on the stack and treat a normal call as a far call, the segment descriptor is pushed FIRST, and EIP second, so the near return will still return to the correct EIP, just leave the stack 4-bytes off! Now, if he did a far return, and a near call, it would be popping an invalid CS off the stack, but the other way around will not cause his GPF, sorry, keep digging you didn't solve it. not saying it's not a stack or call frame problem, but if he's doing a normal call with a normal return, then there is no issue. Now, I would try looking at where GRUB leaves you, does it leave you in a flat memory model, or does it actually use an offset for something? Are you sure the stack is getting setup properly with valid memory (maybe try setting ESP to a known free memory address to make sure, like 0x5000 or something)? Is your code binary, or a relocateable format? Is it linked to the correct location? These are the thins to be looking for, and is what I was trying to narrow down to find out what exactly is going on. Please stop talking crap that you don't know, I was trying to be nice, but now you're just blatantly calling people liars with bad information of your own.