Skip to content

Commit 9aa54c5

Browse files
committed
fix memory access benchmark panicking on ARM
The benchmark tries to write to guest physical address 0, but on ARM guest memory doesn't start at 0, so when resolving the address we panicked. Fix this by instead simply using whatever address guest memory starts with. Signed-off-by: Patrick Roy <[email protected]>
1 parent fe3ba28 commit 9aa54c5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/vmm/benches/memory_access.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
5-
use vm_memory::{GuestAddress, GuestMemory};
5+
use vm_memory::GuestMemory;
66
use vmm::resources::VmResources;
77
use vmm::vmm_config::machine_config::{HugePageConfig, VmConfig};
88

@@ -11,11 +11,10 @@ fn bench_single_page_fault(c: &mut Criterion, configuration: VmResources) {
1111
b.iter_batched(
1212
|| {
1313
let memory = configuration.allocate_guest_memory().unwrap();
14-
let ptr = memory
15-
.get_slice(GuestAddress(0), 1)
16-
.unwrap()
17-
.ptr_guard_mut()
18-
.as_ptr();
14+
// Get a pointer to the first memory region (cannot do `.get_slice(GuestAddress(0),
15+
// 1)`, because on ARM64 guest memory does not start at physical
16+
// address 0).
17+
let ptr = memory.iter().next().unwrap().as_ptr();
1918

2019
// fine to return both here, because ptr is not a reference into `memory` (e.g. no
2120
// self-referential structs are happening here)

0 commit comments

Comments
 (0)