Comments (5)
Some observations:
- The weird interrupt frame stack in the output above indicates that the
x86-interrupt
calling convention is currently broken on the latest LLVM version. The values are all shifted by one field. For example,0x8
is the code segment, not the instruction pointer. And 518 are the CPU flags,0x10000201f48
is the stack pointer and the stack segment is 0. - Cause of the double fault:
- Using QEMU's
-d int
flag, I saw that the double fault occurs directly, without any other exception before. - By disassembling the kernel binary and grepping for the VirtAddr, I discovered that the double fault occurs on the
hlt
instruction. - This indicates that the double fault is not a CPU expection at all, but a misinterpreted interrupt from the PIC.
- If I keep interrupts disabled, the double fault disappears.
- If I remove the PIC remapping, the same double fault occurs. Now the fault is expected because the PIC is mapped to the same IDT entries as the CPU exceptions by default.
- So the issue seems to be that the PIC remapping doesn't work as expected.
- Using QEMU's
from blog_os.
It looks like the issue is that the .data
section is not correctly loaded. It is all zero after loading for some reason.
As a result, the PIC initialization fails, which cause the double fault once interrupts are enabled. Re-initializing the PIC at runtime before initialization seems to fix the issue:
let mut pics = interrupts::PICS.lock();
*pics =
unsafe { pic8259::ChainedPics::new(interrupts::PIC_1_OFFSET, interrupts::PIC_2_OFFSET) };
unsafe { pics.initialize() };
So the issue seems to be the loading of the static
, which is part of the .data
section.
from blog_os.
I found the issue and fixed it in rust-osdev/bootloader#424.
If you're affected by this, run cargo update -p bootloader
.
from blog_os.
I change the older nightly version but still got this problems.
$ rustc --version --verbose
rustc 1.77.0-nightly (11f32b73e 2024-01-31)
binary: rustc
commit-hash: 11f32b73e0dc9287e305b5b9980d24aecdc8c17f
commit-date: 2024-01-31
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6
I use the WSL2 in the ubuntu 22.04 in x86 computer.
from blog_os.
I change the older nightly version but still got this problems.
$ rustc --version --verbose rustc 1.77.0-nightly (11f32b73e 2024-01-31) binary: rustc commit-hash: 11f32b73e0dc9287e305b5b9980d24aecdc8c17f commit-date: 2024-01-31 host: x86_64-unknown-linux-gnu release: 1.77.0-nightly LLVM version: 17.0.6
I use the WSL2 in the ubuntu 22.04 in x86 computer.
Sorry, it turn out that i keep x86_64::instructions::interrupts::int3();
in my _start
function, and i think it cause the double fault. Everything works well when i remove this statement.
from blog_os.
Related Issues (20)
- Translate support me and Comment? HOT 1
- Where can i see APIC example? HOT 3
- data-layout error when running cargo build HOT 10
- GDB missing in edition 2
- Linker error in Post-02 with custom 32-bit bootloader HOT 9
- QEMU booting in endless looping at post-03 HOT 14
- cargo build --target x86_64-blog_os.json error[E0463]: can't find crate for `core` HOT 2
- Edition 3 post-2 build-dependencies problem HOT 4
- How to add USB support? HOT 5
- broken link HOT 2
- Edition 3: Published a new `lazy_heap` crate to streamline new version of heap allocation module HOT 1
- testing failed HOT 4
- question: Book print or `pdf` version? HOT 1
- Edition-3 Post 2 (booting): profiles for the non root package will be ignored
- Edition 3 Post 3: Compiler Error HOT 1
- Edition 3: Post 3: Proposal to change the contents of a certain code snippet
- bootloader seems to generated dead_code warnings HOT 2
- Should I follow edition 2 or 3? HOT 3
- Examples for APIC? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blog_os.