I can load the GDT, update ES;DS;CS... but when I also update SS, the OS crashes and leaves lguest.
Code: Select all
static gdt_entry_t gdt_entries[5] =
{GDT_ENTRY_INIT(0x0,0x0,0x0),
GDT_ENTRY_INIT(0xC09A,0x0,0xFFFFFFFF),
GDT_ENTRY_INIT(0xC092,0x0,0xFFFFFFFF),
GDT_ENTRY_INIT(0xC0FA,0x0,0xFFFFFFFF),
GDT_ENTRY_INIT(0xC0F2,0x0,0xFFFFFFFF)};
then I try to load SS, and I get the general protection exception. This is my "setup_GDT"
Code: Select all
setup_gdt:
movw $0x10,%ax
movw %ax,%ds
movw %ax,%es
movw %ax,%fs
movw %ax,%gs
// TODO: FIXME!!!!If I comment out this, it works without issues
movw %ax,%ss
ljmp $0x08,$fake_label2
fake_label2:
Code: Select all
static void init_gdt()
{
gdt_ptr.size = (sizeof(gdt_entry_t) * 5 -1); //we have 5 entries
gdt_ptr.address = (u32)&gdt_entries;
const struct desc_ptr * gdt_address = &gdt_ptr;
lguest_load_gdt(gdt_address);
setup_gdt();
}
static void lguest_load_gdt(const struct desc_ptr *desc)
{
unsigned int i;
struct desc_struct *gdt = (void *)desc->address;
for (i = 0; i < (unsigned int) (desc->size+1)/8; i++)
hcall(LHCALL_LOAD_GDT_ENTRY, i, gdt[i].a, gdt[i].b, 0);
}
Any hints?
As always, thanks for reading this far. Suggestions are welcome.