Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uhyve and qemu behave different #280

Open
lrapp-x41-pub opened this issue Jan 12, 2022 · 0 comments
Open

uhyve and qemu behave different #280

lrapp-x41-pub opened this issue Jan 12, 2022 · 0 comments

Comments

@lrapp-x41-pub
Copy link

When running the code below, uhyve gets stuck somewhere inside the call_target() function's println! call, but with qemu the code runs as expected.
This issue was observed during the testing for hermit-os/kernel#339 .

#![feature(asm)]

#[cfg(target_os = "hermit")]
extern crate hermit_sys;

// This works in qemu but gets stuck with uhyve somewhere inside the target function's print call
fn main() {
    println!("Main at {:p}", main as *const ());
    println!("Call unmodified some_func()");
    some_func(); 
    println!("Returned from unmodified some_func()");
    println!("Call modified some_func()");
    unsafe {
        // overwrite original function consitsing of a single ret instruction with: call rbx; ret; int3;
        *(some_func as *mut i64) = 0xccc3d3ff;
        // move address of target function to rbx
        asm!("mov rbx, {0}", in(reg) call_target as *const ());
        // call modified function
        some_func()
    }
    println!("Returned from modified some_func()");
}

#[inline(never)]
fn some_func() {
    return
}


#[inline(never)]
fn call_target() {
    println!("Called target!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant