OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 10:57 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: [SOLVED] Enabling the mmu crashes the kernel
PostPosted: Mon Jul 15, 2019 11:53 am 
Offline

Joined: Mon Jul 15, 2019 11:42 am
Posts: 1
Hello,
I've been trying to develop a mini os and i'm still at the early stages.
however, every time i tried to enable the MMU, my kernel crashes and qemu restarts it.
Here is my code:
https://github.com/baselsayeh/test_kernel/blob/master/arch/i386/mmu.c
crashing exatly after mov cr0, eax after calling __enable_mmu
https://github.com/baselsayeh/test_kernel/blob/master/arch/i386/mmu_asm.S

did i do anything wrong?
here is gdb output:

(both 0x00200000 and 0x00300000 is reserved in the linker script)

Code:
0x001003ff in ?? ()
(gdb) si
0x00100404 in ?? ()
(gdb) disas $eip-0x10,+0x20
Dump of assembler code from 0x1003f4 to 0x100414:
   0x001003f4:   mov    %esp,%ebp
   0x001003f6:   mov    0xc(%ebp),%eax
   0x001003f9:   mov    %eax,%cr3
   0x001003fc:   mov    %cr0,%eax
   0x001003ff:   or     $0x80000001,%eax
=> 0x00100404:   mov    %eax,%cr0
   0x00100407:   mov    $0x0,%eax
   0x0010040c:   pop    %ebp
   0x0010040d:   ret   
   0x0010040e:   push   %ebp
   0x0010040f:   mov    %esp,%ebp
   0x00100411:   sub    $0x18,%esp
End of assembler dump.
(gdb) si
0x00100407 in ?? ()
(gdb) disas $eip-0x10,+0x20
Dump of assembler code from 0x1003f7 to 0x100417:
   0x001003f7:   Cannot access memory at address 0x1003f7
(gdb) x/2x 0x0
0x0:   Cannot access memory at address 0x0
(gdb) x/2x 0x1000
0x1000:   Cannot access memory at address 0x1000
(gdb) x/2x 0x2000
0x2000:   Cannot access memory at address 0x2000
(gdb) x/2x 0x3000
0x3000:   Cannot access memory at address 0x3000
(gdb) si
0x0000e05b in ?? ()
(gdb)

and i did not initialize the Global Descriptor Table, as there is no use for it.
i loaded it via
qemu-system-i386 -kernel myos.kernel -m 128 -gdb tcp::9000 -S

i solved it, was not getting the parameter correctly


Top
 Profile  
 
 Post subject: Re: [SOLVED] Enabling the mmu crashes the kernel
PostPosted: Fri Jul 19, 2019 8:21 am 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
Although your code may not at present need a valid GDT because it isn't reloading any segment registers with selectors - you will want to create your own at some point in the near future. Multiboot spec doesn't guarantee the GDT record is valid once it starts executing your kernel. The Multiboot spec doesn't even say which selector is data and which one is code. You definitely will need one when you create an Interrupt Descriptor Table (IDT) when you start handling interrupts and exceptions.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Garnek0 and 51 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group