Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,23 @@ on:
branches:
- main
- develop
workflow_dispatch:
pull_request:
branches:
- main
- develop
schedule:
- cron: '15 4 */1 * *'

env:
CARGO_TERM_COLOR: always
- cron: '0 3 * * *'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install tools
run: |
rustup default nightly
rustup component add rust-src

- name: Build Bootloader and Kernel
run: |
cd src
if [[ $(git branch --show-current) == "main" ]]; then
./builder.rs build -r -p
else
./builder.rs build
fi

- name: Upload artifacts
uses: actions/upload-artifact@v4
- name: Setup the environment
run: rustup default nightly
- name: Build
run: cd src && cargo xtask build
- uses: actions/upload-artifact@v4
with:
name: MilvusVisor
path: src/bin/
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/build_stable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build Hypervisor (Stable)

on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '0 0 1 * *'

jobs:
build_stable:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: cd src && cargo xtask build -r -p
- uses: actions/upload-artifact@v4
with:
name: MilvusVisor
path: bin/
compression-level: 9
19 changes: 1 addition & 18 deletions .github/workflows/check.yml → .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
name: Check compile errors and miss formatting
name: Rustfmt

on:
pull_request:
branches:
- main
- develop

env:
CARGO_TERM_COLOR: always

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install tools
run: |
rustup default nightly
rustup component add rust-src
rustup component add rustfmt

- name: Run cargo fmt
id: fmt
continue-on-error: true
Expand All @@ -35,12 +26,4 @@ jobs:
echo "\`\`\`" >> /tmp/message
gh pr comment -F /tmp/message "$REF"
if: steps.fmt.outcome != 'success'
- name: Build UEFI bootloader
run: |
cd src/hypervisor_bootloader
cargo build

- name: Build kernel
run: |
cd src/hypervisor_kernel
cargo build
44 changes: 27 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ to the users without virtualization overhead.

Currently, MilvusVisor provides the following function.

You can build with enabling some functions by `./builder.rs build -f feature1,feautre2,...`.(`featureN` is described
You can build with enabling some functions by `cargo xtask build -f feature1,feautre2,...`.(`featureN` is described
like `Feature Name: feature_name` in each section.)
If you want to build with extra features, you can build by `make custom_all FEATURES=default,feature1,feature2,...`.
If you want to build with extra features, you can build by `cargo xtask build -f default,feature1,feature2,...`.
If you want to build without any features, you can build by `cargo xtask build -f minimum`.

- Protecting non-volatile data in devices from guest OS (e.g. Firmware, MAC address)
- Intel I210 (Feature Name: `i210`)
Expand Down Expand Up @@ -83,22 +84,23 @@ The following table shows which feature worked on which machines.

## How to build the hypervisor

### By Rust toolchain
### By Rust toolchains

#### Requirements

- `cargo`, `rustc`, and `rust-src` (you can install from https://rustup.rs/)
- Currently, nightly build is needed
- Rust 1.88 or later
- cargo
- rustc

#### Steps (commands list)

```bash
rustup component add rust-src
cd path/to/repo-root/src
./builder.rs build
cargo xtask build # Debug Build
cargo xtask build -r # Release build
```

To customize build options, please see `./builder.rs help`.
To customize build options, please see `cargo xtask help`.

Next [How to run the hypervisor](#how-to-run-the-hypervisor)

Expand All @@ -115,7 +117,7 @@ Next [How to run the hypervisor](#how-to-run-the-hypervisor)

```bash
cd path/to/repo-root/src
./build_by_docker.sh # You can add arguments to pass the make command, like as `-f FEATURES=...`
./build_by_docker.sh # You can add arguments to pass the cargo xtask command, like as `-f ...`
```

For more detail, please see the scripts.
Expand All @@ -125,13 +127,16 @@ For more detail, please see the scripts.
### On QEMU

First, please install QEMU that supports emulating `QEMU ARM Virtual Machine`, `a64fx` CPU.
Then, run the following command to run the built hypervisor.
Then, you should build the hypervisor by the above method.
After that, run the following command to run the built hypervisor.

```bash
cd path/to/repo-root/src
./builder.rs run --bios /usr/share/qemu-efi/QEMU_EFI.fd #Please set the path of your QEMU_EFI.fd
cargo xtask run --bios /usr/share/qemu-efi/QEMU_EFI.fd #Please set the path of your QEMU_EFI.fd
```

For more options, please see `cargo xtask help`.

### On a physical machine from a USB memory stick

#### Requirement
Expand All @@ -142,13 +147,18 @@ cd path/to/repo-root/src

#### Steps

1. Attach your USB memory stick to the development machine which built the hypervisor binary.
2. Identify the EFI partition (in the following description, `/dev/sdX1` is the EFI partition).
3. Run `sudo ./builder.rs write -d /dev/sdX1` to copy the binary.
1. Build the hypervisor by the above method.
2. Attach your USB memory stick to the development machine which built the hypervisor binary.
3. Identify the EFI partition (in the following description, `/dev/sdX1` is the EFI partition).
4. Run `cargo xtask write -d /dev/sdX1` to copy the binary.
!! Please be careful not to specify a wrong partition as `DEVICE` because the script mount/unmount the partition and
copies the binary file with root privilege.!!
4. Detach the USB memory from the development machine, and attach it to the physical machine to run the hypervisor.
5. Boot the physical machine with UEFI, and specify `BOOTAA64.EFI` in the EFI partition as the EFI application to boot.
5. Detach the USB memory from the development machine, and attach it to the physical machine to run the hypervisor.
6. Boot the physical machine with UEFI, and specify `BOOTAA64.EFI` in the EFI partition as the EFI application to boot.

`cargo xtask write` uses `sudo` command.
If you can access the target device without the root privilege, you can add the `-u` option.
For more options, please see `cargo xtask help`.

### PXE Boot

Expand All @@ -171,7 +181,7 @@ The default settings assume that files are deploy on tftp server likes below.

#### Steps

1. Build MilvusVisor with tfp feature like `./builder.rs build -f default,tftp`
1. Build MilvusVisor with tfp feature like `cargo xtask build -f default,tftp`
2. Deploy `BOOTAA64.EFI` and `hypervisor_kernel` on tftp server.(you can rename `BOOTAA64.EFI`)
3. Modify DHCP setting to change the boot file to `BOOTAA64.EFI`(if you renamed, adjust the name).

Expand Down
2 changes: 1 addition & 1 deletion docs/raspberry_pi4.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To enable Raspberry Pi 4 support, you need to add `raspberrypi` feature flag on
bootloader.

```shell
./builder.rs -r -f raspberrypi
cargo xtask build -r -f raspberrypi
```

## How to boot
Expand Down
2 changes: 2 additions & 0 deletions src/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run --package xtask --"
15 changes: 13 additions & 2 deletions src/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Copyright (c) 2022 National Institute of Advanced Industrial Science and Technology (AIST)
# All rights reserved.
#
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php
[workspace]
members = ["common", "hypervisor_bootloader", "hypervisor_kernel", "uefi"]
resolver = "2"
default-members = ["hypervisor_bootloader", "hypervisor_kernel"]
members = ["common", "hypervisor_bootloader", "hypervisor_kernel", "uefi", "xtask"]
resolver = "3"

[workspace.package]
version = "1.5.0"
edition = "2024"
license = "MIT"

[profile.release.package.hypervisor_bootloader]
strip = "symbols"
Expand Down
65 changes: 0 additions & 65 deletions src/Makefile.legacy

This file was deleted.

4 changes: 2 additions & 2 deletions src/build_by_docker.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash
#!/bin/bash

# Copyright (c) 2022 National Institute of Advanced Industrial Science and Technology (AIST)
# All rights reserved.
#
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php

BUILD_CMDLINE="rustup default nightly && rustup component add rust-src && cd /workspace && ./builder.rs build $@"
BUILD_CMDLINE="cd /workspace && cargo xtask build $@"

docker run -it --rm -v ${PWD}:/workspace rust:latest /bin/bash -c "${BUILD_CMDLINE}"
6 changes: 3 additions & 3 deletions src/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# http://opensource.org/licenses/mit-license.php
[package]
name = "common"
version = "1.4.1"
edition = "2021"
resolver = "2"
edition.workspace = true
license.workspace = true
version.workspace = true

[features]
advanced_memory_manager = []
2 changes: 1 addition & 1 deletion src/common/src/acpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod madt;
const RSDP_SIGNATURE: [u8; 8] = *b"RSD PTR ";
const XSDT_SIGNATURE: [u8; 4] = *b"XSDT";

pub const XSDT_STRUCT_SIZE: usize = core::mem::size_of::<XSDT>();
pub const XSDT_STRUCT_SIZE: usize = size_of::<XSDT>();

#[repr(C, packed)]
pub struct RSDP {
Expand Down
2 changes: 1 addition & 1 deletion src/common/src/acpi/iort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Iterator for IdMappingIter {
} else {
let a = self.p;
self.n -= 1;
self.p += core::mem::size_of::<Self::Item>();
self.p += size_of::<Self::Item>();
Some(unsafe { read_unaligned(a as *const Self::Item) })
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/src/acpi/madt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct GicInterruptTranslationServiceStructureList {

impl MADT {
pub const SIGNATURE: [u8; 4] = *b"APIC";
const STRUCT_SIZE: usize = core::mem::size_of::<MADT>();
const STRUCT_SIZE: usize = size_of::<MADT>();

pub fn get_gic_list(&self) -> GicCpuInterfaceStructureList {
let length = self.length as usize - Self::STRUCT_SIZE;
Expand Down Expand Up @@ -97,7 +97,7 @@ impl MADT {
}
base_address += record_length as usize;
}
return None;
None
}

pub fn get_gic_its_list(&self) -> GicInterruptTranslationServiceStructureList {
Expand Down
Loading
Loading