hermit-os / uhyve

A specialized hypervisor for Hermit.
Apache License 2.0
254 stars 29 forks source link

Uhyve hangs if `-v` (verbose flag) is not used #763

Open n0toose opened 6 days ago

n0toose commented 6 days ago

Running Uhyve directly (this does not happen with cargo run) seems to cause the process to hang indefinitely without a (graceful) exit:

$ ./target/debug/uhyve ./data/x86_64/hello_world
frequencies: 1331
CPU frequencies are not all equal
$ ./target/debug/uhyve ./data/x86_64/hello_world --pit --thp --ksm -m 2000MiB
frequencies: 2124
CPU frequencies are not all equal

However, running...

$ ./target/debug/uhyve ./data/x86_64/hello_world -v
$ ./target/debug/uhyve ./data/x86_64/rusty_demo -v

seems to work just fine. Using cargo run also works.

Affects 0222ff73dcf46c44351c34d885522c82b7c5c509, have not managed to bisect where this has seemingly stopped happening yet. Host OS is Ubuntu 24.04.1 LTS x86_64 with 6.8.0-44-generic.

n0toose commented 6 days ago

(I had set the flag to 1 on a previous operating system, forgot to do so again. I assumed that my environment must've broken things somehow - but not in the way that I expected. Perhaps this could explain why the error wasn't caught earlier.)

Possibly related:

n0toose commented 6 days ago

If I'm not wrong, gdb/pwndbg "thinks" that a bunch of barrier.wait()'s have piled up and are keeping the program from exiting.

log.txt

A working (borderline nonsensical) theory is that the kernel tries to inform Uhyve that it should shut down, but it doesn't (why?/how? probably wrong), therefore, it halts indefinitely:

https://github.com/hermit-os/kernel/blob/e608471f42d7b79f871fbe6d60a8b30e50043aef/src/syscalls/interfaces/uhyve.rs#L161-L169

Therefore, the Vcpu never halts, the VM never exits, and Uhyve won't get stopped.

https://github.com/hermit-os/uhyve/blob/0222ff73dcf46c44351c34d885522c82b7c5c509/src/bin/uhyve.rs#L291


This also applies to the WIP v2 version of uhyve-interface.