mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-23 16:31:16 +00:00
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:
parent
0d58e51a3a
commit
71d1296d09
@ -41,7 +41,7 @@ pub const ACPI_APIC_GENERIC_TRANSLATOR: u8 = 15;
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
#[derive(Default)]
|
#[derive(Default, AsBytes)]
|
||||||
struct PciRangeEntry {
|
struct PciRangeEntry {
|
||||||
pub base_address: u64,
|
pub base_address: u64,
|
||||||
pub segment: u16,
|
pub segment: u16,
|
||||||
@ -52,7 +52,7 @@ struct PciRangeEntry {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
#[derive(Default)]
|
#[derive(Default, AsBytes)]
|
||||||
struct MemoryAffinity {
|
struct MemoryAffinity {
|
||||||
pub type_: u8,
|
pub type_: u8,
|
||||||
pub length: u8,
|
pub length: u8,
|
||||||
@ -69,7 +69,7 @@ struct MemoryAffinity {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
#[derive(Default)]
|
#[derive(Default, AsBytes)]
|
||||||
struct ProcessorLocalX2ApicAffinity {
|
struct ProcessorLocalX2ApicAffinity {
|
||||||
pub type_: u8,
|
pub type_: u8,
|
||||||
pub length: u8,
|
pub length: u8,
|
||||||
@ -83,7 +83,7 @@ struct ProcessorLocalX2ApicAffinity {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
#[derive(Default)]
|
#[derive(Default, AsBytes)]
|
||||||
struct ProcessorGiccAffinity {
|
struct ProcessorGiccAffinity {
|
||||||
pub type_: u8,
|
pub type_: u8,
|
||||||
pub length: u8,
|
pub length: u8,
|
||||||
@ -143,7 +143,7 @@ impl MemoryAffinity {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
#[derive(Default)]
|
#[derive(Default, AsBytes)]
|
||||||
struct ViotVirtioPciNode {
|
struct ViotVirtioPciNode {
|
||||||
pub type_: u8,
|
pub type_: u8,
|
||||||
_reserved: u8,
|
_reserved: u8,
|
||||||
@ -155,7 +155,7 @@ struct ViotVirtioPciNode {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
#[derive(Default)]
|
#[derive(Default, AsBytes)]
|
||||||
struct ViotPciRangeNode {
|
struct ViotPciRangeNode {
|
||||||
pub type_: u8,
|
pub type_: u8,
|
||||||
_reserved: u8,
|
_reserved: u8,
|
||||||
|
@ -84,6 +84,7 @@ use vm_migration::{
|
|||||||
};
|
};
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
use vmm_sys_util::signal::{register_signal_handler, SIGRTMIN};
|
use vmm_sys_util::signal::{register_signal_handler, SIGRTMIN};
|
||||||
|
use zerocopy::AsBytes;
|
||||||
|
|
||||||
#[cfg(all(target_arch = "aarch64", feature = "guest_debug"))]
|
#[cfg(all(target_arch = "aarch64", feature = "guest_debug"))]
|
||||||
/// Extract the specified bits of a 64-bit integer.
|
/// 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")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
|
#[derive(AsBytes)]
|
||||||
struct LocalApic {
|
struct LocalApic {
|
||||||
pub r#type: u8,
|
pub r#type: u8,
|
||||||
pub length: u8,
|
pub length: u8,
|
||||||
@ -186,7 +188,7 @@ struct LocalApic {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
#[derive(Default)]
|
#[derive(Default, AsBytes)]
|
||||||
struct Ioapic {
|
struct Ioapic {
|
||||||
pub r#type: u8,
|
pub r#type: u8,
|
||||||
pub length: u8,
|
pub length: u8,
|
||||||
@ -199,6 +201,7 @@ struct Ioapic {
|
|||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
|
#[derive(AsBytes)]
|
||||||
struct GicC {
|
struct GicC {
|
||||||
pub r#type: u8,
|
pub r#type: u8,
|
||||||
pub length: u8,
|
pub length: u8,
|
||||||
@ -223,6 +226,7 @@ struct GicC {
|
|||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
|
#[derive(AsBytes)]
|
||||||
struct GicD {
|
struct GicD {
|
||||||
pub r#type: u8,
|
pub r#type: u8,
|
||||||
pub length: u8,
|
pub length: u8,
|
||||||
@ -237,6 +241,7 @@ struct GicD {
|
|||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
|
#[derive(AsBytes)]
|
||||||
struct GicR {
|
struct GicR {
|
||||||
pub r#type: u8,
|
pub r#type: u8,
|
||||||
pub length: u8,
|
pub length: u8,
|
||||||
@ -248,6 +253,7 @@ struct GicR {
|
|||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
|
#[derive(AsBytes)]
|
||||||
struct GicIts {
|
struct GicIts {
|
||||||
pub r#type: u8,
|
pub r#type: u8,
|
||||||
pub length: u8,
|
pub length: u8,
|
||||||
@ -260,6 +266,7 @@ struct GicIts {
|
|||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
|
#[derive(AsBytes)]
|
||||||
struct ProcessorHierarchyNode {
|
struct ProcessorHierarchyNode {
|
||||||
pub r#type: u8,
|
pub r#type: u8,
|
||||||
pub length: u8,
|
pub length: u8,
|
||||||
@ -272,7 +279,7 @@ struct ProcessorHierarchyNode {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
#[derive(Default)]
|
#[derive(Default, AsBytes)]
|
||||||
struct InterruptSourceOverride {
|
struct InterruptSourceOverride {
|
||||||
pub r#type: u8,
|
pub r#type: u8,
|
||||||
pub length: u8,
|
pub length: u8,
|
||||||
|
Loading…
Reference in New Issue
Block a user