Giter Club home page Giter Club logo

mshv's Introduction

mshv

Microsoft Hypervisor wrappers. This repository provides two crates which are mshv-bindings and mshv-ioctls. These crates will provide the APIs and definitions to create a VMM on Microsoft Hypervisor along with other rust-vmm crates.

Supported Platforms

The mshv-{ioctls, bindings} can be used on x86_64 only.

Build

cargo build

Running the tests

Test (/dev/mshv requires root):

sudo -E ~/.cargo/bin/cargo test

mshv's People

Contributors

andreeaflorescu avatar asherkariv avatar dependabot[bot] avatar jinankjain avatar liuw avatar nunodasneves avatar praveen-pk avatar rbradford avatar russell-islam avatar simongdavies avatar weltling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mshv's Issues

More efficient message handling

Right now the run function of vcpu requires the caller to pass in a buffer.

That buffer is zeroed before given to run. That's wasteful. And then there are two moves for that buffer, one from caller to callee and the other is from callee to caller. Figure out a better API.

I don't want run to take MaybeUninit<hv_message> though. If anything the buffer can be part of vcpu. We will still have one move
(copy) operation when we give it back to the caller.

Some files seem missing when trying to use scripts/generate_binding.py

In the latest scripts/generate_binding.py, we know we need the following files in Linux kernel source code to generate the bindings.

  • include/hyperv/hvgdk_mini.h
  • include/hyperv/hvgdk.h
  • include/hyperv/hvhdk_mini.h
  • include/hyperv/hvhdk.h
  • include/linux/mshv.h

I am confused because I cannot find these files in the latest mainline Linux kernel source code. So, I need some help.

Kenji Mouri

Provide script for bindings.rs

Currently there is no unified way to produce mshv-bindings/src/bindings.rs. Given the file must be generated some times and some customizations are already applied there, there should be scirpt checked in to unify the dev work on this piece.

Upgrade to Rust 2021 edition

These crates are still using the Rust 2018 edition. When we have cycles to spare we can move to the 2021 edition. Hopefully it is a straightforward change.

Configure a CI host in Microsoft internal network

This issue is for tracking the progress on creating an Internal CI at Microsoft so that can be invoked in every PR to validate the changes.

The licensing part of Microsoft Hypervisor is still in progress and that is the reason for creating the CI at Microsoft.

We need to make sure the following conditions are met.

  1. CI host is not exposing any SSH access to anyone other than the Microsoft maintainers.
  2. The agent service is not copying anything other than the build logs
  3. No sources are exposed other than the rust-vmm/mshv codes

Warning about future rust toolchain support

marvin:~/src/cloud-hypervisor (main)$ cargo report future-incompatibilities --id 4
The following warnings were discovered during the build. These warnings are an
indication that the packages contain code that will become an error in a
future release of Rust. These warnings typically cover changes to close
soundness problems, unintended or undocumented behavior, or critical problems
that cannot be fixed in a backwards-compatible fashion, and are not expected
to be in wide use.

Each warning should contain a link for more information on what the warning
means and how to resolve it.


To solve this problem, you can try the following approaches:


- If the issue is not solved by updating the dependencies, a fix has to be
implemented by those dependencies. You can help with that by notifying the
maintainers of this problem (e.g. by creating a bug report) or by proposing a
fix to the maintainers (e.g. by creating a pull request):

  - [email protected]
  - Repository: <not found>
  - Detailed warning command: `cargo report future-incompatibilities --id 4 --package [email protected]`

- If waiting for an upstream fix is not an option, you can use the `[patch]`
section in `Cargo.toml` to use your own version of the dependency. For more
information, see:
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
        
The package `mshv-bindings v0.1.1 (https://github.com/rust-vmm/mshv?branch=main#bf854308)` currently triggers the following future incompatibility lints:
> warning: reference to packed field is unaligned
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/unmarshal.rs:17:13
>    |
> 17 |             self.u.payload.as_ptr()
>    |             ^^^^^^^^^^^^^^^^^^^^^^^
>    |
> note: the lint level is defined here
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/lib.rs:17:10
>    |
> 17 | #![allow(unaligned_references)]
>    |          ^^^^^^^^^^^^^^^^^^^^
>    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>    = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>    = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
> 
> warning: reference to packed field is unaligned
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/unmarshal.rs:31:13
>    |
> 31 |             self.u.payload.as_ptr()
>    |             ^^^^^^^^^^^^^^^^^^^^^^^
>    |
> note: the lint level is defined here
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/lib.rs:17:10
>    |
> 17 | #![allow(unaligned_references)]
>    |          ^^^^^^^^^^^^^^^^^^^^
>    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>    = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>    = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
> 
> warning: reference to packed field is unaligned
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/unmarshal.rs:43:13
>    |
> 43 |             self.u.payload.as_ptr()
>    |             ^^^^^^^^^^^^^^^^^^^^^^^
>    |
> note: the lint level is defined here
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/lib.rs:17:10
>    |
> 17 | #![allow(unaligned_references)]
>    |          ^^^^^^^^^^^^^^^^^^^^
>    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>    = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>    = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
> 
> warning: reference to packed field is unaligned
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/unmarshal.rs:55:13
>    |
> 55 |             self.u.payload.as_ptr()
>    |             ^^^^^^^^^^^^^^^^^^^^^^^
>    |
> note: the lint level is defined here
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/lib.rs:17:10
>    |
> 17 | #![allow(unaligned_references)]
>    |          ^^^^^^^^^^^^^^^^^^^^
>    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>    = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>    = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
> 
> warning: reference to packed field is unaligned
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/unmarshal.rs:67:13
>    |
> 67 |             self.u.payload.as_ptr()
>    |             ^^^^^^^^^^^^^^^^^^^^^^^
>    |
> note: the lint level is defined here
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/lib.rs:17:10
>    |
> 17 | #![allow(unaligned_references)]
>    |          ^^^^^^^^^^^^^^^^^^^^
>    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>    = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>    = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
> 
> warning: reference to packed field is unaligned
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/unmarshal.rs:79:13
>    |
> 79 |             self.u.payload.as_ptr()
>    |             ^^^^^^^^^^^^^^^^^^^^^^^
>    |
> note: the lint level is defined here
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/lib.rs:17:10
>    |
> 17 | #![allow(unaligned_references)]
>    |          ^^^^^^^^^^^^^^^^^^^^
>    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>    = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>    = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
> 
> warning: reference to packed field is unaligned
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/unmarshal.rs:93:13
>    |
> 93 |             self.u.payload.as_ptr()
>    |             ^^^^^^^^^^^^^^^^^^^^^^^
>    |
> note: the lint level is defined here
>   --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/lib.rs:17:10
>    |
> 17 | #![allow(unaligned_references)]
>    |          ^^^^^^^^^^^^^^^^^^^^
>    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>    = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>    = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>    = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
> 
> warning: reference to packed field is unaligned
>    --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/unmarshal.rs:107:13
>     |
> 107 |             self.u.payload.as_ptr()
>     |             ^^^^^^^^^^^^^^^^^^^^^^^
>     |
> note: the lint level is defined here
>    --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/lib.rs:17:10
>     |
> 17  | #![allow(unaligned_references)]
>     |          ^^^^^^^^^^^^^^^^^^^^
>     = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>     = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>     = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>     = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
> 
> warning: reference to packed field is unaligned
>    --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/unmarshal.rs:119:13
>     |
> 119 |             self.u.payload.as_ptr() as *const [u8; std::mem::size_of::<hv_x64_apic_eoi_message>()]
>     |             ^^^^^^^^^^^^^^^^^^^^^^^
>     |
> note: the lint level is defined here
>    --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/lib.rs:17:10
>     |
> 17  | #![allow(unaligned_references)]
>     |          ^^^^^^^^^^^^^^^^^^^^
>     = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>     = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>     = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>     = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
> 
> warning: reference to packed field is unaligned
>    --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/unmarshal.rs:130:13
>     |
> 130 |             self.u.payload.as_ptr()
>     |             ^^^^^^^^^^^^^^^^^^^^^^^
>     |
> note: the lint level is defined here
>    --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/lib.rs:17:10
>     |
> 17  | #![allow(unaligned_references)]
>     |          ^^^^^^^^^^^^^^^^^^^^
>     = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>     = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>     = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>     = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
> 
> warning: reference to packed field is unaligned
>    --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/unmarshal.rs:142:13
>     |
> 142 |             self.u.payload.as_ptr()
>     |             ^^^^^^^^^^^^^^^^^^^^^^^
>     |
> note: the lint level is defined here
>    --> /home/rob/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/lib.rs:17:10
>     |
> 17  | #![allow(unaligned_references)]
>     |          ^^^^^^^^^^^^^^^^^^^^
>     = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
>     = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
>     = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
>     = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
> 

Pass extra argument to the script

Right now arguments to the bindgen are limited in the script. We should be able to pass the argument more flexible way.

example: ./script//generate_binding.py -k "/blah" -o "blah" [rest of arg to the bindgen directly copied]

Unaligned access in marshalling code

I'm using Rust 1.64 and it reports an issue.

Run cargo report future-incompatibilities --id 1 in Cloud Hypervisor build gives the following (only one of several is listed).

warning: reference to packed field is unaligned
--> /home/cloud/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/unmarshal.rs:142:13
|
142 | self.u.payload.as_ptr()
| ^^^^^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> /home/cloud/.cargo/git/checkouts/mshv-cc59226ef45dad4f/bf85430/mshv-bindings/src/lib.rs:17:10
|
17 | #![allow(unaligned_references)]
| ^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #82523 rust-lang/rust#82523
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use read_unaligned/write_unaligned (loads and stores via *p must be properly aligned even when using raw pointers)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.