Skip to content

Commit e6540a0

Browse files
committed
pr feedback + tests
1 parent 100b2b9 commit e6540a0

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

openhcl/openhcl_boot/src/host_params/dt/dma_hint.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use igvm_defs::PAGE_SIZE_4K;
3636
///
3737
/// The table is sorted by VP count, then by assigned memory.
3838
/// (vp_count, vtl2_memory_mb, dma_hint_mb)
39+
#[cfg(not(debug_assertions))]
3940
const LOOKUP_TABLE: &[(u16, u16, u16); 38] = &[
4041
(2, 96, 2),
4142
(2, 98, 4),
@@ -77,6 +78,16 @@ const LOOKUP_TABLE: &[(u16, u16, u16); 38] = &[
7778
(896, 12912, 0), // (516) Needs to be validated as the vNIC number is unknown. (TODO, as part of network device keepalive support).
7879
];
7980

81+
/// TEST ONLY variant of the lookup table above. Since the IGVM manifest specifies additional
82+
/// VTL2 memory for dev (well above what is required for release configs), allow the heuristics
83+
/// to still kick in.
84+
#[cfg(debug_assertions)]
85+
const LOOKUP_TABLE: &[(u16, u16, u16); 3] = &[
86+
(4, 496, 32), // 4 VP, default memory for dev, allocate some memory for DMA.
87+
(16, 768, 128), // 16 VP "heavy", with extra memory above what is required for dev, allocate some memory for DMA.
88+
(32, 1024, 256), // 32 VP "very heavy", with extra memory above what is required for dev, allocate some memory for DMA.
89+
];
90+
8091
const ONE_MB: u64 = 1024 * 1024;
8192

8293
/// Maximum allowed memory size for DMA hint calculation (1 TiB).

openhcl/openhcl_boot/src/host_params/dt/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,14 +534,15 @@ fn topology_from_host_dt(
534534

535535
if dt_page_count.is_some() || cmdline_page_count.is_some() {
536536
// Any external source defined the pool size, use the maximum of all external sources.
537-
max(dt_page_count.unwrap_or(0), cmdline_page_count.unwrap_or(0))
537+
let external = max(dt_page_count.unwrap_or(0), cmdline_page_count.unwrap_or(0));
538+
if external == 0 { None } else { Some(external) }
538539
} else {
539540
// No external source defined the pool size, use heuristics to decide.
540541
let mem_size = vtl2_ram.iter().map(|e| e.range.len()).sum();
541-
vtl2_calculate_dma_hint(parsed.cpu_count(), mem_size)
542+
Some(vtl2_calculate_dma_hint(parsed.cpu_count(), mem_size))
542543
}
543544
};
544-
if vtl2_gpa_pool_size != 0 {
545+
if let Some(vtl2_gpa_pool_size) = vtl2_gpa_pool_size {
545546
// Reserve the specified number of pages for the pool. Use the used
546547
// ranges to figure out which VTL2 memory is free to allocate from.
547548
let pool_size_bytes = vtl2_gpa_pool_size * HV_PAGE_SIZE;

vmm_tests/vmm_tests/tests/tests/x86_64/openhcl_uefi.rs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ async fn nvme_relay(config: PetriVmBuilder<OpenVmmPetriBackend>) -> Result<(), a
165165
///
166166
/// Use the private pool override to test the private pool dma path.
167167
#[openvmm_test(openhcl_uefi_x64[nvme](vhd(ubuntu_2504_server_x64)))]
168-
async fn nvme_relay_private_pool(
168+
async fn nvme_relay_explicit_private_pool(
169169
config: PetriVmBuilder<OpenVmmPetriBackend>,
170170
) -> Result<(), anyhow::Error> {
171171
// Number of pages to reserve as a private pool.
@@ -183,14 +183,43 @@ async fn nvme_relay_private_pool(
183183
.await
184184
}
185185

186+
/// Test an OpenHCL uefi VM with a NVME disk assigned to VTL2 that boots
187+
/// linux, with vmbus relay. This should expose a disk to VTL0 via vmbus.
188+
///
189+
/// There _should_ be enough private pool memory for the NVMe driver to
190+
/// allocate all of its buffers contiguously.
191+
#[cfg(debug_assertions)]
192+
#[openvmm_test(openhcl_uefi_x64[nvme](vhd(ubuntu_2504_server_x64)))]
193+
async fn nvme_relay_heuristic_16vp_768mb_heavy(
194+
config: PetriVmBuilder<OpenVmmPetriBackend>,
195+
) -> Result<(), anyhow::Error> {
196+
nvme_relay_test_core(
197+
config,
198+
"",
199+
Some(ProcessorTopology {
200+
vp_count: 16,
201+
..Default::default()
202+
}),
203+
Some(hvlite_defs::config::Vtl2BaseAddressType::Vtl2Allocate {
204+
size: Some(768 * 1024 * 1024),
205+
}),
206+
Some(ExpectedNvmeDeviceProperties {
207+
save_restore_supported: true,
208+
qsize: 256, // private pool should allow contiguous allocations.
209+
nvme_keepalive: false,
210+
}),
211+
)
212+
.await
213+
}
214+
186215
/// Test an OpenHCL uefi VM with a NVME disk assigned to VTL2 that boots
187216
/// linux, with vmbus relay. This should expose a disk to VTL0 via vmbus.
188217
///
189218
/// There _should_ be enough private pool memory for the NVMe driver to
190219
/// allocate all of its buffers contiguously.
191220
#[cfg(not(debug_assertions))]
192221
#[openvmm_test(openhcl_uefi_x64[nvme](vhd(ubuntu_2504_server_x64)))]
193-
async fn nvme_relay_private_16vp_256mb(
222+
async fn nvme_relay_heuristic_release_16vp_256mb_heavy(
194223
config: PetriVmBuilder<OpenVmmPetriBackend>,
195224
) -> Result<(), anyhow::Error> {
196225
nvme_relay_test_core(
@@ -222,7 +251,7 @@ async fn nvme_relay_private_16vp_256mb(
222251
/// of the heuristics exactly, but there should still be private pool memory.
223252
#[cfg(not(debug_assertions))]
224253
#[openvmm_test(openhcl_uefi_x64[nvme](vhd(ubuntu_2504_server_x64)))]
225-
async fn nvme_relay_private_32vp_500mb(
254+
async fn nvme_relay_heuristic_release_32vp_500mb_very_heavy(
226255
config: PetriVmBuilder<OpenVmmPetriBackend>,
227256
) -> Result<(), anyhow::Error> {
228257
nvme_relay_test_core(

0 commit comments

Comments
 (0)