mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-02 19:45:46 +00:00
virtio-devices: add or adjust comments for impl ByteValued
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
d8becc742c
commit
31b3871eee
@ -100,7 +100,7 @@ pub struct VirtioBalloonConfig {
|
|||||||
const CONFIG_ACTUAL_OFFSET: u64 = 4;
|
const CONFIG_ACTUAL_OFFSET: u64 = 4;
|
||||||
const CONFIG_ACTUAL_SIZE: usize = 4;
|
const CONFIG_ACTUAL_SIZE: usize = 4;
|
||||||
|
|
||||||
// Safe because it only has data and has no implicit padding.
|
// SAFETY: it only has data and has no implicit padding.
|
||||||
unsafe impl ByteValued for VirtioBalloonConfig {}
|
unsafe impl ByteValued for VirtioBalloonConfig {}
|
||||||
|
|
||||||
struct VirtioBalloonResizeReceiver {
|
struct VirtioBalloonResizeReceiver {
|
||||||
|
@ -69,7 +69,7 @@ impl Default for VirtioConsoleConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safe because it only has data and has no implicit padding.
|
// SAFETY: it only has data and has no implicit padding.
|
||||||
unsafe impl ByteValued for VirtioConsoleConfig {}
|
unsafe impl ByteValued for VirtioConsoleConfig {}
|
||||||
|
|
||||||
struct ConsoleEpollHandler {
|
struct ConsoleEpollHandler {
|
||||||
|
@ -79,8 +79,6 @@ struct VirtioIommuRange32 {
|
|||||||
end: u32,
|
end: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuRange32 {}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@ -89,8 +87,6 @@ struct VirtioIommuRange64 {
|
|||||||
end: u64,
|
end: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuRange64 {}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@ -103,8 +99,6 @@ struct VirtioIommuConfig {
|
|||||||
_reserved: [u8; 7],
|
_reserved: [u8; 7],
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuConfig {}
|
|
||||||
|
|
||||||
/// Virtio IOMMU request type
|
/// Virtio IOMMU request type
|
||||||
const VIRTIO_IOMMU_T_ATTACH: u8 = 1;
|
const VIRTIO_IOMMU_T_ATTACH: u8 = 1;
|
||||||
const VIRTIO_IOMMU_T_DETACH: u8 = 2;
|
const VIRTIO_IOMMU_T_DETACH: u8 = 2;
|
||||||
@ -119,8 +113,6 @@ struct VirtioIommuReqHead {
|
|||||||
_reserved: [u8; 3],
|
_reserved: [u8; 3],
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuReqHead {}
|
|
||||||
|
|
||||||
/// Virtio IOMMU request status
|
/// Virtio IOMMU request status
|
||||||
const VIRTIO_IOMMU_S_OK: u8 = 0;
|
const VIRTIO_IOMMU_S_OK: u8 = 0;
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
@ -148,8 +140,6 @@ struct VirtioIommuReqTail {
|
|||||||
_reserved: [u8; 3],
|
_reserved: [u8; 3],
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuReqTail {}
|
|
||||||
|
|
||||||
/// ATTACH request
|
/// ATTACH request
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
@ -159,8 +149,6 @@ struct VirtioIommuReqAttach {
|
|||||||
_reserved: [u8; 8],
|
_reserved: [u8; 8],
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuReqAttach {}
|
|
||||||
|
|
||||||
/// DETACH request
|
/// DETACH request
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
@ -170,8 +158,6 @@ struct VirtioIommuReqDetach {
|
|||||||
_reserved: [u8; 8],
|
_reserved: [u8; 8],
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuReqDetach {}
|
|
||||||
|
|
||||||
/// Virtio IOMMU request MAP flags
|
/// Virtio IOMMU request MAP flags
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
const VIRTIO_IOMMU_MAP_F_READ: u32 = 1;
|
const VIRTIO_IOMMU_MAP_F_READ: u32 = 1;
|
||||||
@ -194,8 +180,6 @@ struct VirtioIommuReqMap {
|
|||||||
_flags: u32,
|
_flags: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuReqMap {}
|
|
||||||
|
|
||||||
/// UNMAP request
|
/// UNMAP request
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
@ -206,8 +190,6 @@ struct VirtioIommuReqUnmap {
|
|||||||
_reserved: [u8; 4],
|
_reserved: [u8; 4],
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuReqUnmap {}
|
|
||||||
|
|
||||||
/// Virtio IOMMU request PROBE types
|
/// Virtio IOMMU request PROBE types
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
const VIRTIO_IOMMU_PROBE_T_NONE: u16 = 0;
|
const VIRTIO_IOMMU_PROBE_T_NONE: u16 = 0;
|
||||||
@ -224,8 +206,6 @@ struct VirtioIommuReqProbe {
|
|||||||
_reserved: [u64; 8],
|
_reserved: [u64; 8],
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuReqProbe {}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@ -234,8 +214,6 @@ struct VirtioIommuProbeProperty {
|
|||||||
length: u16,
|
length: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuProbeProperty {}
|
|
||||||
|
|
||||||
/// Virtio IOMMU request PROBE property RESV_MEM subtypes
|
/// Virtio IOMMU request PROBE property RESV_MEM subtypes
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
const VIRTIO_IOMMU_RESV_MEM_T_RESERVED: u8 = 0;
|
const VIRTIO_IOMMU_RESV_MEM_T_RESERVED: u8 = 0;
|
||||||
@ -251,8 +229,6 @@ struct VirtioIommuProbeResvMem {
|
|||||||
end: u64,
|
end: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuProbeResvMem {}
|
|
||||||
|
|
||||||
/// Virtio IOMMU fault flags
|
/// Virtio IOMMU fault flags
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
const VIRTIO_IOMMU_FAULT_F_READ: u32 = 1;
|
const VIRTIO_IOMMU_FAULT_F_READ: u32 = 1;
|
||||||
@ -284,6 +260,19 @@ struct VirtioIommuFault {
|
|||||||
address: u64,
|
address: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SAFETY: these data structures only contain integers and have no implicit padding
|
||||||
|
unsafe impl ByteValued for VirtioIommuRange32 {}
|
||||||
|
unsafe impl ByteValued for VirtioIommuRange64 {}
|
||||||
|
unsafe impl ByteValued for VirtioIommuConfig {}
|
||||||
|
unsafe impl ByteValued for VirtioIommuReqHead {}
|
||||||
|
unsafe impl ByteValued for VirtioIommuReqTail {}
|
||||||
|
unsafe impl ByteValued for VirtioIommuReqAttach {}
|
||||||
|
unsafe impl ByteValued for VirtioIommuReqDetach {}
|
||||||
|
unsafe impl ByteValued for VirtioIommuReqMap {}
|
||||||
|
unsafe impl ByteValued for VirtioIommuReqUnmap {}
|
||||||
|
unsafe impl ByteValued for VirtioIommuReqProbe {}
|
||||||
|
unsafe impl ByteValued for VirtioIommuProbeProperty {}
|
||||||
|
unsafe impl ByteValued for VirtioIommuProbeResvMem {}
|
||||||
unsafe impl ByteValued for VirtioIommuFault {}
|
unsafe impl ByteValued for VirtioIommuFault {}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -149,7 +149,7 @@ struct VirtioMemReq {
|
|||||||
padding_1: [u16; 3],
|
padding_1: [u16; 3],
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safe because it only has data and has no implicit padding.
|
// SAFETY: it only has data and has no implicit padding.
|
||||||
unsafe impl ByteValued for VirtioMemReq {}
|
unsafe impl ByteValued for VirtioMemReq {}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@ -160,7 +160,7 @@ struct VirtioMemResp {
|
|||||||
state: u16,
|
state: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safe because it only has data and has no implicit padding.
|
// SAFETY: it only has data and has no implicit padding.
|
||||||
unsafe impl ByteValued for VirtioMemResp {}
|
unsafe impl ByteValued for VirtioMemResp {}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@ -186,7 +186,7 @@ pub struct VirtioMemConfig {
|
|||||||
requested_size: u64,
|
requested_size: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safe because it only has data and has no implicit padding.
|
// SAFETY: it only has data and has no implicit padding.
|
||||||
unsafe impl ByteValued for VirtioMemConfig {}
|
unsafe impl ByteValued for VirtioMemConfig {}
|
||||||
|
|
||||||
impl VirtioMemConfig {
|
impl VirtioMemConfig {
|
||||||
|
@ -50,7 +50,7 @@ struct VirtioPmemConfig {
|
|||||||
size: u64,
|
size: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safe because it only has data and has no implicit padding.
|
// SAFETY: it only has data and has no implicit padding.
|
||||||
unsafe impl ByteValued for VirtioPmemConfig {}
|
unsafe impl ByteValued for VirtioPmemConfig {}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
@ -59,7 +59,7 @@ struct VirtioPmemReq {
|
|||||||
type_: u32,
|
type_: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safe because it only has data and has no implicit padding.
|
// SAFETY: it only has data and has no implicit padding.
|
||||||
unsafe impl ByteValued for VirtioPmemReq {}
|
unsafe impl ByteValued for VirtioPmemReq {}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
@ -68,7 +68,7 @@ struct VirtioPmemResp {
|
|||||||
ret: u32,
|
ret: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safe because it only has data and has no implicit padding.
|
// SAFETY: it only has data and has no implicit padding.
|
||||||
unsafe impl ByteValued for VirtioPmemResp {}
|
unsafe impl ByteValued for VirtioPmemResp {}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -75,7 +75,7 @@ struct VirtioPciCap {
|
|||||||
offset: Le32, // Offset within bar.
|
offset: Le32, // Offset within bar.
|
||||||
length: Le32, // Length of the structure, in bytes.
|
length: Le32, // Length of the structure, in bytes.
|
||||||
}
|
}
|
||||||
// It is safe to implement ByteValued. All members are simple numbers and any value is valid.
|
// SAFETY: All members are simple numbers and any value is valid.
|
||||||
unsafe impl ByteValued for VirtioPciCap {}
|
unsafe impl ByteValued for VirtioPciCap {}
|
||||||
|
|
||||||
impl PciCapability for VirtioPciCap {
|
impl PciCapability for VirtioPciCap {
|
||||||
@ -111,7 +111,7 @@ struct VirtioPciNotifyCap {
|
|||||||
cap: VirtioPciCap,
|
cap: VirtioPciCap,
|
||||||
notify_off_multiplier: Le32,
|
notify_off_multiplier: Le32,
|
||||||
}
|
}
|
||||||
// It is safe to implement ByteValued. All members are simple numbers and any value is valid.
|
// SAFETY: All members are simple numbers and any value is valid.
|
||||||
unsafe impl ByteValued for VirtioPciNotifyCap {}
|
unsafe impl ByteValued for VirtioPciNotifyCap {}
|
||||||
|
|
||||||
impl PciCapability for VirtioPciNotifyCap {
|
impl PciCapability for VirtioPciNotifyCap {
|
||||||
@ -156,7 +156,7 @@ struct VirtioPciCap64 {
|
|||||||
offset_hi: Le32,
|
offset_hi: Le32,
|
||||||
length_hi: Le32,
|
length_hi: Le32,
|
||||||
}
|
}
|
||||||
// It is safe to implement ByteValued. All members are simple numbers and any value is valid.
|
// SAFETY: All members are simple numbers and any value is valid.
|
||||||
unsafe impl ByteValued for VirtioPciCap64 {}
|
unsafe impl ByteValued for VirtioPciCap64 {}
|
||||||
|
|
||||||
impl PciCapability for VirtioPciCap64 {
|
impl PciCapability for VirtioPciCap64 {
|
||||||
@ -194,7 +194,7 @@ struct VirtioPciCfgCap {
|
|||||||
cap: VirtioPciCap,
|
cap: VirtioPciCap,
|
||||||
pci_cfg_data: [u8; 4],
|
pci_cfg_data: [u8; 4],
|
||||||
}
|
}
|
||||||
// It is safe to implement ByteValued. All members are simple numbers and any value is valid.
|
// SAFETY: All members are simple numbers and any value is valid.
|
||||||
unsafe impl ByteValued for VirtioPciCfgCap {}
|
unsafe impl ByteValued for VirtioPciCfgCap {}
|
||||||
|
|
||||||
impl PciCapability for VirtioPciCfgCap {
|
impl PciCapability for VirtioPciCfgCap {
|
||||||
|
Loading…
Reference in New Issue
Block a user