Getting int 0x6 when issuing system call (int)
Posted: Mon Apr 22, 2019 8:39 pm
Hi, it's again me, as expected. Sorry, but, uh...
I'm getting an 0x06 (inv. opcode) fault when I call my syscall. The handler is written in C and ASM.
I mean, I push registers in ASM and then I call a C function that do the rest.
syscall.c
idt.asm (290-312)
I disassembled all the functions involved here (disassemble in gdb), and there's no weird SSE or MMX instructions, or any other thing.
Just in case, here is the qemu -d regs dump:
Thanks :S
edit: not working yet
Still not working, what the f***? nothing works with me, f***. Forget this, I'm gonna to be only ring0 so the programs can directly access hardware. Problem done. (Anyways, the wiki says nothing useful about ring3)
I'm getting an 0x06 (inv. opcode) fault when I call my syscall. The handler is written in C and ASM.
I mean, I push registers in ASM and then I call a C function that do the rest.
syscall.c
Code: Select all
#include <kernel/kernel.h>
#include <kernel/terminal.h>
struct __system_stack* stack;
void syscall_wrapper(void)
{
switch (stack->rax) {
case 4:
print_string(stack->rcx); /* The error happens exactly here */
break;
default:
break;
}
return;
}
Code: Select all
isr128:
cli
push byte 0
push byte 80
; The System V x86_64 calling convention...
push r9
push r8
push rcx
push rdx
push rsi
push rdi
cld
call syscall_wrapper
pop rdi
pop rsi
pop rdx
pop rcx
pop r8
pop r9
jmp isr_common_stub
Just in case, here is the qemu -d regs dump:
Code: Select all
check_exception old: 0xffffffff new 0x6
94: v=06 e=0000 i=0 cpl=0 IP=0008:0000000000100040 pc=0000000000100040 SP=0000:000000000010aee8 env->regs[R_EAX]=0000000000000000
RAX=0000000000000000 RBX=000000000010aef2 RCX=0000000000105000 RDX=0000000000000000
RSI=00000000000003d5 RDI=0000000000000054 RBP=000000002badb002 RSP=000000000010aee8
R8 =00000000000003d4 R9 =00000000000b8f00 R10=0000000000000000 R11=0000000000000050
R12=0000000000000000 R13=0000000000000000 R14=0000000000000000 R15=0000000000000000
RIP=0000000000100040 RFL=00000246 [---Z-P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0000 0000000000000000 00000000 00000000
CS =0008 0000000000000000 00000000 00209800 DPL=0 CS64 [---]
SS =0000 0000000000000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0000 0000000000000000 00000000 00000000
FS =0000 0000000000000000 00000000 00000000
GS =0000 0000000000000000 00000000 00000000
LDT=0000 0000000000000000 0000ffff 00008200 DPL=0 LDT
TR =0000 0000000000000000 0000ffff 00008b00 DPL=0 TSS64-busy
GDT= 0000000000104000 0000000f
IDT= 0000000000106180 00000fff
CR0=80000013 CR2=0000000000000000 CR3=0000000000108000 CR4=00000620
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=0000000000000044 CCD=000000000010aeb8 CCO=EFLAGS
EFER=0000000000000500
edit: not working yet
Still not working, what the f***? nothing works with me, f***. Forget this, I'm gonna to be only ring0 so the programs can directly access hardware. Problem done. (Anyways, the wiki says nothing useful about ring3)