|
1 | | -use core::{fmt::Display, ops::Deref}; |
| 1 | +use core::{ |
| 2 | + fmt::{self, Debug, Display}, |
| 3 | + ops::Deref, |
| 4 | +}; |
2 | 5 |
|
3 | 6 | use aarch64_cpu::registers::*; |
4 | 7 | use arm_vcpu::{Aarch64PerCpu, Aarch64VCpuCreateConfig}; |
@@ -116,7 +119,9 @@ impl VCpuOp for VCpu { |
116 | 119 |
|
117 | 120 | fn run(&mut self) -> Result<(), RunError> { |
118 | 121 | info!("Starting vCPU {}", self.bind_id()); |
119 | | - |
| 122 | + self.vcpu |
| 123 | + .setup_current_cpu(self.vm_id().into()) |
| 124 | + .map_err(|e| anyhow!("{e}"))?; |
120 | 125 | while self.is_active() { |
121 | 126 | debug!("vCPU {} entering guest", self.bind_id()); |
122 | 127 | let exit_reason = self.vcpu.run().map_err(|e| anyhow!("{e}"))?; |
@@ -150,6 +155,7 @@ impl VCpuOp for VCpu { |
150 | 155 | debug!("vCPU {} is bringing up CPU {}", self.bind_id(), target_cpu); |
151 | 156 | running.cpu_up(CpuHardId::new(target_cpu as _), entry_point, arg) |
152 | 157 | })??; |
| 158 | + self.vcpu.set_gpr(0, 0); |
153 | 159 | } |
154 | 160 | arm_vcpu::AxVCpuExitReason::CpuDown { _state } => todo!(), |
155 | 161 | arm_vcpu::AxVCpuExitReason::SystemDown => { |
@@ -179,3 +185,13 @@ impl Deref for VCpu { |
179 | 185 | &self.common |
180 | 186 | } |
181 | 187 | } |
| 188 | + |
| 189 | +impl Debug for VCpu { |
| 190 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 191 | + f.debug_struct("VCpu") |
| 192 | + .field("bind_id", &self.bind_id()) |
| 193 | + .field("hard_id", &self.hard_id()) |
| 194 | + .field("vcpu", &self.vcpu) |
| 195 | + .finish() |
| 196 | + } |
| 197 | +} |
0 commit comments