Эх сурвалжийг харах

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.
Philipp Schuster 8 сар өмнө
parent
commit
ecfa1ab153

+ 2 - 2
multiboot2/src/boot_information.rs

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

+ 1 - 1
multiboot2/src/boot_loader_name.rs

@@ -11,7 +11,7 @@ const METADATA_SIZE: usize = mem::size_of::<TagHeader>();
 
 
 /// The bootloader name tag.
 /// The bootloader name tag.
 #[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct BootLoaderNameTag {
 pub struct BootLoaderNameTag {
     header: TagHeader,
     header: TagHeader,
     /// Null-terminated UTF-8 string
     /// Null-terminated UTF-8 string

+ 1 - 1
multiboot2/src/command_line.rs

@@ -15,7 +15,7 @@ const METADATA_SIZE: usize = mem::size_of::<TagHeader>();
 /// The string is a normal C-style UTF-8 zero-terminated string that can be
 /// The string is a normal C-style UTF-8 zero-terminated string that can be
 /// obtained via the `command_line` method.
 /// obtained via the `command_line` method.
 #[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct CommandLineTag {
 pub struct CommandLineTag {
     header: TagHeader,
     header: TagHeader,
     /// Null-terminated UTF-8 string
     /// Null-terminated UTF-8 string

+ 7 - 6
multiboot2/src/efi.rs

@@ -12,7 +12,7 @@ use core::mem::size_of;
 
 
 /// EFI system table in 32 bit mode tag.
 /// EFI system table in 32 bit mode tag.
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct EFISdt32Tag {
 pub struct EFISdt32Tag {
     header: TagHeader,
     header: TagHeader,
     pointer: u32,
     pointer: u32,
@@ -43,7 +43,7 @@ impl TagTrait for EFISdt32Tag {
 
 
 /// EFI system table in 64 bit mode tag.
 /// EFI system table in 64 bit mode tag.
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct EFISdt64Tag {
 pub struct EFISdt64Tag {
     header: TagHeader,
     header: TagHeader,
     pointer: u64,
     pointer: u64,
@@ -75,7 +75,7 @@ impl TagTrait for EFISdt64Tag {
 /// Tag that contains the pointer to the boot loader's UEFI image handle
 /// Tag that contains the pointer to the boot loader's UEFI image handle
 /// (32-bit).
 /// (32-bit).
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct EFIImageHandle32Tag {
 pub struct EFIImageHandle32Tag {
     header: TagHeader,
     header: TagHeader,
     pointer: u32,
     pointer: u32,
@@ -108,7 +108,7 @@ impl TagTrait for EFIImageHandle32Tag {
 /// Tag that contains the pointer to the boot loader's UEFI image handle
 /// Tag that contains the pointer to the boot loader's UEFI image handle
 /// (64-bit).
 /// (64-bit).
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct EFIImageHandle64Tag {
 pub struct EFIImageHandle64Tag {
     header: TagHeader,
     header: TagHeader,
     pointer: u64,
     pointer: u64,
@@ -138,9 +138,10 @@ impl TagTrait for EFIImageHandle64Tag {
     fn dst_len(_: &TagHeader) {}
     fn dst_len(_: &TagHeader) {}
 }
 }
 
 
-/// EFI ExitBootServices was not called tag.
+/// EFI ExitBootServices was not called tag. This tag has no payload and is
+/// just a marker.
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct EFIBootServicesNotExitedTag {
 pub struct EFIBootServicesNotExitedTag {
     header: TagHeader,
     header: TagHeader,
 }
 }

+ 1 - 1
multiboot2/src/elf_sections.rs

@@ -13,7 +13,7 @@ const METADATA_SIZE: usize = mem::size_of::<TagHeader>() + 3 * mem::size_of::<u3
 // The sections iterator is provided via the [`ElfSectionsTag::sections`]
 // The sections iterator is provided via the [`ElfSectionsTag::sections`]
 // method.
 // method.
 #[derive(ptr_meta::Pointee, PartialEq, Eq)]
 #[derive(ptr_meta::Pointee, PartialEq, Eq)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct ElfSectionsTag {
 pub struct ElfSectionsTag {
     header: TagHeader,
     header: TagHeader,
     number_of_sections: u32,
     number_of_sections: u32,

+ 1 - 1
multiboot2/src/end.rs

@@ -3,8 +3,8 @@
 use crate::{TagHeader, TagTrait, TagType, TagTypeId};
 use crate::{TagHeader, TagTrait, TagType, TagTypeId};
 
 
 /// The end tag ends the information struct.
 /// The end tag ends the information struct.
-#[repr(C)]
 #[derive(Debug)]
 #[derive(Debug)]
+#[repr(C, align(8))]
 pub struct EndTag {
 pub struct EndTag {
     typ: TagTypeId,
     typ: TagTypeId,
     size: u32,
     size: u32,

+ 1 - 1
multiboot2/src/framebuffer.rs

@@ -50,7 +50,7 @@ const METADATA_SIZE: usize = mem::size_of::<TagTypeId>()
 
 
 /// The VBE Framebuffer information tag.
 /// The VBE Framebuffer information tag.
 #[derive(ptr_meta::Pointee, Eq)]
 #[derive(ptr_meta::Pointee, Eq)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct FramebufferTag {
 pub struct FramebufferTag {
     header: TagHeader,
     header: TagHeader,
 
 

+ 1 - 1
multiboot2/src/image_load_addr.rs

@@ -9,7 +9,7 @@ use core::mem::size_of;
 /// binary was relocated, for example if the relocatable header tag was
 /// binary was relocated, for example if the relocatable header tag was
 /// specified.
 /// specified.
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct ImageLoadPhysAddrTag {
 pub struct ImageLoadPhysAddrTag {
     header: TagHeader,
     header: TagHeader,
     load_base_addr: u32,
     load_base_addr: u32,

+ 1 - 1
multiboot2/src/memory_map.rs

@@ -26,7 +26,7 @@ const METADATA_SIZE: usize = mem::size_of::<TagHeader>() + 2 * mem::size_of::<u3
 /// boot services are enabled and available for the loaded image (The EFI boot
 /// boot services are enabled and available for the loaded image (The EFI boot
 /// services tag may exist in the Multiboot2 boot information structure).
 /// services tag may exist in the Multiboot2 boot information structure).
 #[derive(ptr_meta::Pointee, Debug, PartialEq, Eq)]
 #[derive(ptr_meta::Pointee, Debug, PartialEq, Eq)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct MemoryMapTag {
 pub struct MemoryMapTag {
     header: TagHeader,
     header: TagHeader,
     entry_size: u32,
     entry_size: u32,

+ 1 - 1
multiboot2/src/module.rs

@@ -13,7 +13,7 @@ const METADATA_SIZE: usize = mem::size_of::<TagHeader>() + 2 * mem::size_of::<u3
 /// (blobs in memory). The tag itself doesn't include the blog, but references
 /// (blobs in memory). The tag itself doesn't include the blog, but references
 /// its location.
 /// its location.
 #[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct ModuleTag {
 pub struct ModuleTag {
     header: TagHeader,
     header: TagHeader,
     mod_start: u32,
     mod_start: u32,

+ 2 - 2
multiboot2/src/rsdp.rs

@@ -24,7 +24,7 @@ const RSDPV1_LENGTH: usize = 20;
 
 
 /// This tag contains a copy of RSDP as defined per ACPI 1.0 specification.
 /// This tag contains a copy of RSDP as defined per ACPI 1.0 specification.
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct RsdpV1Tag {
 pub struct RsdpV1Tag {
     header: TagHeader,
     header: TagHeader,
     signature: [u8; 8],
     signature: [u8; 8],
@@ -99,7 +99,7 @@ impl TagTrait for RsdpV1Tag {
 
 
 /// This tag contains a copy of RSDP as defined per ACPI 2.0 or later specification.
 /// This tag contains a copy of RSDP as defined per ACPI 2.0 or later specification.
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct RsdpV2Tag {
 pub struct RsdpV2Tag {
     header: TagHeader,
     header: TagHeader,
     signature: [u8; 8],
     signature: [u8; 8],

+ 1 - 1
multiboot2/src/smbios.rs

@@ -11,7 +11,7 @@ const METADATA_SIZE: usize = mem::size_of::<TagHeader>() + mem::size_of::<u8>()
 
 
 /// This tag contains a copy of SMBIOS tables as well as their version.
 /// This tag contains a copy of SMBIOS tables as well as their version.
 #[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[derive(ptr_meta::Pointee, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct SmbiosTag {
 pub struct SmbiosTag {
     header: TagHeader,
     header: TagHeader,
     major: u8,
     major: u8,

+ 1 - 1
multiboot2/src/vbe_info.rs

@@ -6,7 +6,7 @@ use core::fmt;
 /// This tag contains VBE metadata, VBE controller information returned by the
 /// This tag contains VBE metadata, VBE controller information returned by the
 /// VBE Function 00h and VBE mode information returned by the VBE Function 01h.
 /// VBE Function 00h and VBE mode information returned by the VBE Function 01h.
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
-#[repr(C)]
+#[repr(C, align(8))]
 pub struct VBEInfoTag {
 pub struct VBEInfoTag {
     typ: TagTypeId,
     typ: TagTypeId,
     length: u32,
     length: u32,