Skip to content

Commit 41f8326

Browse files
committed
feat: 移除冗余的 VmxVcpu 方法并修正指针类型转换
1 parent c7cb436 commit 41f8326

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

src/vmx/vcpu.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,6 @@ impl<H: Hal> VmxVcpu<H> {
225225
Ok(vcpu)
226226
}
227227

228-
/// Set the new [`VmxVcpu`] context from guest OS.
229-
pub fn setup(&mut self, ept_root: HostPhysAddr, entry: GuestPhysAddr) -> Result<()> {
230-
self.setup_vmcs(entry, ept_root)?;
231-
Ok(())
232-
}
233-
234228
// /// Get the identifier of this [`VmxVcpu`].
235229
// pub fn vcpu_id(&self) -> usize {
236230
// get_current_vcpu::<Self>().unwrap().id()
@@ -610,7 +604,7 @@ impl<H: Hal> VmxVcpu<H> {
610604
VmcsHostNW::TR_BASE.write(get_tr_base(tr, &gdtp) as _)?;
611605
VmcsHostNW::GDTR_BASE.write(gdtp.base as _)?;
612606
VmcsHostNW::IDTR_BASE.write(idtp.base as _)?;
613-
VmcsHostNW::RIP.write(Self::vmx_exit as usize)?;
607+
VmcsHostNW::RIP.write(Self::vmx_exit as *const () as usize)?;
614608

615609
VmcsHostNW::IA32_SYSENTER_ESP.write(0)?;
616610
VmcsHostNW::IA32_SYSENTER_EIP.write(0)?;
@@ -1331,11 +1325,6 @@ impl<H: Hal> Debug for VmxVcpu<H> {
13311325
// ==================== 直接在 VmxVcpu<H> 上实现方法,不使用 trait ====================
13321326

13331327
impl<H: Hal> VmxVcpu<H> {
1334-
/// 创建新的 VCPU(替代 AxArchVCpu::new)
1335-
pub fn new(vm_id: VMId, vcpu_id: VCpuId) -> Result<Self> {
1336-
Self::new(vm_id, vcpu_id)
1337-
}
1338-
13391328
/// 设置入口点(替代 AxArchVCpu::set_entry)
13401329
pub fn set_entry(&mut self, entry: GuestPhysAddr) -> Result<()> {
13411330
self.entry = Some(entry);
@@ -1348,11 +1337,6 @@ impl<H: Hal> VmxVcpu<H> {
13481337
Ok(())
13491338
}
13501339

1351-
/// 设置 VMCS(替代 AxArchVCpu::setup)
1352-
pub fn setup(&mut self) -> Result<()> {
1353-
self.setup_vmcs(self.entry.unwrap(), self.ept_root.unwrap())
1354-
}
1355-
13561340
/// 运行 VCPU(替代 AxArchVCpu::run,返回自己的 VmxExitReason)
13571341
pub fn run(&mut self) -> Result<X86VmxExitReason> {
13581342
match self.inner_run() {

0 commit comments

Comments
 (0)