Page 1 of 1

[Closed]GPF with Grub2

Posted: Thu Apr 05, 2012 7:39 am
by gedd
Hi,

I decided to use Grub2 instead of Grub few time ago.
I have a strange issue.
My kernel work properly with Grub and with -kernel QEMU option.
If i use the same kernel with Grub2 a GPF fault is raised.
After searching i discovered that it was the return of a system call which was the problem.

Code: Select all

void _declspec(naked) VGADriver::VGASyscall()
{
	__asm{
		cli
		push	ebp
		mov		ebp,esp
		//sub		ebp, 4
		pushad
	}

	// ...
	// Some code
	// ...
	__asm{
		
		//mov al,0x20  //EOI		
		//out 0x20,al
		//out 0xa0,al
		sti
		popad
		pop ebp
		iretd		// <-------------- here is the problem
	}
}
I use VIsual C++ 2010 and Cygwin for Grub2.

I tried many things and searched for long time but i have not a begin of an answer.

Does anyone have an idea ?
Thanks

Re: GPF with Grub2

Posted: Thu Apr 05, 2012 7:52 am
by xenos
There are many possible reasons for a GPF when you perform an iret - there's a rather long list in Intel's instruction set reference. I guess you have best chances to figure out the exact reason if you run your code using something like Bochs' debugger.

Re: GPF with Grub2

Posted: Wed Apr 11, 2012 4:39 am
by gedd
Ok, but the main question was in fact : does Grub2 has a known sensitivity with interrupts ?
Because this :
GRUB 0.97 --> works
GRUB 1.98 --> Don't works

Of course i'm still searching with a debbugger

Re: GPF with Grub2

Posted: Wed Apr 11, 2012 6:42 am
by brain
Could it be a difference in how the stack is set up by grub? I assume you have just used grubs default rather than set up your own esp value?

Re: GPF with Grub2

Posted: Thu Apr 12, 2012 9:41 am
by gedd
The stack is the Grub stack
It seems to be segment privilège problem...