OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 3:37 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: [SOLVED]My OS boots on my laptop, but not on my desktop PC
PostPosted: Wed Mar 25, 2020 12:55 am 
Offline
Member
Member
User avatar

Joined: Mon Feb 24, 2020 10:18 pm
Posts: 29
Location: Japan
Hello.

Repository: https://github.com/toku-sa-n/ramen/tree/boot_with_uefi

My OS boots with UEFI. It runs under 64-bit mode. After exiting UEFI boot services, it changes paging settings and CR3 value. On my laptop, assigning a value to a valid virtual memory address succeeds. However, this action fails on my desktop PC.
Code:
    MOV RAX, 0xFFFFFFFF80200000
    MOV QWORD[VRAM_PTR], RAX     ;  <--- crash on only my desktop PC.

MOV from memory to a register causes no problems on both my laptop and desktop PC.
Code:
    MOV RAX, QWORD[VRAM_PTR]      ; <--- not crash.

Also, I found that changing the CR3 value wasn't the cause of the crash. Inserting JMP $ immediately after MOV CR3, RAX told me that.
Code:
    MOV RAX, PML4
    MOV CR3, RAX                  ; <--- not crash.

These codes are written in asm/paging_64.asm. (https://github.com/toku-sa-n/ramen/blob/boot_with_uefi/asm/paging_64.asm#L108)
Why does my OS crash on desktop PC?

Just in case: desktop PC
Code:
%uname -a
Linux gentoo_desktop 5.5.11-gentoo #1 SMP Tue Mar 24 23:45:50 JST 2020 x86_64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz GenuineIntel GNU/Linux

laptop
Code:
%uname -a
Linux laptop 5.4.12-gentoo #1 SMP Tue Jan 21 14:56:38 JST 2020 x86_64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz GenuineIntel GNU/Linux

_________________
Ramen OS: https://github.com/toku-sa-n/ramen


Last edited by tokusan on Wed Mar 25, 2020 5:40 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: My OS boots on my laptop, but not on my desktop PC
PostPosted: Wed Mar 25, 2020 2:32 am 
Offline
Member
Member
User avatar

Joined: Thu Aug 06, 2015 6:41 am
Posts: 97
Location: Netherlands
As far as I can tell from your code you only set the 'present' bit (bit 0) in each paging structure entry, but you don't set the 'R/W' bit (bit 1). This means your pages are all marked as read-only.


Top
 Profile  
 
 Post subject: Re: My OS boots on my laptop, but not on my desktop PC
PostPosted: Wed Mar 25, 2020 4:18 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
Note that this only prevents writes in supervisor mode if the CR0.WP flag is set to 1. It's possible that the UEFI in the two computers sets this differently and (as far as I can tell from the rather difficult to follow code) this is never explicitly cleared. This would explain why the code works on one computer but not on the other. This hypothesis can easily be tested by explicitly clearing the flag when paging is enabled.


Top
 Profile  
 
 Post subject: Re: My OS boots on my laptop, but not on my desktop PC
PostPosted: Wed Mar 25, 2020 5:40 am 
Offline
Member
Member
User avatar

Joined: Mon Feb 24, 2020 10:18 pm
Posts: 29
Location: Japan
Thanks for replying. Both ways (setting R/W bit, and clearing CR0.WP) solved my problem!

_________________
Ramen OS: https://github.com/toku-sa-n/ramen


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 150 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