crush system when try to enable paging
Posted: Wed Apr 08, 2020 6:36 pm
hi, when i try to enable paging, qemu just turn off with error "Trying to execute code outside RAM or ROM at 0xefffff54"
What could be the problem?
And did I create the page table correctly?
my bootloader:
CPU dump
link.ld
What could be the problem?
And did I create the page table correctly?
my bootloader:
Code: Select all
bits 32
;multiboot spec
align 4
dd 0x1BADB002 ;magic
dd 0x00 ;flags
dd - (0x1BADB002 + 0x00) ;checksum. m+f+c should be zero
global page_directory
section .text
global start
extern kmain ;kmain is defined in the c file
start:
cli ;block interrupts
xor eax, eax
mov ds, eax
mov esp, stack_space
mov eax, 0x0
mov ebx, 0x0
.fill_table0:
mov ecx, ebx
or ecx, 3 ; Present; Supervisor;
mov [page_table0+eax*4], ecx
add ebx, 4096
inc eax
cmp eax, 1024 ; 1024 frames = 4MB
je .end0
jmp .fill_table0
.end0:
mov eax, 0x0
mov ebx, 0x100000
.fill_table:
mov ecx, ebx
or ecx, 3 ; Present; Supervisor; R/W;
mov [page_table768+eax*4], ecx
add ebx, 4096
inc eax
cmp eax, 1024
je .end
jmp .fill_table
.end:
mov eax, page_table0
and eax, 0xFFFFF000
or eax, 3
mov ebx, page_directory
mov [ebx], eax
mov eax, page_table768
and eax, 0xFFFFF000
or eax, 3
mov ebx, page_directory
mov [ebx], eax ; 0xC0000000
and eax, 0xFFFFF000
;or eax, 3
mov eax, page_directory
mov cr3, eax
mov eax, cr0
or eax, 0x80000001
mov cr0, eax
mov eax, cr0
or eax, 1
mov cr0, eax ; <-- cause a crush
mov ecx, eax
call kmain
hlt
page_directory:
resb 0x1000
page_table0:
resb 0x1000
page_table768:
resb 0x1000
section .bss
resb 8192 ;8KB for stack
stack_space:
Code: Select all
EAX=f000001a EBX=f000ff53 ECX=00000040 EDX=00000037
ESI=f000e2c3 EDI=f000ff53 EBP=f000ff53 ESP=ffff0018
EIP=f000ff54 EFL=00000046 [---Z-P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0040 00000400 0000ffff 00009300
CS =f000 ffff0000 0000ffff 00009b00
SS =0000 00000000 0000ffff 00009300
DS =0000 00000000 0000ffff 00009300
FS =0000 00000000 0000ffff 00009300
GS =0000 00000000 0000ffff 00009300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00000000 0000ffff
IDT= 00000000 0000ffff
CR0=60000010 CR2=00000000 CR3=00000000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=ffff0000 CCD=00000000 CCO=LOGICW
EFER=0000000000000000
FCW=037f FSW=0000 [ST=0] FTW=00 MXCSR=00001f80
FPR0=0000000000000000 0000 FPR1=0000000000000000 0000
FPR2=0000000000000000 0000 FPR3=0000000000000000 0000
FPR4=0000000000000000 0000 FPR5=0000000000000000 0000
FPR6=0000000000000000 0000 FPR7=0000000000000000 0000
XMM00=00000000000000000000000000000000 XMM01=00000000000000000000000000000000
XMM02=00000000000000000000000000000000 XMM03=00000000000000000000000000000000
XMM04=00000000000000000000000000000000 XMM05=00000000000000000000000000000000
XMM06=00000000000000000000000000000000 XMM07=00000000000000000000000000000000
Code: Select all
OUTPUT_FORMAT(elf32-i386)
ENTRY(start)
SECTIONS
{
. = 0x100000;
text_start = .;
.text : { *(.text) }
text_end = .;
.data : { *(.data) }
.bss : { *(.bss) }
end_of_kernel_image = .;
}