Question about QEMU and UEFI runtime services

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
Ethin
Member
Member
Posts: 625
Joined: Sun Jun 23, 2019 5:36 pm
Location: North Dakota, United States

Question about QEMU and UEFI runtime services

Post by Ethin »

So, I successfully managed to get my OS booting on UEFI. However, my OS is now triple faulting for some reason (despite the fact that I have interrupts and a GDT loaded, both of which are valid). At least, that's my working hypothesis.
Confirming this, however, isn't appearing to be trivial. (I'm on qemu 6.0.0.) When I invoke qemu like so:

Code: Select all

qemu-system-x86_64 -drive format=raw,file=/home/ethin/source/kernel/target/x86_64-kernel-none/debug/boot-uefi-kernel.img -drive if=pflash,format=raw,file=OVMF.fd,readonly=on -no-reboot -drive file=disk.img,if=none,id=NVME01 -device nvme,drive=NVME01,serial=0001 -m 20G -usb -rtc clock=host -cpu host -smp cpus=8 -M q35 -name kernel -s -nographic -enable-kvm -debugcon file:qemu.log -global isa-debugcon.iobase=0x402 -d int,cpu_reset -D qemu2.log
Only CPU reset output appears. No interrupts are logged at all. The OVMF log output isn't any help since this doesn't happen in the UEFI preboot environment; I just have that on to debug the bootloader if necessary.
As for the second question, my memory map shows no UEFI runtime services anywhere. It looks like this (kernel output):
[INFO] [kernel] firmware-provided memory map:
[INFO] [kernel] [0-1000]: free
[INFO] [kernel] [1000-87000]: bootloader
[INFO] [kernel] [87000-88000]: free
[INFO] [kernel] [88000-A0000]: bootloader
[INFO] [kernel] [100000-19C000]: bootloader
[INFO] [kernel] [19C000-800000]: free
[INFO] [kernel] [800000-808000]: acpi non-volatile
[INFO] [kernel] [808000-810000]: free
[INFO] [kernel] [810000-900000]: acpi non-volatile
[INFO] [kernel] [900000-1500000]: free
[INFO] [kernel] [1500000-7BEFE000]: free
[INFO] [kernel] [7BEFE000-7BF1E000]: free
[INFO] [kernel] [7BF1E000-7E6F5000]: free
[INFO] [kernel] [7E6F5000-7EAE3000]: free
[INFO] [kernel] [7EAE3000-7EAE4000]: free
[INFO] [kernel] [7EAE4000-7EAE6000]: free
[INFO] [kernel] [7EAE6000-7EB25000]: free
[INFO] [kernel] [7EB25000-7EBCD000]: free
[INFO] [kernel] [7EBCD000-7EC49000]: free
[INFO] [kernel] [7EC49000-7EC86000]: free
[INFO] [kernel] [7EC86000-7EC87000]: free
[INFO] [kernel] [7EC87000-7EC91000]: free
[INFO] [kernel] [7EC91000-7EC94000]: free
[INFO] [kernel] [7EC94000-7ECC8000]: free
[INFO] [kernel] [7ECC8000-7ECCD000]: free
[INFO] [kernel] [7ECCD000-7ECED000]: free
[INFO] [kernel] [7ECED000-7ECF6000]: free
[INFO] [kernel] [7ECF6000-7ED0B000]: free
[INFO] [kernel] [7ED0B000-7ED0D000]: free
[INFO] [kernel] [7ED0D000-7ED21000]: free
[INFO] [kernel] [7ED21000-7ED26000]: free
[INFO] [kernel] [7ED26000-7ED56000]: free
[INFO] [kernel] [7ED56000-7ED60000]: free
[INFO] [kernel] [7ED60000-7ED88000]: free
[INFO] [kernel] [7ED88000-7ED8D000]: free
[INFO] [kernel] [7ED8D000-7ED90000]: free
[INFO] [kernel] [7ED90000-7ED93000]: free
[INFO] [kernel] [7ED93000-7ED9D000]: free
[INFO] [kernel] [7ED9D000-7ED9F000]: free
[INFO] [kernel] [7ED9F000-7EDBB000]: free
[INFO] [kernel] [7EDBB000-7EDBC000]: free
[INFO] [kernel] [7EDBC000-7EDD1000]: free
[INFO] [kernel] [7EDD1000-7EDD9000]: free
[INFO] [kernel] [7EDD9000-7EE00000]: free
[INFO] [kernel] [7EE00000-7F001000]: free
[INFO] [kernel] [7F001000-7F01C000]: free
[INFO] [kernel] [7F01C000-7F01E000]: free
[INFO] [kernel] [7F01E000-7F02B000]: free
[INFO] [kernel] [7F02B000-7F030000]: free
[INFO] [kernel] [7F030000-7F05B000]: free
[INFO] [kernel] [7F05B000-7F05C000]: free
[INFO] [kernel] [7F05C000-7F05F000]: free
[INFO] [kernel] [7F05F000-7F063000]: free
[INFO] [kernel] [7F063000-7F06C000]: free
[INFO] [kernel] [7F06C000-7F072000]: free
[INFO] [kernel] [7F072000-7F085000]: free
[INFO] [kernel] [7F085000-7F08A000]: free
[INFO] [kernel] [7F08A000-7F09D000]: free
[INFO] [kernel] [7F09D000-7F0A1000]: free
[INFO] [kernel] [7F0A1000-7F0C1000]: free
[INFO] [kernel] [7F0C1000-7F0C6000]: free
[INFO] [kernel] [7F0C6000-7F0E3000]: free
[INFO] [kernel] [7F0E3000-7F0EC000]: free
[INFO] [kernel] [7F0EC000-7F109000]: free
[INFO] [kernel] [7F109000-7F10E000]: free
[INFO] [kernel] [7F10E000-7F119000]: free
[INFO] [kernel] [7F119000-7F11A000]: free
[INFO] [kernel] [7F11A000-7F11C000]: free
[INFO] [kernel] [7F11C000-7F11E000]: free
[INFO] [kernel] [7F11E000-7F123000]: free
[INFO] [kernel] [7F123000-7F126000]: free
[INFO] [kernel] [7F126000-7F130000]: free
[INFO] [kernel] [7F130000-7F172000]: free
[INFO] [kernel] [7F172000-7F183000]: free
[INFO] [kernel] [7F183000-7F186000]: free
[INFO] [kernel] [7F186000-7F188000]: free
[INFO] [kernel] [7F188000-7F18B000]: free
[INFO] [kernel] [7F18B000-7F18C000]: free
[INFO] [kernel] [7F18C000-7F18E000]: free
[INFO] [kernel] [7F18E000-7F194000]: free
[INFO] [kernel] [7F194000-7F594000]: free
[INFO] [kernel] [7F594000-7F59A000]: free
[INFO] [kernel] [7F59A000-7F59B000]: free
[INFO] [kernel] [7F59B000-7F59D000]: free
[INFO] [kernel] [7F59D000-7F59E000]: free
[INFO] [kernel] [7F59E000-7F5A4000]: free
[INFO] [kernel] [7F5A4000-7F5A7000]: free
[INFO] [kernel] [7F5A7000-7F5B8000]: free
[INFO] [kernel] [7F5B8000-7F8EF000]: free
[INFO] [kernel] [7F8EF000-7F9EF000]: free
[INFO] [kernel] [7F9EF000-7FAEF000]: free
[INFO] [kernel] [7FAEF000-7FB6F000]: reserved
[INFO] [kernel] [7FB6F000-7FB7F000]: acpi reclaimable
[INFO] [kernel] [7FB7F000-7FBFF000]: acpi non-volatile
[INFO] [kernel] [7FBFF000-7FE00000]: free
[INFO] [kernel] [7FE00000-7FE13000]: free
[INFO] [kernel] [7FE13000-7FE33000]: free
[INFO] [kernel] [7FE33000-7FE59000]: free
[INFO] [kernel] [7FE59000-7FE9B000]: free
[INFO] [kernel] [7FE9B000-7FEBC000]: free
[INFO] [kernel] [7FEBC000-7FF40000]: free
[INFO] [kernel] [7FF40000-80000000]: acpi non-volatile
[INFO] [kernel] [100000000-140000000]: free
[INFO] [kernel] [140000000-140351000]: free
[INFO] [kernel] [140351000-580000000]: free
[INFO] [kernel] [B0000000-C0000000]: reserved
[INFO] [kernel] [FFC00000-100000000]: mmio
Is this normal? The UEFI spec implies that runtime services are always available.
Octocontrabass
Member
Member
Posts: 5567
Joined: Mon Mar 25, 2013 7:01 pm

Re: Question about QEMU and UEFI runtime services

Post by Octocontrabass »

Ethin wrote:Only CPU reset output appears. No interrupts are logged at all.
Try disabling KVM. I'm not sure why, but it seems QEMU can't log interrupts when using KVM.
Ethin wrote:As for the second question, my memory map shows no UEFI runtime services anywhere. Is this normal?
No. Some of those "free" entries should actually be reserved for runtime services.
Ethin
Member
Member
Posts: 625
Joined: Sun Jun 23, 2019 5:36 pm
Location: North Dakota, United States

Re: Question about QEMU and UEFI runtime services

Post by Ethin »

Okay. Thanks. I'm getting this weird triple fault that I can't diagnose (and it happens *after* my IDT and GDT are loaded, which is even weirder because both are valid) but I can't even verify its a triple fault because when I run my kernel qemu becomes a runaway. I've got -D int -d qemu2.log but it wrote over a gigabyte of logs to that file on interrupts alone before I terminated it. And I just find that really strange because that shouldn't be happening at all.
Post Reply