diff --git a/.github/workflows/framework_test.yml b/.github/workflows/framework_test.yml
deleted file mode 100644
index c6998faee..000000000
--- a/.github/workflows/framework_test.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-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/kernel_test.yml b/.github/workflows/kernel_test.yml
index a71ee857d..a5186e0e9 100644
--- a/.github/workflows/kernel_test.yml
+++ b/.github/workflows/kernel_test.yml
@@ -9,7 +9,7 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
- timeout-minutes: 10
+ timeout-minutes: 15
container: asterinas/asterinas:0.4.0
steps:
- run: echo "Running in asterinas/asterinas:0.4.0"
diff --git a/Cargo.toml b/Cargo.toml
index cd7d650f7..2f39b843e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,6 +8,7 @@ members = [
"framework/libs/linux-bzimage/boot-params",
"framework/libs/linux-bzimage/setup",
"framework/libs/ktest",
+ "framework/libs/ktest-proc-macro",
"framework/libs/tdx-guest",
"kernel",
"kernel/aster-nix",
@@ -29,10 +30,10 @@ members = [
"kernel/libs/typeflags-util",
]
exclude = [
- "osdk",
- "target/osdk/base",
"kernel/libs/comp-sys/cargo-component",
"kernel/libs/comp-sys/component",
"kernel/libs/comp-sys/component-macro",
"kernel/libs/comp-sys/controlled",
+ "osdk",
+ "target/osdk/base",
]
diff --git a/Makefile b/Makefile
index 84b0cb776..cfe843ebd 100644
--- a/Makefile
+++ b/Makefile
@@ -63,34 +63,40 @@ endif
# Pass make variables to all subdirectory makes
export
-# Maintain a list of usermode crates that can be tested with `cargo test`
-USERMODE_TESTABLE := \
- framework/libs/align_ext \
- framework/libs/aster-main \
+# Basically, non-OSDK crates do not depend on Aster Frame and can be checked
+# or tested without OSDK.
+NON_OSDK_CRATES := \
+ framework/libs/align_ext \
+ framework/libs/aster-main \
framework/libs/linux-bzimage/builder \
framework/libs/linux-bzimage/boot-params \
- framework/libs/ktest \
- framework/libs/ktest-proc-macro \
- kernel/libs/cpio-decoder \
- kernel/libs/int-to-c-enum \
- kernel/libs/int-to-c-enum/derive \
- kernel/libs/aster-rights \
- kernel/libs/aster-rights-proc \
- kernel/libs/keyable-arc \
- kernel/libs/typeflags \
- kernel/libs/typeflags-util
+ framework/libs/ktest \
+ framework/libs/ktest-proc-macro \
+ framework/libs/tdx-guest \
+ kernel/libs/cpio-decoder \
+ kernel/libs/int-to-c-enum \
+ kernel/libs/int-to-c-enum/derive \
+ kernel/libs/aster-rights \
+ kernel/libs/aster-rights-proc \
+ kernel/libs/keyable-arc \
+ kernel/libs/typeflags \
+ kernel/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 := \
- "kernel/aster-nix" \
- "kernel/comps/block" \
- "kernel/comps/console" \
- "kernel/comps/framebuffer" \
- "kernel/comps/input" \
- "kernel/comps/network" \
- "kernel/comps/time" \
- "kernel/comps/virtio"
+# In contrast, OSDK crates depend on Aster Frame (or being aster-frame itself)
+# and need to be built or tested with OSDK.
+OSDK_CRATES := \
+ framework/aster-frame \
+ framework/libs/linux-bzimage/setup \
+ kernel \
+ kernel/aster-nix \
+ kernel/comps/block \
+ kernel/comps/console \
+ kernel/comps/framebuffer \
+ kernel/comps/input \
+ kernel/comps/network \
+ kernel/comps/time \
+ kernel/comps/virtio \
+ kernel/libs/aster-util
.PHONY: all install_osdk build tools run test docs check clean update_initramfs
@@ -110,12 +116,14 @@ run: build
@cd kernel && cargo osdk run $(CARGO_OSDK_ARGS)
test:
- @for dir in $(USERMODE_TESTABLE); do \
+ @for dir in $(NON_OSDK_CRATES); do \
(cd $$dir && cargo test) || exit 1; \
done
ktest:
- @for dir in $(KTEST_TESTABLE); do \
+ @# Exclude linux-bzimage-setup from ktest since it's hard to be unit tested
+ @for dir in $(OSDK_CRATES); do \
+ [ $$dir = "framework/libs/linux-bzimage/setup" ] && continue; \
(cd $$dir && cargo osdk test) || exit 1; \
done
@@ -128,8 +136,18 @@ format:
@./tools/format_all.sh
check:
- @./tools/format_all.sh --check # Check Rust format issues
- @cargo osdk clippy
+ @./tools/format_all.sh --check # Check Rust format issues
+ @# Check if STD_CRATES and NOSTD_CRATES combined is the same as all workspace members
+ @sed -n '/^\[workspace\]/,/^\[.*\]/{/members = \[/,/\]/p}' Cargo.toml | grep -v "members = \[" | tr -d '", \]' | sort > /tmp/all_crates
+ @echo $(NON_OSDK_CRATES) $(OSDK_CRATES) | tr ' ' '\n' | sort > /tmp/combined_crates
+ @diff -B /tmp/all_crates /tmp/combined_crates || (echo "Error: STD_CRATES and NOSTD_CRATES combined is not the same as all workspace members" && exit 1)
+ @rm /tmp/all_crates /tmp/combined_crates
+ @for dir in $(NON_OSDK_CRATES); do \
+ (cd $$dir && cargo clippy -- -D warnings) || exit 1; \
+ done
+ @for dir in $(OSDK_CRATES); do \
+ (cd $$dir && cargo osdk clippy) || exit 1; \
+ done
clean:
@cargo clean
diff --git a/README.md b/README.md
index 7ac2a6ce5..83dfdc754 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,6 @@
[](https://github.com/asterinas/asterinas/actions/workflows/license_check.yml)
-[](https://github.com/asterinas/asterinas/actions/workflows/framework_test.yml)
[](https://github.com/asterinas/asterinas/actions/workflows/kernel_test.yml)
English | [中文版](README_CN.md)
diff --git a/framework/libs/linux-bzimage/builder/src/lib.rs b/framework/libs/linux-bzimage/builder/src/lib.rs
index bbb445d2b..df757fa54 100644
--- a/framework/libs/linux-bzimage/builder/src/lib.rs
+++ b/framework/libs/linux-bzimage/builder/src/lib.rs
@@ -105,7 +105,7 @@ pub fn legacy32_rust_target_json() -> &'static str {
/// Interestingly, the resulting binary should be the same as the memory
/// dump of the kernel setup header when it's loaded by the bootloader.
fn to_flat_binary(elf_file: &[u8]) -> Vec {
- let elf = xmas_elf::ElfFile::new(&elf_file).unwrap();
+ let elf = xmas_elf::ElfFile::new(elf_file).unwrap();
let mut bin = Vec::::new();
for program in elf.program_iter() {
diff --git a/framework/libs/linux-bzimage/builder/src/pe_header.rs b/framework/libs/linux-bzimage/builder/src/pe_header.rs
index c7680983e..f8848cd91 100644
--- a/framework/libs/linux-bzimage/builder/src/pe_header.rs
+++ b/framework/libs/linux-bzimage/builder/src/pe_header.rs
@@ -166,6 +166,8 @@ bitflags::bitflags! {
}
// The `flags` field choices in the PE section header.
+// We follow the Linux naming, thus ignoring the clippy name warnings.
+#[allow(clippy::enum_variant_names)]
#[derive(Serialize, Clone, Copy)]
#[repr(u32)]
enum PeSectionHdrFlagsAlign {
@@ -238,10 +240,10 @@ impl ImageSectionAddrInfo {
}
Self {
- text: SetupVA::from(text_start.unwrap())..SetupVA::from(text_end.unwrap()),
- data: SetupVA::from(data_start.unwrap())..SetupVA::from(data_end.unwrap()),
- bss: SetupVA::from(bss_start.unwrap())..SetupVA::from(bss_end.unwrap()),
- rodata: SetupVA::from(rodata_start.unwrap())..SetupVA::from(rodata_end.unwrap()),
+ text: text_start.unwrap()..text_end.unwrap(),
+ data: data_start.unwrap()..data_end.unwrap(),
+ bss: bss_start.unwrap()..bss_end.unwrap(),
+ rodata: rodata_start.unwrap()..rodata_end.unwrap(),
}
}
@@ -351,90 +353,90 @@ pub(crate) fn make_pe_coff_header(setup_elf: &[u8], image_size: usize) -> ImageP
let addr_info = ImageSectionAddrInfo::from(&elf);
// PE section headers
- let mut sec_hdrs = Vec::::new();
- // .reloc
- sec_hdrs.push(PeSectionHdr {
- name: [b'.', b'r', b'e', b'l', b'o', b'c', 0, 0],
- virtual_size: relocs.len() as u32,
- virtual_address: usize::from(SetupVA::from(reloc_offset)) as u32,
- raw_data_size: relocs.len() as u32,
- data_addr: usize::from(reloc_offset) as u32,
- relocs: 0,
- line_numbers: 0,
- num_relocs: 0,
- num_lin_numbers: 0,
- flags: (PeSectionHdrFlags::CNT_INITIALIZED_DATA
- | PeSectionHdrFlags::MEM_READ
- | PeSectionHdrFlags::MEM_DISCARDABLE)
- .bits
- | PeSectionHdrFlagsAlign::_1Bytes as u32,
- });
- // .text
- sec_hdrs.push(PeSectionHdr {
- name: [b'.', b't', b'e', b'x', b't', 0, 0, 0],
- virtual_size: addr_info.text_virt_size() as u32,
- virtual_address: usize::from(addr_info.text.start) as u32,
- raw_data_size: addr_info.text_file_size() as u32,
- data_addr: usize::from(SetupFileOffset::from(addr_info.text.start)) as u32,
- relocs: 0,
- line_numbers: 0,
- num_relocs: 0,
- num_lin_numbers: 0,
- flags: (PeSectionHdrFlags::CNT_CODE
- | PeSectionHdrFlags::MEM_READ
- | PeSectionHdrFlags::MEM_EXECUTE)
- .bits
- | PeSectionHdrFlagsAlign::_16Bytes as u32,
- });
- // .data
- sec_hdrs.push(PeSectionHdr {
- name: [b'.', b'd', b'a', b't', b'a', 0, 0, 0],
- virtual_size: addr_info.data_virt_size() as u32,
- virtual_address: usize::from(addr_info.data.start) as u32,
- raw_data_size: addr_info.data_file_size() as u32,
- data_addr: usize::from(SetupFileOffset::from(addr_info.data.start)) as u32,
- relocs: 0,
- line_numbers: 0,
- num_relocs: 0,
- num_lin_numbers: 0,
- flags: (PeSectionHdrFlags::CNT_INITIALIZED_DATA
- | PeSectionHdrFlags::MEM_READ
- | PeSectionHdrFlags::MEM_WRITE)
- .bits
- | PeSectionHdrFlagsAlign::_16Bytes as u32,
- });
- // .bss
- sec_hdrs.push(PeSectionHdr {
- name: [b'.', b'b', b's', b's', 0, 0, 0, 0],
- virtual_size: addr_info.bss_virt_size() as u32,
- virtual_address: usize::from(addr_info.bss.start) as u32,
- raw_data_size: 0,
- data_addr: 0,
- relocs: 0,
- line_numbers: 0,
- num_relocs: 0,
- num_lin_numbers: 0,
- flags: (PeSectionHdrFlags::CNT_UNINITIALIZED_DATA
- | PeSectionHdrFlags::MEM_READ
- | PeSectionHdrFlags::MEM_WRITE)
- .bits
- | PeSectionHdrFlagsAlign::_16Bytes as u32,
- });
- // .rodata
- sec_hdrs.push(PeSectionHdr {
- name: [b'.', b'r', b'o', b'd', b'a', b't', b'a', 0],
- virtual_size: addr_info.rodata_virt_size() as u32,
- virtual_address: usize::from(addr_info.rodata.start) as u32,
- raw_data_size: addr_info.rodata_file_size() as u32,
- data_addr: usize::from(SetupFileOffset::from(addr_info.rodata.start)) as u32,
- relocs: 0,
- line_numbers: 0,
- num_relocs: 0,
- num_lin_numbers: 0,
- flags: (PeSectionHdrFlags::CNT_INITIALIZED_DATA | PeSectionHdrFlags::MEM_READ).bits
- | PeSectionHdrFlagsAlign::_16Bytes as u32,
- });
-
+ let sec_hdrs = [
+ // .reloc
+ PeSectionHdr {
+ name: [b'.', b'r', b'e', b'l', b'o', b'c', 0, 0],
+ virtual_size: relocs.len() as u32,
+ virtual_address: usize::from(SetupVA::from(reloc_offset)) as u32,
+ raw_data_size: relocs.len() as u32,
+ data_addr: usize::from(reloc_offset) as u32,
+ relocs: 0,
+ line_numbers: 0,
+ num_relocs: 0,
+ num_lin_numbers: 0,
+ flags: (PeSectionHdrFlags::CNT_INITIALIZED_DATA
+ | PeSectionHdrFlags::MEM_READ
+ | PeSectionHdrFlags::MEM_DISCARDABLE)
+ .bits
+ | PeSectionHdrFlagsAlign::_1Bytes as u32,
+ },
+ // .text
+ PeSectionHdr {
+ name: [b'.', b't', b'e', b'x', b't', 0, 0, 0],
+ virtual_size: addr_info.text_virt_size() as u32,
+ virtual_address: usize::from(addr_info.text.start) as u32,
+ raw_data_size: addr_info.text_file_size() as u32,
+ data_addr: usize::from(SetupFileOffset::from(addr_info.text.start)) as u32,
+ relocs: 0,
+ line_numbers: 0,
+ num_relocs: 0,
+ num_lin_numbers: 0,
+ flags: (PeSectionHdrFlags::CNT_CODE
+ | PeSectionHdrFlags::MEM_READ
+ | PeSectionHdrFlags::MEM_EXECUTE)
+ .bits
+ | PeSectionHdrFlagsAlign::_16Bytes as u32,
+ },
+ // .data
+ PeSectionHdr {
+ name: [b'.', b'd', b'a', b't', b'a', 0, 0, 0],
+ virtual_size: addr_info.data_virt_size() as u32,
+ virtual_address: usize::from(addr_info.data.start) as u32,
+ raw_data_size: addr_info.data_file_size() as u32,
+ data_addr: usize::from(SetupFileOffset::from(addr_info.data.start)) as u32,
+ relocs: 0,
+ line_numbers: 0,
+ num_relocs: 0,
+ num_lin_numbers: 0,
+ flags: (PeSectionHdrFlags::CNT_INITIALIZED_DATA
+ | PeSectionHdrFlags::MEM_READ
+ | PeSectionHdrFlags::MEM_WRITE)
+ .bits
+ | PeSectionHdrFlagsAlign::_16Bytes as u32,
+ },
+ // .bss
+ PeSectionHdr {
+ name: [b'.', b'b', b's', b's', 0, 0, 0, 0],
+ virtual_size: addr_info.bss_virt_size() as u32,
+ virtual_address: usize::from(addr_info.bss.start) as u32,
+ raw_data_size: 0,
+ data_addr: 0,
+ relocs: 0,
+ line_numbers: 0,
+ num_relocs: 0,
+ num_lin_numbers: 0,
+ flags: (PeSectionHdrFlags::CNT_UNINITIALIZED_DATA
+ | PeSectionHdrFlags::MEM_READ
+ | PeSectionHdrFlags::MEM_WRITE)
+ .bits
+ | PeSectionHdrFlagsAlign::_16Bytes as u32,
+ },
+ // .rodata
+ PeSectionHdr {
+ name: [b'.', b'r', b'o', b'd', b'a', b't', b'a', 0],
+ virtual_size: addr_info.rodata_virt_size() as u32,
+ virtual_address: usize::from(addr_info.rodata.start) as u32,
+ raw_data_size: addr_info.rodata_file_size() as u32,
+ data_addr: usize::from(SetupFileOffset::from(addr_info.rodata.start)) as u32,
+ relocs: 0,
+ line_numbers: 0,
+ num_relocs: 0,
+ num_lin_numbers: 0,
+ flags: (PeSectionHdrFlags::CNT_INITIALIZED_DATA | PeSectionHdrFlags::MEM_READ).bits
+ | PeSectionHdrFlagsAlign::_16Bytes as u32,
+ },
+ ];
// Write the MS-DOS header
bin.extend_from_slice(&MZ_MAGIC.to_le_bytes());
// Write the MS-DOS stub at 0x3c
diff --git a/framework/libs/linux-bzimage/setup/src/loader.rs b/framework/libs/linux-bzimage/setup/src/loader.rs
index 158c92ee9..03d79c81a 100644
--- a/framework/libs/linux-bzimage/setup/src/loader.rs
+++ b/framework/libs/linux-bzimage/setup/src/loader.rs
@@ -19,7 +19,7 @@ pub fn load_elf(file: &[u8]) {
}
fn load_segment(file: &xmas_elf::ElfFile, program: &xmas_elf::program::ProgramHeader64) {
- let SegmentData::Undefined(header_data) = program.get_data(&file).unwrap() else {
+ let SegmentData::Undefined(header_data) = program.get_data(file).unwrap() else {
panic!("[setup] Unexpected segment data type!");
};
// Safety: the physical address from the ELF file is valid
diff --git a/framework/libs/linux-bzimage/setup/src/main.rs b/framework/libs/linux-bzimage/setup/src/main.rs
index bb972ea70..cad7e2b66 100644
--- a/framework/libs/linux-bzimage/setup/src/main.rs
+++ b/framework/libs/linux-bzimage/setup/src/main.rs
@@ -40,5 +40,5 @@ fn get_payload(boot_params: &BootParams) -> &'static [u8] {
let payload_length = hdr.payload_length as usize;
// Safety: the payload_offset and payload_length is valid if we assume that the
// boot_params struct is correct.
- unsafe { core::slice::from_raw_parts_mut(payload_offset as *mut u8, payload_length as usize) }
+ unsafe { core::slice::from_raw_parts_mut(payload_offset as *mut u8, payload_length) }
}
diff --git a/framework/libs/linux-bzimage/setup/src/x86/amd64_efi/efi.rs b/framework/libs/linux-bzimage/setup/src/x86/amd64_efi/efi.rs
index bdc7a0545..1e7a70bc8 100644
--- a/framework/libs/linux-bzimage/setup/src/x86/amd64_efi/efi.rs
+++ b/framework/libs/linux-bzimage/setup/src/x86/amd64_efi/efi.rs
@@ -12,6 +12,10 @@ use super::{
relocation::apply_rela_dyn_relocations,
};
+// Suppress warnings since using todo!.
+#[allow(unreachable_code)]
+#[allow(unused_variables)]
+#[allow(clippy::diverging_sub_expression)]
#[export_name = "efi_stub_entry"]
extern "sysv64" fn efi_stub_entry(handle: Handle, mut system_table: SystemTable) -> ! {
unsafe {
@@ -19,13 +23,9 @@ extern "sysv64" fn efi_stub_entry(handle: Handle, mut system_table: SystemTable<
}
uefi_services::init(&mut system_table).unwrap();
- // Suppress TODO warning.
- #[allow(unreachable_code)]
- efi_phase_boot(
- handle,
- system_table,
- todo!("Use EFI boot services to fill boot params"),
- );
+ let boot_params_ptr = todo!("Use EFI boot services to fill boot params");
+
+ efi_phase_boot(handle, system_table, boot_params_ptr);
}
#[export_name = "efi_handover_entry"]
@@ -65,7 +65,7 @@ fn efi_phase_boot(
let Ok(loaded_image) = boot_services.open_protocol_exclusive::(handle) else {
panic!("Failed to open LoadedImage protocol");
};
- loaded_image.data_type().clone()
+ loaded_image.data_type()
};
let (system_table, memory_map) = system_table.exit_boot_services(memory_type);
@@ -115,8 +115,8 @@ fn efi_phase_runtime(
break;
}
e820_table[e820_entries] = linux_boot_params::BootE820Entry {
- addr: md.phys_start as u64,
- size: md.page_count as u64 * 4096,
+ addr: md.phys_start,
+ size: md.page_count * 4096,
typ: match md.ty {
uefi::table::boot::MemoryType::CONVENTIONAL => linux_boot_params::E820Type::Ram,
uefi::table::boot::MemoryType::RESERVED => linux_boot_params::E820Type::Reserved,
diff --git a/framework/libs/linux-bzimage/setup/src/x86/amd64_efi/mod.rs b/framework/libs/linux-bzimage/setup/src/x86/amd64_efi/mod.rs
index d3acbf704..d4662166a 100644
--- a/framework/libs/linux-bzimage/setup/src/x86/amd64_efi/mod.rs
+++ b/framework/libs/linux-bzimage/setup/src/x86/amd64_efi/mod.rs
@@ -13,8 +13,8 @@ global_asm!(include_str!("setup.S"));
pub const ASTER_ENTRY_POINT: u32 = 0x8001200;
unsafe fn call_aster_entrypoint(entrypoint: u64, boot_params_ptr: u64) -> ! {
- asm!("mov rsi, {}", in(reg) boot_params_ptr as u64);
- asm!("mov rax, {}", in(reg) entrypoint as u64);
+ asm!("mov rsi, {}", in(reg) boot_params_ptr);
+ asm!("mov rax, {}", in(reg) entrypoint);
asm!("jmp rax");
unreachable!();
diff --git a/framework/libs/linux-bzimage/setup/src/x86/amd64_efi/relocation.rs b/framework/libs/linux-bzimage/setup/src/x86/amd64_efi/relocation.rs
index d1e34bdac..8e77352de 100644
--- a/framework/libs/linux-bzimage/setup/src/x86/amd64_efi/relocation.rs
+++ b/framework/libs/linux-bzimage/setup/src/x86/amd64_efi/relocation.rs
@@ -30,7 +30,7 @@ fn get_rela_array() -> &'static [Elf64Rela] {
end = in(reg) end,
start = in(reg) start,
);
- len / core::mem::size_of::() as usize
+ len / core::mem::size_of::()
};
#[cfg(feature = "debug_print")]
unsafe {
@@ -44,7 +44,7 @@ fn get_rela_array() -> &'static [Elf64Rela] {
print_str("\n");
}
// Safety: the linker will ensure that the symbols are valid.
- unsafe { core::slice::from_raw_parts(start as *const Elf64Rela, len) }
+ unsafe { core::slice::from_raw_parts(start, len) }
}
const R_X86_64_RELATIVE: u32 = 8;
diff --git a/framework/libs/linux-bzimage/setup/src/x86/mod.rs b/framework/libs/linux-bzimage/setup/src/x86/mod.rs
index 350f28c34..d1831f3ee 100644
--- a/framework/libs/linux-bzimage/setup/src/x86/mod.rs
+++ b/framework/libs/linux-bzimage/setup/src/x86/mod.rs
@@ -16,6 +16,7 @@ const START_OF_SETUP32_VA: usize = 0x100000;
/// The setup is a position-independent executable. We can get the loaded base
/// address from the symbol.
#[inline]
+#[allow(clippy::fn_to_numeric_cast)]
pub fn get_image_loaded_offset() -> isize {
extern "C" {
fn start_of_setup32();
diff --git a/framework/libs/tdx-guest/Cargo.toml b/framework/libs/tdx-guest/Cargo.toml
index 75edd653f..02383f272 100644
--- a/framework/libs/tdx-guest/Cargo.toml
+++ b/framework/libs/tdx-guest/Cargo.toml
@@ -9,5 +9,5 @@ edition = "2021"
x86_64 = "0.14.10"
bitflags = "1.3"
raw-cpuid = "10"
-lazy_static = "1.4.0"
+lazy_static = { version = "1.4.0", features = ["spin_no_std"] }
diff --git a/framework/libs/tdx-guest/src/lib.rs b/framework/libs/tdx-guest/src/lib.rs
index c23e80caf..ae1347d5d 100644
--- a/framework/libs/tdx-guest/src/lib.rs
+++ b/framework/libs/tdx-guest/src/lib.rs
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright(c) 2023-2024 Intel Corporation.
-#![no_std]
+#![cfg_attr(not(test), no_std)]
#![allow(dead_code)]
#![allow(unused_variables)]
diff --git a/kernel/comps/framebuffer/src/lib.rs b/kernel/comps/framebuffer/src/lib.rs
index 62b0d5872..b1b79c10c 100644
--- a/kernel/comps/framebuffer/src/lib.rs
+++ b/kernel/comps/framebuffer/src/lib.rs
@@ -7,7 +7,7 @@
extern crate alloc;
-use alloc::vec::Vec;
+use alloc::{vec, vec::Vec};
use core::{
fmt,
ops::{Index, IndexMut},
@@ -26,13 +26,16 @@ fn framebuffer_init() -> Result<(), ComponentInitError> {
pub(crate) static WRITER: Once> = Once::new();
+// ignore the warnings since we use the `todo!` macro.
+#[allow(unused_variables)]
+#[allow(unreachable_code)]
+#[allow(clippy::diverging_sub_expression)]
pub(crate) fn init() {
let mut writer = {
let framebuffer = boot::framebuffer_arg();
- let mut writer = None;
let mut size = 0;
for i in aster_frame::vm::FRAMEBUFFER_REGIONS.get().unwrap().iter() {
- size = i.len() as usize;
+ size = i.len();
}
let page_size = size / PAGE_SIZE;
@@ -40,13 +43,10 @@ pub(crate) fn init() {
let start_paddr = framebuffer.address;
let io_mem = todo!("IoMem is private for components now, should fix it.");
- let mut buffer: Vec = Vec::with_capacity(size);
- for _ in 0..size {
- buffer.push(0);
- }
+ let mut buffer: Vec = vec![0; size];
log::debug!("Found framebuffer:{:?}", framebuffer);
- writer = Some(Writer {
+ Writer {
io_mem,
x_pos: 0,
y_pos: 0,
@@ -54,9 +54,7 @@ pub(crate) fn init() {
width: framebuffer.width as usize,
height: framebuffer.height as usize,
buffer: buffer.leak(),
- });
-
- writer.unwrap()
+ }
};
writer.clear();
diff --git a/osdk/src/base_crate/mod.rs b/osdk/src/base_crate/mod.rs
index ec08d52e1..9ebfeda08 100644
--- a/osdk/src/base_crate/mod.rs
+++ b/osdk/src/base_crate/mod.rs
@@ -4,7 +4,11 @@
//! It will depend on the kernel crate.
//!
-use std::{fs, path::{Path, PathBuf}, str::FromStr};
+use std::{
+ fs,
+ path::{Path, PathBuf},
+ str::FromStr,
+};
use crate::util::get_cargo_metadata;
diff --git a/osdk/src/commands/build/mod.rs b/osdk/src/commands/build/mod.rs
index bd19f2d1b..be6cdd09b 100644
--- a/osdk/src/commands/build/mod.rs
+++ b/osdk/src/commands/build/mod.rs
@@ -117,7 +117,11 @@ pub fn do_build(
bundle
}
-fn build_kernel_elf(args: &CargoArgs, cargo_target_directory: impl AsRef, rustflags: &[&str]) -> AsterBin {
+fn build_kernel_elf(
+ args: &CargoArgs,
+ cargo_target_directory: impl AsRef,
+ rustflags: &[&str],
+) -> AsterBin {
let target = "x86_64-unknown-none";
let env_rustflags = std::env::var("RUSTFLAGS").unwrap_or_default();
diff --git a/osdk/src/commands/check.rs b/osdk/src/commands/check.rs
index c81f9d9e9..c27c65109 100644
--- a/osdk/src/commands/check.rs
+++ b/osdk/src/commands/check.rs
@@ -10,7 +10,7 @@ pub fn execute_check_command() {
command
.arg("check")
.arg("--target")
- .arg("x86_64-unkown-none");
+ .arg("x86_64-unknown-none");
command.args(COMMON_CARGO_ARGS);
let status = command.status().unwrap();
if !status.success() {