GRUB page fault when using UEFI?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
melodyrs
Posts: 5
Joined: Fri Jan 10, 2025 3:07 am
Libera.chat IRC: melodyrs

GRUB page fault when using UEFI?

Post by melodyrs »

I've spent a few days now trying to understand why I'm getting a page fault when GRUB is booted with UEFI but not with BIOS.
Everything works up until https://gitlab.freedesktop.org/gnu-grub ... ain=1#L112 where GRUB jumps to a memory address some thousand bytes away from where the entry point is loaded. I think GRUB loads some code at that address which is supposed to do some relocations?

At this point, I'm not sure if this a GRUB issue or an issue with my code? I've attached a basic reproduction that has the same bug.

Code: Select all

make run
works but

Code: Select all

make run_bios
page faults

(I originally had this posted in General Programming but realized that's the wrong board)
Octocontrabass
Member
Member
Posts: 6275
Joined: Mon Mar 25, 2013 7:01 pm

Re: GRUB page fault when using UEFI?

Post by Octocontrabass »

melodyrs wrote: ↑Thu Jul 23, 2026 1:00 pmAt this point, I'm not sure if this a GRUB issue or an issue with my code?
Which versions of GRUB and OVMF are you using?
melodyrs wrote: ↑Thu Jul 23, 2026 1:00 pmI've attached
No you haven't.
melodyrs
Posts: 5
Joined: Fri Jan 10, 2025 3:07 am
Libera.chat IRC: melodyrs

Re: GRUB page fault when using UEFI?

Post by melodyrs »

No you haven't.
Sorry, thought I did.
Which versions of GRUB and OVMF are you using?
I'm using GRUB 2:2.14-1 and OVMF 202605-1.
Attachments
Archive.zip
(1.42 KiB) Downloaded 57 times
ashy5000
Posts: 8
Joined: Tue Jun 09, 2026 12:48 am

Re: GRUB page fault when using UEFI?

Post by ashy5000 »

Hi,

I ran into this issue a while back. If I remember correctly, it was caused by an attempt to write to a page that was not writeable, and that was outside the memory of the kernel (which was loaded into memory correctly). I found a patch to GRUB that solved this issue, but I'm not sure if it is actually a bug in GRUB or just an issue in how I was configuring it. The explanation given by the patch author seems reasonable, but, again, I haven't looked very deep into the issue, so it's quite possible the patch isn't needed, especially given that it hasn't been included in the latest versions of GRUB. I'll attach it if you want to try it out:

grub_patch.txt
(3.33 KiB) Downloaded 63 times
- Ashy5000
https://github.com/Ashy5000/muse

Live long and prosper!
Octocontrabass
Member
Member
Posts: 6275
Joined: Mon Mar 25, 2013 7:01 pm

Re: GRUB page fault when using UEFI?

Post by Octocontrabass »

An updated version of that patch will be included in the next version of GRUB.

In the meantime, you can either build a version of GRUB that includes the above commit or revert to a version prior to the commit that introduced the bug such as 2.12.
melodyrs
Posts: 5
Joined: Fri Jan 10, 2025 3:07 am
Libera.chat IRC: melodyrs

Re: GRUB page fault when using UEFI?

Post by melodyrs »

An updated version of that patch will be included in the next version of GRUB.
I was doing my debugging with GRUB commit 94a457f and was getting boot loops (I presumed from a page fault and grub's debug build installing an interrupt to catch that). Maybe there's something else going on...?
Post Reply