mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-21 20:15:21 +00:00
vm-virtio: initialize MSI-X vectors with VIRTIO_MSI_NO_VECTOR
In case of the virtio frontend driver doesn't need interupts for certain queue event, it may explicitly write VIRTIO_MSI_NO_VECTOR to the virtio common configuration, or it may doesn't configure the event type vector at all. This patch initializes both MSI-X configuration vector and queue vector with VIRTIO_MSI_NO_VECTOR, so that the backend drivers won't trigger unexpected interrupts to the guest. Signed-off-by: Zide Chen <zide.chen@intel.com>
This commit is contained in:
parent
40a3c31df4
commit
f685f0e0b2
@ -75,8 +75,6 @@ const VIRTIO_F_VERSION_1: u32 = 32;
|
|||||||
const VIRTIO_F_IOMMU_PLATFORM: u32 = 33;
|
const VIRTIO_F_IOMMU_PLATFORM: u32 = 33;
|
||||||
const VIRTIO_F_IN_ORDER: u32 = 35;
|
const VIRTIO_F_IN_ORDER: u32 = 35;
|
||||||
|
|
||||||
const VIRTIO_MSI_NO_VECTOR: u16 = 0xffff;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ActivateError {
|
pub enum ActivateError {
|
||||||
EpollCtl(std::io::Error),
|
EpollCtl(std::io::Error),
|
||||||
|
@ -16,7 +16,7 @@ use crate::transport::VirtioTransport;
|
|||||||
use crate::{
|
use crate::{
|
||||||
ActivateResult, Queue, VirtioDevice, VirtioDeviceType, VirtioInterrupt, VirtioInterruptType,
|
ActivateResult, Queue, VirtioDevice, VirtioDeviceType, VirtioInterrupt, VirtioInterruptType,
|
||||||
DEVICE_ACKNOWLEDGE, DEVICE_DRIVER, DEVICE_DRIVER_OK, DEVICE_FAILED, DEVICE_FEATURES_OK,
|
DEVICE_ACKNOWLEDGE, DEVICE_DRIVER, DEVICE_DRIVER_OK, DEVICE_FAILED, DEVICE_FEATURES_OK,
|
||||||
DEVICE_INIT, VIRTIO_MSI_NO_VECTOR,
|
DEVICE_INIT,
|
||||||
};
|
};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use libc::EFD_NONBLOCK;
|
use libc::EFD_NONBLOCK;
|
||||||
@ -45,7 +45,7 @@ use vm_migration::{
|
|||||||
Migratable, MigratableError, Pausable, Snapshot, SnapshotDataSection, Snapshottable,
|
Migratable, MigratableError, Pausable, Snapshot, SnapshotDataSection, Snapshottable,
|
||||||
Transportable,
|
Transportable,
|
||||||
};
|
};
|
||||||
use vm_virtio::{queue, VirtioIommuRemapping};
|
use vm_virtio::{queue, VirtioIommuRemapping, VIRTIO_MSI_NO_VECTOR};
|
||||||
use vmm_sys_util::{errno::Result, eventfd::EventFd};
|
use vmm_sys_util::{errno::Result, eventfd::EventFd};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -423,7 +423,7 @@ impl VirtioPciDevice {
|
|||||||
device_feature_select: 0,
|
device_feature_select: 0,
|
||||||
driver_feature_select: 0,
|
driver_feature_select: 0,
|
||||||
queue_select: 0,
|
queue_select: 0,
|
||||||
msix_config: Arc::new(AtomicU16::new(0)),
|
msix_config: Arc::new(AtomicU16::new(VIRTIO_MSI_NO_VECTOR)),
|
||||||
},
|
},
|
||||||
msix_config,
|
msix_config,
|
||||||
msix_num,
|
msix_num,
|
||||||
|
@ -23,6 +23,8 @@ pub use queue::*;
|
|||||||
pub type VirtioIommuRemapping =
|
pub type VirtioIommuRemapping =
|
||||||
Box<dyn Fn(u64) -> std::result::Result<u64, std::io::Error> + Send + Sync>;
|
Box<dyn Fn(u64) -> std::result::Result<u64, std::io::Error> + Send + Sync>;
|
||||||
|
|
||||||
|
pub const VIRTIO_MSI_NO_VECTOR: u16 = 0xffff;
|
||||||
|
|
||||||
// Types taken from linux/virtio_ids.h
|
// Types taken from linux/virtio_ids.h
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||||
|
|
||||||
use crate::VirtioIommuRemapping;
|
use crate::{VirtioIommuRemapping, VIRTIO_MSI_NO_VECTOR};
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::fmt::{self, Display};
|
use std::fmt::{self, Display};
|
||||||
@ -438,7 +438,7 @@ impl Queue {
|
|||||||
max_size,
|
max_size,
|
||||||
size: max_size,
|
size: max_size,
|
||||||
ready: false,
|
ready: false,
|
||||||
vector: 0,
|
vector: VIRTIO_MSI_NO_VECTOR,
|
||||||
desc_table: GuestAddress(0),
|
desc_table: GuestAddress(0),
|
||||||
avail_ring: GuestAddress(0),
|
avail_ring: GuestAddress(0),
|
||||||
used_ring: GuestAddress(0),
|
used_ring: GuestAddress(0),
|
||||||
@ -486,7 +486,7 @@ impl Queue {
|
|||||||
self.size = self.max_size;
|
self.size = self.max_size;
|
||||||
self.next_avail = Wrapping(0);
|
self.next_avail = Wrapping(0);
|
||||||
self.next_used = Wrapping(0);
|
self.next_used = Wrapping(0);
|
||||||
self.vector = 0;
|
self.vector = VIRTIO_MSI_NO_VECTOR;
|
||||||
self.desc_table = GuestAddress(0);
|
self.desc_table = GuestAddress(0);
|
||||||
self.avail_ring = GuestAddress(0);
|
self.avail_ring = GuestAddress(0);
|
||||||
self.used_ring = GuestAddress(0);
|
self.used_ring = GuestAddress(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user