@@ -112,18 +112,15 @@ pub struct AddressSpaceManager {
112
112
/// Track the whole address space - this must be sorted.
113
113
address_space : ArrayVec < AddressRange , MAX_ADDRESS_RANGES > ,
114
114
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 ,
120
117
}
121
118
122
119
impl AddressSpaceManager {
123
120
pub const fn new_const ( ) -> Self {
124
121
Self {
125
122
address_space : ArrayVec :: new_const ( ) ,
126
- vtl2_pool : None ,
123
+ vtl2_pool : false ,
127
124
}
128
125
}
129
126
@@ -322,11 +319,6 @@ impl AddressSpaceManager {
322
319
// multiple of 4k.
323
320
let len = len. div_ceil ( PAGE_SIZE_4K ) * PAGE_SIZE_4K ;
324
321
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
-
330
322
fn find_index < ' a > (
331
323
mut iter : impl Iterator < Item = ( usize , & ' a AddressRange ) > ,
332
324
preferred_vnode : Option < u32 > ,
@@ -353,7 +345,7 @@ impl AddressSpaceManager {
353
345
}
354
346
} ;
355
347
356
- index. map ( |index| {
348
+ let alloc = index. map ( |index| {
357
349
self . allocate_range (
358
350
index,
359
351
len,
@@ -367,7 +359,13 @@ impl AddressSpaceManager {
367
359
} ,
368
360
allocation_policy,
369
361
)
370
- } )
362
+ } ) ;
363
+
364
+ if allocation_type == AllocationType :: GpaPool && alloc. is_some ( ) {
365
+ self . vtl2_pool = true ;
366
+ }
367
+
368
+ alloc
371
369
}
372
370
373
371
/// Returns an iterator for all VTL2 ranges.
@@ -388,8 +386,8 @@ impl AddressSpaceManager {
388
386
} )
389
387
}
390
388
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 {
393
391
self . vtl2_pool
394
392
}
395
393
}
@@ -445,6 +443,7 @@ mod tests {
445
443
)
446
444
. unwrap ( ) ;
447
445
assert_eq ! ( range. range, MemoryRange :: new( 0x1F000 ..0x20000 ) ) ;
446
+ assert ! ( address_space. has_vtl2_pool( ) ) ;
448
447
449
448
let range = address_space
450
449
. allocate (
0 commit comments