Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 5 additions & 33 deletions sys/kerncore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ mod tests {
size: 0x0001_0000,
label: "good".to_string(),
},
TestRegion {
base: 0x123A_5678,
size: 0x0001_0000,
label: "good".to_string(),
},
]
}
const GOOD_REGION_0_IDX: usize = 0;
Expand Down Expand Up @@ -418,37 +423,4 @@ mod tests {
ranges but passes through bad one, but can",
);
}

#[test]
fn cannot_access_slice_spanning_over_uncontained_memory() {
// Using a custom region table to not cause
// cannot_access_uncontained_memory to spuriously fail.
let region_table = vec![
TestRegion {
base: 0x1238_5678,
size: 0x0001_0000,
label: "good".to_string(),
},
TestRegion {
// 64 kiB separated from previous region
base: 0x123A_5678,
size: 0x0001_0000,
label: "good".to_string(),
},
];

let base = region_table[GOOD_REGION_0_IDX].base + 10;
let end = region_table[GOOD_REGION_1_IDX].end_addr() - 10;
let slice = TestSlice {
base,
size: end - base,
};

assert!(
// Load-bearing tiny punctuation character:
!can_access(slice, &region_table, accept_only_good_regions,),
"should NOT be able to access slice that starts and ends in \
good ranges but passes through uncontained memory, but can",
);
}
}
Loading