Investigate talc dealloc panic deadlock
This commit is contained in:
parent
79fe31e54f
commit
7002d2feab
25
Cargo.lock
generated
25
Cargo.lock
generated
@ -45,9 +45,9 @@ checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.9.4"
|
version = "2.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394"
|
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "build_const"
|
name = "build_const"
|
||||||
@ -177,11 +177,10 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lock_api"
|
name = "lock_api"
|
||||||
version = "0.4.13"
|
version = "0.4.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765"
|
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
|
||||||
"scopeguard",
|
"scopeguard",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -255,18 +254,18 @@ checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.101"
|
version = "1.0.103"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
|
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.40"
|
version = "1.0.41"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
@ -330,9 +329,9 @@ checksum = "5cdeee85371b1ec1f4b305c91787271a39f56b66e673bdbd73b7742150de5b0e"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.106"
|
version = "2.0.109"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
|
checksum = "2f17c7e013e88258aa9543dcbe81aca68a667a9ac37cd69c9fbc07858bfe0e2f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -361,9 +360,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.19"
|
version = "1.0.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
|
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "volatile"
|
name = "volatile"
|
||||||
|
|||||||
@ -5,13 +5,20 @@
|
|||||||
|
|
||||||
use crate::constants::KERNEL_BUILD_PROFILE;
|
use crate::constants::KERNEL_BUILD_PROFILE;
|
||||||
use crate::{LOGGER, LogLevel, format, log_info, log_trace, memory::HHDM_RESPONSE};
|
use crate::{LOGGER, LogLevel, format, log_info, log_trace, memory::HHDM_RESPONSE};
|
||||||
|
use crate::memory::alloc::boxed::Box;
|
||||||
use free_list::{PAGE_SIZE, PageLayout};
|
use free_list::{PAGE_SIZE, PageLayout};
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
use spin::Mutex;
|
||||||
use x86_64::{
|
use x86_64::{
|
||||||
PhysAddr, VirtAddr,
|
PhysAddr, VirtAddr,
|
||||||
registers::control::*,
|
registers::control::*,
|
||||||
structures::paging::{PageTable, PageTableFlags},
|
structures::paging::{PageTable, PageTableFlags},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
pub static ref KERNEL_PML4: Mutex<Option<Box<PageTable>>> = Mutex::new(None);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn switch_ptable() {
|
pub fn switch_ptable() {
|
||||||
let allocated_region = crate::memory::FREELIST
|
let allocated_region = crate::memory::FREELIST
|
||||||
.lock()
|
.lock()
|
||||||
@ -20,9 +27,20 @@ pub fn switch_ptable() {
|
|||||||
log_info!("Got region for new PML4: 0x{:x}", allocated_region.start());
|
log_info!("Got region for new PML4: 0x{:x}", allocated_region.start());
|
||||||
let pml4_start_vaddr = allocated_region.start() + HHDM_RESPONSE.offset() as usize;
|
let pml4_start_vaddr = allocated_region.start() + HHDM_RESPONSE.offset() as usize;
|
||||||
let pml4_ptr = pml4_start_vaddr as *mut PageTable;
|
let pml4_ptr = pml4_start_vaddr as *mut PageTable;
|
||||||
let mut pml4 = unsafe { crate::memory::alloc::boxed::Box::from_raw(pml4_ptr) };
|
|
||||||
*pml4 = PageTable::new();
|
/*
|
||||||
log_info!("Initialized page table at 0x{:p}", pml4);
|
Dropping this PML4 causes a deadlock. Here is why:
|
||||||
|
- The allocator, Talc, did not allocate the memory we built the PML4 in.
|
||||||
|
- When this function exits, the allocator is *locked*.
|
||||||
|
- The allocator is told to drop this PML4, and panics, because it was never "allocated" to begin with.
|
||||||
|
- The allocator panics.
|
||||||
|
- The panic function tries to call the logging code.
|
||||||
|
- The logging code tries to acquire lock on the allocator, but it will never get it, since it is locked
|
||||||
|
until the function finishes exiting. Which it won't, because the allocator panicked.
|
||||||
|
*/
|
||||||
|
//let mut pml4 = unsafe { crate::memory::alloc::boxed::Box::from_raw(pml4_ptr) };
|
||||||
|
//*pml4 = PageTable::new();
|
||||||
|
//log_info!("Initialized page table at 0x{:p}", pml4);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_mappings() {
|
pub fn get_mappings() {
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![feature(abi_x86_interrupt)]
|
#![feature(abi_x86_interrupt)]
|
||||||
|
#![feature(breakpoint)]
|
||||||
|
|
||||||
mod arch;
|
mod arch;
|
||||||
mod boot;
|
mod boot;
|
||||||
@ -160,6 +161,7 @@ unsafe extern "C" fn main() -> ! {
|
|||||||
log_info!("Virtualization provider: {:?}", virt_supported());
|
log_info!("Virtualization provider: {:?}", virt_supported());
|
||||||
|
|
||||||
arch::x86_64::paging::switch_ptable();
|
arch::x86_64::paging::switch_ptable();
|
||||||
|
log_info!("Made it this far");
|
||||||
|
|
||||||
panic!("Finished boot, but cannot start init because processes not implemented!");
|
panic!("Finished boot, but cannot start init because processes not implemented!");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
use core::panic::*;
|
use core::panic::*;
|
||||||
|
|
||||||
use crate::format;
|
|
||||||
use crate::{LOGGER, LogLevel};
|
use crate::{LOGGER, LogLevel};
|
||||||
|
use crate::format;
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
pub fn panic(info: &PanicInfo) -> ! {
|
pub fn panic(info: &PanicInfo) -> ! {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user