GPF on syscall INT instruction

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
Peterbjornx
Member
Member
Posts: 116
Joined: Thu May 06, 2010 4:34 am
Libera.chat IRC: peterbjornx
Location: Leiden, The Netherlands
Contact:

GPF on syscall INT instruction

Post by Peterbjornx »

I use a memory based syscall interface, and at the very moment the INT instruction executes it GPFs with error 0402:
Bochs output:

Code: Select all

00080492882d[CPU0 ] interrupt(): vector = 80, TYPE = 4, EXT = 0
00080492882e[CPU0 ] interrupt(): soft_int && (gate.dpl < CPL)
00080492882d[CPU0 ] exception(0x0d): error_code=0402
00080492882d[CPU0 ] interrupt(): vector = 0d, TYPE = 3, EXT = 1
00080492882d[CPU0 ] interrupt(): INTERRUPT TO INNER PRIVILEGE
Asm code of syscall

Code: Select all

void syscall(syscall_parameter_block *p){
	uint32_t p_addr = (uint32_t) p;
	_asm {
		mov eax, dword ptr [p_addr]
		mov esi, eax
		int 80h
	}
}
, i set up TSS exactly like jamesm tutorial and bochs says it is valid

Code: Select all

<bochs:14> info tss
tr:s=0x2b, base=0x00000000c0007938, valid=1
ss:esp(0): 0x0010:0xc04f4f96
ss:esp(1): 0x0000:0x00000000
ss:esp(2): 0x0000:0x00000000
cr3: 0x00000000
eip: 0x00000000
eflags: 0x00000000
cs: 0x000b ds: 0x0013 ss: 0x0013
es: 0x0013 fs: 0x0013 gs: 0x0013
eax: 0x00000000  ebx: 0x00000000  ecx: 0x00000000  edx: 0x00000000
esi: 0x00000000  edi: 0x00000000  ebp: 0x00000000  esp: 0x00000000
ldt: 0x0000
i/o map: 0x0000
<bochs:15>
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: GPF on syscall INT instruction

Post by gerryg400 »

The DPL of the syscall IDT entry needs to be numerically >= to the CPL. To make a syscall this way from ring 3, the DPL needs to be 3. Seems like your DPL is < the CPL.
If a trainstation is where trains stop, what is a workstation ?
Post Reply