mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-03 20:15:45 +00:00
vmm, devices: Use APIC address constant
In order to avoid introducing a dependency on arch in the devices crate pass the constant in to the IOAPIC device creation. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
162791b571
commit
b5ee9212c1
@ -15,6 +15,7 @@ use kvm_bindings::kvm_msi;
|
|||||||
use kvm_ioctls::VmFd;
|
use kvm_ioctls::VmFd;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{io, result};
|
use std::{io, result};
|
||||||
|
use vm_memory::GuestAddress;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
@ -156,6 +157,7 @@ pub struct Ioapic {
|
|||||||
reg_sel: u32,
|
reg_sel: u32,
|
||||||
reg_entries: [RedirectionTableEntry; NUM_IOAPIC_PINS],
|
reg_entries: [RedirectionTableEntry; NUM_IOAPIC_PINS],
|
||||||
vm_fd: Arc<VmFd>,
|
vm_fd: Arc<VmFd>,
|
||||||
|
apic_address: GuestAddress,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BusDevice for Ioapic {
|
impl BusDevice for Ioapic {
|
||||||
@ -194,12 +196,13 @@ impl BusDevice for Ioapic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Ioapic {
|
impl Ioapic {
|
||||||
pub fn new(vm_fd: Arc<VmFd>) -> Ioapic {
|
pub fn new(vm_fd: Arc<VmFd>, apic_address: GuestAddress) -> Ioapic {
|
||||||
Ioapic {
|
Ioapic {
|
||||||
id: 0,
|
id: 0,
|
||||||
reg_sel: 0,
|
reg_sel: 0,
|
||||||
reg_entries: [0; NUM_IOAPIC_PINS],
|
reg_entries: [0; NUM_IOAPIC_PINS],
|
||||||
vm_fd,
|
vm_fd,
|
||||||
|
apic_address,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +242,7 @@ impl Ioapic {
|
|||||||
let redirection_hint: u8 = 1;
|
let redirection_hint: u8 = 1;
|
||||||
|
|
||||||
// Generate MSI message address
|
// Generate MSI message address
|
||||||
let address_lo: u32 = 0xfee0_0000
|
let address_lo: u32 = self.apic_address.0 as u32
|
||||||
| u32::from(destination_id) << 12
|
| u32::from(destination_id) << 12
|
||||||
| u32::from(redirection_hint) << 3
|
| u32::from(redirection_hint) << 3
|
||||||
| u32::from(destination_mode) << 2;
|
| u32::from(destination_mode) << 2;
|
||||||
|
@ -28,7 +28,7 @@ use qcow::{self, ImageType, QcowFile};
|
|||||||
use std::fs::{File, OpenOptions};
|
use std::fs::{File, OpenOptions};
|
||||||
use std::io::{self, sink, stdout};
|
use std::io::{self, sink, stdout};
|
||||||
|
|
||||||
use arch::layout::{IOAPIC_SIZE, IOAPIC_START};
|
use arch::layout::{APIC_START, IOAPIC_SIZE, IOAPIC_START};
|
||||||
use std::os::unix::fs::OpenOptionsExt;
|
use std::os::unix::fs::OpenOptionsExt;
|
||||||
use std::os::unix::io::AsRawFd;
|
use std::os::unix::io::AsRawFd;
|
||||||
use std::ptr::null_mut;
|
use std::ptr::null_mut;
|
||||||
@ -305,7 +305,10 @@ impl DeviceManager {
|
|||||||
|
|
||||||
let ioapic = if userspace_ioapic {
|
let ioapic = if userspace_ioapic {
|
||||||
// Create IOAPIC
|
// Create IOAPIC
|
||||||
let ioapic = Arc::new(Mutex::new(ioapic::Ioapic::new(vm_info.vm_fd.clone())));
|
let ioapic = Arc::new(Mutex::new(ioapic::Ioapic::new(
|
||||||
|
vm_info.vm_fd.clone(),
|
||||||
|
APIC_START,
|
||||||
|
)));
|
||||||
buses
|
buses
|
||||||
.mmio
|
.mmio
|
||||||
.insert(ioapic.clone(), IOAPIC_START.0, IOAPIC_SIZE)
|
.insert(ioapic.clone(), IOAPIC_START.0, IOAPIC_SIZE)
|
||||||
|
Loading…
Reference in New Issue
Block a user