Skip to content

multiboot2: fix handling of efi memory map #216

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 9 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions integration-test/bins/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion multiboot2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Multiboot2-compliant bootloaders, such as GRUB. It supports all tags from the
specification including full support for the sections of ELF files. This library
is `no_std` and can be used in a Multiboot2-kernel.
"""
version = "0.20.0"
version = "0.20.1"
authors = [
"Philipp Oppermann <[email protected]>",
"Calvin Lee <[email protected]>",
Expand Down
8 changes: 7 additions & 1 deletion multiboot2/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# CHANGELOG for crate `multiboot2`

## Unreleased
## 0.20.1 (2024-05-26)

- fixed the handling of `EFIMemoryMapTag` and `EFIMemoryAreaIter`
- **BREAKING** Fixed wrong creation of `EFIMemoryMapTag`.
`EFIMemoryMapTag::new` was replaced by `EFIMemoryMapTag::new_from_descs` and
`EFIMemoryMapTag::new_from_map`.
- `ModuleTag::new`'s `end` parameter now must be bigger than `start`.

## 0.20.0 (2024-05-01)

Expand Down
19 changes: 12 additions & 7 deletions multiboot2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ pub use end::EndTag;
pub use framebuffer::{FramebufferColor, FramebufferField, FramebufferTag, FramebufferType};
pub use image_load_addr::ImageLoadPhysAddrTag;
pub use memory_map::{
BasicMemoryInfoTag, EFIMemoryAreaType, EFIMemoryDesc, EFIMemoryMapTag, MemoryArea,
MemoryAreaType, MemoryAreaTypeId, MemoryMapTag,
BasicMemoryInfoTag, EFIMemoryAreaType, EFIMemoryAttribute, EFIMemoryDesc, EFIMemoryMapTag,
MemoryArea, MemoryAreaType, MemoryAreaTypeId, MemoryMapTag,
};
pub use module::{ModuleIter, ModuleTag};
pub use ptr_meta::Pointee;
Expand Down Expand Up @@ -302,7 +302,10 @@ impl<'a> BootInformation<'a> {
// If the EFIBootServicesNotExited is present, then we should not use
// the memory map, as it could still be in use.
match self.get_tag::<EFIBootServicesNotExitedTag>() {
Some(_tag) => None,
Some(_tag) => {
log::debug!("The EFI memory map is present but the UEFI Boot Services Not Existed Tag is present. Returning None.");
None
}
None => self.get_tag::<EFIMemoryMapTag>(),
}
}
Expand Down Expand Up @@ -1450,15 +1453,15 @@ mod tests {
#[cfg_attr(miri, ignore)]
fn efi_memory_map() {
#[repr(C, align(8))]
struct Bytes([u8; 72]);
struct Bytes([u8; 80]);
// test that the EFI memory map is detected.
let bytes: Bytes = Bytes([
72, 0, 0, 0, // size
80, 0, 0, 0, // size
0, 0, 0, 0, // reserved
17, 0, 0, 0, // EFI memory map type
56, 0, 0, 0, // EFI memory map size
64, 0, 0, 0, // EFI memory map size
48, 0, 0, 0, // EFI descriptor size
1, 0, 0, 0, // EFI descriptor version, don't think this matters.
1, 0, 0, 0, // EFI descriptor version
7, 0, 0, 0, // Type: EfiConventionalMemory
0, 0, 0, 0, // Padding
0, 0, 16, 0, // Physical Address: should be 0x100000
Expand All @@ -1469,6 +1472,8 @@ mod tests {
0, 0, 0, 0, // Extension of pages
0, 0, 0, 0, // Attributes of this memory range.
0, 0, 0, 0, // Extension of attributes
0, 0, 0, 0, // More padding to extend the efi mmap to `desc_size`.
0, 0, 0, 0, // padding/alignment for end tag
0, 0, 0, 0, // end tag type.
8, 0, 0, 0, // end tag size.
]);
Expand Down
Loading