Page 1 of 1

Qemu/OVMF boots to black screen

Posted: Fri Jul 28, 2023 4:16 pm
by Roverx64
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

Re: Qemu/OVMF boots to black screen

Posted: Tue Aug 08, 2023 4:08 pm
by Octocontrabass
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().

Re: Qemu/OVMF boots to black screen

Posted: Tue Aug 08, 2023 4:25 pm
by Roverx64
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.

Re: Qemu/OVMF boots to black screen

Posted: Tue Aug 08, 2023 5:03 pm
by Octocontrabass
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.

Re: Qemu/OVMF boots to black screen

Posted: Tue Aug 08, 2023 5:13 pm
by Roverx64
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