From f24409067d0d4c88d53c0422dfef200bf269e4f4 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Sun, 28 May 2023 06:13:22 +0000 Subject: [PATCH 1/6] build: Add RISC-V to Rust toolchain targets Signed-off-by: Akira Moroo --- resources/Dockerfile | 1 + rust-toolchain.toml | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/Dockerfile b/resources/Dockerfile index c61fb6d7..211051b9 100644 --- a/resources/Dockerfile +++ b/resources/Dockerfile @@ -91,6 +91,7 @@ RUN export ARCH="$(uname -m)" \ && rustup component add clippy \ && rustup component add rust-src \ && rustup target add aarch64-unknown-linux-gnu \ + && rustup target add riscv64gc-unknown-linux-gnu \ && rustup target add x86_64-unknown-linux-gnu \ && rm -rf "$CARGO_HOME/registry" \ && ln -s "$CARGO_REGISTRY_DIR" "$CARGO_HOME/registry" \ diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 27c3246f..44fc6842 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,9 @@ [toolchain] channel = "nightly-2023-02-10" components = ["rust-src", "clippy", "rustfmt"] -targets = ["aarch64-unknown-linux-gnu", "x86_64-unknown-linux-gnu"] +targets = [ + "aarch64-unknown-linux-gnu", + "riscv64gc-unknown-linux-gnu", + "x86_64-unknown-linux-gnu", +] profile = "default" From 9848f06571c6ede27abd17ebea3043bccac80956 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Sun, 28 May 2023 06:14:54 +0000 Subject: [PATCH 2/6] resources: Do rustup after coreboot installation Signed-off-by: Akira Moroo --- resources/Dockerfile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/resources/Dockerfile b/resources/Dockerfile index 211051b9..a28c97a9 100644 --- a/resources/Dockerfile +++ b/resources/Dockerfile @@ -84,6 +84,14 @@ ENV AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR=/usr/lib/aarch64-linux-gnu/ ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR=/usr/lib/aarch64-linux-gnu/ ENV OPENSSL_INCLUDE_DIR=/usr/include/ +# Checkout coreboot repository and setup cross toolchains +RUN if [ "$TARGETARCH" = "amd64" ]; then \ + git clone --quiet --branch "$COREBOOT_VERSION" --depth 1 https://github.com/coreboot/coreboot.git "$COREBOOT_DIR" \ + && cd "$COREBOOT_DIR" \ + && git submodule update --init --checkout \ + && make crossgcc-i386 CPUS=`nproc`; \ + fi + # Install the rust toolchain RUN export ARCH="$(uname -m)" \ && nohup curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$RUST_TOOLCHAIN" \ @@ -102,11 +110,3 @@ RUN export ARCH="$(uname -m)" \ RUN echo 'source $CARGO_HOME/env' >> $HOME/.bashrc \ && mkdir $HOME/.cargo \ && ln -s $CARGO_HOME/env $HOME/.cargo/env - -# Checkout coreboot repository and setup cross toolchains -RUN if [ "$TARGETARCH" = "amd64" ]; then \ - git clone --quiet --branch "$COREBOOT_VERSION" --depth 1 https://github.com/coreboot/coreboot.git "$COREBOOT_DIR" \ - && cd "$COREBOOT_DIR" \ - && git submodule update --init --checkout \ - && make crossgcc-i386 CPUS=`nproc`; \ - fi From cf560e3b32d44f5387a8d15e217d1f057fbb4215 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Sun, 28 May 2023 06:17:26 +0000 Subject: [PATCH 3/6] tests: Remove Ubuntu 18.04 Bionic from test targets Ubuntu 18.04 will reach its EOL on 31 May 2023. Signed-off-by: Akira Moroo --- scripts/fetch_images.sh | 7 ------- src/integration.rs | 12 ------------ 2 files changed, 19 deletions(-) diff --git a/scripts/fetch_images.sh b/scripts/fetch_images.sh index 52e92e83..5cd3f49c 100755 --- a/scripts/fetch_images.sh +++ b/scripts/fetch_images.sh @@ -39,13 +39,6 @@ fetch_disk_images() { CLEAR_OS_IMAGE_URL="$CLEAR_OS_URL_BASE/$CLEAR_OS_IMAGE_NAME" fetch_image "$CLEAR_OS_IMAGE_NAME" "$CLEAR_OS_IMAGE_URL" - BIONIC_OS_IMAGE_NAME="bionic-server-cloudimg-amd64.img" - BIONIC_OS_RAW_IMAGE_NAME="bionic-server-cloudimg-amd64-raw.img" - BIONIC_OS_IMAGE_BASE="https://cloud-images.ubuntu.com/bionic/current" - BIONIC_OS_IMAGE_URL="$BIONIC_OS_IMAGE_BASE/$BIONIC_OS_IMAGE_NAME" - fetch_image "$BIONIC_OS_IMAGE_NAME" "$BIONIC_OS_IMAGE_URL" - convert_image "$BIONIC_OS_IMAGE_NAME" "$BIONIC_OS_RAW_IMAGE_NAME" - FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-amd64.img" FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-amd64-raw.img" FOCAL_OS_IMAGE_BASE="https://cloud-images.ubuntu.com/focal/current" diff --git a/src/integration.rs b/src/integration.rs index 5c244892..3b4904d1 100644 --- a/src/integration.rs +++ b/src/integration.rs @@ -609,16 +609,10 @@ mod tests { handle_child_output(&tmp_dir, r, &output); } - const BIONIC_IMAGE_NAME: &str = "bionic-server-cloudimg-amd64-raw.img"; const FOCAL_IMAGE_NAME: &str = "focal-server-cloudimg-amd64-raw.img"; const JAMMY_IMAGE_NAME: &str = "jammy-server-cloudimg-amd64-raw.img"; const CLEAR_IMAGE_NAME: &str = "clear-31311-cloudguest.img"; - #[test] - fn test_boot_qemu_bionic() { - test_boot(BIONIC_IMAGE_NAME, &UbuntuCloudInit {}, spawn_qemu) - } - #[test] fn test_boot_qemu_focal() { test_boot(FOCAL_IMAGE_NAME, &UbuntuCloudInit {}, spawn_qemu) @@ -634,12 +628,6 @@ mod tests { test_boot(CLEAR_IMAGE_NAME, &ClearCloudInit {}, spawn_qemu) } - #[test] - #[cfg(not(feature = "coreboot"))] - fn test_boot_ch_bionic() { - test_boot(BIONIC_IMAGE_NAME, &UbuntuCloudInit {}, spawn_ch) - } - #[test] #[cfg(not(feature = "coreboot"))] fn test_boot_ch_focal() { From 5ab9a6d8042b1148f53b8cb8e484e709c44db03b Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Sun, 28 May 2023 06:19:31 +0000 Subject: [PATCH 4/6] tests: Bump Cloud Hypervisor version to v32.0 Signed-off-by: Akira Moroo --- scripts/fetch_images.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/fetch_images.sh b/scripts/fetch_images.sh index 5cd3f49c..b68f6b25 100755 --- a/scripts/fetch_images.sh +++ b/scripts/fetch_images.sh @@ -3,7 +3,7 @@ set -x fetch_ch() { CH_PATH="$1" - CH_VERSION="v30.0" + CH_VERSION="v32.0" CH_URL="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/$CH_VERSION/cloud-hypervisor" if [ ! -f "$CH_PATH" ]; then wget --quiet $CH_URL -O $CH_PATH From eb53986716e6ea933e9ae65269546c991f1fc6cb Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Sun, 28 May 2023 06:20:24 +0000 Subject: [PATCH 5/6] build: Update toolchain to nightly-2023-05-26 Signed-off-by: Akira Moroo --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 44fc6842..8ecb9d64 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2023-02-10" +channel = "nightly-2023-05-26" components = ["rust-src", "clippy", "rustfmt"] targets = [ "aarch64-unknown-linux-gnu", From 67b46347b4eca68dcde6464b1126624ef6a7ec2b Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Sun, 28 May 2023 06:21:11 +0000 Subject: [PATCH 6/6] build: Remove unneeded mut as suggested by clippy Signed-off-by: Akira Moroo --- src/block.rs | 6 +++--- src/efi/alloc.rs | 2 +- src/efi/mod.rs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/block.rs b/src/block.rs index 24917839..e6ed210c 100644 --- a/src/block.rs +++ b/src/block.rs @@ -262,14 +262,14 @@ impl<'a> VirtioBlockDevice<'a> { let mut state = self.state.borrow_mut(); let next_head = state.next_head; - let mut d = &mut state.descriptors[next_head]; + let d = &mut state.descriptors[next_head]; let next_desc = (next_head + 1) % QUEUE_SIZE; d.addr = (&header as *const _) as u64; d.length = core::mem::size_of::() as u32; d.flags = VIRTQ_DESC_F_NEXT; d.next = next_desc as u16; - let mut d = &mut state.descriptors[next_desc]; + let d = &mut state.descriptors[next_desc]; let next_desc = (next_desc + 1) % QUEUE_SIZE; if request != RequestType::Flush { match data { @@ -294,7 +294,7 @@ impl<'a> VirtioBlockDevice<'a> { }; d.next = next_desc as u16; - let mut d = &mut state.descriptors[next_desc]; + let d = &mut state.descriptors[next_desc]; d.addr = (&footer as *const _) as u64; d.length = core::mem::size_of::() as u32; d.flags = VIRTQ_DESC_F_WRITE; diff --git a/src/efi/alloc.rs b/src/efi/alloc.rs index c306af06..6d31a616 100644 --- a/src/efi/alloc.rs +++ b/src/efi/alloc.rs @@ -55,7 +55,7 @@ impl Allocator { self.key += 1; if self.first_allocation.is_none() { - let mut a = &mut self.allocations[0]; + let a = &mut self.allocations[0]; a.in_use = true; a.next_allocation = None; diff --git a/src/efi/mod.rs b/src/efi/mod.rs index eb245cfd..10df108d 100644 --- a/src/efi/mod.rs +++ b/src/efi/mod.rs @@ -212,8 +212,8 @@ fn convert_internal_pointer(descriptors: &[alloc::MemoryDescriptor], ptr: u64) - } unsafe fn fixup_at_virtual(descriptors: &[alloc::MemoryDescriptor]) { - let mut st = &mut ST; - let mut rs = &mut RS; + let st = &mut ST; + let rs = &mut RS; let ptr = convert_internal_pointer(descriptors, (not_available as *const ()) as u64).unwrap(); rs.get_time = transmute(ptr); @@ -1174,7 +1174,7 @@ pub fn efi_exec( let mut stdin = console::STDIN; let mut stdout = console::STDOUT; - let mut st = unsafe { &mut ST }; + let st = unsafe { &mut ST }; st.con_in = &mut stdin; st.con_out = &mut stdout; st.std_err = &mut stdout;