rust-osdev / rust-osdev/bootloader

vga_printline causes GPF in stage_3 protected mode

Open
#217 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.7k
Forks
240
PR merge metrics
No merged PRs in 30d

Description

Hello I've been stepping through the bootloader code to learn more about osdev. Upon entering stage_3 I attempted to add a call vga_printline with a test string I defined in stage_3.s this caused repeated rebooting. I verified it wasn't just me invoking vga_printline incorrectly by adding jmp no_cpuid after call check_cpuid so as to simulate a no_cpuid result and invoke vga_printline as it was intended but received the same rebooting. Running qemu with -d int outputs check_exception old: 0x8 new 0xd which I believe is Double Fault -> GPF.

Some investigation revealed the faulting instruction is mov eax, vga_position line 121 in stage_2.s but I'm not sure why that would be. My method for determining this was not the best as I would mov a dummy value into edi then would check edi after the fault for the dummy value using qemu's monitor. If the dummy value was there I would move the instruction further along in the execution then repeat the process. So maybe double check this 😄 .

Steps to reproduce (using master branch):

  1. add jmp no_cpuid to line 17 in src/asm/stage_3.s
  2. in examples/basic create a disk image with cargo kimage
  3. invoke qemu-system-x86_64 --no-shutdown --no-reboot -drive format=raw,file=target/x86_64-custom/debug/boot-bios-basic_example.img -monitor stdio -d int (I believe the default runner behavior just exits immediately)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure from src/asm/stage_3.s by adding jmp no_cpuid, building the image with cargo kimage, and running the supplied QEMU command. Then inspect the execution around line 121 in stage_2.s, where mov eax, vga_position is reported as faulting, and trace the vga_printline call and protected-mode setup. Done means vga_printline no longer causes repeated rebooting in stage_3.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.