OSDev.org

The Place to Start for Operating System Developers
It is currently Sun Apr 28, 2024 10:40 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Qemu/OVMF boots to black screen
PostPosted: Fri Jul 28, 2023 4:16 pm 
Offline

Joined: Thu Jul 27, 2023 4:35 pm
Posts: 3
Location: Texas
After some time of not compiling my code, I came back to work on it and Qemu now displays a black screen.
The EFI bootloader worked both in Qemu and on real hardware when I last worked on it with the same source code. I unfortunately overwrote the working efi file when I was troubleshooting the issue with real hardware.

I do have a working efi file of an older version so I don't think It's Qemu or OVMF since it boots on real hardware too. (Included in the zip) I have also tested with an older gcc cross compiler (11.0.1) and older qemu (7.2.4) compiled from source and neither has fixed or has had any impact on the issue.

I have noticed that removing any reference to 'Print(...);' in my bootloader code does allow the bootloader to continue running until 'setCR3' where it presumably pages faults due to other code I had to remove to reach that point. Some other functions such as any file based UEFI function. Using the inline assembly helped me conclude where I was actually getting when removing UEFI functions and the code runs the same without them present.

Maybe this is related to how my bootloader is being linked against gnuefi? I have tried to use GDB but I cannot get to to display actual assembly instructions or C code for any of my efi code.
Changing the Qemu video outputs also causes seemingly unrelated faults to occur such as Undefined Opcode and Page Faults (UEFI prints them to the log file).

The display also seems to be printing out to the serial file since using 'cat ./Other/RoverOS.log' shows the GRUB boot menu screen and random characters (which I assume is actually the framebuffer being outputted).
The GRUB command line will also say there are 'no supported video modes' when using the 'videotest' command.
I followed the UEFI tutorial on the wiki and I get the same results as my code.

I am unsure of why the code is no longer working. Maybe I am overlooking something simple.

The current code is here: https://mega.nz/file/F2p2VIgZ#8yGb-I-hW ... sim6NV5ZSo
And the old code that used to work is here: https://github.com/Roverx64/RoverOS


Top
 Profile  
 
 Post subject: Re: Qemu/OVMF boots to black screen
PostPosted: Tue Aug 08, 2023 4:08 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
Roverx64 wrote:
After some time of not compiling my code, I came back to work on it and Qemu now displays a black screen.

What changed in your code between when it last worked and now? If you build the old code in your current environment, does it work?

Roverx64 wrote:
Using the inline assembly helped me conclude where I was actually getting when removing UEFI functions and the code runs the same without them present.

The inline assembly clobbers registers without telling the compiler. Either fix it or get rid of it.

Roverx64 wrote:
Maybe this is related to how my bootloader is being linked against gnuefi?

GNU-EFI is an awful ugly hack, but as far as I know it's a reliable awful ugly hack. You don't need uefi_call_wrapper().


Top
 Profile  
 
 Post subject: Re: Qemu/OVMF boots to black screen
PostPosted: Tue Aug 08, 2023 4:25 pm 
Offline

Joined: Thu Jul 27, 2023 4:35 pm
Posts: 3
Location: Texas
Octocontrabass wrote:
What changed in your code between when it last worked and now? If you build the old code in your current environment, does it work?

I changed nothing and I have actually since found the cause of this issue before my post got approved.
The gnuefi linker script elf_x86_64_efi.lds causes my issues, and using an older version fixes it. (I am using gnuefi from https://github.com/vathpela/gnu-efi)
It would reach my bootloader, but calling any gnuefi function would make it jump into the void and cause a #UD/Page fault.
Using the old version of the linker script works for Qemu and real hardware.

Octocontrabass wrote:
The inline assembly clobbers registers without telling the compiler. Either fix it or get rid of it.

I know. I only added them after this issue started so I could determine how far I was actually getting. They were never present when I got this issue.
GDB does not show my bootloader code when I set breakpoints either. Maybe this has to do with the code being position independent.

Octocontrabass wrote:
You don't need uefi_call_wrapper().

I only use it for UEFI functions that gnu-efi doesn't have a dedicated function for.


Top
 Profile  
 
 Post subject: Re: Qemu/OVMF boots to black screen
PostPosted: Tue Aug 08, 2023 5:03 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
Roverx64 wrote:
The gnuefi linker script elf_x86_64_efi.lds causes my issues, and using an older version fixes it.

I don't see how that would help, unless you accidentally mixed files from two different versions of GNU-EFI.

Roverx64 wrote:
I only use it for UEFI functions that gnu-efi doesn't have a dedicated function for.

But you don't need it at all. It only exists for backwards compatibility with old compilers.


Top
 Profile  
 
 Post subject: Re: Qemu/OVMF boots to black screen
PostPosted: Tue Aug 08, 2023 5:13 pm 
Offline

Joined: Thu Jul 27, 2023 4:35 pm
Posts: 3
Location: Texas
Octocontrabass wrote:
I don't see how that would help, unless you accidentally mixed files from two different versions of GNU-EFI.

Completely deleting the gnu-efi folder and re-downloading it with git still causes the black screen issue. Replacing that specific file fixes the issue I am having.

Octocontrabass wrote:
But you don't need it at all. It only exists for backwards compatibility with old compilers.

I didn't know that. I'll remove them in my next update.

The older lds I am using is here.
https://pastebin.com/XDZByztj


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: FrankRay78, Majestic-12 [Bot] and 60 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