Skip to content

Commit e78529a

Browse files
authored
Merge pull request #216 from rust-osdev/efi-mmap
multiboot2: fix handling of efi memory map
2 parents 3077c3b + 188b14b commit e78529a

File tree

8 files changed

+329
-71
lines changed

8 files changed

+329
-71
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integration-test/bins/Cargo.lock

+18-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

multiboot2/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Multiboot2-compliant bootloaders, such as GRUB. It supports all tags from the
66
specification including full support for the sections of ELF files. This library
77
is `no_std` and can be used in a Multiboot2-kernel.
88
"""
9-
version = "0.20.0"
9+
version = "0.20.1"
1010
authors = [
1111
"Philipp Oppermann <[email protected]>",
1212
"Calvin Lee <[email protected]>",

multiboot2/Changelog.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# CHANGELOG for crate `multiboot2`
22

3-
## Unreleased
3+
## 0.20.1 (2024-05-26)
4+
5+
- fixed the handling of `EFIMemoryMapTag` and `EFIMemoryAreaIter`
6+
- **BREAKING** Fixed wrong creation of `EFIMemoryMapTag`.
7+
`EFIMemoryMapTag::new` was replaced by `EFIMemoryMapTag::new_from_descs` and
8+
`EFIMemoryMapTag::new_from_map`.
9+
- `ModuleTag::new`'s `end` parameter now must be bigger than `start`.
410

511
## 0.20.0 (2024-05-01)
612

multiboot2/src/lib.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ pub use end::EndTag;
7777
pub use framebuffer::{FramebufferColor, FramebufferField, FramebufferTag, FramebufferType};
7878
pub use image_load_addr::ImageLoadPhysAddrTag;
7979
pub use memory_map::{
80-
BasicMemoryInfoTag, EFIMemoryAreaType, EFIMemoryDesc, EFIMemoryMapTag, MemoryArea,
81-
MemoryAreaType, MemoryAreaTypeId, MemoryMapTag,
80+
BasicMemoryInfoTag, EFIMemoryAreaType, EFIMemoryAttribute, EFIMemoryDesc, EFIMemoryMapTag,
81+
MemoryArea, MemoryAreaType, MemoryAreaTypeId, MemoryMapTag,
8282
};
8383
pub use module::{ModuleIter, ModuleTag};
8484
pub use ptr_meta::Pointee;
@@ -302,7 +302,10 @@ impl<'a> BootInformation<'a> {
302302
// If the EFIBootServicesNotExited is present, then we should not use
303303
// the memory map, as it could still be in use.
304304
match self.get_tag::<EFIBootServicesNotExitedTag>() {
305-
Some(_tag) => None,
305+
Some(_tag) => {
306+
log::debug!("The EFI memory map is present but the UEFI Boot Services Not Existed Tag is present. Returning None.");
307+
None
308+
}
306309
None => self.get_tag::<EFIMemoryMapTag>(),
307310
}
308311
}
@@ -1450,15 +1453,15 @@ mod tests {
14501453
#[cfg_attr(miri, ignore)]
14511454
fn efi_memory_map() {
14521455
#[repr(C, align(8))]
1453-
struct Bytes([u8; 72]);
1456+
struct Bytes([u8; 80]);
14541457
// test that the EFI memory map is detected.
14551458
let bytes: Bytes = Bytes([
1456-
72, 0, 0, 0, // size
1459+
80, 0, 0, 0, // size
14571460
0, 0, 0, 0, // reserved
14581461
17, 0, 0, 0, // EFI memory map type
1459-
56, 0, 0, 0, // EFI memory map size
1462+
64, 0, 0, 0, // EFI memory map size
14601463
48, 0, 0, 0, // EFI descriptor size
1461-
1, 0, 0, 0, // EFI descriptor version, don't think this matters.
1464+
1, 0, 0, 0, // EFI descriptor version
14621465
7, 0, 0, 0, // Type: EfiConventionalMemory
14631466
0, 0, 0, 0, // Padding
14641467
0, 0, 16, 0, // Physical Address: should be 0x100000
@@ -1469,6 +1472,8 @@ mod tests {
14691472
0, 0, 0, 0, // Extension of pages
14701473
0, 0, 0, 0, // Attributes of this memory range.
14711474
0, 0, 0, 0, // Extension of attributes
1475+
0, 0, 0, 0, // More padding to extend the efi mmap to `desc_size`.
1476+
0, 0, 0, 0, // padding/alignment for end tag
14721477
0, 0, 0, 0, // end tag type.
14731478
8, 0, 0, 0, // end tag size.
14741479
]);

0 commit comments

Comments
 (0)