Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triple fault during kernel loading on ASUS UX303L #441

Open
apache-hb opened this issue Dec 27, 2024 · 4 comments
Open

Triple fault during kernel loading on ASUS UX303L #441

apache-hb opened this issue Dec 27, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@apache-hb
Copy link

Laptop

Component Name
Model ASUS UX303L
BIOS American Megatrends v204 (2.15.1236) Released 2012
GOP Version 5.0.1036
EC Version B01S090301
Processor Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz
Total Memory 8192 MB
Intel Virtualization Technology [Enabled]
Intel AES-NI [Enabled]
Fast Boot [Disabled]
Launch CSM [Disabled]
Secure Boot Control [Disabled]
Boot Mode UEFI Only

USB Drive

Component Name
Name Netac OnlyDisk USB Device 64GB

I copied template-x86_64.iso onto the drive using rufus in ISO mode, but observed identical behaviour with DD mode as well as flashing from a linux host onto the USB drive.

Limine

Component Name
Limine prebuilt from git clone https://github.com/limine-bootloader/limine.git --branch=v8.x-binary
Template https://github.com/limine-bootloader/limine-c-template.git cloned 26-12-2024

Expected behaviour

A kernel is loaded and executes.

Actual behaviour

Limine displays the boot prompt and all other menus successfully. But when loading a kernel the system resets.

Tested with limine-c-template cloned 26-12-2024 and my own kernel, neither of which loaded.

Build log

elliothb@ELLIOT-SERVER:~/github$ git clone https://github.com/limine-bootloader/limine-c-template.git
Cloning into 'limine-c-template'...
remote: Enumerating objects: 688, done.
remote: Counting objects: 100% (214/214), done.
remote: Compressing objects: 100% (128/128), done.
remote: Total 688 (delta 154), reused 134 (delta 83), pack-reused 474 (from 1)
Receiving objects: 100% (688/688), 91.48 KiB | 1.41 MiB/s, done.
Resolving deltas: 100% (420/420), done.
elliothb@ELLIOT-SERVER:~/github$ cd limine-c-template/
elliothb@ELLIOT-SERVER:~/github/limine-c-template$ gmake all
rm -rf limine
git clone https://github.com/limine-bootloader/limine.git --branch=v8.x-binary --depth=1
Cloning into 'limine'...
remote: Enumerating objects: 19, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 19 (delta 6), reused 11 (delta 6), pack-reused 0 (from 0)
Receiving objects: 100% (19/19), 797.20 KiB | 2.42 MiB/s, done.
Resolving deltas: 100% (6/6), done.
gmake -C limine \
        CC="cc" \
        CFLAGS="-g -O2 -pipe" \
        CPPFLAGS="" \
        LDFLAGS="" \
        LIBS=""
gmake[1]: Entering directory '/home/elliothb/github/limine-c-template/limine'
cc -g -O2 -pipe -Wall -Wextra    -std=c99 limine.c  -o limine
gmake[1]: Leaving directory '/home/elliothb/github/limine-c-template/limine'
./kernel/get-deps
+ dirname ./kernel/get-deps
+ srcdir=./kernel
+ test -z ./kernel
+ cd ./kernel
+ clone_repo_commit https://github.com/osdev0/freestnd-c-hdrs-0bsd.git freestnd-c-hdrs-0bsd 0353851fdebe0eb6a4d2c608c5393040d310bf35
+ test -d freestnd-c-hdrs-0bsd/.git
+ test -d freestnd-c-hdrs-0bsd
+ test -d freestnd-c-hdrs-0bsd
+ git clone https://github.com/osdev0/freestnd-c-hdrs-0bsd.git freestnd-c-hdrs-0bsd
Cloning into 'freestnd-c-hdrs-0bsd'...
remote: Enumerating objects: 186, done.
remote: Counting objects: 100% (186/186), done.
remote: Compressing objects: 100% (129/129), done.
remote: Total 186 (delta 121), reused 118 (delta 56), pack-reused 0 (from 0)
Receiving objects: 100% (186/186), 28.03 KiB | 1.75 MiB/s, done.
Resolving deltas: 100% (121/121), done.
+ git -C freestnd-c-hdrs-0bsd checkout 0353851fdebe0eb6a4d2c608c5393040d310bf35
Note: switching to '0353851fdebe0eb6a4d2c608c5393040d310bf35'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 0353851 Update macro names and include guards
+ clone_repo_commit https://github.com/osdev0/cc-runtime.git cc-runtime 9c281448fe40498a6341d74f55c9af4f642c0b1d
+ test -d cc-runtime/.git
+ test -d cc-runtime
+ test -d cc-runtime
+ git clone https://github.com/osdev0/cc-runtime.git cc-runtime
Cloning into 'cc-runtime'...
remote: Enumerating objects: 399, done.
remote: Counting objects: 100% (35/35), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 399 (delta 30), reused 30 (delta 29), pack-reused 364 (from 1)
Receiving objects: 100% (399/399), 145.13 KiB | 2.27 MiB/s, done.
Resolving deltas: 100% (290/290), done.
+ git -C cc-runtime checkout 9c281448fe40498a6341d74f55c9af4f642c0b1d
Note: switching to '9c281448fe40498a6341d74f55c9af4f642c0b1d'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 9c28144 Misc build system updates
+ download_by_hash https://github.com/limine-bootloader/limine/raw/7cddb61183685d9bddd2eb13d42223d929c2abe6/limine.h src/limine.h c00e7d4cd6e2674eca481f978b64a7fb8c8479cc32c466ec35aad2207761bf01
+ DOWNLOAD_COMMAND=curl -Lo
+ command -v curl -Lo
+ SHA256_COMMAND=sha256sum
+ command -v sha256sum
+ test -f src/limine.h
+ rm -f src/limine.h
+ mkdir -p src/limine.h
+ rm -rf src/limine.h
+ curl -Lo src/limine.h https://github.com/limine-bootloader/limine/raw/7cddb61183685d9bddd2eb13d42223d929c2abe6/limine.h
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 18604  100 18604    0     0  47287      0 --:--:-- --:--:-- --:--:-- 47287
+ sha256sum src/limine.h
+ grep c00e7d4cd6e2674eca481f978b64a7fb8c8479cc32c466ec35aad2207761bf01
touch kernel-deps
gmake -C kernel
gmake[1]: Entering directory '/home/elliothb/github/limine-c-template/kernel'
mkdir -p "$(dirname obj-x86_64/main.c.o)"
cc -g -O2 -pipe -Wall -Wextra -std=gnu11 -nostdinc -ffreestanding -fno-stack-protector -fno-stack-check -fno-PIC -ffunction-sections -fdata-sections -m64 -march=x86-64 -mno-80387 -mno-mmx -mno-sse -mno-sse2 -mno-red-zone -mcmodel=kernel -I src -isystem freestnd-c-hdrs-0bsd  -DLIMINE_API_REVISION=2 -MMD -MP -c src/main.c -o obj-x86_64/main.c.o
rm -rf cc-runtime-x86_64
cp -r cc-runtime cc-runtime-x86_64
gmake -C cc-runtime-x86_64 -f cc-runtime.mk \
        CC="cc" \
        AR="ar" \
        CFLAGS="-g -O2 -pipe -Wall -Wextra -std=gnu11 -nostdinc -ffreestanding -fno-stack-protector -fno-stack-check -fno-PIC -ffunction-sections -fdata-sections -m64 -march=x86-64 -mno-80387 -mno-mmx -mno-sse -mno-sse2 -mno-red-zone -mcmodel=kernel" \
        CPPFLAGS='-isystem ../freestnd-c-hdrs-0bsd -DCC_RUNTIME_NO_FLOAT'
gmake[2]: Entering directory '/home/elliothb/github/limine-c-template/kernel/cc-runtime-x86_64'
Building cc-runtime.a...
-rw-r--r-- 1 elliothb elliothb 537852 Dec 27 13:25 cc-runtime.a
Done.
gmake[2]: Leaving directory '/home/elliothb/github/limine-c-template/kernel/cc-runtime-x86_64'
mkdir -p "$(dirname bin-x86_64/kernel)"
cc -g -O2 -pipe -Wall -Wextra -std=gnu11 -nostdinc -ffreestanding -fno-stack-protector -fno-stack-check -fno-PIC -ffunction-sections -fdata-sections -m64 -march=x86-64 -mno-80387 -mno-mmx -mno-sse -mno-sse2 -mno-red-zone -mcmodel=kernel -Wl,-m,elf_x86_64 -Wl,--build-id=none -nostdlib -static -z max-page-size=0x1000 -Wl,--gc-sections -T linker-x86_64.ld obj-x86_64/main.c.o cc-runtime-x86_64/cc-runtime.a -o bin-x86_64/kernel
gmake[1]: Leaving directory '/home/elliothb/github/limine-c-template/kernel'
rm -rf iso_root
mkdir -p iso_root/boot
cp -v kernel/bin-x86_64/kernel iso_root/boot/
'kernel/bin-x86_64/kernel' -> 'iso_root/boot/kernel'
mkdir -p iso_root/boot/limine
cp -v limine.conf iso_root/boot/limine/
'limine.conf' -> 'iso_root/boot/limine/limine.conf'
mkdir -p iso_root/EFI/BOOT
cp -v limine/limine-bios.sys limine/limine-bios-cd.bin limine/limine-uefi-cd.bin iso_root/boot/limine/
'limine/limine-bios.sys' -> 'iso_root/boot/limine/limine-bios.sys'
'limine/limine-bios-cd.bin' -> 'iso_root/boot/limine/limine-bios-cd.bin'
'limine/limine-uefi-cd.bin' -> 'iso_root/boot/limine/limine-uefi-cd.bin'
cp -v limine/BOOTX64.EFI iso_root/EFI/BOOT/
'limine/BOOTX64.EFI' -> 'iso_root/EFI/BOOT/BOOTX64.EFI'
cp -v limine/BOOTIA32.EFI iso_root/EFI/BOOT/
'limine/BOOTIA32.EFI' -> 'iso_root/EFI/BOOT/BOOTIA32.EFI'
xorriso -as mkisofs -R -r -J -b boot/limine/limine-bios-cd.bin \
        -no-emul-boot -boot-load-size 4 -boot-info-table -hfsplus \
        -apm-block-size 2048 --efi-boot boot/limine/limine-uefi-cd.bin \
        -efi-boot-part --efi-boot-image --protective-msdos-label \
        iso_root -o template-x86_64.iso
xorriso 1.5.4 : RockRidge filesystem manipulator, libburnia project.

Drive current: -outdev 'stdio:template-x86_64.iso'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data,  154g free
Added to ISO image: directory '/'='/home/elliothb/github/limine-c-template/iso_root'
xorriso : UPDATE :      11 files added in 1 seconds
xorriso : UPDATE :      11 files added in 1 seconds
ISO image produced: 2014 sectors
Written to medium : 2014 sectors at LBA 0
Writing to 'stdio:template-x86_64.iso' completed successfully.

./limine/limine bios-install template-x86_64.iso
Physical block size of 512 bytes.
Installing to GPT. Logical block size of 512 bytes.
Secondary header at LBA 0x1f77.
Secondary header valid.
GPT partition NOT specified. Attempting GPT embedding.
New maximum count of partition entries: 44.
Stage 2 to be located at 0x3e00 and 0x3eac00.
Reminder: Remember to copy the limine-bios.sys file in either
          the root, /boot, /limine, or /boot/limine directories of
          one of the partitions on the device, or boot will fail!
Limine BIOS stages installed successfully!
rm -rf iso_root
elliothb@ELLIOT-SERVER:~/github/limine-c-template$ 

@apache-hb
Copy link
Author

Video demonstrating the issue.

20241227_141347.mp4

@apache-hb
Copy link
Author

I've narrowed down the reset to somewhere in these lines
https://github.com/limine-bootloader/limine/blob/v8.x/common/protos/limine_32.asm_x86#L76-L92

@apache-hb
Copy link
Author

More testing narrowed it down to the call .p2 instruction

@apache-hb
Copy link
Author

Some more discussion happened on discord, these are the important bits:

  • Limine produces a very strange memory map, inspecting the UEFI memory map with the UEFI shell is mostly normal.
  • The memory map changes between system resets.

Possible issues are either the stack pointer being incorrect, or the memory mappings for the higher half being incorrect.

@mintsuki mintsuki added the bug Something isn't working label Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants