Skip to content

Commit 7b4b6ba

Browse files
chris-ooCopilot
andauthored
openhcl_boot: correctly report that the vtl2 pool has allocations (#1935)
#1754 had a bug where we never tracked that we allocated a pool range, which breaks enabling nvme keep alive. Fix this by correctly reporting it and updating the test. --------- Co-authored-by: Copilot <[email protected]>
1 parent c8fcf4c commit 7b4b6ba

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

openhcl/openhcl_boot/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ fn shim_main(shim_params_raw_offset: isize) -> ! {
626626
can_trust_host,
627627
is_confidential_debug,
628628
sidecar.as_ref(),
629-
address_space.vtl2_pool().is_some(),
629+
address_space.has_vtl2_pool(),
630630
)
631631
.unwrap();
632632

openhcl/openhcl_boot/src/memory.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,15 @@ pub struct AddressSpaceManager {
112112
/// Track the whole address space - this must be sorted.
113113
address_space: ArrayVec<AddressRange, MAX_ADDRESS_RANGES>,
114114

115-
/// Track the VTL2 pool privately separately, as well.
116-
///
117-
/// Today, we only support a single range, but we could easily support more
118-
/// ranges in the future by making this an ArrayVec instead of an Option.
119-
vtl2_pool: Option<AllocatedRange>,
115+
/// Track that the VTL2 GPA pool has at least one allocation.
116+
vtl2_pool: bool,
120117
}
121118

122119
impl AddressSpaceManager {
123120
pub const fn new_const() -> Self {
124121
Self {
125122
address_space: ArrayVec::new_const(),
126-
vtl2_pool: None,
123+
vtl2_pool: false,
127124
}
128125
}
129126

@@ -322,11 +319,6 @@ impl AddressSpaceManager {
322319
// multiple of 4k.
323320
let len = len.div_ceil(PAGE_SIZE_4K) * PAGE_SIZE_4K;
324321

325-
// We only support a single VTL2 pool range, today.
326-
if allocation_type == AllocationType::GpaPool && self.vtl2_pool.is_some() {
327-
return None;
328-
}
329-
330322
fn find_index<'a>(
331323
mut iter: impl Iterator<Item = (usize, &'a AddressRange)>,
332324
preferred_vnode: Option<u32>,
@@ -353,7 +345,7 @@ impl AddressSpaceManager {
353345
}
354346
};
355347

356-
index.map(|index| {
348+
let alloc = index.map(|index| {
357349
self.allocate_range(
358350
index,
359351
len,
@@ -367,7 +359,13 @@ impl AddressSpaceManager {
367359
},
368360
allocation_policy,
369361
)
370-
})
362+
});
363+
364+
if allocation_type == AllocationType::GpaPool && alloc.is_some() {
365+
self.vtl2_pool = true;
366+
}
367+
368+
alloc
371369
}
372370

373371
/// Returns an iterator for all VTL2 ranges.
@@ -388,8 +386,8 @@ impl AddressSpaceManager {
388386
})
389387
}
390388

391-
/// The memory range for the VTL2 pool.
392-
pub fn vtl2_pool(&self) -> Option<AllocatedRange> {
389+
/// Returns true if there are VTL2 pool allocations.
390+
pub fn has_vtl2_pool(&self) -> bool {
393391
self.vtl2_pool
394392
}
395393
}
@@ -445,6 +443,7 @@ mod tests {
445443
)
446444
.unwrap();
447445
assert_eq!(range.range, MemoryRange::new(0x1F000..0x20000));
446+
assert!(address_space.has_vtl2_pool());
448447

449448
let range = address_space
450449
.allocate(

0 commit comments

Comments
 (0)