mirror of
https://github.com/obhq/obliteration.git
synced 2024-11-23 03:09:52 +00:00
Implements MultiThreadResume for CpuManager (#1068)
Co-authored-by: tompro <tomas.prochazka@apertia.cz>
This commit is contained in:
parent
f919cd89b9
commit
93894163b5
@ -9,9 +9,11 @@ use super::ram::RamMap;
|
||||
use super::{VmmEvent, VmmEventHandler};
|
||||
use crate::error::RustError;
|
||||
use crate::screen::Screen;
|
||||
use gdbstub::common::Tid;
|
||||
use gdbstub::common::{Signal, Tid};
|
||||
use gdbstub::stub::MultiThreadStopReason;
|
||||
use gdbstub::target::ext::base::multithread::MultiThreadBase;
|
||||
use gdbstub::target::ext::base::multithread::{
|
||||
MultiThreadBase, MultiThreadResume, MultiThreadResumeOps,
|
||||
};
|
||||
use gdbstub::target::ext::thread_extra_info::{ThreadExtraInfo, ThreadExtraInfoOps};
|
||||
use gdbstub::target::{TargetError, TargetResult};
|
||||
use std::collections::BTreeMap;
|
||||
@ -496,6 +498,11 @@ impl<H: Hypervisor, S: Screen> MultiThreadBase for CpuManager<H, S> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn support_resume(&mut self) -> Option<MultiThreadResumeOps<'_, Self>> {
|
||||
Some(self)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn support_thread_extra_info(&mut self) -> Option<ThreadExtraInfoOps<'_, Self>> {
|
||||
Some(self)
|
||||
@ -508,6 +515,24 @@ impl<H: Hypervisor, S: Screen> ThreadExtraInfo for CpuManager<H, S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<H: Hypervisor, S: Screen> MultiThreadResume for CpuManager<H, S> {
|
||||
fn resume(&mut self) -> Result<(), Self::Error> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn clear_resume_actions(&mut self) -> Result<(), Self::Error> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn set_resume_action_continue(
|
||||
&mut self,
|
||||
tid: Tid,
|
||||
signal: Option<Signal>,
|
||||
) -> Result<(), Self::Error> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
/// Encapsulates arguments for a function to run a CPU.
|
||||
struct Args<H: Hypervisor, S: Screen> {
|
||||
hv: Arc<H>,
|
||||
|
@ -1,19 +1,13 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
use super::controller::CpuController;
|
||||
use super::{CpuManager, GdbError};
|
||||
use crate::screen::Screen;
|
||||
use crate::vmm::hv::Hypervisor;
|
||||
use gdbstub::common::Tid;
|
||||
use gdbstub::target::ext::base::multithread::MultiThreadBase;
|
||||
use gdbstub::target::ext::base::BaseOps;
|
||||
use gdbstub::target::ext::breakpoints::{
|
||||
Breakpoints, BreakpointsOps, SwBreakpoint, SwBreakpointOps,
|
||||
};
|
||||
use gdbstub::target::ext::thread_extra_info::{ThreadExtraInfo, ThreadExtraInfoOps};
|
||||
use gdbstub::target::{TargetError as GdbTargetError, TargetResult};
|
||||
use gdbstub_arch::x86::reg::X86_64CoreRegs;
|
||||
use gdbstub::target::TargetResult;
|
||||
use gdbstub_arch::x86::X86_64_SSE;
|
||||
use std::num::NonZero;
|
||||
|
||||
pub type GdbRegs = gdbstub_arch::x86::reg::X86_64CoreRegs;
|
||||
|
||||
|
@ -26,7 +26,7 @@ mod run;
|
||||
|
||||
pub fn new(cpu: usize, ram: Ram, debug: bool) -> Result<Kvm, KvmError> {
|
||||
// Open KVM device.
|
||||
let kvm = unsafe { open(b"/dev/kvm\0".as_ptr().cast(), O_RDWR) };
|
||||
let kvm = unsafe { open("/dev/kvm\0".as_ptr().cast(), O_RDWR) };
|
||||
|
||||
if kvm < 0 {
|
||||
return Err(KvmError::OpenKvmFailed(Error::last_os_error()));
|
||||
@ -45,7 +45,7 @@ pub fn new(cpu: usize, ram: Ram, debug: bool) -> Result<Kvm, KvmError> {
|
||||
// Check max CPU.
|
||||
let max = get_ext(kvm.as_fd(), KVM_CAP_MAX_VCPUS).map_err(KvmError::GetMaxCpuFailed)?;
|
||||
|
||||
if TryInto::<usize>::try_into(max).unwrap() < cpu {
|
||||
if usize::try_from(max).unwrap() < cpu {
|
||||
return Err(KvmError::MaxCpuTooLow(cpu));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user