Skip to content

Commit

Permalink
treewide: fix usages of MemoryDescriptor (add explicit padding field)
Browse files Browse the repository at this point in the history
  • Loading branch information
phip1611 committed Oct 1, 2024
1 parent 8f43158 commit f88e106
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions uefi-raw/src/table/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ mod tests {
let descs = [
MemoryDescriptor {
ty: MemoryType::CONVENTIONAL,
_pad0: 0,
phys_start: 0x1000,
virt_start: 0x1000,
page_count: 1,
Expand Down
3 changes: 3 additions & 0 deletions uefi/src/mem/memory_map/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,20 +432,23 @@ mod tests {
const BASE_MMAP_UNSORTED: [MemoryDescriptor; 3] = [
MemoryDescriptor {
ty: MemoryType::CONVENTIONAL,
_pad0: 0,
phys_start: 0x3000,
virt_start: 0x3000,
page_count: 1,
att: MemoryAttribute::WRITE_BACK,
},
MemoryDescriptor {
ty: MemoryType::CONVENTIONAL,
_pad0: 0,
phys_start: 0x2000,
virt_start: 0x2000,
page_count: 1,
att: MemoryAttribute::WRITE_BACK,
},
MemoryDescriptor {
ty: MemoryType::CONVENTIONAL,
_pad0: 0,
phys_start: 0x1000,
virt_start: 0x1000,
page_count: 1,
Expand Down
12 changes: 12 additions & 0 deletions uefi/src/mem/memory_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ mod tests_mmap_artificial {

const BASE: MemoryDescriptor = MemoryDescriptor {
ty: TY,
_pad0: 0,
phys_start: 0,
virt_start: 0,
page_count: 0,
Expand Down Expand Up @@ -169,6 +170,7 @@ mod tests_mmap_artificial {

const BASE: MemoryDescriptor = MemoryDescriptor {
ty: TY,
_pad0: 0,
phys_start: 0,
virt_start: 0,
page_count: 0,
Expand Down Expand Up @@ -278,6 +280,7 @@ mod tests_mmap_real {
| MemoryAttribute::WRITE_COMBINE
| MemoryAttribute::WRITE_THROUGH
| MemoryAttribute::WRITE_BACK,
..Default::default()
},
MemoryDescriptor {
ty: MemoryType::CONVENTIONAL,
Expand All @@ -288,6 +291,7 @@ mod tests_mmap_real {
| MemoryAttribute::WRITE_COMBINE
| MemoryAttribute::WRITE_THROUGH
| MemoryAttribute::WRITE_BACK,
..Default::default()
},
MemoryDescriptor {
ty: MemoryType::BOOT_SERVICES_DATA,
Expand All @@ -298,6 +302,7 @@ mod tests_mmap_real {
| MemoryAttribute::WRITE_COMBINE
| MemoryAttribute::WRITE_THROUGH
| MemoryAttribute::WRITE_BACK,
..Default::default()
},
MemoryDescriptor {
ty: MemoryType::CONVENTIONAL,
Expand All @@ -308,6 +313,7 @@ mod tests_mmap_real {
| MemoryAttribute::WRITE_COMBINE
| MemoryAttribute::WRITE_THROUGH
| MemoryAttribute::WRITE_BACK,
..Default::default()
},
MemoryDescriptor {
ty: MemoryType::CONVENTIONAL,
Expand All @@ -318,6 +324,7 @@ mod tests_mmap_real {
| MemoryAttribute::WRITE_COMBINE
| MemoryAttribute::WRITE_THROUGH
| MemoryAttribute::WRITE_BACK,
..Default::default()
},
MemoryDescriptor {
ty: MemoryType::ACPI_NON_VOLATILE,
Expand All @@ -328,6 +335,7 @@ mod tests_mmap_real {
| MemoryAttribute::WRITE_COMBINE
| MemoryAttribute::WRITE_THROUGH
| MemoryAttribute::WRITE_BACK,
..Default::default()
},
MemoryDescriptor {
ty: MemoryType::CONVENTIONAL,
Expand All @@ -338,6 +346,7 @@ mod tests_mmap_real {
| MemoryAttribute::WRITE_COMBINE
| MemoryAttribute::WRITE_THROUGH
| MemoryAttribute::WRITE_BACK,
..Default::default()
},
MemoryDescriptor {
ty: MemoryType::ACPI_NON_VOLATILE,
Expand All @@ -348,6 +357,7 @@ mod tests_mmap_real {
| MemoryAttribute::WRITE_COMBINE
| MemoryAttribute::WRITE_THROUGH
| MemoryAttribute::WRITE_BACK,
..Default::default()
},
MemoryDescriptor {
ty: MemoryType::CONVENTIONAL,
Expand All @@ -358,6 +368,7 @@ mod tests_mmap_real {
| MemoryAttribute::WRITE_COMBINE
| MemoryAttribute::WRITE_THROUGH
| MemoryAttribute::WRITE_BACK,
..Default::default()
},
MemoryDescriptor {
ty: MemoryType::ACPI_NON_VOLATILE,
Expand All @@ -368,6 +379,7 @@ mod tests_mmap_real {
| MemoryAttribute::WRITE_COMBINE
| MemoryAttribute::WRITE_THROUGH
| MemoryAttribute::WRITE_BACK,
..Default::default()
},
];
assert_eq!(entries.as_slice(), &expected);
Expand Down
3 changes: 3 additions & 0 deletions uefi/tests/memory_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@ fn parse_boot_information_efi_mmap() {
virt_start: 0x3000,
page_count: 1,
att: MemoryAttribute::WRITE_BACK,
..Default::default()
},
MemoryDescriptor {
ty: MemoryType::CONVENTIONAL,
phys_start: 0x2000,
virt_start: 0x2000,
page_count: 1,
att: MemoryAttribute::WRITE_BACK,
..Default::default()
},
MemoryDescriptor {
ty: MemoryType::CONVENTIONAL,
phys_start: 0x1000,
virt_start: 0x1000,
page_count: 1,
att: MemoryAttribute::WRITE_BACK,
..Default::default()
},
];
let map_size = mmap_source.len() * desc_size;
Expand Down

0 comments on commit f88e106

Please sign in to comment.