I am writing an operating system, I have set up paging, loading ELF executables, and multitasking. When I load a program, and then run it, it runs for a while, but after a one or two reschedules, when it switches the page directory, it jumps to "0" for some reason. I tried debugging with Bochs, but the only thing I noticed is that it happens after switching the page directory.
I will attach the scheduler and paging code, Bochs debugger output (part of it), and a screenshot of a page fault (caused by a random instruction at EIP 1).
I really cannot figure out what the problem is. All help will be appreciated. If you need any more code or info, please ask
Bochs debugger output (the relevant part):
Code: Select all
(0).[105706000] [0x0000000000102117] 0008:00102117 (unk. ctxt): mov cr3, eax ; 0f22d8
(0).[105706001] [0x000000000010211a] 0008:0010211a (unk. ctxt): mov eax, cr0 ; 0f20c0
(0).[105706002] [0x000000000010211d] 0008:0010211d (unk. ctxt): mov dword ptr ss:[ebp-4], eax ; 8945fc
(0).[105706003] [0x0000000000102120] 0008:00102120 (unk. ctxt): or dword ptr ss:[ebp-4], 0x80000000 ; 814dfc00000080
(0).[105706004] [0x0000000000102127] 0008:00102127 (unk. ctxt): mov eax, dword ptr ss:[ebp-4] ; 8b45fc
(0).[105706005] [0x000000000010212a] 0008:0010212a (unk. ctxt): mov cr0, eax ; 0f22c0
(0).[105706006] [0x000000000010212d] 0008:0010212d (unk. ctxt): leave ; c9
(0).[105706007] [0x000000000010212e] 0008:0010212e (unk. ctxt): ret ; c3 ; XXX
00105706008i[CPU0 ] LOCK prefix unallowed (op1=0x53, modrm=0x00)
(0).[105706008] [0x0000000000000000] 0008:00000000 (unk. ctxt): push ebx ; 53
00105706009i[CPU0 ] LOCK prefix unallowed (op1=0x53, modrm=0x00)
(0).[105706009] [0x0000000000000001] 0008:00000001 (unk. ctxt): inc dword ptr ds:[eax] ; ff00
CPU 0: Exception 0x0e - (#PF) page fault occured (error_code=0x0002)
CPU 0: Interrupt 0x0e occured (error_code=0x0002)