Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openhcl/underhill_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ impl DiagState {

#[derive(Inspect)]
struct Workers {
#[inspect(safe)]
vm: WorkerHandle,
#[inspect(skip)]
vm_rpc: mesh::Sender<UhVmRpc>,
Expand Down
3 changes: 2 additions & 1 deletion openhcl/underhill_core/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3582,7 +3582,8 @@ async fn new_underhill_vm(
state_units
.add("partition")
.depends_on(devices.chipset_unit())
.depends_on(vmtime.handle()),
.depends_on(vmtime.handle())
.inspect_sensitivity(inspect::SensitivityLevel::Safe),
WrappedPartition(partition.clone()),
PartitionUnitParams {
processor_topology: &processor_topology,
Expand Down
1 change: 1 addition & 0 deletions openhcl/virt_mshv_vtl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ struct UhCvmVpState {
/// Hypervisor enlightenment emulator state.
hv: VtlArray<ProcessorVtlHv, 2>,
/// LAPIC state.
#[inspect(safe)]
lapics: VtlArray<LapicState, 2>,
/// Guest VSM state for this vp. Some when VTL 1 is enabled.
vtl1: Option<GuestVsmVpState>,
Expand Down
3 changes: 2 additions & 1 deletion openhcl/virt_mshv_vtl/src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub struct UhProcessor<'a, T: Backing> {
// together by the compiler.
#[inspect(skip)]
runner: ProcessorRunner<'a, T::HclBacking<'a>>,
#[inspect(mut)]
#[inspect(mut, safe)]
backing: T,
}

Expand Down Expand Up @@ -157,6 +157,7 @@ impl VtlsTlbLocked {
#[cfg(guest_arch = "x86_64")]
#[derive(Inspect)]
pub(crate) struct LapicState {
#[inspect(safe)]
lapic: LocalApic,
activity: MpState,
nmi_pending: bool,
Expand Down
2 changes: 1 addition & 1 deletion openhcl/virt_mshv_vtl/src/processor/snp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub struct SnpBacked {
hv_sint_notifications: u16,
general_stats: VtlArray<GeneralStats, 2>,
exit_stats: VtlArray<ExitStats, 2>,
#[inspect(flatten)]
#[inspect(flatten, safe)]
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#[inspect(flatten, safe)] does not currently apply safe sensitivity: the inspect derive ignores sensitivity attributes on flatten fields and only emits resp.merge(...). If the intent is to make this subtree visible for SensitivityLevel::Safe requests, you’ll need to mark the specific inner fields as #[inspect(safe)] (as done for LAPIC stats) or restructure to use a sensitivity-aware child/field instead of flatten. Otherwise, consider dropping safe here to avoid confusion.

Suggested change
#[inspect(flatten, safe)]
#[inspect(flatten)]

Copilot uses AI. Check for mistakes.
cvm: UhCvmVpState,
}

Expand Down
2 changes: 1 addition & 1 deletion openhcl/virt_mshv_vtl/src/processor/tdx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ pub struct TdxBacked {
#[inspect(skip)]
flush_page: user_driver::memory::MemoryBlock,

#[inspect(flatten)]
#[inspect(flatten, safe)]
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#[inspect(flatten, safe)] is misleading here: the inspect derive currently ignores sensitivity attributes on flatten fields (flatten just emits resp.merge(...)). This means safe has no effect, and only inner fields explicitly marked safe will be visible under a SensitivityLevel::Safe request. Consider removing safe from this attribute, or (if you need the whole subtree to be safe) wrap it as a named child via Response::sensitivity_child(...)/a non-flatten field so the sensitivity is actually applied.

Suggested change
#[inspect(flatten, safe)]
#[inspect(flatten)]

Copilot uses AI. Check for mistakes.
cvm: UhCvmVpState,

/// Per-processor state for [`TdxTscDeadlineService`].
Expand Down
2 changes: 1 addition & 1 deletion vmm_core/src/partition_unit/vp_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ struct Inner {
pub struct VpSet {
#[inspect(flatten)]
inner: Arc<Inner>,
#[inspect(rename = "vp", iter_by_index)]
#[inspect(rename = "vp", iter_by_index, safe)]
vps: Vec<Vp>,
#[inspect(skip)]
started: bool,
Expand Down
12 changes: 11 additions & 1 deletion vmm_core/state_unit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ struct Unit {
dependencies: Vec<u64>,
dependents: Vec<u64>,
state: State,
inspect_sensitivity: inspect::SensitivityLevel,
}

/// An error returned when a state unit name is already in use.
Expand Down Expand Up @@ -313,7 +314,7 @@ impl Inspect for Inner {
fn inspect(&self, req: inspect::Request<'_>) {
let mut resp = req.respond();
for unit in self.units.values() {
resp.child(unit.name.as_ref(), |req| {
resp.sensitivity_child(unit.name.as_ref(), unit.inspect_sensitivity, |req| {
let mut resp = req.respond();
if !unit.dependencies.is_empty() {
resp.field_with("dependencies", || {
Expand Down Expand Up @@ -444,6 +445,7 @@ impl StateUnits {
name: name.into(),
dependencies: Vec::new(),
dependents: Vec::new(),
inspect_sensitivity: inspect::SensitivityLevel::Unspecified,
}
}

Expand Down Expand Up @@ -827,6 +829,7 @@ pub struct UnitBuilder<'a> {
name: Arc<str>,
dependencies: Vec<u64>,
dependents: Vec<u64>,
inspect_sensitivity: inspect::SensitivityLevel,
}

impl UnitBuilder<'_> {
Expand All @@ -848,6 +851,12 @@ impl UnitBuilder<'_> {
self
}

/// Sets the sensitivity level for this unit's inspect data. Defaults to Unspecified.
pub fn inspect_sensitivity(mut self, sensitivity: inspect::SensitivityLevel) -> Self {
self.inspect_sensitivity = sensitivity;
self
}
Comment on lines +854 to +858
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change introduces a new public builder API (UnitBuilder::inspect_sensitivity) and changes the inspect tree construction to use sensitivity_child(...), but there are no unit tests exercising the sensitivity behavior (e.g., that SensitivityLevel::Safe requests include Safe units and exclude Unspecified ones). Adding a focused test would help prevent regressions in inspect filtering semantics.

Copilot uses AI. Check for mistakes.

fn handle_id(&self, handle: &UnitHandle) -> u64 {
// Ensure this handle is associated with this set of state units.
assert_eq!(
Expand Down Expand Up @@ -891,6 +900,7 @@ impl UnitBuilder<'_> {
dependencies: self.dependencies,
dependents: self.dependents,
state: State::Stopped,
inspect_sensitivity: self.inspect_sensitivity,
},
);
let unit_id = UnitId {
Expand Down
15 changes: 15 additions & 0 deletions vmm_core/virt_support_apic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,39 @@ pub struct LocalApic {
needs_offload_reeval: bool,
scan_irr: bool,

#[inspect(safe)]
stats: Stats,
}

#[derive(Inspect, Default)]
struct Stats {
#[inspect(safe)]
eoi: Counter,
#[inspect(safe)]
eoi_level: Counter,
#[inspect(safe)]
spurious_eoi: Counter,
#[inspect(safe)]
lazy_eoi: Counter,
#[inspect(safe)]
interrupt: Counter,
#[inspect(safe)]
nmi: Counter,
#[inspect(safe)]
extint: Counter,
#[inspect(safe)]
init: Counter,
#[inspect(safe)]
sipi: Counter,
#[inspect(safe)]
self_ipi: Counter,
#[inspect(safe)]
broadcast_ipi: Counter,
#[inspect(safe)]
other_ipi: Counter,
#[inspect(safe)]
offload_push: Counter,
#[inspect(safe)]
offload_pull: Counter,
}

Expand Down
Loading