Skip to content

Guard the lower 1MB of memory #446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Test to ensure MemoryRegions are always frame aligned
  • Loading branch information
Wasabi375 committed Jun 22, 2024
commit 0f4dd1f074dc239c7f332d214d22a99980d912fe
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
- name: Run api tests
run: cargo test -p bootloader_api
- name: Run bootloader common tests
if: runner.os == 'Linux'
run: cargo test -p bootloader-x86_64-common
- name: Run integration tests
run: cargo test -- --test-threads 1
Expand Down
27 changes: 27 additions & 0 deletions common/src/legacy_memory_region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,33 @@ mod tests {
}]
}

#[test]
fn test_all_regions_frame_alligned() {
let regions = create_single_test_region();
let mut allocator = LegacyFrameAllocator::new(regions.into_iter());
// allocate at least 1 frame
allocator.allocate_frame();

let mut regions = [MaybeUninit::uninit(); 10];
let kernel_slice_start = PhysAddr::new(0x50000);
let kernel_slice_len = 0x0500;
let ramdisk_slice_start = None;
let ramdisk_slice_len = 0;

let kernel_regions = allocator.construct_memory_map(
&mut regions,
kernel_slice_start,
kernel_slice_len,
ramdisk_slice_start,
ramdisk_slice_len,
);

for region in kernel_regions.iter() {
assert!(region.start % 0x1000 == 0);
assert!(region.end % 0x1000 == 0);
}
}

#[test]
fn test_kernel_and_ram_in_same_region() {
let regions = create_single_test_region();
Expand Down
Loading