I'm writing an own os and when I try to change the GDT it fires IRQ 6 (invalid opcode). When the hardware virtualization is disabled everything is fine.
The code which supposed to change the GDT:
Code: Select all
call get_gdt_base
lea GDTdescriptor, %ebx
movl %eax, %ds:2(%ebx)
lea memory_descriptor, %eax
sgdt (oldGDTdescriptor)
push %eax
call create_base_gdt
movw $8, %dx
mulw %dx
decw %ax
movw %ax, %ds:(%ebx)
lgdt (GDTdescriptor)
movl $0x10,%eax
mov %ax,%ds
mov %ax,%es
mov %ax,%fs
mov %ax,%gs
mov %ax,%ss
jmp $8,$next
next:
movl $0x3FFE0, %eax
movl %eax, %esp
call main
Function "create_base_gdt" creates a GDT with the following entries:
Code: Select all
.quad 0x0
.quad 0x00C09B0000008000 /*code segment*/
.quad 0x00C0930000008000 /*data segment*/
Thank you in advance,
Andrej