Skip to content

Commit 66b7c14

Browse files
committed
multiboot2: align(8) for all tags
This was already transitively the case as soon as they have a `header: TagHeader` field, however, for perfection, this can now safely be added.
1 parent e034db3 commit 66b7c14

13 files changed

+21
-20
lines changed

multiboot2/src/boot_information.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl core::error::Error for MbiLoadError {}
3838

3939
/// The basic header of a [`BootInformation`] as sized Rust type.
4040
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
41-
#[repr(C)]
41+
#[repr(C, align(8))]
4242
pub struct BootInformationHeader {
4343
// size is multiple of 8
4444
total_size: u32,
@@ -68,7 +68,7 @@ impl AsBytes for BootInformationHeader {}
6868
/// This type holds the whole data of the MBI. This helps to better satisfy miri
6969
/// when it checks for memory issues.
7070
#[derive(ptr_meta::Pointee)]
71-
#[repr(C)]
71+
#[repr(C, align(8))]
7272
struct BootInformationInner {
7373
header: BootInformationHeader,
7474
tags: [u8],

multiboot2/src/boot_loader_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const METADATA_SIZE: usize = mem::size_of::<TagHeader>();
1111

1212
/// The bootloader name tag.
1313
#[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
14-
#[repr(C)]
14+
#[repr(C, align(8))]
1515
pub struct BootLoaderNameTag {
1616
header: TagHeader,
1717
/// Null-terminated UTF-8 string

multiboot2/src/command_line.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const METADATA_SIZE: usize = mem::size_of::<TagHeader>();
1515
/// The string is a normal C-style UTF-8 zero-terminated string that can be
1616
/// obtained via the `command_line` method.
1717
#[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
18-
#[repr(C)]
18+
#[repr(C, align(8))]
1919
pub struct CommandLineTag {
2020
header: TagHeader,
2121
/// Null-terminated UTF-8 string

multiboot2/src/efi.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use core::mem::size_of;
1212

1313
/// EFI system table in 32 bit mode tag.
1414
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
15-
#[repr(C)]
15+
#[repr(C, align(8))]
1616
pub struct EFISdt32Tag {
1717
header: TagHeader,
1818
pointer: u32,
@@ -43,7 +43,7 @@ impl TagTrait for EFISdt32Tag {
4343

4444
/// EFI system table in 64 bit mode tag.
4545
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
46-
#[repr(C)]
46+
#[repr(C, align(8))]
4747
pub struct EFISdt64Tag {
4848
header: TagHeader,
4949
pointer: u64,
@@ -75,7 +75,7 @@ impl TagTrait for EFISdt64Tag {
7575
/// Tag that contains the pointer to the boot loader's UEFI image handle
7676
/// (32-bit).
7777
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
78-
#[repr(C)]
78+
#[repr(C, align(8))]
7979
pub struct EFIImageHandle32Tag {
8080
header: TagHeader,
8181
pointer: u32,
@@ -108,7 +108,7 @@ impl TagTrait for EFIImageHandle32Tag {
108108
/// Tag that contains the pointer to the boot loader's UEFI image handle
109109
/// (64-bit).
110110
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
111-
#[repr(C)]
111+
#[repr(C, align(8))]
112112
pub struct EFIImageHandle64Tag {
113113
header: TagHeader,
114114
pointer: u64,
@@ -138,9 +138,10 @@ impl TagTrait for EFIImageHandle64Tag {
138138
fn dst_len(_: &TagHeader) {}
139139
}
140140

141-
/// EFI ExitBootServices was not called tag.
141+
/// EFI ExitBootServices was not called tag. This tag has no payload and is
142+
/// just a marker.
142143
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
143-
#[repr(C)]
144+
#[repr(C, align(8))]
144145
pub struct EFIBootServicesNotExitedTag {
145146
header: TagHeader,
146147
}

multiboot2/src/elf_sections.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const METADATA_SIZE: usize = mem::size_of::<TagHeader>() + 3 * mem::size_of::<u3
1313
// The sections iterator is provided via the [`ElfSectionsTag::sections`]
1414
// method.
1515
#[derive(ptr_meta::Pointee, PartialEq, Eq)]
16-
#[repr(C)]
16+
#[repr(C, align(8))]
1717
pub struct ElfSectionsTag {
1818
header: TagHeader,
1919
number_of_sections: u32,

multiboot2/src/end.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use crate::{TagHeader, TagTrait, TagType, TagTypeId};
44

55
/// The end tag ends the information struct.
6-
#[repr(C)]
76
#[derive(Debug)]
7+
#[repr(C, align(8))]
88
pub struct EndTag {
99
typ: TagTypeId,
1010
size: u32,

multiboot2/src/framebuffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const METADATA_SIZE: usize = mem::size_of::<TagTypeId>()
5050

5151
/// The VBE Framebuffer information tag.
5252
#[derive(ptr_meta::Pointee, Eq)]
53-
#[repr(C)]
53+
#[repr(C, align(8))]
5454
pub struct FramebufferTag {
5555
header: TagHeader,
5656

multiboot2/src/image_load_addr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use core::mem::size_of;
99
/// binary was relocated, for example if the relocatable header tag was
1010
/// specified.
1111
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
12-
#[repr(C)]
12+
#[repr(C, align(8))]
1313
pub struct ImageLoadPhysAddrTag {
1414
header: TagHeader,
1515
load_base_addr: u32,

multiboot2/src/memory_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const METADATA_SIZE: usize = mem::size_of::<TagHeader>() + 2 * mem::size_of::<u3
2626
/// boot services are enabled and available for the loaded image (The EFI boot
2727
/// services tag may exist in the Multiboot2 boot information structure).
2828
#[derive(ptr_meta::Pointee, Debug, PartialEq, Eq)]
29-
#[repr(C)]
29+
#[repr(C, align(8))]
3030
pub struct MemoryMapTag {
3131
header: TagHeader,
3232
entry_size: u32,

multiboot2/src/module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const METADATA_SIZE: usize = mem::size_of::<TagHeader>() + 2 * mem::size_of::<u3
1313
/// (blobs in memory). The tag itself doesn't include the blog, but references
1414
/// its location.
1515
#[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
16-
#[repr(C)]
16+
#[repr(C, align(8))]
1717
pub struct ModuleTag {
1818
header: TagHeader,
1919
mod_start: u32,

0 commit comments

Comments
 (0)