mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: Update virtio-iommu to follow 5.8-rc4 kernel
The virtio configuration structures have been slightly modified between 5.6-rc4 and 5.8-rc4, forcing the virtio-iommu device to be updated accordingly. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -101,9 +101,8 @@ unsafe impl ByteValued for VirtioIommuRange64 {}
|
|||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
struct VirtioIommuTopoConfig {
|
struct VirtioIommuTopoConfig {
|
||||||
offset: u32,
|
num_items: u16,
|
||||||
num_items: u32,
|
offset: u16,
|
||||||
item_length: u32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuTopoConfig {}
|
unsafe impl ByteValued for VirtioIommuTopoConfig {}
|
||||||
@@ -121,32 +120,36 @@ struct VirtioIommuConfig {
|
|||||||
unsafe impl ByteValued for VirtioIommuConfig {}
|
unsafe impl ByteValued for VirtioIommuConfig {}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
const VIRTIO_IOMMU_TOPO_PCI_RANGE: u16 = 1;
|
const VIRTIO_IOMMU_TOPO_PCI_RANGE: u8 = 1;
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
const VIRTIO_IOMMU_TOPO_ENDPOINT: u16 = 2;
|
const VIRTIO_IOMMU_TOPO_MMIO: u8 = 2;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
struct VirtioIommuTopoPciRange {
|
struct VirtioIommuTopoPciRange {
|
||||||
type_: u16,
|
type_: u8,
|
||||||
hierarchy: u16,
|
reserved: u8,
|
||||||
requester_start: u16,
|
length: u16,
|
||||||
requester_end: u16,
|
|
||||||
endpoint_start: u32,
|
endpoint_start: u32,
|
||||||
|
segment: u16,
|
||||||
|
bdf_start: u16,
|
||||||
|
bdf_end: u16,
|
||||||
|
padding: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuTopoPciRange {}
|
unsafe impl ByteValued for VirtioIommuTopoPciRange {}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
struct VirtioIommuTopoEndpoint {
|
struct VirtioIommuTopoMmio {
|
||||||
type_: u16,
|
type_: u8,
|
||||||
reserved: u16,
|
reserved: u8,
|
||||||
|
length: u16,
|
||||||
endpoint: u32,
|
endpoint: u32,
|
||||||
address: u64,
|
address: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl ByteValued for VirtioIommuTopoEndpoint {}
|
unsafe impl ByteValued for VirtioIommuTopoMmio {}
|
||||||
|
|
||||||
/// Virtio IOMMU request type
|
/// Virtio IOMMU request type
|
||||||
const VIRTIO_IOMMU_T_ATTACH: u8 = 1;
|
const VIRTIO_IOMMU_T_ATTACH: u8 = 1;
|
||||||
@@ -894,7 +897,7 @@ impl Iommu {
|
|||||||
//
|
//
|
||||||
// This function is dedicated to PCI, which means it will exclusively
|
// This function is dedicated to PCI, which means it will exclusively
|
||||||
// create VIRTIO_IOMMU_TOPO_PCI_RANGE entries.
|
// create VIRTIO_IOMMU_TOPO_PCI_RANGE entries.
|
||||||
pub fn attach_pci_devices(&mut self, domain: u16, device_ids: Vec<u32>) {
|
pub fn attach_pci_devices(&mut self, segment: u16, device_ids: Vec<u32>) {
|
||||||
if device_ids.is_empty() {
|
if device_ids.is_empty() {
|
||||||
warn!("No device to attach to virtual IOMMU");
|
warn!("No device to attach to virtual IOMMU");
|
||||||
return;
|
return;
|
||||||
@@ -910,18 +913,19 @@ impl Iommu {
|
|||||||
let dev_id = *device_id;
|
let dev_id = *device_id;
|
||||||
topo_pci_ranges.push(VirtioIommuTopoPciRange {
|
topo_pci_ranges.push(VirtioIommuTopoPciRange {
|
||||||
type_: VIRTIO_IOMMU_TOPO_PCI_RANGE,
|
type_: VIRTIO_IOMMU_TOPO_PCI_RANGE,
|
||||||
hierarchy: domain,
|
length: size_of::<VirtioIommuTopoPciRange>() as u16,
|
||||||
requester_start: dev_id as u16,
|
|
||||||
requester_end: dev_id as u16,
|
|
||||||
endpoint_start: dev_id,
|
endpoint_start: dev_id,
|
||||||
|
segment,
|
||||||
|
bdf_start: dev_id as u16,
|
||||||
|
bdf_end: dev_id as u16,
|
||||||
|
..Default::default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
self.config_topo_pci_ranges = topo_pci_ranges;
|
self.config_topo_pci_ranges = topo_pci_ranges;
|
||||||
|
|
||||||
// Update the configuration to include the topology.
|
// Update the configuration to include the topology.
|
||||||
self.config.topo_config.offset = size_of::<VirtioIommuConfig>() as u32;
|
self.config.topo_config.num_items = self.config_topo_pci_ranges.len() as u16;
|
||||||
self.config.topo_config.num_items = self.config_topo_pci_ranges.len() as u32;
|
self.config.topo_config.offset = size_of::<VirtioIommuConfig>() as u16;
|
||||||
self.config.topo_config.item_length = size_of::<VirtioIommuTopoPciRange>() as u32;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_external_mapping(&mut self, device_id: u32, mapping: Arc<dyn ExternalDmaMapping>) {
|
pub fn add_external_mapping(&mut self, device_id: u32, mapping: Arc<dyn ExternalDmaMapping>) {
|
||||||
|
|||||||
Reference in New Issue
Block a user