mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-05 21:15:45 +00:00
arch: fix end of table entry in smbios
Previously the code used the SmbiosSysInfo structure for that purpose. Handle 0x0003, DMI type 127, 27 bytes <TRUNCATED> Wrong DMI structures length: 130 bytes announced, structures occupy 131 bytes. Fix this by using the correct structure and padding. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
a62b611659
commit
05e0daa411
@ -125,10 +125,20 @@ pub struct SmbiosSysInfo {
|
|||||||
pub family: u8,
|
pub family: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
#[repr(packed)]
|
||||||
|
#[derive(Default, Copy, Clone)]
|
||||||
|
pub struct SmbiosEndOfTable {
|
||||||
|
pub typ: u8,
|
||||||
|
pub length: u8,
|
||||||
|
pub handle: u16,
|
||||||
|
}
|
||||||
|
|
||||||
// SAFETY: These data structures only contain a series of integers
|
// SAFETY: These data structures only contain a series of integers
|
||||||
unsafe impl ByteValued for Smbios30Entrypoint {}
|
unsafe impl ByteValued for Smbios30Entrypoint {}
|
||||||
unsafe impl ByteValued for SmbiosBiosInfo {}
|
unsafe impl ByteValued for SmbiosBiosInfo {}
|
||||||
unsafe impl ByteValued for SmbiosSysInfo {}
|
unsafe impl ByteValued for SmbiosSysInfo {}
|
||||||
|
unsafe impl ByteValued for SmbiosEndOfTable {}
|
||||||
|
|
||||||
fn write_and_incr<T: ByteValued>(
|
fn write_and_incr<T: ByteValued>(
|
||||||
mem: &GuestMemoryMmap,
|
mem: &GuestMemoryMmap,
|
||||||
@ -212,13 +222,13 @@ pub fn setup_smbios(
|
|||||||
|
|
||||||
{
|
{
|
||||||
handle += 1;
|
handle += 1;
|
||||||
let smbios_sysinfo = SmbiosSysInfo {
|
let smbios_end = SmbiosEndOfTable {
|
||||||
typ: END_OF_TABLE,
|
typ: END_OF_TABLE,
|
||||||
length: mem::size_of::<SmbiosSysInfo>() as u8,
|
length: mem::size_of::<SmbiosEndOfTable>() as u8,
|
||||||
handle,
|
handle,
|
||||||
..Default::default()
|
|
||||||
};
|
};
|
||||||
curptr = write_and_incr(mem, smbios_sysinfo, curptr)?;
|
curptr = write_and_incr(mem, smbios_end, curptr)?;
|
||||||
|
curptr = write_and_incr(mem, 0u8, curptr)?;
|
||||||
curptr = write_and_incr(mem, 0u8, curptr)?;
|
curptr = write_and_incr(mem, 0u8, curptr)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user