feat(boot): gate hardware fixtures behind diagnostics
This commit is contained in:
1 parent
21f3ad4280
commit
bfd0c0c565
24 files changed
+357
-218
No files matched your search
@@ -88,6 +88,7 @@ pub enum Base {
|
||||
}
|
||||
|
||||
impl Base {
|
||||
/// Parse and check one option line.
|
||||
pub fn parse(text: &str) -> Result<Self, &'static str> {
|
||||
let Some(register) = text.strip_prefix('x') else {
|
||||
return Ok(Self::Address(number(text)?));
|
||||
@@ -423,7 +424,23 @@ impl System {
|
||||
Ok(options)
|
||||
}
|
||||
|
||||
/// Parse and check one option line.
|
||||
/// The first authored fixture requested by these typed options. Shared
|
||||
/// parsing remains stable across mounts; production mounts reject a fixture
|
||||
/// before taking over hardware.
|
||||
pub fn diagnostic_option(&self) -> Option<&'static str> {
|
||||
[
|
||||
(self.native_memory_check, "--native-memory-check"),
|
||||
(self.native_mmio_check, "--native-mmio-check"),
|
||||
(self.native_clock_check, "--native-clock-check"),
|
||||
(self.native_bootstrap_check, "--native-bootstrap-check"),
|
||||
(self.native_shared_check, "--native-shared-check"),
|
||||
(self.audio_check.is_some(), "--audio-check"),
|
||||
(self.network_check.is_some(), "--network-check"),
|
||||
]
|
||||
.into_iter()
|
||||
.find_map(|(enabled, flag)| enabled.then_some(flag))
|
||||
}
|
||||
|
||||
pub fn parse(text: &str) -> Result<Self, &'static str> {
|
||||
let mut options = Self::default();
|
||||
let mut words = text.split_ascii_whitespace();
|
||||
@@ -1052,6 +1069,31 @@ mod tests {
|
||||
use super::*;
|
||||
use alloc::{format, string::ToString, vec};
|
||||
|
||||
#[test]
|
||||
fn diagnostic_options_are_typed() {
|
||||
for text in ["--system", "--system --wifi --native-memory-check"] {
|
||||
assert_eq!(System::parse(text).unwrap().diagnostic_option(), None);
|
||||
}
|
||||
for (text, flag) in [
|
||||
("--system --native-memory-check", "--native-memory-check"),
|
||||
(
|
||||
"--system --native-cores 1 --native-clock-check",
|
||||
"--native-clock-check",
|
||||
),
|
||||
("--system --native-mmio-check", "--native-mmio-check"),
|
||||
(
|
||||
"--system --native-cores 2 --native-bootstrap-check",
|
||||
"--native-bootstrap-check",
|
||||
),
|
||||
(
|
||||
"--system --native-cores 2 --native-shared-check",
|
||||
"--native-shared-check",
|
||||
),
|
||||
] {
|
||||
assert_eq!(System::parse(text).unwrap().diagnostic_option(), Some(flag));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn host_check_lines_round_trip_and_refuse_combined_fixtures() {
|
||||
let line = "--host-check --native-dma-check \
|
||||
|
||||
@@ -25,6 +25,8 @@ test = false
|
||||
[workspace]
|
||||
|
||||
[features]
|
||||
default = []
|
||||
diagnostics = []
|
||||
native-profile = ["stela-runtime/native-profile"]
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -90,6 +90,7 @@ pub(crate) enum StartupError {
|
||||
DeliveryTimeout,
|
||||
}
|
||||
pub const LVT_MASKED: u32 = 1 << 16;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub const TIMER_PERIODIC: u32 = 1 << 17;
|
||||
const SOFTWARE_ENABLE: u32 = 1 << 8;
|
||||
const DIVIDE_BY_ONE: u32 = 0b1011;
|
||||
|
||||
@@ -170,11 +170,13 @@ impl Framebuffer {
|
||||
}
|
||||
|
||||
/// Pixels per row in memory, at least the width.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub fn stride(&self) -> usize {
|
||||
self.stride
|
||||
}
|
||||
|
||||
/// The mode's pixel layout, as GOP names it.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub fn format(&self) -> &'static str {
|
||||
match self.encoding {
|
||||
Encoding::Bgr => "BGR",
|
||||
@@ -185,6 +187,7 @@ impl Framebuffer {
|
||||
|
||||
/// The same mode with only its top `height` rows, so that text written
|
||||
/// to it leaves the rows below for something else.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub fn top(self, height: usize) -> Self {
|
||||
Self {
|
||||
height: height.min(self.height),
|
||||
@@ -203,6 +206,7 @@ impl Framebuffer {
|
||||
}
|
||||
|
||||
/// The pixel value of a colour in this mode's layout.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub fn rgb(&self, red: u8, green: u8, blue: u8) -> u32 {
|
||||
let (red, green, blue) = (u32::from(red), u32::from(green), u32::from(blue));
|
||||
self.encoding.encode((red << 16) | (green << 8) | blue)
|
||||
@@ -221,6 +225,7 @@ impl Framebuffer {
|
||||
}
|
||||
|
||||
/// The pixel at (`x`, `y`), which is visible.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub fn read(&self, x: usize, y: usize) -> u32 {
|
||||
assert!(x < self.width && y < self.height, "pixel outside the mode");
|
||||
let line = (self.base + y * self.stride * BYTES_PER_PIXEL) as *const u32;
|
||||
|
||||
+16
-203
@@ -4,21 +4,21 @@
|
||||
//! CMPXCHG16B, LAHF/SAHF in 64-bit mode) and NX for its page tables.
|
||||
pub mod msr;
|
||||
|
||||
use Register::{Eax, Ebx, Ecx, Edx};
|
||||
use alloc::{format, string::String, vec, vec::Vec};
|
||||
#[cfg(feature = "diagnostics")]
|
||||
use Register::{Eax, Ebx};
|
||||
use Register::{Ecx, Edx};
|
||||
#[cfg(feature = "diagnostics")]
|
||||
mod report;
|
||||
use core::arch::x86_64::{__cpuid, __cpuid_count, CpuidResult};
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub use report::*;
|
||||
|
||||
const EXTENDED: u32 = 0x8000_0000;
|
||||
const VENDOR: u32 = 0;
|
||||
const VERSION: u32 = 1;
|
||||
const BRAND: [u32; 3] = [0x8000_0002, 0x8000_0003, 0x8000_0004];
|
||||
const ADDRESS_SIZES: u32 = 0x8000_0008;
|
||||
const TSC_CRYSTAL: u32 = 0x15;
|
||||
const FREQUENCY: u32 = 0x16;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum Register {
|
||||
#[cfg(feature = "diagnostics")]
|
||||
Eax,
|
||||
#[cfg(feature = "diagnostics")]
|
||||
Ebx,
|
||||
Ecx,
|
||||
Edx,
|
||||
@@ -27,6 +27,7 @@ enum Register {
|
||||
/// One CPUID feature bit.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Feature {
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub name: &'static str,
|
||||
leaf: u32,
|
||||
subleaf: u32,
|
||||
@@ -34,9 +35,10 @@ pub struct Feature {
|
||||
bit: u32,
|
||||
}
|
||||
|
||||
const fn bit(name: &'static str, leaf: u32, register: Register, bit: u32) -> Feature {
|
||||
const fn bit(_name: &'static str, leaf: u32, register: Register, bit: u32) -> Feature {
|
||||
Feature {
|
||||
name,
|
||||
#[cfg(feature = "diagnostics")]
|
||||
name: _name,
|
||||
leaf,
|
||||
subleaf: 0,
|
||||
register,
|
||||
@@ -54,7 +56,9 @@ impl Feature {
|
||||
pub fn present(&self) -> bool {
|
||||
leaf(self.leaf, self.subleaf).is_some_and(|result| {
|
||||
let value = match self.register {
|
||||
#[cfg(feature = "diagnostics")]
|
||||
Register::Eax => result.eax,
|
||||
#[cfg(feature = "diagnostics")]
|
||||
Register::Ebx => result.ebx,
|
||||
Register::Ecx => result.ecx,
|
||||
Register::Edx => result.edx,
|
||||
@@ -64,197 +68,6 @@ impl Feature {
|
||||
}
|
||||
}
|
||||
|
||||
const SSE3: Feature = bit("SSE3", 1, Ecx, 0);
|
||||
const PCLMULQDQ: Feature = bit("PCLMULQDQ", 1, Ecx, 1);
|
||||
const SSSE3: Feature = bit("SSSE3", 1, Ecx, 9);
|
||||
const FMA: Feature = bit("FMA", 1, Ecx, 12);
|
||||
const CX16: Feature = bit("CMPXCHG16B", 1, Ecx, 13);
|
||||
const PCID: Feature = bit("PCID", 1, Ecx, 17);
|
||||
const SSE41: Feature = bit("SSE4.1", 1, Ecx, 19);
|
||||
const SSE42: Feature = bit("SSE4.2", 1, Ecx, 20);
|
||||
pub const X2APIC: Feature = bit("x2APIC", 1, Ecx, 21);
|
||||
const MOVBE: Feature = bit("MOVBE", 1, Ecx, 22);
|
||||
const POPCNT: Feature = bit("POPCNT", 1, Ecx, 23);
|
||||
pub const TSC_DEADLINE: Feature = bit("TSC-deadline", 1, Ecx, 24);
|
||||
const AES: Feature = bit("AES", 1, Ecx, 25);
|
||||
const XSAVE: Feature = bit("XSAVE", 1, Ecx, 26);
|
||||
const OSXSAVE: Feature = bit("OSXSAVE", 1, Ecx, 27);
|
||||
const AVX: Feature = bit("AVX", 1, Ecx, 28);
|
||||
const F16C: Feature = bit("F16C", 1, Ecx, 29);
|
||||
const RDRAND: Feature = bit("RDRAND", 1, Ecx, 30);
|
||||
const HYPERVISOR: Feature = bit("hypervisor", 1, Ecx, 31);
|
||||
const CX8: Feature = bit("CMPXCHG8B", 1, Edx, 8);
|
||||
const APIC: Feature = bit("APIC", 1, Edx, 9);
|
||||
pub const ARAT: Feature = bit("ARAT", 6, Eax, 2);
|
||||
const FSGSBASE: Feature = bit("FSGSBASE", 7, Ebx, 0);
|
||||
const BMI1: Feature = bit("BMI1", 7, Ebx, 3);
|
||||
const AVX2: Feature = bit("AVX2", 7, Ebx, 5);
|
||||
const SMEP: Feature = bit("SMEP", 7, Ebx, 7);
|
||||
const BMI2: Feature = bit("BMI2", 7, Ebx, 8);
|
||||
const ERMS: Feature = bit("ERMS", 7, Ebx, 9);
|
||||
const INVPCID: Feature = bit("INVPCID", 7, Ebx, 10);
|
||||
const AVX512F: Feature = bit("AVX512F", 7, Ebx, 16);
|
||||
const AVX512DQ: Feature = bit("AVX512DQ", 7, Ebx, 17);
|
||||
const RDSEED: Feature = bit("RDSEED", 7, Ebx, 18);
|
||||
const SMAP: Feature = bit("SMAP", 7, Ebx, 20);
|
||||
const AVX512CD: Feature = bit("AVX512CD", 7, Ebx, 28);
|
||||
const SHA: Feature = bit("SHA", 7, Ebx, 29);
|
||||
const AVX512BW: Feature = bit("AVX512BW", 7, Ebx, 30);
|
||||
const AVX512VL: Feature = bit("AVX512VL", 7, Ebx, 31);
|
||||
pub const LA57: Feature = bit("LA57", 7, Ecx, 16);
|
||||
const FSRM: Feature = bit("FSRM", 7, Edx, 4);
|
||||
const LAHF_LM: Feature = bit("LAHF/SAHF-64", 0x8000_0001, Ecx, 0);
|
||||
const LZCNT: Feature = bit("LZCNT", 0x8000_0001, Ecx, 5);
|
||||
const NX: Feature = bit("NX", 0x8000_0001, Edx, 20);
|
||||
const PAGE_1G: Feature = bit("1GiB-pages", 0x8000_0001, Edx, 26);
|
||||
const RDTSCP: Feature = bit("RDTSCP", 0x8000_0001, Edx, 27);
|
||||
|
||||
pub const INVARIANT_TSC: Feature = bit("invariant-TSC", 0x8000_0007, Edx, 8);
|
||||
|
||||
/// What Stela needs of any host: x86-64-v2 and NX.
|
||||
pub const FLOOR: [Feature; 8] = [SSE3, SSSE3, SSE41, SSE42, POPCNT, CX16, LAHF_LM, NX];
|
||||
/// x86-64-v3 beyond v2 (the psABI's microarchitecture levels).
|
||||
const V3: [Feature; 9] = [AVX, AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE, OSXSAVE];
|
||||
/// x86-64-v4 beyond v3.
|
||||
const V4: [Feature; 5] = [AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL];
|
||||
/// Everything the report lists.
|
||||
const REPORTED: [Feature; 45] = [
|
||||
SSE3,
|
||||
SSSE3,
|
||||
SSE41,
|
||||
SSE42,
|
||||
POPCNT,
|
||||
CX16,
|
||||
LAHF_LM,
|
||||
NX,
|
||||
CX8,
|
||||
PCLMULQDQ,
|
||||
AES,
|
||||
SHA,
|
||||
AVX,
|
||||
AVX2,
|
||||
F16C,
|
||||
FMA,
|
||||
BMI1,
|
||||
BMI2,
|
||||
LZCNT,
|
||||
MOVBE,
|
||||
XSAVE,
|
||||
OSXSAVE,
|
||||
AVX512F,
|
||||
AVX512BW,
|
||||
AVX512CD,
|
||||
AVX512DQ,
|
||||
AVX512VL,
|
||||
ERMS,
|
||||
FSRM,
|
||||
RDRAND,
|
||||
RDSEED,
|
||||
FSGSBASE,
|
||||
RDTSCP,
|
||||
APIC,
|
||||
X2APIC,
|
||||
TSC_DEADLINE,
|
||||
ARAT,
|
||||
INVARIANT_TSC,
|
||||
LA57,
|
||||
PAGE_1G,
|
||||
PCID,
|
||||
INVPCID,
|
||||
SMEP,
|
||||
SMAP,
|
||||
HYPERVISOR,
|
||||
];
|
||||
|
||||
/// The floor features this CPU lacks.
|
||||
pub fn missing_floor() -> Vec<&'static str> {
|
||||
FLOOR
|
||||
.iter()
|
||||
.filter(|feature| !feature.present())
|
||||
.map(|feature| feature.name)
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The highest x86-64 microarchitecture level CPUID enumerates.
|
||||
pub fn level() -> u8 {
|
||||
let all = |features: &[Feature]| features.iter().all(Feature::present);
|
||||
match (all(&FLOOR), all(&V3), all(&V4)) {
|
||||
(false, _, _) => 1,
|
||||
(true, false, _) => 2,
|
||||
(true, true, false) => 3,
|
||||
(true, true, true) => 4,
|
||||
}
|
||||
}
|
||||
|
||||
fn text(registers: &[u32]) -> String {
|
||||
let bytes: Vec<u8> = registers.iter().flat_map(|r| r.to_le_bytes()).collect();
|
||||
String::from_utf8_lossy(&bytes)
|
||||
.trim_matches(|c: char| c == '\0' || c == ' ')
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Lines of the CPU report: identity, address sizes, frequency leaves and
|
||||
/// every reported feature, present and absent.
|
||||
pub fn report() -> Vec<String> {
|
||||
let vendor = __cpuid(VENDOR);
|
||||
let version = __cpuid(VERSION).eax;
|
||||
let family = (version >> 8) & 0xf;
|
||||
let model = (version >> 4) & 0xf;
|
||||
let (family, model) = if family == 0xf {
|
||||
(
|
||||
family + ((version >> 20) & 0xff),
|
||||
model | ((version >> 12) & 0xf0),
|
||||
)
|
||||
} else if family == 0x6 {
|
||||
(family, model | ((version >> 12) & 0xf0))
|
||||
} else {
|
||||
(family, model)
|
||||
};
|
||||
let brand: Vec<u32> = BRAND
|
||||
.iter()
|
||||
.filter_map(|&l| leaf(l, 0))
|
||||
.flat_map(|r| [r.eax, r.ebx, r.ecx, r.edx])
|
||||
.collect();
|
||||
let mut lines = vec![format!(
|
||||
"vendor={:?} brand={:?} family={family:#x} model={model:#x} stepping={} max_leaf={:#x} \
|
||||
max_extended={:#x}",
|
||||
text(&[vendor.ebx, vendor.edx, vendor.ecx]),
|
||||
text(&brand),
|
||||
version & 0xf,
|
||||
vendor.eax,
|
||||
__cpuid(EXTENDED).eax,
|
||||
)];
|
||||
if let Some(sizes) = leaf(ADDRESS_SIZES, 0) {
|
||||
lines.push(format!(
|
||||
"address bits physical={} virtual={}",
|
||||
sizes.eax & 0xff,
|
||||
(sizes.eax >> 8) & 0xff
|
||||
));
|
||||
}
|
||||
if let Some(crystal) = leaf(TSC_CRYSTAL, 0) {
|
||||
lines.push(format!(
|
||||
"leaf 0x15 tsc/crystal={}/{} crystal_hz={}",
|
||||
crystal.ebx, crystal.eax, crystal.ecx
|
||||
));
|
||||
}
|
||||
if let Some(frequency) = leaf(FREQUENCY, 0) {
|
||||
lines.push(format!(
|
||||
"leaf 0x16 base_mhz={} max_mhz={} bus_mhz={}",
|
||||
frequency.eax & 0xffff,
|
||||
frequency.ebx & 0xffff,
|
||||
frequency.ecx & 0xffff
|
||||
));
|
||||
}
|
||||
let (present, absent): (Vec<&Feature>, Vec<&Feature>) =
|
||||
REPORTED.iter().partition(|feature| feature.present());
|
||||
let names = |features: Vec<&Feature>| -> String {
|
||||
features
|
||||
.iter()
|
||||
.map(|feature| feature.name)
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
};
|
||||
lines.push(format!("present {}", names(present)));
|
||||
lines.push(format!("absent {}", names(absent)));
|
||||
lines.push(format!("x86-64 level v{}", level()));
|
||||
lines
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
//! CPUID feature and identity inventory for a diagnostics mount.
|
||||
use super::*;
|
||||
use alloc::{format, string::String, vec, vec::Vec};
|
||||
|
||||
const VENDOR: u32 = 0;
|
||||
const VERSION: u32 = 1;
|
||||
const BRAND: [u32; 3] = [0x8000_0002, 0x8000_0003, 0x8000_0004];
|
||||
const ADDRESS_SIZES: u32 = 0x8000_0008;
|
||||
const TSC_CRYSTAL: u32 = 0x15;
|
||||
const FREQUENCY: u32 = 0x16;
|
||||
|
||||
const SSE3: Feature = bit("SSE3", 1, Ecx, 0);
|
||||
const PCLMULQDQ: Feature = bit("PCLMULQDQ", 1, Ecx, 1);
|
||||
const SSSE3: Feature = bit("SSSE3", 1, Ecx, 9);
|
||||
const FMA: Feature = bit("FMA", 1, Ecx, 12);
|
||||
const CX16: Feature = bit("CMPXCHG16B", 1, Ecx, 13);
|
||||
const PCID: Feature = bit("PCID", 1, Ecx, 17);
|
||||
const SSE41: Feature = bit("SSE4.1", 1, Ecx, 19);
|
||||
const SSE42: Feature = bit("SSE4.2", 1, Ecx, 20);
|
||||
pub const X2APIC: Feature = bit("x2APIC", 1, Ecx, 21);
|
||||
const MOVBE: Feature = bit("MOVBE", 1, Ecx, 22);
|
||||
const POPCNT: Feature = bit("POPCNT", 1, Ecx, 23);
|
||||
pub const TSC_DEADLINE: Feature = bit("TSC-deadline", 1, Ecx, 24);
|
||||
const AES: Feature = bit("AES", 1, Ecx, 25);
|
||||
const XSAVE: Feature = bit("XSAVE", 1, Ecx, 26);
|
||||
const OSXSAVE: Feature = bit("OSXSAVE", 1, Ecx, 27);
|
||||
const AVX: Feature = bit("AVX", 1, Ecx, 28);
|
||||
const F16C: Feature = bit("F16C", 1, Ecx, 29);
|
||||
const RDRAND: Feature = bit("RDRAND", 1, Ecx, 30);
|
||||
const HYPERVISOR: Feature = bit("hypervisor", 1, Ecx, 31);
|
||||
const CX8: Feature = bit("CMPXCHG8B", 1, Edx, 8);
|
||||
const APIC: Feature = bit("APIC", 1, Edx, 9);
|
||||
pub const ARAT: Feature = bit("ARAT", 6, Eax, 2);
|
||||
const FSGSBASE: Feature = bit("FSGSBASE", 7, Ebx, 0);
|
||||
const BMI1: Feature = bit("BMI1", 7, Ebx, 3);
|
||||
const AVX2: Feature = bit("AVX2", 7, Ebx, 5);
|
||||
const SMEP: Feature = bit("SMEP", 7, Ebx, 7);
|
||||
const BMI2: Feature = bit("BMI2", 7, Ebx, 8);
|
||||
const ERMS: Feature = bit("ERMS", 7, Ebx, 9);
|
||||
const INVPCID: Feature = bit("INVPCID", 7, Ebx, 10);
|
||||
const AVX512F: Feature = bit("AVX512F", 7, Ebx, 16);
|
||||
const AVX512DQ: Feature = bit("AVX512DQ", 7, Ebx, 17);
|
||||
const RDSEED: Feature = bit("RDSEED", 7, Ebx, 18);
|
||||
const SMAP: Feature = bit("SMAP", 7, Ebx, 20);
|
||||
const AVX512CD: Feature = bit("AVX512CD", 7, Ebx, 28);
|
||||
const SHA: Feature = bit("SHA", 7, Ebx, 29);
|
||||
const AVX512BW: Feature = bit("AVX512BW", 7, Ebx, 30);
|
||||
const AVX512VL: Feature = bit("AVX512VL", 7, Ebx, 31);
|
||||
const FSRM: Feature = bit("FSRM", 7, Edx, 4);
|
||||
const LAHF_LM: Feature = bit("LAHF/SAHF-64", 0x8000_0001, Ecx, 0);
|
||||
const LZCNT: Feature = bit("LZCNT", 0x8000_0001, Ecx, 5);
|
||||
const NX: Feature = bit("NX", 0x8000_0001, Edx, 20);
|
||||
const PAGE_1G: Feature = bit("1GiB-pages", 0x8000_0001, Edx, 26);
|
||||
const RDTSCP: Feature = bit("RDTSCP", 0x8000_0001, Edx, 27);
|
||||
|
||||
/// What Stela needs of any host: x86-64-v2 and NX.
|
||||
pub const FLOOR: [Feature; 8] = [SSE3, SSSE3, SSE41, SSE42, POPCNT, CX16, LAHF_LM, NX];
|
||||
/// x86-64-v3 beyond v2 (the psABI's microarchitecture levels).
|
||||
const V3: [Feature; 9] = [AVX, AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE, OSXSAVE];
|
||||
/// x86-64-v4 beyond v3.
|
||||
const V4: [Feature; 5] = [AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL];
|
||||
/// Everything the report lists.
|
||||
const REPORTED: [Feature; 45] = [
|
||||
SSE3,
|
||||
SSSE3,
|
||||
SSE41,
|
||||
SSE42,
|
||||
POPCNT,
|
||||
CX16,
|
||||
LAHF_LM,
|
||||
NX,
|
||||
CX8,
|
||||
PCLMULQDQ,
|
||||
AES,
|
||||
SHA,
|
||||
AVX,
|
||||
AVX2,
|
||||
F16C,
|
||||
FMA,
|
||||
BMI1,
|
||||
BMI2,
|
||||
LZCNT,
|
||||
MOVBE,
|
||||
XSAVE,
|
||||
OSXSAVE,
|
||||
AVX512F,
|
||||
AVX512BW,
|
||||
AVX512CD,
|
||||
AVX512DQ,
|
||||
AVX512VL,
|
||||
ERMS,
|
||||
FSRM,
|
||||
RDRAND,
|
||||
RDSEED,
|
||||
FSGSBASE,
|
||||
RDTSCP,
|
||||
APIC,
|
||||
X2APIC,
|
||||
TSC_DEADLINE,
|
||||
ARAT,
|
||||
INVARIANT_TSC,
|
||||
LA57,
|
||||
PAGE_1G,
|
||||
PCID,
|
||||
INVPCID,
|
||||
SMEP,
|
||||
SMAP,
|
||||
HYPERVISOR,
|
||||
];
|
||||
|
||||
/// The floor features this CPU lacks.
|
||||
pub fn missing_floor() -> Vec<&'static str> {
|
||||
FLOOR
|
||||
.iter()
|
||||
.filter(|feature| !feature.present())
|
||||
.map(|feature| feature.name)
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The highest x86-64 microarchitecture level CPUID enumerates.
|
||||
pub fn level() -> u8 {
|
||||
let all = |features: &[Feature]| features.iter().all(Feature::present);
|
||||
match (all(&FLOOR), all(&V3), all(&V4)) {
|
||||
(false, _, _) => 1,
|
||||
(true, false, _) => 2,
|
||||
(true, true, false) => 3,
|
||||
(true, true, true) => 4,
|
||||
}
|
||||
}
|
||||
|
||||
fn text(registers: &[u32]) -> String {
|
||||
let bytes: Vec<u8> = registers.iter().flat_map(|r| r.to_le_bytes()).collect();
|
||||
String::from_utf8_lossy(&bytes)
|
||||
.trim_matches(|c: char| c == '\0' || c == ' ')
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Lines of the CPU report: identity, address sizes, frequency leaves and
|
||||
/// every reported feature, present and absent.
|
||||
pub fn report() -> Vec<String> {
|
||||
let vendor = __cpuid(VENDOR);
|
||||
let version = __cpuid(VERSION).eax;
|
||||
let family = (version >> 8) & 0xf;
|
||||
let model = (version >> 4) & 0xf;
|
||||
let (family, model) = if family == 0xf {
|
||||
(
|
||||
family + ((version >> 20) & 0xff),
|
||||
model | ((version >> 12) & 0xf0),
|
||||
)
|
||||
} else if family == 0x6 {
|
||||
(family, model | ((version >> 12) & 0xf0))
|
||||
} else {
|
||||
(family, model)
|
||||
};
|
||||
let brand: Vec<u32> = BRAND
|
||||
.iter()
|
||||
.filter_map(|&l| leaf(l, 0))
|
||||
.flat_map(|r| [r.eax, r.ebx, r.ecx, r.edx])
|
||||
.collect();
|
||||
let mut lines = vec![format!(
|
||||
"vendor={:?} brand={:?} family={family:#x} model={model:#x} stepping={} max_leaf={:#x} \
|
||||
max_extended={:#x}",
|
||||
text(&[vendor.ebx, vendor.edx, vendor.ecx]),
|
||||
text(&brand),
|
||||
version & 0xf,
|
||||
vendor.eax,
|
||||
__cpuid(EXTENDED).eax,
|
||||
)];
|
||||
if let Some(sizes) = leaf(ADDRESS_SIZES, 0) {
|
||||
lines.push(format!(
|
||||
"address bits physical={} virtual={}",
|
||||
sizes.eax & 0xff,
|
||||
(sizes.eax >> 8) & 0xff
|
||||
));
|
||||
}
|
||||
if let Some(crystal) = leaf(TSC_CRYSTAL, 0) {
|
||||
lines.push(format!(
|
||||
"leaf 0x15 tsc/crystal={}/{} crystal_hz={}",
|
||||
crystal.ebx, crystal.eax, crystal.ecx
|
||||
));
|
||||
}
|
||||
if let Some(frequency) = leaf(FREQUENCY, 0) {
|
||||
lines.push(format!(
|
||||
"leaf 0x16 base_mhz={} max_mhz={} bus_mhz={}",
|
||||
frequency.eax & 0xffff,
|
||||
frequency.ebx & 0xffff,
|
||||
frequency.ecx & 0xffff
|
||||
));
|
||||
}
|
||||
let (present, absent): (Vec<&Feature>, Vec<&Feature>) =
|
||||
REPORTED.iter().partition(|feature| feature.present());
|
||||
let names = |features: Vec<&Feature>| -> String {
|
||||
features
|
||||
.iter()
|
||||
.map(|feature| feature.name)
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
};
|
||||
lines.push(format!("present {}", names(present)));
|
||||
lines.push(format!("absent {}", names(absent)));
|
||||
lines.push(format!("x86-64 level v{}", level()));
|
||||
lines
|
||||
}
|
||||
@@ -731,6 +731,7 @@ pub extern "sysv64" fn entry(handoff: u64) -> ! {
|
||||
));
|
||||
output::fatal("native clock fixture requires one exclusive processor and volatile input");
|
||||
}
|
||||
#[cfg(feature = "diagnostics")]
|
||||
if options.native_memory_check {
|
||||
output::arguments(format_args!(
|
||||
"CHECK native-memory heap cpu={heap:#x} physical={:#x} bytes={:#x}\n",
|
||||
@@ -771,6 +772,7 @@ pub extern "sysv64" fn entry(handoff: u64) -> ! {
|
||||
.chain(options.restore_source.iter())
|
||||
.chain(options.nor.iter().filter(|_| !state_in_storage))
|
||||
.collect();
|
||||
#[cfg(feature = "diagnostics")]
|
||||
if let Some(mode) = options.audio_check {
|
||||
let audio_handoff = handoff
|
||||
.storage
|
||||
@@ -851,6 +853,7 @@ pub extern "sysv64" fn entry(handoff: u64) -> ! {
|
||||
range.guest, range.bytes, range.host
|
||||
));
|
||||
}
|
||||
#[cfg(feature = "diagnostics")]
|
||||
if let Some(url) = &options.network_check {
|
||||
let Some(Ok(network)) = &host_network else {
|
||||
output::fatal("the network check failed")
|
||||
@@ -985,6 +988,7 @@ pub extern "sysv64" fn entry(handoff: u64) -> ! {
|
||||
handoff.apic_base,
|
||||
layout::physical(handoff.apic_base & crate::apic::BASE_ADDRESS),
|
||||
);
|
||||
#[cfg(feature = "diagnostics")]
|
||||
if options.native_bootstrap_check || options.native_shared_check {
|
||||
for processor in executors.processors() {
|
||||
// SAFETY: BSP owns its ICR, physical AP/private descriptors ready.
|
||||
@@ -1687,14 +1691,17 @@ fn install_host(handoff: &Handoff, options: &Options, ram: &[RamRange]) -> Insta
|
||||
// SAFETY: once on the BSP, with interrupts off and owned native resources.
|
||||
// Retain the processor-local state through every native call and handler.
|
||||
crate::status::begin("Installing the host processor state");
|
||||
let mut host_owner =
|
||||
unsafe { host::install(config) }.unwrap_or_else(|error| output::fatal(error));
|
||||
let host_owner = unsafe { host::install(config) }.unwrap_or_else(|error| output::fatal(error));
|
||||
#[cfg(feature = "diagnostics")]
|
||||
let mut host_owner = host_owner;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
if options.native_bootstrap_check {
|
||||
host::fp_diagnostic::check(&mut host_owner.host())
|
||||
.unwrap_or_else(|error| output::fatal(error));
|
||||
}
|
||||
let apic_hz = host::statistics().apic_hz;
|
||||
crate::status::done("");
|
||||
#[cfg(feature = "diagnostics")]
|
||||
if options.native_clock_check {
|
||||
// SAFETY: original loader capture remains pinned in this actual
|
||||
// HostOwner's physmap. Parsing never supplies hardware ownership.
|
||||
@@ -1716,6 +1723,7 @@ fn install_host(handoff: &Handoff, options: &Options, ram: &[RamRange]) -> Insta
|
||||
});
|
||||
stop_here("bounded native clock fixture complete", 0x10);
|
||||
}
|
||||
#[cfg(feature = "diagnostics")]
|
||||
if options.native_mmio_check {
|
||||
// SAFETY: explicit bounded native diagnostic on the original retained
|
||||
// handoff/owner. Success stops before guest entry; permanent mapping
|
||||
@@ -1934,6 +1942,7 @@ fn start_devices(
|
||||
let bsp = native_processors.expect("validated native roster");
|
||||
storage_handoff.completion =
|
||||
host::completion_signal(bsp.processors[bsp.selected[0] as usize].apic_id);
|
||||
#[cfg(feature = "diagnostics")]
|
||||
if options.audio_check.is_some() {
|
||||
// The audio check retains the final slice even after shutdown.
|
||||
storage_handoff.dma.end -= crate::audio_check::DMA_BYTES;
|
||||
|
||||
@@ -39,6 +39,7 @@ use stela_runtime::machine::{
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) mod fp_diagnostic;
|
||||
pub(super) mod local;
|
||||
#[cfg(feature = "native-profile")]
|
||||
|
||||
@@ -402,6 +402,7 @@ pub fn tsc_hz() -> u64 {
|
||||
}
|
||||
|
||||
/// How [`tsc_hz`] found the rate.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub fn tsc_source() -> TscSource {
|
||||
tsc_hz();
|
||||
match TSC_SOURCE.load(Ordering::Relaxed) {
|
||||
|
||||
@@ -63,7 +63,6 @@ use stela_runtime::pc::{
|
||||
};
|
||||
use uefi::boot;
|
||||
|
||||
pub const OPTION: &[u8] = stela_boot_core::options::HOST_CHECK.as_bytes();
|
||||
const BEAT_SECONDS: u64 = 10;
|
||||
/// The stop code at `--deadline`.
|
||||
const DEADLINE_CODE: u32 = 0x10;
|
||||
|
||||
@@ -20,6 +20,7 @@ use uefi::{
|
||||
boot::{AllocateType, MemoryType},
|
||||
};
|
||||
mod apic;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
mod audio_check;
|
||||
mod choice;
|
||||
mod console;
|
||||
@@ -29,6 +30,7 @@ mod entropy;
|
||||
mod firmware;
|
||||
mod handoff;
|
||||
mod heap;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
mod host_check;
|
||||
mod host_firmware;
|
||||
mod installer;
|
||||
@@ -44,9 +46,11 @@ pub mod native_memory;
|
||||
pub(crate) mod native_mmio;
|
||||
mod native_smp;
|
||||
#[allow(dead_code)]
|
||||
#[cfg(feature = "diagnostics")]
|
||||
mod native_stack_check;
|
||||
#[allow(dead_code)]
|
||||
mod native_stacks;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
mod native_work_check;
|
||||
mod output;
|
||||
mod paging;
|
||||
@@ -117,9 +121,12 @@ fn main() -> Status {
|
||||
if options.starts_with(b"--system") {
|
||||
system::boot(options, volume, log, host_firmware);
|
||||
}
|
||||
if options.starts_with(host_check::OPTION) {
|
||||
if options.starts_with(stela_boot_core::options::HOST_CHECK.as_bytes()) {
|
||||
drop(volume);
|
||||
#[cfg(feature = "diagnostics")]
|
||||
host_check::boot(options);
|
||||
#[cfg(not(feature = "diagnostics"))]
|
||||
output::fatal("host checks require a diagnostics build");
|
||||
}
|
||||
drop(volume);
|
||||
let (mut handoff, tables) =
|
||||
|
||||
@@ -22,6 +22,7 @@ use stela_drivers::platform::work::{
|
||||
service::{Clock, Idle, RaisedWork},
|
||||
};
|
||||
mod counter;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) mod diagnostic;
|
||||
pub(crate) mod hpet;
|
||||
mod pm;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
//! Native IOMMU backends. Discovery/ownership must supply a qualified unit;
|
||||
//! there is no identity-mapping substitute for an unavailable domain.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) mod diagnostic;
|
||||
pub use stela_boot_core::dmar;
|
||||
pub use stela_boot_core::firmware_state;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
mod isolation_diagnostic;
|
||||
pub use stela_boot_core::{requester, vtd};
|
||||
|
||||
|
||||
@@ -15,14 +15,17 @@ use stela_drivers::platform::work::Cpu;
|
||||
mod context;
|
||||
#[allow(dead_code)]
|
||||
mod crs;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) mod diagnostic;
|
||||
#[allow(dead_code)]
|
||||
pub mod ioapic;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) mod level_diagnostic;
|
||||
#[allow(dead_code)]
|
||||
pub mod madt;
|
||||
#[allow(dead_code)]
|
||||
pub(crate) mod root;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) mod work_diagnostic;
|
||||
|
||||
static CONTEXT: context::Context = context::Context::new();
|
||||
@@ -179,6 +182,7 @@ pub fn dispatch(vector: u8) -> bool {
|
||||
/// # Safety
|
||||
/// Called only by the genuine existing CPU interrupt handler with IRQs off;
|
||||
/// `interrupted_rsp` is Frame.rsp from that entry, not the ISR's current RSP.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) unsafe fn dispatch_frame(vector: u8, interrupted_rsp: usize) -> bool {
|
||||
unsafe { dispatch_entry(vector, Some(interrupted_rsp)) }
|
||||
}
|
||||
|
||||
@@ -9,13 +9,14 @@ mod ecam;
|
||||
mod shared;
|
||||
pub(crate) mod shootdown;
|
||||
use ecam::RootWindow;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) mod diagnostic;
|
||||
mod platform;
|
||||
|
||||
pub(crate) use capture::{Prepared, Wire};
|
||||
pub(crate) use platform::{
|
||||
ExclusiveHpet, HpetMapping, QualifiedRam, RootPublication, ScopedSource,
|
||||
};
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) use platform::ScopedSource;
|
||||
pub(crate) use platform::{ExclusiveHpet, HpetMapping, QualifiedRam, RootPublication};
|
||||
pub(crate) use shared::{PROCESSORS, Source};
|
||||
|
||||
use stela_drivers::bus::mmio::owned::Error;
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
//! is distinct from the direct `SYSTEM_MODE` profile's single-agent translation contract.
|
||||
pub(crate) mod bootstrap;
|
||||
pub(crate) mod canonical;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
mod context_check;
|
||||
pub(crate) mod executor;
|
||||
pub(crate) mod firmware;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) mod kernel_check;
|
||||
pub(crate) use stela_boot_core::memory_types;
|
||||
pub(crate) mod resources;
|
||||
|
||||
@@ -33,6 +33,7 @@ pub(crate) type CanonicalMachine<'a, D> =
|
||||
/// its shared-window WB CPU aliases for the entire boot. All earlier input
|
||||
/// copies have completed; no raw V1 guest or asynchronous producer can access
|
||||
/// these bytes after registration. The physical map and controls stay pinned.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) unsafe fn reserve(
|
||||
handoff: &'static Handoff,
|
||||
ranges: &[host::RamRange],
|
||||
@@ -222,6 +223,7 @@ pub(crate) struct Preparation<'host, 'plan, D> {
|
||||
/// mappings and synchronous device producers stay pinned for the machine's
|
||||
/// lifetime. Guest execution and asynchronous writers begin only after this
|
||||
/// constructor returns and their complete platform state has been installed.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) unsafe fn prepare<'host, D: Devices>(
|
||||
preparation: Preparation<'host, '_, D>,
|
||||
) -> Result<CanonicalMachine<'host, D>, &'static str> {
|
||||
@@ -320,6 +322,7 @@ pub(crate) unsafe fn prepare_with_locks<'host, D: Devices>(
|
||||
/// # Safety
|
||||
/// `prepare`'s complete closed producer/mount contract remains valid. This is
|
||||
/// admitted only after the final platform owner joins its complete graph.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) unsafe fn run_slice<D: Devices>(
|
||||
machine: &mut CanonicalMachine<'_, D>,
|
||||
limit: u64,
|
||||
|
||||
@@ -59,6 +59,7 @@ struct Argument {
|
||||
source: topology::Snapshot,
|
||||
effective_pat: u64,
|
||||
// An explicit authored diagnostic request, never execution/ISA authority.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
fp_qualification: bool,
|
||||
stack_bottom: u64,
|
||||
stack_top: u64,
|
||||
@@ -112,6 +113,7 @@ impl Processor {
|
||||
|
||||
/// Directed interrupt completion evidence only; this never grants a
|
||||
/// stopped generation or returned native frame to the runtime.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub(crate) unsafe fn check_doorbell(
|
||||
&self,
|
||||
sender: &Apic,
|
||||
@@ -207,15 +209,19 @@ unsafe extern "sysv64" fn enter(argument: u64) -> ! {
|
||||
let loader_root = config.window_root;
|
||||
// SAFETY: configured pool/arena/bounce entries belong only to this AP;
|
||||
// tables/local record remain pinned through every native call and park.
|
||||
let mut owner =
|
||||
let owner =
|
||||
unsafe { host::install(config) }.map_err(|_| "AP private host installation failed")?;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
let mut owner = owner;
|
||||
let apic = u32::try_from(argument.processor.apic_id).map_err(|_| "AP APIC ID")?;
|
||||
host::join_shootdown(
|
||||
crate::native_mmio::PROCESSORS
|
||||
.slot(apic)
|
||||
.ok_or("AP missing from the aperture's processors")?,
|
||||
);
|
||||
#[cfg(feature = "diagnostics")]
|
||||
super::context_check::check(&mut owner.host())?;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
if argument.fp_qualification {
|
||||
host::fp_diagnostic::check(&mut owner.host())?;
|
||||
}
|
||||
@@ -373,7 +379,7 @@ pub(crate) unsafe fn start(
|
||||
capture: &'static firmware::Capture,
|
||||
ram: &[host::RamRange],
|
||||
tsc_base: u64,
|
||||
fp_qualification: bool,
|
||||
_fp_qualification: bool,
|
||||
serialized: bool,
|
||||
) -> Result<Executors, StartupFailure> {
|
||||
let cores = handoff.native_resources.cores as usize;
|
||||
@@ -453,7 +459,8 @@ pub(crate) unsafe fn start(
|
||||
processor,
|
||||
source: memory_source,
|
||||
effective_pat,
|
||||
fp_qualification,
|
||||
#[cfg(feature = "diagnostics")]
|
||||
fp_qualification: _fp_qualification,
|
||||
stack_bottom: layout::stack() + slot as u64 * resources::STACK_STRIDE + PAGE,
|
||||
stack_top: layout::stack()
|
||||
+ slot as u64 * resources::STACK_STRIDE
|
||||
|
||||
@@ -399,6 +399,7 @@ pub fn disable_firmware_console() {
|
||||
}
|
||||
|
||||
/// Send every line to the screen as well, for a report that is all detail.
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub fn raw_screen() {
|
||||
RAW_SCREEN.store(true, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
//! of that partition with a known pattern, reads it back and reports its
|
||||
//! hash. Without either option nothing here touches the hardware.
|
||||
mod bluetooth_platform;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
mod media_check;
|
||||
use stela_boot_core::storage as options;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
mod reset_check;
|
||||
pub use options::split;
|
||||
|
||||
@@ -50,7 +52,9 @@ pub struct Prepared {
|
||||
handoff: Handoff,
|
||||
open: Vec<Target>,
|
||||
check: Vec<Target>,
|
||||
#[cfg(feature = "diagnostics")]
|
||||
usb_reset_check: bool,
|
||||
#[cfg(feature = "diagnostics")]
|
||||
usb_media_check: bool,
|
||||
}
|
||||
|
||||
@@ -74,6 +78,10 @@ pub fn prepare(
|
||||
let (open, check, _) = split(text)?;
|
||||
let usb_reset_check = options::reset_requested(text, &open, &check)?;
|
||||
let usb_media_check = options::media_requested(text, &open, &check)?;
|
||||
#[cfg(not(feature = "diagnostics"))]
|
||||
if usb_reset_check || usb_media_check {
|
||||
return Err("USB checks require a diagnostics build");
|
||||
}
|
||||
if open.is_empty() && check.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
@@ -84,7 +92,9 @@ pub fn prepare(
|
||||
handoff,
|
||||
open,
|
||||
check,
|
||||
#[cfg(feature = "diagnostics")]
|
||||
usb_reset_check,
|
||||
#[cfg(feature = "diagnostics")]
|
||||
usb_media_check,
|
||||
}))
|
||||
}
|
||||
@@ -265,6 +275,7 @@ impl Prepared {
|
||||
pub fn run(self) {
|
||||
// SAFETY: one CPU after ExitBootServices; `dma` was reserved for this.
|
||||
let mut dma = unsafe { RegionAllocator::new(self.handoff.dma.clone()) };
|
||||
#[cfg(feature = "diagnostics")]
|
||||
let mut devices = if self.usb_media_check {
|
||||
// SAFETY: same exclusive post-EBS grant as probe; this explicit
|
||||
// fixture diagnostic attaches native USB and retains every owner.
|
||||
@@ -284,6 +295,9 @@ impl Prepared {
|
||||
// SAFETY: this handoff describes the running machine and its tables.
|
||||
unsafe { probe(&self.handoff, &mut dma) }
|
||||
};
|
||||
#[cfg(not(feature = "diagnostics"))]
|
||||
// SAFETY: this handoff describes the running machine and its tables.
|
||||
let mut devices = unsafe { probe(&self.handoff, &mut dma) };
|
||||
for window in &devices.unmapped {
|
||||
output::arguments(format_args!("STORAGE UNMAPPED ecam={window:x?}\n"));
|
||||
}
|
||||
|
||||
@@ -311,6 +311,10 @@ pub const INSTALL_PIECES_FILE: &str = "install-pieces.bin";
|
||||
fn inputs(options: &[u8], mut volume: FileSystem) -> Result<Inputs, &'static str> {
|
||||
let text = core::str::from_utf8(options).map_err(|_| "stela.cfg is not UTF-8")?;
|
||||
let system = System::parse(text)?;
|
||||
#[cfg(not(feature = "diagnostics"))]
|
||||
if system.diagnostic_option().is_some() {
|
||||
return Err("diagnostic options require a diagnostics build");
|
||||
}
|
||||
// Read while the firmware's FAT driver runs; the engine reports a file
|
||||
// it cannot use.
|
||||
let wifi_key = system
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# CFG-OPTIONS go after `--host-check --nor-file GUID:/stela/STELALOG.BIN`
|
||||
# in stela.cfg (default: --key-seconds 120 --deadline 1800). STELA_EFI names
|
||||
# the stela.efi to install; the default is `cargo xtask boot build --release`'s.
|
||||
# the stela.efi to install; the default is `cargo xtask boot build --release --diagnostics`'s.
|
||||
set -euo pipefail
|
||||
|
||||
EFI=${STELA_EFI:-${0:A:h:h:h}/target/boot/x86_64-unknown-uefi/release/stela.efi}
|
||||
|
||||
+19
-3
@@ -124,6 +124,9 @@ pub enum Command {
|
||||
Build {
|
||||
#[arg(long)]
|
||||
release: bool,
|
||||
/// Include authored hardware fixtures in the mount.
|
||||
#[arg(long)]
|
||||
diagnostics: bool,
|
||||
},
|
||||
/// Boot `stela.efi` with an ARM image in x86 QEMU.
|
||||
Run(Box<Run>),
|
||||
@@ -480,8 +483,14 @@ fn storage_disks(paths: &[PathBuf], serials: &[String]) -> Result<Vec<(PathBuf,
|
||||
|
||||
pub fn run(command: Command) -> Result<ExitCode> {
|
||||
match command {
|
||||
Command::Build { release } => {
|
||||
println!("{}", build(release)?.display());
|
||||
Command::Build {
|
||||
release,
|
||||
diagnostics,
|
||||
} => {
|
||||
println!(
|
||||
"{}",
|
||||
build_with_diagnostics(release, diagnostics)?.display()
|
||||
);
|
||||
Ok(ExitCode::SUCCESS)
|
||||
}
|
||||
Command::Run(arguments) => launch(*arguments),
|
||||
@@ -489,9 +498,16 @@ pub fn run(command: Command) -> Result<ExitCode> {
|
||||
}
|
||||
|
||||
pub fn build(release: bool) -> Result<PathBuf> {
|
||||
build_with_diagnostics(release, false)
|
||||
}
|
||||
|
||||
fn build_with_diagnostics(release: bool, diagnostics: bool) -> Result<PathBuf> {
|
||||
let mut command = cargo();
|
||||
command.args(["build", "--locked", "--manifest-path", BOOT_MANIFEST]);
|
||||
command.args(["--target", BOOT_TARGET, "--target-dir", BOOT_TARGET_DIR]);
|
||||
if diagnostics {
|
||||
command.args(["--features", "diagnostics"]);
|
||||
}
|
||||
if release {
|
||||
command.arg("--release");
|
||||
}
|
||||
@@ -651,7 +667,7 @@ fn launch(arguments: Run) -> Result<ExitCode> {
|
||||
let attached = storage_disks(&arguments.storage_disk, &arguments.storage_serial)?;
|
||||
let image = match &arguments.image {
|
||||
Some(image) => image.clone(),
|
||||
None => build(true)?,
|
||||
None => build_with_diagnostics(true, true)?,
|
||||
};
|
||||
let paths = storage::Paths::new(arguments.output.clone());
|
||||
if paths.output.exists() {
|
||||
|
||||
@@ -52,6 +52,7 @@ pub fn run(fix: bool) -> Result<()> {
|
||||
// are checked.
|
||||
uefi(["-p", "stela-runtime", "--no-default-features"]),
|
||||
uefi(BOOT),
|
||||
uefi([BOOT[0], BOOT[1], "--features", "diagnostics"]),
|
||||
// Native GPU hooks are optional while their larger vendor ports are
|
||||
// in progress, but their C/Rust ABI and UEFI target still belong to
|
||||
// the gate.
|
||||
|
||||
Reference in new issue
Block a user