fix(boot): a parked processor takes no processor index and no heap cache, where every processor parked before the firmware's AML took both, so the PEs' processors came after them and on a PC of more than 32 threads ran without a heap cache of their own
This commit is contained in:
1 parent
81ea469eb4
commit
effd5be415
3 files changed
+43
-8
No files matched your search
@@ -279,6 +279,11 @@ pub(crate) unsafe fn configure_xstate(
|
||||
/// How many processors have become active.
|
||||
static ACTIVE: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
/// The index of a processor that only idles parked: past every running
|
||||
/// processor's, and not `u32::MAX`, which the step watchdog's records read
|
||||
/// as none.
|
||||
pub(crate) const PARKED: u32 = u32::MAX - 1;
|
||||
|
||||
/// How many processors have become active: each one's [`processor`] is
|
||||
/// below it.
|
||||
#[cfg(feature = "nvk")]
|
||||
@@ -300,6 +305,7 @@ pub(crate) unsafe fn activate(
|
||||
local: &mut Local,
|
||||
handler: super::super::interrupts::Handler,
|
||||
tables: *const super::super::interrupts::Tables,
|
||||
parked: bool,
|
||||
) {
|
||||
assert!(
|
||||
local.this.is_null(),
|
||||
@@ -311,14 +317,23 @@ pub(crate) unsafe fn activate(
|
||||
);
|
||||
local.handler = handler;
|
||||
local.entry_tables = tables;
|
||||
local.index = ACTIVE.fetch_add(1, Ordering::Relaxed);
|
||||
// A parked processor takes no dense index, which the running ones'
|
||||
// per-processor records are sized by, and no heap cache: it never
|
||||
// allocates but in the fatal report, which takes the heap's lock.
|
||||
local.index = if parked {
|
||||
PARKED
|
||||
} else {
|
||||
ACTIVE.fetch_add(1, Ordering::Relaxed)
|
||||
};
|
||||
local.this = local;
|
||||
// SAFETY: the descriptor owner pins this private record for the CPU lifetime.
|
||||
unsafe { set_base(local as *mut Local as u64) };
|
||||
// SAFETY: the pinned record at this processor's new GS base, and no
|
||||
// processor allocates before it gets here: the boot processor's first
|
||||
// is this call, and an AP's entry reaches here first.
|
||||
unsafe { crate::ALLOCATOR.tag_cpu(local.heap_core.get()) };
|
||||
if !parked {
|
||||
// SAFETY: the pinned record at this processor's new GS base, and no
|
||||
// processor allocates before it gets here: the boot processor's first
|
||||
// is this call, and an AP's entry reaches here first.
|
||||
unsafe { crate::ALLOCATOR.tag_cpu(local.heap_core.get()) };
|
||||
}
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
@@ -363,7 +378,8 @@ pub(crate) fn activated_base() -> u64 {
|
||||
current() as u64
|
||||
}
|
||||
|
||||
/// This processor's index, dense from zero. Once [`activate`] has run on it.
|
||||
/// This processor's index, dense from zero, or [`PARKED`]. Once [`activate`]
|
||||
/// has run on it.
|
||||
/// The BSP installs its record before any AP starts.
|
||||
pub(crate) fn processor() -> u32 {
|
||||
// SAFETY: the record is pinned for the processor's life, and `index` is set
|
||||
|
||||
@@ -571,6 +571,25 @@ pub(crate) unsafe fn enable_avx() {
|
||||
/// for its whole lifetime, including its parked state. Interrupts are disabled;
|
||||
/// no native execution/handler can still refer to preceding tables or GS state.
|
||||
pub(crate) unsafe fn install_on(tables: &'static mut Tables, handler: Handler) {
|
||||
// SAFETY: the caller's.
|
||||
unsafe { install_tables(tables, handler, false) }
|
||||
}
|
||||
|
||||
/// [`install_on`] for a processor that only idles parked: it takes no
|
||||
/// processor index and no heap cache of the running processors'
|
||||
/// (`host::local::activate`).
|
||||
///
|
||||
/// # Safety
|
||||
/// As [`install_on`], and the processor runs nothing but its idle loop and
|
||||
/// the fatal report.
|
||||
pub(crate) unsafe fn install_parked(tables: &'static mut Tables, handler: Handler) {
|
||||
// SAFETY: the caller's.
|
||||
unsafe { install_tables(tables, handler, true) }
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
/// As [`install_on`].
|
||||
unsafe fn install_tables(tables: &'static mut Tables, handler: Handler, parked: bool) {
|
||||
if tables.xstate.is_some() {
|
||||
output::fatal("native xstate descriptor owner cannot be reinstalled");
|
||||
}
|
||||
@@ -643,7 +662,7 @@ pub(crate) unsafe fn install_on(tables: &'static mut Tables, handler: Handler) {
|
||||
// Loading a GS selector above resets its base; establish the private
|
||||
// CPL0 record after GDT/segment setup, before making our IDT active.
|
||||
let retained_tables = tables as *const Tables;
|
||||
host::local::activate(&mut tables.local, handler, retained_tables);
|
||||
host::local::activate(&mut tables.local, handler, retained_tables, parked);
|
||||
let idt = &raw mut tables.idt;
|
||||
let table = &stela_vector_table;
|
||||
for (&vector, &handler) in VECTOR_NUMBERS.iter().zip(table) {
|
||||
|
||||
@@ -122,7 +122,7 @@ unsafe extern "sysv64" fn enter(argument: u64) -> ! {
|
||||
};
|
||||
// SAFETY: interrupts are masked since the trampoline; the tables are
|
||||
// this processor's and leaked, and nothing used the trampoline's own.
|
||||
unsafe { interrupts::install_on(tables, interrupt) };
|
||||
unsafe { interrupts::install_parked(tables, interrupt) };
|
||||
if parking.x2apic {
|
||||
// SAFETY: CPL0 with interrupts masked; this processor makes no APIC
|
||||
// handle.
|
||||
|
||||
Reference in new issue
Block a user