Privileged intruction in user mode leads to triple fault.
Posted: Fri Jul 09, 2021 10:43 am
I have successfully implemented scheduler in my OS. Now I'm able to run programs in ring 3. However, executing any privileged instruction in user mode leads to triple fault.
I don't know why. I have handlers for all exceptions and they work in kernel mode.
I thought that maybe it's the problem with my TSS. I set it as follows:
I have no other idea what might be causing this error.
I don't know why. I have handlers for all exceptions and they work in kernel mode.
I thought that maybe it's the problem with my TSS. I set it as follows:
Code: Select all
memset(&tss_entry, 0, sizeof(tss_entry));
tss_entry.rsp0 = (uint64_t) &kernel_stack + 0x4000;
GDT.tss.limit_low = limit & 0xFFFF;
GDT.tss.base_low = base & 0xFFFF;
GDT.tss.base_middle = (base >> 16) & 0xFF;
GDT.tss.access = 0xE9;
GDT.tss.granularity = (limit >> 16) & 0xF;
GDT.tss.base_high = (base >> 24) & 0xFF;
*((uint64_t*) &GDT.tssu) = (base >> 32);
flush_tss();