Skip to content

Commit 31bfc5a

Browse files
committed
Add debugging logs for testing purpose
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 999fa37 commit 31bfc5a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/hyperlight_host/src/func/call_ctx.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ mod tests {
239239

240240
#[test]
241241
fn ensure_multiusesandbox_multi_calls_dont_reset_state() {
242+
env_logger::builder()
243+
.filter_module("hyperlight", log::LevelFilter::Trace)
244+
.filter_level(log::LevelFilter::Info)
245+
.init();
242246
let sandbox = TestSandbox::new();
243247
let result = sandbox.call_add_to_static_multiple_times(5);
244248
assert!(result.is_ok());

src/hyperlight_host/src/hypervisor/whp.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags};
3939
use crate::{new_error, Result};
4040

4141
pub(crate) fn is_hypervisor_present() -> bool {
42+
println!("whp in_is_hypervisor_present");
4243
let mut capability: WHV_CAPABILITY = Default::default();
4344
let written_size: Option<*mut u32> = None;
4445

@@ -88,6 +89,8 @@ unsafe impl Sync for WhpVm {}
8889

8990
impl WhpVm {
9091
pub(crate) fn new(mmap_file_handle: HandleWrapper) -> Result<Self> {
92+
println!("whp in_is_hypervisor_present");
93+
9194
const NUM_CPU: u32 = 1;
9295
let partition = unsafe {
9396
let partition = WHvCreatePartition()?;
@@ -111,6 +114,8 @@ impl WhpVm {
111114

112115
/// Helper for setting arbitrary registers.
113116
fn set_registers(&self, registers: &[(WHV_REGISTER_NAME, WHV_REGISTER_VALUE)]) -> Result<()> {
117+
println!("whp set_registers");
118+
114119
let register_count = registers.len();
115120
let mut register_names: Vec<WHV_REGISTER_NAME> = vec![];
116121
let mut register_values: Vec<WHV_REGISTER_VALUE> = vec![];
@@ -136,6 +141,8 @@ impl WhpVm {
136141

137142
impl Vm for WhpVm {
138143
fn get_regs(&self) -> Result<CommonRegisters> {
144+
println!("whp get_regs");
145+
139146
let mut whv_regs_values: [WHV_REGISTER_VALUE; WHP_REGS_NAMES_LEN] =
140147
unsafe { std::mem::zeroed() };
141148

@@ -164,12 +171,14 @@ impl Vm for WhpVm {
164171
}
165172

166173
fn set_regs(&self, regs: &CommonRegisters) -> Result<()> {
174+
println!("whp set_regs");
167175
let whp_regs: [(WHV_REGISTER_NAME, WHV_REGISTER_VALUE); WHP_REGS_NAMES_LEN] = regs.into();
168176
self.set_registers(&whp_regs)?;
169177
Ok(())
170178
}
171179

172180
fn get_sregs(&self) -> Result<CommonSpecialRegisters> {
181+
println!("whp get_sregs");
173182
let mut whp_sregs_values: [WHV_REGISTER_VALUE; WHP_SREGS_NAMES_LEN] =
174183
unsafe { std::mem::zeroed() };
175184

@@ -198,12 +207,14 @@ impl Vm for WhpVm {
198207
}
199208

200209
fn set_sregs(&self, sregs: &CommonSpecialRegisters) -> Result<()> {
210+
println!("whp set_sregs");
201211
let whp_regs: [(WHV_REGISTER_NAME, WHV_REGISTER_VALUE); WHP_SREGS_NAMES_LEN] = sregs.into();
202212
self.set_registers(&whp_regs)?;
203213
Ok(())
204214
}
205215

206216
fn get_fpu(&self) -> Result<CommonFpu> {
217+
println!("whp get_fpu");
207218
let mut whp_fpu_values: [WHV_REGISTER_VALUE; WHP_FPU_NAMES_LEN] =
208219
unsafe { std::mem::zeroed() };
209220

@@ -227,12 +238,14 @@ impl Vm for WhpVm {
227238
}
228239

229240
fn set_fpu(&self, fpu: &CommonFpu) -> Result<()> {
241+
println!("whp set_fpu");
230242
let whp_fpu: [(WHV_REGISTER_NAME, WHV_REGISTER_VALUE); WHP_FPU_NAMES_LEN] = fpu.into();
231243
self.set_registers(&whp_fpu)?;
232244
Ok(())
233245
}
234246

235247
unsafe fn map_memory(&mut self, regions: &[MemoryRegion]) -> Result<()> {
248+
println!("whp map_memory");
236249
if regions.is_empty() {
237250
return Err(new_error!("No memory regions to map"));
238251
}
@@ -302,6 +315,8 @@ impl Vm for WhpVm {
302315

303316
#[expect(non_upper_case_globals, reason = "Windows API constant are lower case")]
304317
fn run_vcpu(&mut self) -> Result<HyperlightExit> {
318+
println!("whp run_vpu");
319+
305320
let mut exit_context: WHV_RUN_VP_EXIT_CONTEXT = Default::default();
306321

307322
unsafe {
@@ -359,6 +374,7 @@ impl Vm for WhpVm {
359374
}
360375

361376
fn get_partition_handle(&self) -> WHV_PARTITION_HANDLE {
377+
println!("whp get_partition_handle");
362378
self.partition
363379
}
364380
}
@@ -372,6 +388,7 @@ impl Drop for WhpVm {
372388
}
373389

374390
unsafe fn try_load_whv_map_gpa_range2() -> Result<WHvMapGpaRange2Func> {
391+
println!("whp try_load_whv_map_gpa_range2");
375392
let library = unsafe {
376393
LoadLibraryExA(
377394
s!("winhvplatform.dll"),

0 commit comments

Comments
 (0)