Skip to content

Instantly share code, notes, and snippets.

@jessicah
Last active September 23, 2015 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessicah/ee554151a4dc71323963 to your computer and use it in GitHub Desktop.
Save jessicah/ee554151a4dc71323963 to your computer and use it in GitHub Desktop.

The UEFI loader is causing a CPU panic both on hardware and in QEMU.

In order to test, you'll need a disk/disk image formatted with GPT, and a partition with the BFS type code and an x86_64 image built from [].

A quick summary of the fault is described in https://github.com/jessicah/haiku/commit/ca5c952aca13749b962d72445e725070cb67dfe7.

Quick and dirty steps to build on Haiku:

  mkdir -p generated/image
  mkdir -p generated/loader
  cd generated/image
  ../../configure --build-cross-tools x86_64 ../../../buildtools --use-gcc-pipe -j4
  jam -q -j4 @nightly-raw
  cd ../loader
  ../../configure --build-cross-tools x86_64 ../../../buildtools --boot-platform=efi --use-gcc-pipe -j4
  jam -q -j4 haiku_loader.efi

You can optimise by not building the cross-tools twice :p

Testing with QEMU will look similar to:

  qemu-system-x86_64 -smp cpus=2 -boot order=c -m 512 \
    -hda fat:loader/objects/haiku/x86_64/common/system/boot \
    -hdb harddisk.img -net none -bios OVMF.fd -no-reboot -serial stdio

You can create a copy-on-write disk image with:

  qemu-img create -f qcow2 -o backing_file=/dev/disk/scsi/0/0/0/raw harddisk.img

See https://github.com/jessicah/haiku/blob/efi.merge/src/system/boot/platform/efi/devices.cpp#L656-L679 for code you can change to hardcode UUID of the boot partition, and whether to call add_block_devices() or not.

CPU at 3.193 GHz
factors: 1344872 3193588122
Welcome to the Haiku boot loader!
ENTER: platform_add_boot_device
loaded image options length = 44 bytes
loaded image options data = 'fs0:\haiku_loader.efi0'
don't have a UUID, hard-coding one
Processing device path 0...
Adding a new ATAPI device...
address = 0x000000001c004338
added to device node list
guid: 00000000-0000-0000-0000000000000000
uuid = 00000000000000000000000000000000
Processing device path 1...
Adding a new ATAPI device...
address = 0x000000001c0045a8
added to device node list
guid: 19650dd6-b079-42db-a84e67cae73d81be
uuid = d60d651979b0db42a84e67cae73d81be
Processing device path 2...
Adding a new ATAPI device...
address = 0x000000001c004818
added to device node list
Processing device path 3...
The current ATAPI device = 0x000000001c004338
Adding a new partition...
address = 0x000000001c005088
uuid = fafd1abe000000000000000000000000
uuid = 8576347899e0d64bb9482ec5b9df8025
Processing device path 4...
The current ATAPI device = 0x000000001c0045a8
Adding a new partition...
address = 0x000000001c005148
uuid = ed812ea3ca0de54990c4b2d1b5d5a769
uuid = 8576347899e0d64bb9482ec5b9df8025
Processing device path 5...
The current ATAPI device = 0x000000001c0045a8
Adding a new partition...
address = 0x000000001c005208
uuid = 33a77d99ba640d4bbb2adf22c63974d7
uuid = 8576347899e0d64bb9482ec5b9df8025
Processing device path 6...
The current ATAPI device = 0x000000001c0045a8
Adding a new partition...
address = 0x000000001c0052c8
uuid = 30ba4016e7937c4ab7215adfb5317685
uuid = 8576347899e0d64bb9482ec5b9df8025
Processing device path 7...
The current ATAPI device = 0x000000001c0045a8
Adding a new partition...
address = 0x000000001c005388
uuid = 8576347899e0d64bb9482ec5b9df8025
uuid = 8576347899e0d64bb9482ec5b9df8025
boot partition offset = 957241344
Processing device path 8...
The current ATAPI device = 0x000000001c0045a8
Adding a new partition...
address = 0x000000001c005448
uuid = bc4f4d29803d3043801647e6670f6a5e
uuid = 8576347899e0d64bb9482ec5b9df8025
Processing device path 9...
Processing device path 10...
Finished processing devices & partitions
EXIT: platform_add_boot_device: shouldn't know which volume to boot from...
add_partitions_for(0x000000001c0045a8, mountFS = no)
!!!! X64 Exception Type - 06(#UD - Invalid Opcode) CPU Apic ID - 00000000 !!!!
RIP - 000000000009F001, CS - 0000000000000028, RFLAGS - 0000000000000206
RAX - 0000000000000010, RCX - 00000000000003F8, RDX - 0000000000000000
RBX - 0000000000000003, RSP - 000000001FF5C5A8, RBP - 000000001FF5C5E0
RSI - 000000001FF5C5B8, RDI - 000000001C0045A8
R8 - 0000000000000003, R9 - 0000000000000000, R10 - 00000000FFFFFFFF
R11 - 0000000000000008, R12 - 000000001C0045A8, R13 - 0000000000000001
R14 - 000000001E0600A0, R15 - 0000000000000000
DS - 0000000000000008, ES - 0000000000000008, FS - 0000000000000008
GS - 0000000000000008, SS - 0000000000000008
CR0 - 0000000080000033, CR2 - 0000000000000000, CR3 - 000000001FEFB000
CR4 - 0000000000000668, CR8 - 0000000000000000
DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
GDTR - 000000001FEDFF18 000000000000003F, LDTR - 0000000000000000
IDTR - 000000001F81A018 0000000000000FFF, TR - 0000000000000000
FXSAVE_STATE - 000000001FF5C200
!!!! Can't find image information. !!!!
CPU at 3.193 GHz
factors: 1344788 3193785413
Welcome to the Haiku boot loader!
ENTER: platform_add_boot_device
loaded image options length = 44 bytes
loaded image options data = 'fs0:\haiku_loader.efi0'
don't have a UUID, hard-coding one
EXIT: platform_add_boot_device: not adding block devices
no boot path found, scan for all partitions...
ENTER: platform_add_block_devices
Processing device path 0...
Processing device path 1...
Processing device path 2...
Processing device path 3...
Adding a new partition...
address = 0x000000001c004338
uuid = fafd1abe000000000000000000000000
uuid = 8576347899e0d64bb9482ec5b9df8025
added to partition node list
Processing device path 4...
Adding a new partition...
address = 0x000000001c0043f8
uuid = ed812ea3ca0de54990c4b2d1b5d5a769
uuid = 8576347899e0d64bb9482ec5b9df8025
added to partition node list
Processing device path 5...
Adding a new partition...
address = 0x000000001c0044b8
uuid = 33a77d99ba640d4bbb2adf22c63974d7
uuid = 8576347899e0d64bb9482ec5b9df8025
added to partition node list
Processing device path 6...
Adding a new partition...
address = 0x000000001c004578
uuid = 30ba4016e7937c4ab7215adfb5317685
uuid = 8576347899e0d64bb9482ec5b9df8025
added to partition node list
Processing device path 7...
Adding a new partition...
address = 0x000000001c004638
uuid = 8576347899e0d64bb9482ec5b9df8025
uuid = 8576347899e0d64bb9482ec5b9df8025
added to partition node list
Processing device path 8...
Adding a new partition...
address = 0x000000001c0046f8
uuid = bc4f4d29803d3043801647e6670f6a5e
uuid = 8576347899e0d64bb9482ec5b9df8025
added to partition node list
Processing device path 9...
Processing device path 10...
Finished processing devices & partitions
EXIT: platform_add_block_devices
add_partitions_for(0x000000001c004338, mountFS = yes)
add_partitions_for(fd = 0, mountFS = yes)
0x000000001c0047e0 Partition::Partition
0x000000001c0047e0 Partition::Scan()
check for partitioning_system: GUID Partition Map
check for partitioning_system: Intel Partition Map
priority: 500
check for partitioning_system: Intel Extended Partition
0x000000001c0047e0 Partition::~Partition
add_partitions_for(0x000000001c0043f8, mountFS = yes)
add_partitions_for(fd = 0, mountFS = yes)
0x000000001c0047e0 Partition::Partition
0x000000001c0047e0 Partition::Scan()
check for partitioning_system: GUID Partition Map
check for partitioning_system: Intel Partition Map
priority: 500
check for partitioning_system: Intel Extended Partition
0x000000001c0047e0 Partition::_Mount check for file_system: BFS Filesystem
0x000000001c0047e0 Partition::_Mount check for file_system: FAT32 Filesystem
add_partitions_for(0x000000001c0044b8, mountFS = yes)
add_partitions_for(fd = 2, mountFS = yes)
0x000000001c005138 Partition::Partition
0x000000001c005138 Partition::Scan()
check for partitioning_system: GUID Partition Map
check for partitioning_system: Intel Partition Map
check for partitioning_system: Intel Extended Partition
0x000000001c005138 Partition::_Mount check for file_system: BFS Filesystem
0x000000001c005138 Partition::_Mount check for file_system: FAT32 Filesystem
0x000000001c005138 Partition::_Mount check for file_system: TAR Filesystem
0x000000001c005138 Partition::~Partition
add_partitions_for(0x000000001c004578, mountFS = yes)
add_partitions_for(fd = 2, mountFS = yes)
0x000000001c005138 Partition::Partition
0x000000001c005138 Partition::Scan()
check for partitioning_system: GUID Partition Map
check for partitioning_system: Intel Partition Map
check for partitioning_system: Intel Extended Partition
0x000000001c005138 Partition::_Mount check for file_system: BFS Filesystem
add_partitions_for(0x000000001c004638, mountFS = yes)
add_partitions_for(fd = 4, mountFS = yes)
0x000000001c005768 Partition::Partition
0x000000001c005768 Partition::Scan()
check for partitioning_system: GUID Partition Map
check for partitioning_system: Intel Partition Map
check for partitioning_system: Intel Extended Partition
0x000000001c005768 Partition::_Mount check for file_system: BFS Filesystem
add_partitions_for(0x000000001c0046f8, mountFS = yes)
add_partitions_for(fd = 6, mountFS = yes)
0x000000001c005d98 Partition::Partition
0x000000001c005d98 Partition::Scan()
check for partitioning_system: GUID Partition Map
check for partitioning_system: Intel Partition Map
check for partitioning_system: Intel Extended Partition
0x000000001c005d98 Partition::_Mount check for file_system: BFS Filesystem
PackageVolumeInfo::SetTo()
old state directory "state_2015-09-12_03:35:42"
old state directory "state_2015-09-12_03:40:50"
old state directory "state_2015-09-12_03:45:28"
old state directory "state_2015-09-12_04:08:37"
old state directory "state_2015-09-12_04:44:06"
old state directory "state_2015-09-12_09:12:49"
old state directory "state_2015-09-13_02:45:26"
old state directory "state_2015-09-13_03:01:35"
old state directory "state_2015-09-13_03:08:56"
old state directory "state_2015-09-13_03:18:53"
old state directory "state_2015-09-13_03:34:11"
old state directory "state_2015-09-13_04:15:07"
old state directory "state_2015-09-13_06:28:24"
old state directory "state_2015-09-13_06:56:11"
old state directory "state_2015-09-13_07:01:17"
old state directory "state_2015-09-14_23:28:33"
old state directory "state_2015-09-14_23:54:03"
old state directory "state_2015-09-15_00:00:29"
old state directory "state_2015-09-15_00:32:02"
old state directory "state_2015-09-15_00:56:21"
old state directory "state_2015-09-15_01:20:10"
old state directory "state_2015-09-15_01:30:40"
old state directory "state_2015-09-15_01:56:06"
old state directory "state_2015-09-15_09:13:22"
old state directory "state_2015-09-16_23:12:04"
old state directory "state_2015-09-16_23:21:30"
old state directory "state_2015-09-18_09:44:38"
old state directory "state_2015-09-20_08:44:31"
old state directory "state_2015-09-23_13:13:22"
old state directory "state_2015-09-23_13:13:48"
old state directory "state_2015-09-23_13:27:06"
PackageVolumeInfo::SetTo()
old state directory "state_2015-09-12_03:35:42"
old state directory "state_2015-09-12_03:40:50"
old state directory "state_2015-09-12_03:45:28"
old state directory "state_2015-09-12_04:08:37"
old state directory "state_2015-09-12_04:44:06"
old state directory "state_2015-09-12_09:12:49"
old state directory "state_2015-09-13_02:45:26"
old state directory "state_2015-09-13_03:01:35"
old state directory "state_2015-09-13_03:08:56"
old state directory "state_2015-09-13_03:18:53"
old state directory "state_2015-09-13_03:34:11"
old state directory "state_2015-09-13_04:15:07"
old state directory "state_2015-09-13_06:28:24"
old state directory "state_2015-09-13_06:56:11"
old state directory "state_2015-09-13_07:01:17"
old state directory "state_2015-09-14_23:28:33"
old state directory "state_2015-09-14_23:54:03"
old state directory "state_2015-09-15_00:00:29"
old state directory "state_2015-09-15_00:32:02"
old state directory "state_2015-09-15_00:56:21"
old state directory "state_2015-09-15_01:20:10"
old state directory "state_2015-09-15_01:30:40"
old state directory "state_2015-09-15_01:56:06"
old state directory "state_2015-09-15_09:13:22"
old state directory "state_2015-09-16_23:12:04"
old state directory "state_2015-09-16_23:21:30"
old state directory "state_2015-09-18_09:44:38"
old state directory "state_2015-09-20_08:44:31"
old state directory "state_2015-09-23_13:13:22"
old state directory "state_2015-09-23_13:13:48"
old state directory "state_2015-09-23_13:27:06"
PackageVolumeInfo::SetTo()
old state directory "state_2015-09-23_08:47:59"
old state directory "state_2015-09-23_09:07:14"
PackageVolumeInfo::SetTo()
old state directory "state_2015-09-23_08:47:59"
old state directory "state_2015-09-23_09:07:14"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment