vmm: Implemented zerocopy::AsBytes for SDT structures

For structures that are used in SDT ACPI tables it is necessary for them
to implement this trait for the newly safe Std::write() API.

Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
This commit is contained in:
Rob Bradford 2023-04-26 17:07:41 +01:00 committed by Rob Bradford
parent 0d58e51a3a
commit 71d1296d09
2 changed files with 15 additions and 8 deletions

View File

@ -41,7 +41,7 @@ pub const ACPI_APIC_GENERIC_TRANSLATOR: u8 = 15;
#[allow(dead_code)]
#[repr(packed)]
#[derive(Default)]
#[derive(Default, AsBytes)]
struct PciRangeEntry {
pub base_address: u64,
pub segment: u16,
@ -52,7 +52,7 @@ struct PciRangeEntry {
#[allow(dead_code)]
#[repr(packed)]
#[derive(Default)]
#[derive(Default, AsBytes)]
struct MemoryAffinity {
pub type_: u8,
pub length: u8,
@ -69,7 +69,7 @@ struct MemoryAffinity {
#[allow(dead_code)]
#[repr(packed)]
#[derive(Default)]
#[derive(Default, AsBytes)]
struct ProcessorLocalX2ApicAffinity {
pub type_: u8,
pub length: u8,
@ -83,7 +83,7 @@ struct ProcessorLocalX2ApicAffinity {
#[allow(dead_code)]
#[repr(packed)]
#[derive(Default)]
#[derive(Default, AsBytes)]
struct ProcessorGiccAffinity {
pub type_: u8,
pub length: u8,
@ -143,7 +143,7 @@ impl MemoryAffinity {
#[allow(dead_code)]
#[repr(packed)]
#[derive(Default)]
#[derive(Default, AsBytes)]
struct ViotVirtioPciNode {
pub type_: u8,
_reserved: u8,
@ -155,7 +155,7 @@ struct ViotVirtioPciNode {
#[allow(dead_code)]
#[repr(packed)]
#[derive(Default)]
#[derive(Default, AsBytes)]
struct ViotPciRangeNode {
pub type_: u8,
_reserved: u8,

View File

@ -84,6 +84,7 @@ use vm_migration::{
};
use vmm_sys_util::eventfd::EventFd;
use vmm_sys_util::signal::{register_signal_handler, SIGRTMIN};
use zerocopy::AsBytes;
#[cfg(all(target_arch = "aarch64", feature = "guest_debug"))]
/// Extract the specified bits of a 64-bit integer.
@ -176,6 +177,7 @@ pub type Result<T> = result::Result<T, Error>;
#[cfg(target_arch = "x86_64")]
#[allow(dead_code)]
#[repr(packed)]
#[derive(AsBytes)]
struct LocalApic {
pub r#type: u8,
pub length: u8,
@ -186,7 +188,7 @@ struct LocalApic {
#[allow(dead_code)]
#[repr(packed)]
#[derive(Default)]
#[derive(Default, AsBytes)]
struct Ioapic {
pub r#type: u8,
pub length: u8,
@ -199,6 +201,7 @@ struct Ioapic {
#[cfg(target_arch = "aarch64")]
#[allow(dead_code)]
#[repr(packed)]
#[derive(AsBytes)]
struct GicC {
pub r#type: u8,
pub length: u8,
@ -223,6 +226,7 @@ struct GicC {
#[cfg(target_arch = "aarch64")]
#[allow(dead_code)]
#[repr(packed)]
#[derive(AsBytes)]
struct GicD {
pub r#type: u8,
pub length: u8,
@ -237,6 +241,7 @@ struct GicD {
#[cfg(target_arch = "aarch64")]
#[allow(dead_code)]
#[repr(packed)]
#[derive(AsBytes)]
struct GicR {
pub r#type: u8,
pub length: u8,
@ -248,6 +253,7 @@ struct GicR {
#[cfg(target_arch = "aarch64")]
#[allow(dead_code)]
#[repr(packed)]
#[derive(AsBytes)]
struct GicIts {
pub r#type: u8,
pub length: u8,
@ -260,6 +266,7 @@ struct GicIts {
#[cfg(target_arch = "aarch64")]
#[allow(dead_code)]
#[repr(packed)]
#[derive(AsBytes)]
struct ProcessorHierarchyNode {
pub r#type: u8,
pub length: u8,
@ -272,7 +279,7 @@ struct ProcessorHierarchyNode {
#[allow(dead_code)]
#[repr(packed)]
#[derive(Default)]
#[derive(Default, AsBytes)]
struct InterruptSourceOverride {
pub r#type: u8,
pub length: u8,