mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-07-15 21:57:15 +00:00
hypervisor: Move msr and msr_data macro to arch/x86
Currently these two macros(msr, msr_data) reside both on kvm and mshv module. Definition is same for both module. Moving them to arch/x86 module eliminates redundancy and makes more sense. Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
parent
aac86f4523
commit
8c85dd32fa
@ -14,4 +14,5 @@
|
|||||||
pub mod emulator;
|
pub mod emulator;
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
#[macro_use]
|
||||||
pub mod x86;
|
pub mod x86;
|
||||||
|
@ -122,3 +122,23 @@ pub fn segment_type_ro(t: u8) -> bool {
|
|||||||
pub fn segment_type_expand_down(t: u8) -> bool {
|
pub fn segment_type_expand_down(t: u8) -> bool {
|
||||||
!segment_type_code(t) && (t & EXPAND_DOWN_SEGMENT_TYPE != 0)
|
!segment_type_code(t) && (t & EXPAND_DOWN_SEGMENT_TYPE != 0)
|
||||||
}
|
}
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! msr {
|
||||||
|
($msr:expr) => {
|
||||||
|
MsrEntry {
|
||||||
|
index: $msr,
|
||||||
|
data: 0x0,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! msr_data {
|
||||||
|
($msr:expr, $data:expr) => {
|
||||||
|
MsrEntry {
|
||||||
|
index: $msr,
|
||||||
|
data: $data,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -8,11 +8,10 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
use vm_memory::GuestAddress;
|
|
||||||
|
|
||||||
use crate::arch::x86::{msr_index, SegmentRegisterOps, MTRR_ENABLE, MTRR_MEM_TYPE_WB};
|
use crate::arch::x86::{msr_index, SegmentRegisterOps, MTRR_ENABLE, MTRR_MEM_TYPE_WB};
|
||||||
use crate::kvm::{Cap, Kvm, KvmError, KvmResult};
|
use crate::kvm::{Cap, Kvm, KvmError, KvmResult};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
use vm_memory::GuestAddress;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Export generically-named wrappers of kvm-bindings for Unix-based platforms
|
/// Export generically-named wrappers of kvm-bindings for Unix-based platforms
|
||||||
@ -95,25 +94,6 @@ impl SegmentRegisterOps for SegmentRegister {
|
|||||||
|
|
||||||
pub const KVM_TSS_ADDRESS: GuestAddress = GuestAddress(0xfffb_d000);
|
pub const KVM_TSS_ADDRESS: GuestAddress = GuestAddress(0xfffb_d000);
|
||||||
|
|
||||||
macro_rules! msr {
|
|
||||||
($msr:expr) => {
|
|
||||||
MsrEntry {
|
|
||||||
index: $msr,
|
|
||||||
data: 0x0,
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
macro_rules! msr_data {
|
|
||||||
($msr:expr, $data:expr) => {
|
|
||||||
MsrEntry {
|
|
||||||
index: $msr,
|
|
||||||
data: $data,
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn boot_msr_entries() -> MsrEntries {
|
pub fn boot_msr_entries() -> MsrEntries {
|
||||||
MsrEntries::from_entries(&[
|
MsrEntries::from_entries(&[
|
||||||
msr!(msr_index::MSR_IA32_SYSENTER_CS),
|
msr!(msr_index::MSR_IA32_SYSENTER_CS),
|
||||||
|
@ -28,6 +28,10 @@ extern crate serde_derive;
|
|||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate thiserror;
|
extern crate thiserror;
|
||||||
|
|
||||||
|
/// Architecture specific definitions
|
||||||
|
#[macro_use]
|
||||||
|
pub mod arch;
|
||||||
|
|
||||||
#[cfg(feature = "kvm")]
|
#[cfg(feature = "kvm")]
|
||||||
/// KVM implementation module
|
/// KVM implementation module
|
||||||
pub mod kvm;
|
pub mod kvm;
|
||||||
@ -42,9 +46,6 @@ pub mod hypervisor;
|
|||||||
/// Vm related module
|
/// Vm related module
|
||||||
pub mod vm;
|
pub mod vm;
|
||||||
|
|
||||||
/// Architecture specific definitions
|
|
||||||
pub mod arch;
|
|
||||||
|
|
||||||
/// CPU related module
|
/// CPU related module
|
||||||
mod cpu;
|
mod cpu;
|
||||||
|
|
||||||
|
@ -49,15 +49,6 @@ pub enum IoEventAddress {
|
|||||||
/// Representation of an memory mapped I/O address.
|
/// Representation of an memory mapped I/O address.
|
||||||
Mmio(u64),
|
Mmio(u64),
|
||||||
}
|
}
|
||||||
macro_rules! msr {
|
|
||||||
($msr:expr) => {
|
|
||||||
MsrEntry {
|
|
||||||
index: $msr,
|
|
||||||
data: 0x0,
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SegmentRegisterOps for SegmentRegister {
|
impl SegmentRegisterOps for SegmentRegister {
|
||||||
fn segment_type(&self) -> u8 {
|
fn segment_type(&self) -> u8 {
|
||||||
|
Loading…
Reference in New Issue
Block a user