From bd878dd1c9ab3e9f886d185106a021434c9b6324 Mon Sep 17 00:00:00 2001 From: Zhang Junyang Date: Tue, 27 Feb 2024 11:23:06 +0800 Subject: [PATCH] Update dev image for OSDK and bump version to 0.4.0 --- .github/workflows/docker_build.yml | 2 +- .github/workflows/framework_test.yml | 25 ++++++++ .../{aster_ci.yml => kernel_test.yml} | 26 ++++---- .github/workflows/osdk_ci.yml | 27 --------- .github/workflows/osdk_publish.yml | 4 +- .github/workflows/osdk_test.yml | 33 ++++++++++ Cargo.lock | 60 +++++++++++++++---- Cargo.toml | 2 +- Makefile | 2 +- README.md | 6 +- README_CN.md | 2 +- VERSION | 2 +- .../aster-frame/src/bus/pci/common_device.rs | 4 +- framework/aster-frame/src/vm/frame.rs | 3 +- framework/aster-frame/src/vm/space.rs | 2 +- framework/libs/ktest/src/lib.rs | 5 +- framework/libs/ktest/src/tree.rs | 1 - osdk/Cargo.toml | 2 +- .../base_crate/x86_64-custom.json.template | 2 +- rust-toolchain.toml | 4 +- services/aster-nix/Cargo.toml | 6 +- services/aster-nix/src/fs/devpts/ptmx.rs | 4 +- services/aster-nix/src/fs/devpts/slave.rs | 5 +- services/aster-nix/src/fs/epoll/epoll_file.rs | 8 +-- services/aster-nix/src/fs/ext2/block_group.rs | 8 +-- services/aster-nix/src/fs/ext2/dir.rs | 2 - services/aster-nix/src/fs/file_handle.rs | 2 - .../aster-nix/src/fs/inode_handle/dyn_cap.rs | 8 +-- services/aster-nix/src/fs/utils/dentry.rs | 1 - services/aster-nix/src/lib.rs | 16 ++--- services/aster-nix/src/net/iface/virtio.rs | 1 - .../src/net/socket/ip/stream/connecting.rs | 1 - services/aster-nix/src/process/signal/mod.rs | 5 +- services/aster-nix/src/thread/mod.rs | 5 +- .../aster-nix/src/thread/work_queue/mod.rs | 7 +-- services/aster-nix/src/vm/vmar/dyn_cap.rs | 2 +- services/aster-nix/src/vm/vmar/mod.rs | 5 -- services/aster-nix/src/vm/vmar/vm_mapping.rs | 5 +- services/comps/network/src/lib.rs | 4 +- services/libs/keyable-arc/src/lib.rs | 1 - tools/bump_version.sh | 4 +- tools/docker/Dockerfile.ubuntu22.04 | 27 ++++++--- 42 files changed, 188 insertions(+), 153 deletions(-) create mode 100644 .github/workflows/framework_test.yml rename .github/workflows/{aster_ci.yml => kernel_test.yml} (81%) delete mode 100644 .github/workflows/osdk_ci.yml create mode 100644 .github/workflows/osdk_test.yml diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index 7d6937d6d..99846b351 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -21,7 +21,7 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Fetch versions in the repo id: fetch-versions diff --git a/.github/workflows/framework_test.yml b/.github/workflows/framework_test.yml new file mode 100644 index 000000000..c6998faee --- /dev/null +++ b/.github/workflows/framework_test.yml @@ -0,0 +1,25 @@ +name: Framework Test + +on: + pull_request: + push: + branches: + - main + +jobs: + unit-test: + runs-on: ubuntu-latest + timeout-minutes: 10 + container: asterinas/asterinas:0.4.0 + steps: + - run: echo "Running in asterinas/asterinas:0.4.0" + + - uses: actions/checkout@v4 + + - run: make install_osdk + + - run: make update_initramfs + + - name: Unit test + id: test + run: cd framework/aster-frame && cargo osdk test \ No newline at end of file diff --git a/.github/workflows/aster_ci.yml b/.github/workflows/kernel_test.yml similarity index 81% rename from .github/workflows/aster_ci.yml rename to .github/workflows/kernel_test.yml index 096fc6fdf..a71ee857d 100644 --- a/.github/workflows/aster_ci.yml +++ b/.github/workflows/kernel_test.yml @@ -1,4 +1,4 @@ -name: Asterinas CI +name: Kernel Test on: pull_request: @@ -7,14 +7,14 @@ on: - main jobs: - aster-lint: + lint: runs-on: ubuntu-latest timeout-minutes: 10 - container: asterinas/asterinas:0.3.0 + container: asterinas/asterinas:0.4.0 steps: - - run: echo "Running in asterinas/asterinas:0.3.0" + - run: echo "Running in asterinas/asterinas:0.4.0" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: make install_osdk @@ -22,14 +22,14 @@ jobs: id: check run: make check - aster-unit-test: + unit-test: runs-on: ubuntu-latest timeout-minutes: 15 - container: asterinas/asterinas:0.3.0 + container: asterinas/asterinas:0.4.0 steps: - - run: echo "Running in asterinas/asterinas:0.3.0" + - run: echo "Running in asterinas/asterinas:0.4.0" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: make install_osdk @@ -43,14 +43,14 @@ jobs: # TODO: add component check. - aster-integration-test: + integration-test: runs-on: ubuntu-latest timeout-minutes: 30 - container: asterinas/asterinas:0.3.1 + container: asterinas/asterinas:0.4.0 steps: - - run: echo "Running in asterinas/asterinas:0.3.1" + - run: echo "Running in asterinas/asterinas:0.4.0" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: make install_osdk diff --git a/.github/workflows/osdk_ci.yml b/.github/workflows/osdk_ci.yml deleted file mode 100644 index 66675791b..000000000 --- a/.github/workflows/osdk_ci.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: OSDK CI - -on: - pull_request: - paths: - - osdk/** - push: - branches: - - main - -jobs: - osdk-ci: - runs-on: ubuntu-latest - timeout-minutes: 10 - container: asterinas/asterinas:0.3.0 - steps: - - run: echo "Running in asterinas/asterinas:0.3.0" - - - uses: actions/checkout@v3 - - - name: Lint - id: lint - run: cd osdk && cargo clippy -- -D warnings - - - name: Unit test - id: unit_test - run: cd osdk && cargo build && cargo test diff --git a/.github/workflows/osdk_publish.yml b/.github/workflows/osdk_publish.yml index 028bf1d91..fecb83805 100644 --- a/.github/workflows/osdk_publish.yml +++ b/.github/workflows/osdk_publish.yml @@ -12,9 +12,9 @@ jobs: osdk-publish: runs-on: ubuntu-latest timeout-minutes: 10 - container: asterinas/asterinas:0.3.0 + container: asterinas/asterinas:0.4.0 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: katyo/publish-crates@v2 with: path: './osdk' diff --git a/.github/workflows/osdk_test.yml b/.github/workflows/osdk_test.yml new file mode 100644 index 000000000..43cd5fc3a --- /dev/null +++ b/.github/workflows/osdk_test.yml @@ -0,0 +1,33 @@ +name: OSDK Test + +on: + pull_request: + paths: + - framework/** + - osdk/** + - tools/** + - Cargo.toml + push: + branches: + - main + +jobs: + osdk-test: + runs-on: ubuntu-latest + timeout-minutes: 10 + container: asterinas/asterinas:0.4.0 + steps: + - run: echo "Running in asterinas/asterinas:0.4.0" + + - uses: actions/checkout@v4 + + - name: Lint + id: lint + run: cd osdk && cargo clippy -- -D warnings + + # The OSDK unit test features a recursive call of Cargo, + # which will break when RUSTUP_HOME is altered in the case + # of actions/checkout@v4 + - name: Unit test + id: unit_test + run: cd osdk && cargo build && RUSTUP_HOME=/root/.rustup cargo test diff --git a/Cargo.lock b/Cargo.lock index 32b898806..c380aa737 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,19 +21,26 @@ checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "d713b3834d76b85304d4d525563c1276e2e30dc97cc67bfb4585a4a29fc2c89f" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] name = "align_ext" version = "0.1.0" +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "aml" version = "0.16.4" @@ -291,7 +298,7 @@ dependencies = [ [[package]] name = "asterinas" -version = "0.3.1" +version = "0.4.0" dependencies = [ "aster-frame", "aster-framebuffer", @@ -510,6 +517,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "dary_heap" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7762d17f1241643615821a8455a0b2c3e803784b058693d990b11f2dce25a0ca" + [[package]] name = "defmt" version = "0.3.5" @@ -681,6 +694,10 @@ name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", + "allocator-api2", +] [[package]] name = "heapless" @@ -835,19 +852,22 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libflate" -version = "1.4.0" -source = "git+https://github.com/asterinas/libflate?rev=b781da6#b781da6b6841e380f4cfa3529d5070afad56ea32" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7d5654ae1795afc7ff76f4365c2c8791b0feb18e8996a96adad8ffd7c3b2bf" dependencies = [ "adler32", "core2", "crc32fast", + "dary_heap", "libflate_lz77", ] [[package]] name = "libflate_lz77" -version = "1.2.0" -source = "git+https://github.com/asterinas/libflate?rev=b781da6#b781da6b6841e380f4cfa3529d5070afad56ea32" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be5f52fb8c451576ec6b79d3f4deb327398bc05bbdbd99021a6e77a4c855d524" dependencies = [ "core2", "hashbrown 0.13.2", @@ -901,11 +921,11 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" -version = "0.9.0" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e7d46de488603ffdd5f30afbc64fbba2378214a2c3a2fb83abf3d33126df17" +checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" dependencies = [ - "hashbrown 0.13.2", + "hashbrown 0.14.3", ] [[package]] @@ -1621,3 +1641,23 @@ name = "zero" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fe21bcc34ca7fe6dd56cc2cb1261ea59d6b93620215aefb5ea6032265527784" + +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.49", +] diff --git a/Cargo.toml b/Cargo.toml index 5c6d886b6..82efdd68e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "asterinas" -version = "0.3.1" +version = "0.4.0" edition = "2021" [dependencies] diff --git a/Makefile b/Makefile index 6962e7022..82cbbca70 100644 --- a/Makefile +++ b/Makefile @@ -81,8 +81,8 @@ USERMODE_TESTABLE := \ services/libs/typeflags-util # Maintain a list of kernel crates that can be tested with `cargo osdk test` +# The framework is tested independently, thus not included here KTEST_TESTABLE := \ - "framework/aster-frame" \ "services/aster-nix" \ "services/comps/block" \ "services/comps/console" \ diff --git a/README.md b/README.md index 1d36f00ca..6498dbbe1 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@ A secure, fast, and general-purpose OS kernel written in Rust and compatible with Linux

-[![Asterinas CI](https://github.com/asterinas/asterinas/actions/workflows/aster_ci.yml/badge.svg)](https://github.com/asterinas/asterinas/actions/workflows/aster_ci.yml) +[![Check License](https://github.com/asterinas/asterinas/actions/workflows/license_check.yml/badge.svg)](https://github.com/asterinas/asterinas/actions/workflows/license_check.yml) +[![Framework Test](https://github.com/asterinas/asterinas/actions/workflows/framework_test.yml/badge.svg)](https://github.com/asterinas/asterinas/actions/workflows/framework_test.yml) +[![Kernel Test](https://github.com/asterinas/asterinas/actions/workflows/kernel_test.yml/badge.svg)](https://github.com/asterinas/asterinas/actions/workflows/kernel_test.yml) English | [中文版](README_CN.md) @@ -51,7 +53,7 @@ git clone https://github.com/asterinas/asterinas 2. Run a Docker container as the development environment. ```bash -docker run -it --privileged --network=host --device=/dev/kvm -v ./asterinas:/root/asterinas asterinas/asterinas:0.3.1 +docker run -it --privileged --network=host --device=/dev/kvm -v ./asterinas:/root/asterinas asterinas/asterinas:0.4.0 ``` 3. Install the Asterinas OSDK from source. diff --git a/README_CN.md b/README_CN.md index 1334b4e2f..f715f9dcd 100644 --- a/README_CN.md +++ b/README_CN.md @@ -47,7 +47,7 @@ git clone https://github.com/asterinas/asterinas 2. 运行一个作为开发环境的Docker容器。 ```bash -docker run -it --privileged --network=host --device=/dev/kvm -v ./asterinas:/root/asterinas asterinas/asterinas:0.3.0 +docker run -it --privileged --network=host --device=/dev/kvm -v ./asterinas:/root/asterinas asterinas/asterinas:0.4.0 ``` 3. 从源码编译安装 Asterinas OSDK diff --git a/VERSION b/VERSION index 9e11b32fc..1d0ba9ea1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.1 +0.4.0 diff --git a/framework/aster-frame/src/bus/pci/common_device.rs b/framework/aster-frame/src/bus/pci/common_device.rs index ba19c64fd..71b863e21 100644 --- a/framework/aster-frame/src/bus/pci/common_device.rs +++ b/framework/aster-frame/src/bus/pci/common_device.rs @@ -90,9 +90,7 @@ pub struct BarManager { impl BarManager { /// Gain access to the BAR space and return None if that BAR is set to be invisible or absent. pub fn bar(&self, idx: u8) -> Option { - let Some((bar, visible)) = self.bars[idx as usize].clone() else { - return None; - }; + let (bar, visible) = self.bars[idx as usize].clone()?; if visible { Some(bar) } else { diff --git a/framework/aster-frame/src/vm/frame.rs b/framework/aster-frame/src/vm/frame.rs index 73a78c998..aaaf7ac09 100644 --- a/framework/aster-frame/src/vm/frame.rs +++ b/framework/aster-frame/src/vm/frame.rs @@ -2,14 +2,13 @@ use alloc::vec; use core::{ - iter::Iterator, marker::PhantomData, ops::{BitAnd, BitOr, Not, Range}, }; use pod::Pod; -use super::{frame_allocator, HasPaddr, Paddr, VmIo}; +use super::{frame_allocator, HasPaddr, VmIo}; use crate::{config::PAGE_SIZE, prelude::*, Error}; /// A collection of page frames (physical memory pages). diff --git a/framework/aster-frame/src/vm/space.rs b/framework/aster-frame/src/vm/space.rs index a36ac67c2..e0450bd8e 100644 --- a/framework/aster-frame/src/vm/space.rs +++ b/framework/aster-frame/src/vm/space.rs @@ -4,7 +4,7 @@ use core::ops::Range; use bitflags::bitflags; -use super::{is_page_aligned, MapArea, MemorySet, Vaddr, VmFrameVec, VmIo}; +use super::{is_page_aligned, MapArea, MemorySet, VmFrameVec, VmIo}; use crate::{arch::mm::PageTableFlags, config::PAGE_SIZE, prelude::*, sync::Mutex, Error}; /// Virtual memory space. diff --git a/framework/libs/ktest/src/lib.rs b/framework/libs/ktest/src/lib.rs index 569ab34be..e90e50084 100644 --- a/framework/libs/ktest/src/lib.rs +++ b/framework/libs/ktest/src/lib.rs @@ -95,7 +95,6 @@ pub mod tree; extern crate alloc; use alloc::{boxed::Box, string::String}; -use core::result::Result; pub use ktest_proc_macro::ktest; @@ -220,9 +219,7 @@ impl core::iter::Iterator for KtestIter { type Item = KtestItem; fn next(&mut self) -> Option { - let Some(ktest_item) = ktest_array!().get(self.index) else { - return None; - }; + let ktest_item = ktest_array!().get(self.index)?; self.index += 1; Some(ktest_item.clone()) } diff --git a/framework/libs/ktest/src/tree.rs b/framework/libs/ktest/src/tree.rs index 3a99e60ba..3d908fd9a 100644 --- a/framework/libs/ktest/src/tree.rs +++ b/framework/libs/ktest/src/tree.rs @@ -13,7 +13,6 @@ use alloc::{ vec, vec::Vec, }; -use core::iter::{FromIterator, Iterator}; use crate::{ path::{KtestPath, PathElement}, diff --git a/osdk/Cargo.toml b/osdk/Cargo.toml index 3d837e487..8822d206d 100644 --- a/osdk/Cargo.toml +++ b/osdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-osdk" -version = "0.2.0" +version = "0.4.0" edition = "2021" description = "Accelerate OS development with Asterinas OSDK" license = "MPL-2.0" diff --git a/osdk/src/base_crate/x86_64-custom.json.template b/osdk/src/base_crate/x86_64-custom.json.template index a5fadfaa0..a7d797f8d 100644 --- a/osdk/src/base_crate/x86_64-custom.json.template +++ b/osdk/src/base_crate/x86_64-custom.json.template @@ -1,6 +1,6 @@ { "llvm-target": "x86_64-unknown-none", - "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", + "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", "code-model": "kernel", "cpu": "x86-64", "arch": "x86_64", diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 65d0da22a..d6a6b4796 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-12-01" -components = ["rust-src", "rustc-dev", "llvm-tools-preview"] \ No newline at end of file +channel = "nightly-2024-01-01" +components = ["rust-src", "rustc-dev", "llvm-tools-preview"] diff --git a/services/aster-nix/Cargo.toml b/services/aster-nix/Cargo.toml index ddcaac544..3f2ada40f 100644 --- a/services/aster-nix/Cargo.toml +++ b/services/aster-nix/Cargo.toml @@ -51,14 +51,12 @@ bitflags = "1.3" ringbuf = { version = "0.3.2", default-features = false, features = ["alloc"] } keyable-arc = { path = "../libs/keyable-arc" } # unzip initramfs -libflate = { git = "https://github.com/asterinas/libflate", rev = "b781da6", features = [ - "no_std", -] } +libflate = { version ="2", default-features = false } core2 = { version = "0.4", default_features = false, features = ["alloc"] } lending-iterator = "0.1.7" spin = "0.9.4" vte = "0.10" -lru = "0.9.0" +lru = "0.12.3" log = "0.4" getrandom = { version = "0.2.10", default-features = false, features = [ "rdrand", diff --git a/services/aster-nix/src/fs/devpts/ptmx.rs b/services/aster-nix/src/fs/devpts/ptmx.rs index 3b24e8459..bd76a188f 100644 --- a/services/aster-nix/src/fs/devpts/ptmx.rs +++ b/services/aster-nix/src/fs/devpts/ptmx.rs @@ -1,9 +1,7 @@ // SPDX-License-Identifier: MPL-2.0 use super::*; -use crate::{ - device::PtyMaster, events::IoEvents, fs::inode_handle::FileIo, process::signal::Poller, -}; +use crate::{events::IoEvents, fs::inode_handle::FileIo, process::signal::Poller}; /// Same major number with Linux. const PTMX_MAJOR_NUM: u32 = 5; diff --git a/services/aster-nix/src/fs/devpts/slave.rs b/services/aster-nix/src/fs/devpts/slave.rs index d3169b514..b02328018 100644 --- a/services/aster-nix/src/fs/devpts/slave.rs +++ b/services/aster-nix/src/fs/devpts/slave.rs @@ -2,10 +2,7 @@ use super::*; use crate::{ - device::PtySlave, - events::IoEvents, - fs::inode_handle::FileIo, - process::{signal::Poller, Gid, Uid}, + device::PtySlave, events::IoEvents, fs::inode_handle::FileIo, process::signal::Poller, }; /// Same major number with Linux, the minor number is the index of slave. diff --git a/services/aster-nix/src/fs/epoll/epoll_file.rs b/services/aster-nix/src/fs/epoll/epoll_file.rs index 37d44a4d0..bf3c18051 100644 --- a/services/aster-nix/src/fs/epoll/epoll_file.rs +++ b/services/aster-nix/src/fs/epoll/epoll_file.rs @@ -7,12 +7,8 @@ use core::{ use super::*; use crate::{ - events::{IoEvents, Observer}, - fs::{ - file_handle::FileLike, - file_table::{FdEvents, FileDescripter}, - utils::IoctlCmd, - }, + events::Observer, + fs::{file_handle::FileLike, file_table::FdEvents, utils::IoctlCmd}, process::signal::{Pollee, Poller}, }; diff --git a/services/aster-nix/src/fs/ext2/block_group.rs b/services/aster-nix/src/fs/ext2/block_group.rs index 45268a94b..7df1f9e5d 100644 --- a/services/aster-nix/src/fs/ext2/block_group.rs +++ b/services/aster-nix/src/fs/ext2/block_group.rs @@ -342,9 +342,7 @@ impl GroupMetadata { } pub fn alloc_inode(&mut self, is_dir: bool) -> Option { - let Some(inode_idx) = self.inode_bitmap.alloc() else { - return None; - }; + let inode_idx = self.inode_bitmap.alloc()?; self.dec_free_inodes(); if is_dir { self.inc_dirs(); @@ -365,9 +363,7 @@ impl GroupMetadata { } pub fn alloc_block(&mut self) -> Option { - let Some(block_idx) = self.block_bitmap.alloc() else { - return None; - }; + let block_idx = self.block_bitmap.alloc()?; self.dec_free_blocks(); Some(block_idx as u32) } diff --git a/services/aster-nix/src/fs/ext2/dir.rs b/services/aster-nix/src/fs/ext2/dir.rs index 5f00e3742..5cb984132 100644 --- a/services/aster-nix/src/fs/ext2/dir.rs +++ b/services/aster-nix/src/fs/ext2/dir.rs @@ -1,7 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -use core::iter::Iterator; - use super::{ inode::{FileType, MAX_FNAME_LEN}, prelude::*, diff --git a/services/aster-nix/src/fs/file_handle.rs b/services/aster-nix/src/fs/file_handle.rs index f4f66d98d..994963ade 100644 --- a/services/aster-nix/src/fs/file_handle.rs +++ b/services/aster-nix/src/fs/file_handle.rs @@ -2,8 +2,6 @@ //! Opend File Handle -use core::any::Any; - use crate::{ events::{IoEvents, Observer}, fs::{ diff --git a/services/aster-nix/src/fs/inode_handle/dyn_cap.rs b/services/aster-nix/src/fs/inode_handle/dyn_cap.rs index 4722f3c88..83c40a4f1 100644 --- a/services/aster-nix/src/fs/inode_handle/dyn_cap.rs +++ b/services/aster-nix/src/fs/inode_handle/dyn_cap.rs @@ -1,14 +1,10 @@ // SPDX-License-Identifier: MPL-2.0 -use aster_rights::{Rights, TRights}; +use aster_rights::TRights; use inherit_methods_macro::inherit_methods; use super::*; -use crate::{ - events::IoEvents, - prelude::*, - process::{signal::Poller, Gid, Uid}, -}; +use crate::prelude::*; impl InodeHandle { pub fn new( diff --git a/services/aster-nix/src/fs/utils/dentry.rs b/services/aster-nix/src/fs/utils/dentry.rs index 3a508fa70..ae24b14cc 100644 --- a/services/aster-nix/src/fs/utils/dentry.rs +++ b/services/aster-nix/src/fs/utils/dentry.rs @@ -1,6 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -use alloc::string::String; use core::{ sync::atomic::{AtomicU32, Ordering}, time::Duration, diff --git a/services/aster-nix/src/lib.rs b/services/aster-nix/src/lib.rs index 95ce514f1..8eb70ebf3 100644 --- a/services/aster-nix/src/lib.rs +++ b/services/aster-nix/src/lib.rs @@ -6,23 +6,23 @@ #![allow(dead_code)] #![allow(incomplete_features)] #![allow(unused_variables)] -#![feature(exclusive_range_pattern)] +#![feature(btree_cursors)] #![feature(btree_extract_if)] #![feature(const_option)] +#![feature(exclusive_range_pattern)] #![feature(extend_one)] +#![feature(fn_traits)] +#![feature(format_args_nl)] +#![feature(int_roundings)] #![feature(let_chains)] +#![feature(linked_list_remove)] +#![feature(register_tool)] // FIXME: This feature is used to support vm capbility now as a work around. // Since this is an incomplete feature, use this feature is unsafe. // We should find a proper method to replace this feature with min_specialization, which is a sound feature. #![feature(specialization)] -#![feature(fn_traits)] -#![feature(linked_list_remove)] -#![feature(trait_alias)] -#![feature(register_tool)] -#![feature(format_args_nl)] -#![feature(int_roundings)] #![feature(step_trait)] -#![feature(btree_cursors)] +#![feature(trait_alias)] #![register_tool(component_access_control)] use aster_frame::{ diff --git a/services/aster-nix/src/net/iface/virtio.rs b/services/aster-nix/src/net/iface/virtio.rs index 674aeb32f..180dcb17b 100644 --- a/services/aster-nix/src/net/iface/virtio.rs +++ b/services/aster-nix/src/net/iface/virtio.rs @@ -1,6 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -use aster_frame::sync::SpinLock; use aster_network::AnyNetworkDevice; use aster_virtio::device::network::DEVICE_NAME; use smoltcp::{ diff --git a/services/aster-nix/src/net/socket/ip/stream/connecting.rs b/services/aster-nix/src/net/socket/ip/stream/connecting.rs index 63b37dbf4..626fe01df 100644 --- a/services/aster-nix/src/net/socket/ip/stream/connecting.rs +++ b/services/aster-nix/src/net/socket/ip/stream/connecting.rs @@ -1,6 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -use alloc::sync::Arc; use core::sync::atomic::{AtomicBool, Ordering}; use super::{connected::ConnectedStream, init::InitStream}; diff --git a/services/aster-nix/src/process/signal/mod.rs b/services/aster-nix/src/process/signal/mod.rs index 7ea0bda6f..c2dd30356 100644 --- a/services/aster-nix/src/process/signal/mod.rs +++ b/services/aster-nix/src/process/signal/mod.rs @@ -210,10 +210,7 @@ pub fn handle_user_signal( /// It the stack is not used by any handler, we will return the new sp in alternate signal stack. fn use_alternate_signal_stack(posix_thread: &PosixThread) -> Option { let mut sig_stack = posix_thread.sig_stack().lock(); - - let Some(sig_stack) = &mut *sig_stack else { - return None; - }; + let sig_stack = (*sig_stack).as_mut()?; if sig_stack.is_disabled() { return None; diff --git a/services/aster-nix/src/thread/mod.rs b/services/aster-nix/src/thread/mod.rs index 1ddfa6a92..e2ddaa36d 100644 --- a/services/aster-nix/src/thread/mod.rs +++ b/services/aster-nix/src/thread/mod.rs @@ -2,10 +2,7 @@ //! Posix thread implementation -use core::{ - any::Any, - sync::atomic::{AtomicU32, Ordering}, -}; +use core::sync::atomic::{AtomicU32, Ordering}; use aster_frame::task::Task; diff --git a/services/aster-nix/src/thread/work_queue/mod.rs b/services/aster-nix/src/thread/work_queue/mod.rs index b349b5f65..308771b74 100644 --- a/services/aster-nix/src/thread/work_queue/mod.rs +++ b/services/aster-nix/src/thread/work_queue/mod.rs @@ -146,13 +146,10 @@ impl WorkQueue { /// the calling worker is located. fn dequeue(&self, request_cpu: u32) -> Option> { let mut inner = self.inner.lock_irq_disabled(); - let Some(index) = inner + let index = inner .pending_work_items .iter() - .position(|item| item.is_valid_cpu(request_cpu)) - else { - return None; - }; + .position(|item| item.is_valid_cpu(request_cpu))?; let item = inner.pending_work_items.remove(index); Some(item) } diff --git a/services/aster-nix/src/vm/vmar/dyn_cap.rs b/services/aster-nix/src/vm/vmar/dyn_cap.rs index 8759dc2d5..d3112cc7a 100644 --- a/services/aster-nix/src/vm/vmar/dyn_cap.rs +++ b/services/aster-nix/src/vm/vmar/dyn_cap.rs @@ -2,7 +2,7 @@ use core::ops::Range; -use aster_frame::vm::{Vaddr, VmIo}; +use aster_frame::vm::VmIo; use aster_rights::Rights; use super::{ diff --git a/services/aster-nix/src/vm/vmar/mod.rs b/services/aster-nix/src/vm/vmar/mod.rs index 46f42170c..d8b08ff66 100644 --- a/services/aster-nix/src/vm/vmar/mod.rs +++ b/services/aster-nix/src/vm/vmar/mod.rs @@ -8,11 +8,6 @@ mod options; mod static_cap; pub mod vm_mapping; -use alloc::{ - collections::BTreeMap, - sync::{Arc, Weak}, - vec::Vec, -}; use core::ops::Range; use align_ext::AlignExt; diff --git a/services/aster-nix/src/vm/vmar/vm_mapping.rs b/services/aster-nix/src/vm/vmar/vm_mapping.rs index a18ae630d..fe935d0b3 100644 --- a/services/aster-nix/src/vm/vmar/vm_mapping.rs +++ b/services/aster-nix/src/vm/vmar/vm_mapping.rs @@ -2,10 +2,7 @@ use core::ops::Range; -use aster_frame::{ - sync::Mutex, - vm::{VmFrame, VmFrameVec, VmIo, VmMapOptions, VmPerm, VmSpace}, -}; +use aster_frame::vm::{VmFrame, VmFrameVec, VmIo, VmMapOptions, VmPerm, VmSpace}; use super::{interval::Interval, is_intersected, Vmar, Vmar_}; use crate::{ diff --git a/services/comps/network/src/lib.rs b/services/comps/network/src/lib.rs index 617c6959e..36bb3eb5a 100644 --- a/services/comps/network/src/lib.rs +++ b/services/comps/network/src/lib.rs @@ -61,9 +61,7 @@ pub fn register_device(name: String, device: Arc Option>>> { let lock = COMPONENT.get().unwrap().network_device_table.lock(); - let Some((_, device)) = lock.get(str) else { - return None; - }; + let (_, device) = lock.get(str)?; Some(device.clone()) } diff --git a/services/libs/keyable-arc/src/lib.rs b/services/libs/keyable-arc/src/lib.rs index fe5d241c1..abab99e5f 100644 --- a/services/libs/keyable-arc/src/lib.rs +++ b/services/libs/keyable-arc/src/lib.rs @@ -112,7 +112,6 @@ use alloc::sync::{Arc, Weak}; use core::{ borrow::Borrow, cmp::Ordering, - convert::AsRef, fmt, hash::{Hash, Hasher}, marker::Unsize, diff --git a/tools/bump_version.sh b/tools/bump_version.sh index 7118ad745..fbd9c07ac 100755 --- a/tools/bump_version.sh +++ b/tools/bump_version.sh @@ -20,6 +20,7 @@ update_image_versions() { SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) ASTER_SRC_DIR=${SCRIPT_DIR}/.. CARGO_TOML_PATH=${ASTER_SRC_DIR}/Cargo.toml +OSDK_CARGO_TOML_PATH=${ASTER_SRC_DIR}/osdk/Cargo.toml VERSION_PATH=${ASTER_SRC_DIR}/VERSION # Get and check the new version number @@ -32,6 +33,7 @@ fi # Update Cargo.toml update_cargo_versions ${CARGO_TOML_PATH} +update_cargo_versions ${OSDK_CARGO_TOML_PATH} # Automatically bump Cargo.lock file cargo update -p asterinas --precise $new_version @@ -50,4 +52,4 @@ done # Create or update VERSION echo "${new_version}" > ${VERSION_PATH} -echo "Bumped Asterinas version to $new_version" +echo "Bumped Asterinas & OSDK version to $new_version" diff --git a/tools/docker/Dockerfile.ubuntu22.04 b/tools/docker/Dockerfile.ubuntu22.04 index 6cdd4114b..bea55eb33 100644 --- a/tools/docker/Dockerfile.ubuntu22.04 +++ b/tools/docker/Dockerfile.ubuntu22.04 @@ -91,12 +91,12 @@ RUN apt clean && rm -rf /var/lib/apt/lists/* FROM build-qemu as qemu -# Fetch and install QEMU from https://download.qemu.org/qemu-8.1.1.tar.xz +# Fetch and install QEMU from the official source # # The QEMU version in the Ubuntu 22.04 repository is 6.*, which has a bug to cause OVMF debug to fail. # The libslirp dependency is for QEMU's network backend. WORKDIR /root -RUN wget -O qemu.tar.xz https://download.qemu.org/qemu-8.1.1.tar.xz \ +RUN wget -O qemu.tar.xz https://download.qemu.org/qemu-8.2.1.tar.xz \ && mkdir /root/qemu \ && tar xf qemu.tar.xz --strip-components=1 -C /root/qemu \ && rm qemu.tar.xz @@ -123,7 +123,7 @@ FROM build-ovmf as ovmf # Fetch and build OVMF from the EDK2 official source WORKDIR /root -RUN git clone --depth 1 --branch edk2-stable202311 --recurse-submodules --shallow-submodules https://github.com/tianocore/edk2.git +RUN git clone --depth 1 --branch edk2-stable202402 --recurse-submodules --shallow-submodules https://github.com/tianocore/edk2.git WORKDIR /root/edk2 RUN source ./edksetup.sh \ && make -C BaseTools \ @@ -142,6 +142,7 @@ RUN apt update && apt-get install -y --no-install-recommends \ flex \ gawk \ gettext \ + libfreetype6-dev \ pkg-config RUN apt clean && rm -rf /var/lib/apt/lists/* @@ -153,13 +154,24 @@ FROM build-grub as grub # in the GRUB release. The Ubuntu release notoriously modifies the GRUB source code and enforce # EFI handover boot, which is deprecated. So we have to build GRUB from source. WORKDIR /root -RUN wget -O grub.tar.xz https://git.savannah.gnu.org/cgit/grub.git/snapshot/grub-grub-2.12-rc1.tar.gz \ +RUN wget -O grub.tar.xz https://ftp.gnu.org/gnu/grub/grub-2.12.tar.xz \ && mkdir /root/grub \ && tar xf grub.tar.xz --strip-components=1 -C /root/grub \ && rm grub.tar.xz +# Fetch and install the Unicode font data for grub. +RUN wget -O unifont.pcf.gz https://unifoundry.com/pub/unifont/unifont-15.1.04/font-builds/unifont-15.1.04.pcf.gz \ + && mkdir -pv /usr/share/fonts/unifont \ + && gunzip -c unifont.pcf.gz > /usr/share/fonts/unifont/unifont.pcf \ + && rm unifont.pcf.gz WORKDIR /root/grub -RUN ./bootstrap \ - && ./configure --target=x86_64 --with-platform=efi --prefix=/usr/local/grub \ +RUN echo depends bli part_gpt > grub-core/extra_deps.lst \ + && ./configure \ + --target=x86_64 \ + --disable-efiemu \ + --with-platform=efi \ + --enable-grub-mkfont \ + --prefix=/usr/local/grub \ + --disable-werror \ && make -j \ && make install WORKDIR /root @@ -188,11 +200,12 @@ RUN make defconfig \ FROM build-base as rust -# Install Rust +# Install Rust with both nightly and stable ENV PATH="/root/.cargo/bin:${PATH}" ARG ASTER_RUST_VERSION RUN curl https://sh.rustup.rs -sSf | \ sh -s -- --default-toolchain ${ASTER_RUST_VERSION} -y \ + && rustup toolchain install stable \ && rm -rf /root/.cargo/registry && rm -rf /root/.cargo/git \ && cargo -V \ && rustup component add rust-src rustc-dev llvm-tools-preview