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.
ITchimp
Member
Posts: 134 Joined: Sat Aug 18, 2018 8:44 pm
Post
by ITchimp » Mon Aug 17, 2020 2:19 am
I have my interrupt table set up, ready to try
I am doing this in kernel mode ... basically, it is just doing syscall without doing it from user space...
when I do it, I got gpf, here is the transcript/
Code: Select all
(0).[1244325120] [0x0000000000100170] 0008:0000000000100170 (unk. ctxt): mov eax, 0x00000000 ; b800000000
Next at t=1244325121
(0) [0x0000000000100175] 0008:0000000000100175 (unk. ctxt): int 0x80 ; cd80
<bochs:8>
(0).[1244325121] [0x0000000000100175] 0008:0000000000100175 (unk. ctxt): int 0x80 ; cd80
CPU 0: Interrupt 0x80 occured (error_code=0x0000)
(0).[1244325122] [0x0000000000000000] 0008:0000000000000000 (unk. ctxt): push ebx ; 53
(0).[1244325123] [0x0000000000000001] 0008:0000000000000001 (unk. ctxt): inc dword ptr ds:[eax] ; ff00
(0).[1244325124] [0x0000000000000003] 0008:0000000000000003 (unk. ctxt): lock push ebx ; f053
CPU 0: Exception 0x06 - (#UD) undefined opcode occured (error_code=0x0000)
CPU 0: Interrupt 0x06 occured (error_code=0x0000)
(0).[1244325125] [0x00000000001013b0] 0008:00000000001013b0 (unk. ctxt): cli ; fa
(0).[1244325126] [0x00000000001013b1] 0008:00000000001013b1 (unk. ctxt): push 0x00000000 ; 6a00
(0).[1244325127] [0x00000000001013b3] 0008:00000000001013b3 (unk. ctxt): push 0x00000006
Octocontrabass
Member
Posts: 5572 Joined: Mon Mar 25, 2013 7:01 pm
Post
by Octocontrabass » Mon Aug 17, 2020 2:29 am
ITchimp wrote: when I do it, I got gpf, here is the transcript/
I don't see #GP anywhere in that log. I do see #UD, which looks like it's caused by executing something that is not code.
Are you sure you're setting up the IDT entry for interrupt 0x80 correctly?
ITchimp
Member
Posts: 134 Joined: Sat Aug 18, 2018 8:44 pm
Post
by ITchimp » Mon Aug 17, 2020 3:26 am
I think it looks right
Code: Select all
IDT[0x7d]=??? descriptor hi=0x00000000, lo=0x00000000
IDT[0x7e]=??? descriptor hi=0x00000000, lo=0x00000000
IDT[0x7f]=??? descriptor hi=0x00000000, lo=0x00000000
IDT[0x80]=32-Bit Interrupt Gate target=0x0008:0x00000000, DPL=0
IDT[0x81]=??? descriptor hi=0x00000000, lo=0x00000000
IDT[0x82]=??? descriptor hi=0x00000000, lo=0x00000000
iansjack
Member
Posts: 4703 Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK
Post
by iansjack » Mon Aug 17, 2020 3:31 am
Do you really mean the code for interrupt 0x80 starts at address 0? That doesn't sound like a good idea.
It's best to make the first page of your address space non-executable to guard against null function pointers or return addresses.