[Closed]GPF with Grub2

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
gedd
Member
Member
Posts: 104
Joined: Thu Apr 10, 2008 1:47 am

[Closed]GPF with Grub2

Post 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
Last edited by gedd on Mon Apr 23, 2012 3:33 am, edited 1 time in total.
[ Grub 2 | Visual Studio 2013 | PE File ]
The OsDev E.T.
Don't send OsDev MIB !
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: GPF with Grub2

Post 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.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
gedd
Member
Member
Posts: 104
Joined: Thu Apr 10, 2008 1:47 am

Re: GPF with Grub2

Post 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
[ Grub 2 | Visual Studio 2013 | PE File ]
The OsDev E.T.
Don't send OsDev MIB !
User avatar
brain
Member
Member
Posts: 234
Joined: Thu Nov 05, 2009 5:04 pm
Location: UK
Contact:

Re: GPF with Grub2

Post 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?
gedd
Member
Member
Posts: 104
Joined: Thu Apr 10, 2008 1:47 am

Re: GPF with Grub2

Post by gedd »

The stack is the Grub stack
It seems to be segment privilège problem...
[ Grub 2 | Visual Studio 2013 | PE File ]
The OsDev E.T.
Don't send OsDev MIB !
Post Reply