AHCI: Page fault when enumerating HBA memory space #1174
-
Can anyone explain why this would cause a page fault by overflowing the stack? Was able to narrow the source down to precisely that stage in the AHCI initialization process by attempting to print test lines onto the screen and seeing which point those test lines would no longer print due to the page fault panic. The point at which the test lines no longer print is at the very top of the "filter_map" closure. The only possibility I can think of is the use of heap-allocated structures ( |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
To further elaborate: it appears to be some sort of overflow. Attempts to access out-of-bounds memory addresses and when I go on to allocate a page at each offending address, it attempts to access even more out-of-bounds memory each and every time. Which is strange seeing as though creating a vector of disks shouldn't cause a stack overflow, and neither should what is essentially a clone of the Redox AHCI driver with kernel-mode-compatibility tweaking. |
Beta Was this translation helpful? Give feedback.
-
Nearly a whole month and an attempted complete rewrite of the AHCI driver later (by porting Aero's implementation instead of trying to rewrite Redox's since Aero is GPLv3 and so is my own kernel, so no licensing issues) I finally have a promising lead: Turns out QEMU is placing the ABAR in legacy I/O port space instead of MMIO space. The hilarious thing about this is I had to comment out the assertion check of the header type because for some reason it isn't seeing a zero (normal) there despite the fact that the pcics crate is correctly seeing it as a normal header. Is there any way to prevent this and/or force-enable MMIO disk access from the QEMU side of things? |
Beta Was this translation helpful? Give feedback.
-
Finally figured out the problem after taking to StackOverflow for help: the problem is rust-osdev/x86_64#396. |
Beta Was this translation helpful? Give feedback.
Finally figured out the problem after taking to StackOverflow for help: the problem is rust-osdev/x86_64#396.
SelectorErrorCode::index()
is performing a misaligned read of the bits in the selector code given by the fault.