Skip to content

Commit 2d1256c

Browse files
ManciukicShadowCurse
authored andcommitted
Revert "fix(memory): validate memory region state before resuming"
This reverts commit b58c536. Signed-off-by: Riccardo Mancini <mancio@amazon.com>
1 parent c37849c commit 2d1256c

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

src/vmm/src/vstate/memory.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ pub enum MemoryError {
5555
OffsetTooLarge,
5656
/// Cannot retrieve snapshot file metadata: {0}
5757
FileMetadata(std::io::Error),
58-
/// Memory region state is invalid: {0}
59-
InvalidRegionState(&'static str),
58+
/// Memory region is not aligned
59+
Unaligned,
6060
/// Error protecting memory slot: {0}
6161
Mprotect(std::io::Error),
6262
}
@@ -231,23 +231,9 @@ impl GuestRegionMmapExt {
231231
slot_from: u32,
232232
) -> Result<Self, MemoryError> {
233233
let slot_cnt = state.plugged.len();
234-
let slot_size = u64_to_usize(region.len()).checked_div(slot_cnt).ok_or(
235-
MemoryError::InvalidRegionState("memory region should be aligned to the slot size"),
236-
)?;
237-
238-
// validate the region state to avoid spurious crashes when resuming from an invalid state
239-
if state.region_type == GuestRegionType::Dram {
240-
if slot_cnt != 1 {
241-
return Err(MemoryError::InvalidRegionState(
242-
"DRAM region should contain only one slot",
243-
));
244-
}
245-
if !state.plugged[0] {
246-
return Err(MemoryError::InvalidRegionState(
247-
"DRAM region should be plugged",
248-
));
249-
}
250-
}
234+
let slot_size = u64_to_usize(region.len())
235+
.checked_div(slot_cnt)
236+
.ok_or(MemoryError::Unaligned)?;
251237

252238
Ok(GuestRegionMmapExt {
253239
inner: region,

0 commit comments

Comments
 (0)