mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
hypervisor: x86: provide a generic DescriptorTable structure
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
75797827d5
commit
d2b194c4f1
@ -198,3 +198,10 @@ pub struct StandardRegisters {
|
||||
pub rip: u64,
|
||||
pub rflags: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "with-serde", derive(Deserialize, Serialize))]
|
||||
pub struct DescriptorTable {
|
||||
pub base: u64,
|
||||
pub limit: u16,
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
//
|
||||
//
|
||||
|
||||
use crate::arch::x86::{SegmentRegister, StandardRegisters};
|
||||
use crate::arch::x86::{DescriptorTable, SegmentRegister, StandardRegisters};
|
||||
use crate::kvm::{Cap, Kvm, KvmError, KvmResult};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize};
|
||||
/// Export generically-named wrappers of kvm-bindings for Unix-based platforms
|
||||
///
|
||||
pub use {
|
||||
kvm_bindings::kvm_cpuid_entry2 as CpuIdEntry, kvm_bindings::kvm_dtable as DescriptorTable,
|
||||
kvm_bindings::kvm_cpuid_entry2 as CpuIdEntry, kvm_bindings::kvm_dtable,
|
||||
kvm_bindings::kvm_fpu as FpuState, kvm_bindings::kvm_lapic_state as LapicState,
|
||||
kvm_bindings::kvm_mp_state as MpState, kvm_bindings::kvm_msr_entry as MsrEntry,
|
||||
kvm_bindings::kvm_regs, kvm_bindings::kvm_segment, kvm_bindings::kvm_sregs as SpecialRegisters,
|
||||
@ -152,3 +152,22 @@ impl From<kvm_segment> for SegmentRegister {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DescriptorTable> for kvm_dtable {
|
||||
fn from(dt: DescriptorTable) -> Self {
|
||||
Self {
|
||||
base: dt.base,
|
||||
limit: dt.limit,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<kvm_dtable> for DescriptorTable {
|
||||
fn from(dt: kvm_dtable) -> Self {
|
||||
Self {
|
||||
base: dt.base,
|
||||
limit: dt.limit,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
// Copyright 2018-2019 CrowdStrike, Inc.
|
||||
//
|
||||
//
|
||||
use crate::arch::x86::{SegmentRegister, StandardRegisters};
|
||||
use crate::arch::x86::{DescriptorTable, SegmentRegister, StandardRegisters};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
@ -23,7 +23,7 @@ pub use {
|
||||
mshv_bindings::Msrs as MsrEntries, mshv_bindings::Msrs,
|
||||
mshv_bindings::SegmentRegister as MshvSegmentRegister, mshv_bindings::SpecialRegisters,
|
||||
mshv_bindings::StandardRegisters as MshvStandardRegisters, mshv_bindings::SuspendRegisters,
|
||||
mshv_bindings::VcpuEvents, mshv_bindings::XSave as Xsave,
|
||||
mshv_bindings::TableRegister, mshv_bindings::VcpuEvents, mshv_bindings::XSave as Xsave,
|
||||
mshv_bindings::Xcrs as ExtendedControlRegisters,
|
||||
};
|
||||
|
||||
@ -155,3 +155,21 @@ impl From<MshvSegmentRegister> for SegmentRegister {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DescriptorTable> for TableRegister {
|
||||
fn from(dt: DescriptorTable) -> Self {
|
||||
Self {
|
||||
base: dt.base,
|
||||
limit: dt.limit,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<TableRegister> for DescriptorTable {
|
||||
fn from(dt: TableRegister) -> Self {
|
||||
Self {
|
||||
base: dt.base,
|
||||
limit: dt.limit,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user