Skip to content

Regression updating from 0.3.2 to 0.3.3 #194

Open
@ludfjig

Description

@ludfjig

After Hyperlight updated to [email protected] we experienced sporadic "131 errors". A repro can be found here. Make sure to run it in release mode. The error sometimes doesn't show up depending on the number of iterations, for example if I replace 10_000 with 1000, it runs fine. Not sure why...

use std::{
    hint::black_box,
    sync::Arc,
    thread::{JoinHandle, spawn},
};

use mshv_bindings::{
    hv_partition_property_code_HV_PARTITION_PROPERTY_SYNTHETIC_PROC_FEATURES,
    hv_partition_synthetic_processor_features,
};
use mshv_ioctls::{Mshv, VmFd};

fn main() {
    let mshv = Arc::new(Mshv::new().expect("Failed to open mshv device"));
    let handles: Vec<JoinHandle<()>> = (0..10_000)
        .map(|_| {
            let mshv = Arc::clone(&mshv);
            spawn(move || {
                black_box(create_vm(&mshv));
            })
        })
        .collect();

    for handle in handles {
        handle.join().expect("Thread panicked");
    }
}

fn create_vm(mshv: &Mshv) -> VmFd {
    let vm = mshv
        .create_vm_with_args(&Default::default())
        .expect("Failed to create VM");
    let features: hv_partition_synthetic_processor_features = Default::default();
    vm.hvcall_set_partition_property(
        hv_partition_property_code_HV_PARTITION_PROPERTY_SYNTHETIC_PROC_FEATURES,
        unsafe { features.as_uint64[0] },
    )
    .expect("Failed to set vm property");
    vm.initialize().expect("Failed to initialize vm");
    vm.create_vcpu(0).expect("Failed to create vcpu");
    vm
}

On 0.3.2, this works fine, but on 0.3.3 I get errors such as

...
thread '<unnamed>' panicked at src/main.rs:32:10:
Failed to create VM: Errno(Error(131))

thread '<unnamed>' panicked at src/main.rs:39:21:
Failed to initialize vm: Errno(Error(131))
...

My system:

[ ~/mshv3-tester ]$ uname -a
Linux aure-linux3-dev-vm 6.6.57.mshv4-1000.g59e1545b.lv3 #1 SMP Tue Nov 19 14:35:16 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
[ ~/mshv3-tester ]$ rustc --version
rustc 1.85.0 (4d91de4e4 2025-02-17)
[ ~/mshv3-tester ]$ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions