Miscellaneous clippy fixes for Rust 2024
This commit is contained in:
parent
69327eee8d
commit
c7a2c81366
|
|
@ -935,9 +935,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
|
|||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.31.1"
|
||||
version = "0.32.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
|
||||
|
||||
[[package]]
|
||||
name = "hash32"
|
||||
|
|
@ -2140,11 +2140,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "unwinding"
|
||||
version = "0.2.5"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51f06a05848f650946acef3bf525fe96612226b61f74ae23ffa4e98bfbb8ab3c"
|
||||
checksum = "60612c845ef41699f39dc8c5391f252942c0a88b7d15da672eff0d14101bbd6d"
|
||||
dependencies = [
|
||||
"gimli 0.31.1",
|
||||
"gimli 0.32.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
#![no_std]
|
||||
#![deny(unsafe_code)]
|
||||
#![feature(step_trait)]
|
||||
#![feature(trait_upcasting)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
|
|
|
|||
|
|
@ -263,12 +263,9 @@ impl<L: BlockLog> CryptoLog<L> {
|
|||
let data_nodes: Vec<Arc<DataNode>> = buf
|
||||
.iter()
|
||||
.map(|block_buf| {
|
||||
let data_node = {
|
||||
let mut node = DataNode::new_uninit();
|
||||
node.0.copy_from_slice(block_buf.as_slice());
|
||||
Arc::new(node)
|
||||
};
|
||||
data_node
|
||||
let mut node = DataNode::new_uninit();
|
||||
node.0.copy_from_slice(block_buf.as_slice());
|
||||
Arc::new(node)
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
#![no_std]
|
||||
#![deny(unsafe_code)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(negative_impls)]
|
||||
#![feature(slice_as_chunks)]
|
||||
#![allow(unfulfilled_lint_expectations)]
|
||||
#![expect(dead_code, deprecated, unused_imports)]
|
||||
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ impl CapabilityMsixData {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
let _old_irq = core::mem::replace(&mut self.irqs[index as usize], Some(irq));
|
||||
let _old_irq = self.irqs[index as usize].replace(irq);
|
||||
// Enable this msix vector
|
||||
self.table_bar
|
||||
.io_mem()
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ pub trait SysBranchNode: SysNode {
|
|||
fn visit_children_with(
|
||||
&self,
|
||||
min_id: u64,
|
||||
f: &mut dyn for<'a> FnMut(&'a Arc<(dyn SysObj)>) -> Option<()>,
|
||||
f: &mut dyn for<'a> FnMut(&'a Arc<dyn SysObj>) -> Option<()>,
|
||||
);
|
||||
|
||||
/// Returns a child with a specified name.
|
||||
|
|
|
|||
|
|
@ -615,7 +615,7 @@ macro_rules! inherit_sys_branch_node {
|
|||
fn visit_children_with(
|
||||
&self,
|
||||
min_id: u64,
|
||||
f: &mut dyn for<'a> FnMut(&'a alloc::sync::Arc<(dyn $crate::SysObj)>) -> Option<()>,
|
||||
f: &mut dyn for<'a> FnMut(&'a alloc::sync::Arc<dyn $crate::SysObj>) -> Option<()>,
|
||||
) {
|
||||
let children_guard = self.$field.children_ref().read();
|
||||
for child_arc in children_guard.values() {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
//! The system time of Asterinas.
|
||||
|
||||
#![feature(let_chains)]
|
||||
#![no_std]
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
#![no_std]
|
||||
#![deny(unsafe_code)]
|
||||
#![feature(extract_if)]
|
||||
|
||||
pub mod boolean_value;
|
||||
pub mod device;
|
||||
|
|
|
|||
|
|
@ -153,10 +153,7 @@ impl<E: Ext> UdpSocket<E> {
|
|||
return Err(SendError::TooLarge);
|
||||
}
|
||||
|
||||
let buffer = match socket.send(size, meta) {
|
||||
Ok(data) => data,
|
||||
Err(err) => return Err(err.into()),
|
||||
};
|
||||
let buffer = socket.send(size, meta)?;
|
||||
let result = f(buffer);
|
||||
|
||||
self.0
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@
|
|||
//! ```
|
||||
//!
|
||||
|
||||
#![feature(let_chains)]
|
||||
#![feature(proc_macro_diagnostic)]
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ impl FileMetadata {
|
|||
|
||||
/// The type of the file.
|
||||
#[repr(u32)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, TryFromInt)]
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, TryFromInt)]
|
||||
pub enum FileType {
|
||||
/// FIFO special file
|
||||
FiFo = 0o010000,
|
||||
|
|
@ -292,6 +292,7 @@ pub enum FileType {
|
|||
/// Block device
|
||||
Block = 0o060000,
|
||||
/// Regular file
|
||||
#[default]
|
||||
File = 0o100000,
|
||||
/// Symbolic link
|
||||
Link = 0o120000,
|
||||
|
|
@ -299,12 +300,6 @@ pub enum FileType {
|
|||
Socket = 0o140000,
|
||||
}
|
||||
|
||||
impl Default for FileType {
|
||||
fn default() -> Self {
|
||||
Self::File
|
||||
}
|
||||
}
|
||||
|
||||
const MAGIC: &[u8] = b"070701";
|
||||
const TRAILER_NAME: &str = "TRAILER!!!";
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,12 @@ use crate::{
|
|||
/// A cursor never ends up on an interior node. In other words, when methods
|
||||
/// of `Cursor` or `CursorMut` finish, the cursor will either not positioned on any node
|
||||
/// or positioned on some leaf node.
|
||||
#[derive(Default)]
|
||||
enum CursorState<'a, P>
|
||||
where
|
||||
P: NonNullPtr + Send + Sync,
|
||||
{
|
||||
#[default]
|
||||
Inactive,
|
||||
AtNode {
|
||||
node: NodeEntryRef<'a, P>,
|
||||
|
|
@ -37,12 +39,6 @@ where
|
|||
},
|
||||
}
|
||||
|
||||
impl<P: NonNullPtr + Send + Sync> Default for CursorState<'_, P> {
|
||||
fn default() -> Self {
|
||||
Self::Inactive
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, P: NonNullPtr + Send + Sync> CursorState<'a, P> {
|
||||
fn move_to(&mut self, node: NodeEntryRef<'a, P>, index: u64) {
|
||||
let operation_offset = node.entry_offset(index);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ use crate::{
|
|||
|
||||
/// Initializes "/dev/shm" for POSIX shared memory usage.
|
||||
pub fn init_in_first_process(fs_resolver: &FsResolver, ctx: &Context) -> Result<()> {
|
||||
use crate::fs::utils::InodeMode;
|
||||
|
||||
let dev_path = fs_resolver.lookup(&FsPath::try_from("/dev")?)?;
|
||||
|
||||
// Create the "shm" directory under "/dev" and mount a ramfs on it.
|
||||
|
|
|
|||
|
|
@ -493,8 +493,8 @@ impl Iterator for ExfatDentryIterator<'_> {
|
|||
let dentry_result = ExfatDentry::try_from(RawExfatDentry::from_bytes(&dentry_buf)).unwrap();
|
||||
|
||||
self.entry += 1;
|
||||
if self.size.is_some() {
|
||||
self.size = Some(self.size.unwrap() - DENTRY_SIZE);
|
||||
if let Some(s) = self.size {
|
||||
self.size = Some(s - DENTRY_SIZE);
|
||||
}
|
||||
|
||||
Some(Ok(dentry_result))
|
||||
|
|
|
|||
|
|
@ -658,7 +658,6 @@ impl ExfatInode {
|
|||
.page_cache
|
||||
.discard_range(read_off..read_off + read_len);
|
||||
|
||||
let mut buf_offset = 0;
|
||||
let bio_segment = BioSegment::alloc(1, BioDirection::FromDevice);
|
||||
|
||||
let start_pos = inner.start_chain.walk_to_cluster_at_offset(read_off)?;
|
||||
|
|
@ -673,7 +672,6 @@ impl ExfatInode {
|
|||
.block_device()
|
||||
.read_blocks(physical_bid, bio_segment.clone())?;
|
||||
bio_segment.reader().unwrap().read_fallible(writer)?;
|
||||
buf_offset += BLOCK_SIZE;
|
||||
|
||||
cur_offset += BLOCK_SIZE;
|
||||
if cur_offset >= cluster_size {
|
||||
|
|
@ -1521,7 +1519,7 @@ impl Inode for ExfatInode {
|
|||
}
|
||||
|
||||
// Skip . and ..
|
||||
let dir_to_skip = if dir_cnt >= 2 { dir_cnt - 2 } else { 0 };
|
||||
let dir_to_skip = dir_cnt.saturating_sub(2);
|
||||
|
||||
// Skip previous directories.
|
||||
let (off, _) = inner.visit_sub_inodes(0, dir_to_skip, &mut empty_visitor, &fs_guard)?;
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ impl BlockGroup {
|
|||
.inner
|
||||
.write()
|
||||
.inode_cache
|
||||
.extract_if(|_, inode| Arc::strong_count(inode) == 1)
|
||||
.extract_if(.., |_, inode| Arc::strong_count(inode) == 1)
|
||||
.map(|(_, inode)| inode)
|
||||
.collect();
|
||||
|
||||
|
|
|
|||
|
|
@ -413,9 +413,10 @@ bitflags! {
|
|||
}
|
||||
|
||||
#[repr(u16)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, TryFromInt)]
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, TryFromInt)]
|
||||
pub enum ErrorsBehaviour {
|
||||
/// Continue execution
|
||||
#[default]
|
||||
Continue = 1,
|
||||
// Remount fs read-only
|
||||
RemountReadonly = 2,
|
||||
|
|
@ -423,12 +424,6 @@ pub enum ErrorsBehaviour {
|
|||
Panic = 3,
|
||||
}
|
||||
|
||||
impl Default for ErrorsBehaviour {
|
||||
fn default() -> Self {
|
||||
Self::Continue
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(u32)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, TryFromInt)]
|
||||
pub enum OsId {
|
||||
|
|
|
|||
|
|
@ -24,20 +24,15 @@ use crate::{
|
|||
///
|
||||
/// This type defines how mount and unmount events are propagated
|
||||
/// from this mount to other mounts.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Default, Copy, PartialEq, Eq)]
|
||||
pub enum MountPropType {
|
||||
/// A private type is the default mount type. Mount and unmount events
|
||||
/// do not propagate to or from the private mounts.
|
||||
#[default]
|
||||
Private,
|
||||
// TODO: Implement other propagation types.
|
||||
}
|
||||
|
||||
impl Default for MountPropType {
|
||||
fn default() -> Self {
|
||||
Self::Private
|
||||
}
|
||||
}
|
||||
|
||||
static ID_ALLOCATOR: Once<SpinLock<IdAlloc>> = Once::new();
|
||||
|
||||
/// The reserved mount ID, which represents an invalid mount.
|
||||
|
|
|
|||
|
|
@ -138,15 +138,13 @@ impl<T: FdOps> DirOps for FdDirOps<T> {
|
|||
let thread = self.dir.thread();
|
||||
let posix_thread = thread.as_posix_thread().unwrap();
|
||||
|
||||
let is_valid = if let Some(file_table) = posix_thread.file_table().lock().as_ref()
|
||||
if let Some(file_table) = posix_thread.file_table().lock().as_ref()
|
||||
&& let Ok(file) = file_table.read().get_file(child_ops.file_desc())
|
||||
{
|
||||
child_ops.is_valid(file)
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
is_valid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use crate::{
|
|||
utils::{
|
||||
AccessMode, CachePage, CreationFlags, Extension, FallocMode, FileSystem, Inode,
|
||||
InodeIo, InodeMode, InodeType, Metadata, OpenArgs, PageCacheBackend, SeekFrom,
|
||||
StatusFlags, XattrName, XattrNamespace, XattrSetFlags, chmod, mkmod,
|
||||
StatusFlags, XattrName, XattrNamespace, XattrSetFlags, mkmod,
|
||||
},
|
||||
},
|
||||
prelude::*,
|
||||
|
|
@ -146,7 +146,7 @@ impl InodeIo for MemfdInode {
|
|||
// <https://elixir.bootlin.com/linux/v6.16.5/source/mm/shmem.c#L3309-L3310>
|
||||
// <https://github.com/google/gvisor/blob/6db745970118635edec4c973f47df2363924d3a7/test/syscalls/linux/memfd.cc#L261-L280>
|
||||
let old_size = self.inode.size();
|
||||
let new_size = offset.checked_add(reader.remain()).unwrap_or(usize::MAX);
|
||||
let new_size = offset.saturating_add(reader.remain());
|
||||
if new_size > old_size {
|
||||
let eof_page = old_size.align_down(PAGE_SIZE);
|
||||
if offset >= eof_page {
|
||||
|
|
|
|||
|
|
@ -160,15 +160,14 @@ macro_rules! chmod {
|
|||
};
|
||||
|
||||
(@apply $mode:expr, $who:ident, $op:expr, $perms:ident $(, $($rest:tt)*)?) => {{
|
||||
use $crate::fs::utils::{InodeMode, chmod, who_and_perms_to_mask, who_to_mask, perms_to_mask};
|
||||
let mask = who_and_perms_to_mask!($who, $perms);
|
||||
let mask = $crate::fs::utils::who_and_perms_to_mask!($who, $perms);
|
||||
let new_mode = match $op {
|
||||
'+' => $mode | mask,
|
||||
'-' => $mode & !mask,
|
||||
'=' => ($mode & !who_and_perms_to_mask!($who, rwx)) | mask,
|
||||
'=' => ($mode & !$crate::fs::utils::who_and_perms_to_mask!($who, rwx)) | mask,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
chmod!(new_mode $(, $($rest)*)?)
|
||||
$crate::fs::utils::chmod!(new_mode $(, $($rest)*)?)
|
||||
}};
|
||||
}
|
||||
|
||||
|
|
@ -178,13 +177,15 @@ macro_rules! chmod {
|
|||
/// `InodeMode::empty()`. See [`chmod`] for details.
|
||||
macro_rules! mkmod {
|
||||
($($args:tt)*) => {
|
||||
$crate::fs::utils::chmod!(InodeMode::empty(), $($args)*)
|
||||
$crate::fs::utils::chmod!($crate::fs::utils::InodeMode::empty(), $($args)*)
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! who_and_perms_to_mask {
|
||||
($who:ident, $perms:ident) => {
|
||||
InodeMode::from_bits_truncate(who_to_mask!($who) & perms_to_mask!($perms))
|
||||
$crate::fs::utils::InodeMode::from_bits_truncate(
|
||||
$crate::fs::utils::who_to_mask!($who) & $crate::fs::utils::perms_to_mask!($perms),
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -252,8 +253,6 @@ pub(crate) use who_to_mask;
|
|||
mod test {
|
||||
use ostd::prelude::*;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[ktest]
|
||||
fn test_mkmod_and_chmod() {
|
||||
let mode0 = mkmod!(a+rw);
|
||||
|
|
|
|||
|
|
@ -7,12 +7,8 @@
|
|||
#![no_main]
|
||||
#![deny(unsafe_code)]
|
||||
#![feature(btree_cursors)]
|
||||
#![feature(btree_extract_if)]
|
||||
#![feature(debug_closure_helpers)]
|
||||
#![feature(extract_if)]
|
||||
#![feature(format_args_nl)]
|
||||
#![feature(integer_sign_cast)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(linked_list_cursors)]
|
||||
#![feature(linked_list_retain)]
|
||||
#![feature(negative_impls)]
|
||||
|
|
@ -20,7 +16,6 @@
|
|||
#![feature(register_tool)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(trait_alias)]
|
||||
#![feature(trait_upcasting)]
|
||||
#![feature(associated_type_defaults)]
|
||||
#![feature(try_with_capacity)]
|
||||
#![register_tool(component_access_control)]
|
||||
|
|
|
|||
|
|
@ -53,17 +53,14 @@ pub fn sys_eventfd2(init_val: u64, flags: u32, ctx: &Context) -> Result<SyscallR
|
|||
|
||||
fn do_sys_eventfd2(init_val: u64, flags: Flags, ctx: &Context) -> FileDesc {
|
||||
let event_file = EventFile::new(init_val, flags);
|
||||
let fd = {
|
||||
let file_table = ctx.thread_local.borrow_file_table();
|
||||
let mut file_table_locked = file_table.unwrap().write();
|
||||
let fd_flags = if flags.contains(Flags::EFD_CLOEXEC) {
|
||||
FdFlags::CLOEXEC
|
||||
} else {
|
||||
FdFlags::empty()
|
||||
};
|
||||
file_table_locked.insert(Arc::new(event_file), fd_flags)
|
||||
let file_table = ctx.thread_local.borrow_file_table();
|
||||
let mut file_table_locked = file_table.unwrap().write();
|
||||
let fd_flags = if flags.contains(Flags::EFD_CLOEXEC) {
|
||||
FdFlags::CLOEXEC
|
||||
} else {
|
||||
FdFlags::empty()
|
||||
};
|
||||
fd
|
||||
file_table_locked.insert(Arc::new(event_file), fd_flags)
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ pub(super) struct LinuxSchedAttr {
|
|||
// Reference: <https://elixir.bootlin.com/linux/v6.17.7/source/include/uapi/linux/sched/types.h#L7>
|
||||
const SCHED_ATTR_SIZE_VER0: u32 = 48;
|
||||
// Reference: <https://elixir.bootlin.com/linux/v6.17.7/source/include/uapi/linux/sched/types.h#L8>
|
||||
#[cfg_attr(target_arch = "x86_64", expect(dead_code))]
|
||||
const SCHED_ATTR_SIZE_VER1: u32 = 56;
|
||||
|
||||
const_assert!(size_of::<LinuxSchedAttr>() == SCHED_ATTR_SIZE_VER1 as usize);
|
||||
|
|
|
|||
|
|
@ -51,11 +51,10 @@ fn get_random_seed() -> <StdRng as SeedableRng>::Seed {
|
|||
use ostd::arch::boot::DEVICE_TREE;
|
||||
|
||||
let chosen = DEVICE_TREE.get().unwrap().find_node("/chosen").unwrap();
|
||||
let seed = chosen
|
||||
chosen
|
||||
.property("rng-seed")
|
||||
.unwrap()
|
||||
.value
|
||||
.try_into()
|
||||
.unwrap();
|
||||
seed
|
||||
.unwrap()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,11 +40,9 @@ pub fn mem_total() -> usize {
|
|||
use ostd::boot::{boot_info, memory_region::MemoryRegionType};
|
||||
|
||||
let regions = &boot_info().memory_regions;
|
||||
let total = regions
|
||||
regions
|
||||
.iter()
|
||||
.filter(|region| region.typ() == MemoryRegionType::Usable)
|
||||
.map(|region| region.len())
|
||||
.sum::<usize>();
|
||||
|
||||
total
|
||||
.sum::<usize>()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,13 +58,13 @@ iced-x86 = { version = "1.21.0", default-features = false, features = [
|
|||
"gas",
|
||||
], optional = true }
|
||||
tdx-guest = { version = "0.2.2", optional = true }
|
||||
unwinding = { version = "=0.2.5", default-features = false, features = ["fde-gnu-eh-frame-hdr", "hide-trace", "panic", "personality", "unwinder"] }
|
||||
unwinding = { version = "=0.2.8", default-features = false, features = ["fde-gnu-eh-frame-hdr", "hide-trace", "panic", "personality", "unwinder"] }
|
||||
|
||||
[target.riscv64imac-unknown-none-elf.dependencies]
|
||||
riscv = { version = "0.15.0", features = ["s-mode"] }
|
||||
sbi-rt = "0.0.3"
|
||||
fdt = { version = "0.1.5", features = ["pretty-printing"] }
|
||||
unwinding = { version = "=0.2.5", default-features = false, features = ["fde-static", "hide-trace", "panic", "personality", "unwinder"] }
|
||||
unwinding = { version = "=0.2.8", default-features = false, features = ["fde-static", "hide-trace", "panic", "personality", "unwinder"] }
|
||||
|
||||
[target.loongarch64-unknown-none-softfloat.dependencies]
|
||||
loongArch64 = "0.2.5"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use core::mem::MaybeUninit;
|
||||
|
||||
use xmas_elf::program::{ProgramHeader, SegmentData};
|
||||
|
||||
/// Load the kernel ELF payload to memory.
|
||||
|
|
@ -37,5 +35,5 @@ fn load_segment(file: &xmas_elf::ElfFile, program: &xmas_elf::program::ProgramHe
|
|||
|
||||
let (left, right) = dst_slice.split_at_mut(program.file_size as usize);
|
||||
left.write_copy_of_slice(segment_data);
|
||||
MaybeUninit::fill(right, 0);
|
||||
right.write_filled(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(maybe_uninit_fill)]
|
||||
#![feature(maybe_uninit_slice)]
|
||||
#![feature(maybe_uninit_write_slice)]
|
||||
|
||||
mod console;
|
||||
mod loader;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ unsafe extern "sysv64" fn main_efi_common64(
|
|||
fn allocate_boot_params() -> &'static mut BootParams {
|
||||
let boot_params = {
|
||||
let bytes = alloc_pages(AllocateType::AnyPages, size_of::<BootParams>());
|
||||
MaybeUninit::fill(bytes, 0);
|
||||
bytes.write_filled(0);
|
||||
// SAFETY: Zero initialization gives a valid representation for `BootParams`.
|
||||
unsafe { &mut *bytes.as_mut_ptr().cast::<BootParams>() }
|
||||
};
|
||||
|
|
@ -64,22 +64,24 @@ fn efi_phase_boot(boot_params: &mut BootParams) {
|
|||
);
|
||||
|
||||
// Load the command line if it is not loaded.
|
||||
if boot_params.hdr.cmd_line_ptr == 0 && boot_params.ext_cmd_line_ptr == 0 {
|
||||
if let Some(cmdline) = load_cmdline() {
|
||||
boot_params.hdr.cmd_line_ptr = cmdline.as_ptr().addr().try_into().unwrap();
|
||||
boot_params.ext_cmd_line_ptr = 0;
|
||||
boot_params.hdr.cmdline_size = (cmdline.count_bytes() + 1).try_into().unwrap();
|
||||
}
|
||||
if boot_params.hdr.cmd_line_ptr == 0
|
||||
&& boot_params.ext_cmd_line_ptr == 0
|
||||
&& let Some(cmdline) = load_cmdline()
|
||||
{
|
||||
boot_params.hdr.cmd_line_ptr = cmdline.as_ptr().addr().try_into().unwrap();
|
||||
boot_params.ext_cmd_line_ptr = 0;
|
||||
boot_params.hdr.cmdline_size = (cmdline.count_bytes() + 1).try_into().unwrap();
|
||||
}
|
||||
|
||||
// Load the init ramdisk if it is not loaded.
|
||||
if boot_params.hdr.ramdisk_image == 0 && boot_params.ext_ramdisk_image == 0 {
|
||||
if let Some(initrd) = load_initrd() {
|
||||
boot_params.hdr.ramdisk_image = initrd.as_ptr().addr().try_into().unwrap();
|
||||
boot_params.ext_ramdisk_image = 0;
|
||||
boot_params.hdr.ramdisk_size = initrd.len().try_into().unwrap();
|
||||
boot_params.ext_ramdisk_size = 0;
|
||||
}
|
||||
if boot_params.hdr.ramdisk_image == 0
|
||||
&& boot_params.ext_ramdisk_image == 0
|
||||
&& let Some(initrd) = load_initrd()
|
||||
{
|
||||
boot_params.hdr.ramdisk_image = initrd.as_ptr().addr().try_into().unwrap();
|
||||
boot_params.ext_ramdisk_image = 0;
|
||||
boot_params.hdr.ramdisk_size = initrd.len().try_into().unwrap();
|
||||
boot_params.ext_ramdisk_size = 0;
|
||||
}
|
||||
|
||||
// Fill the boot params with the RSDP address if it is not provided.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::fmt;
|
||||
use core::{arch::asm, ops::Range};
|
||||
use core::{arch::asm, intrinsics::AtomicOrdering::Relaxed, ops::Range};
|
||||
|
||||
use crate::{
|
||||
Pod,
|
||||
|
|
@ -166,7 +166,7 @@ impl PageTableEntry {
|
|||
/// Parse a bit-flag bits `val` in the representation of `from` to `to` in bits.
|
||||
macro_rules! parse_flags {
|
||||
($val:expr, $from:expr, $to:expr) => {
|
||||
($val as usize & $from.bits() as usize) >> $from.bits().ilog2() << $to.bits().ilog2()
|
||||
(($val as usize & $from.bits() as usize) >> $from.bits().ilog2() << $to.bits().ilog2())
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +235,6 @@ impl PageTableEntryTrait for PageTableEntry {
|
|||
}
|
||||
}
|
||||
|
||||
#[expect(clippy::precedence)]
|
||||
fn set_prop(&mut self, prop: PageProperty) {
|
||||
let mut flags = PageTableFlags::VALID.bits()
|
||||
// FIXME: To avoid the PageModifyFault exception,
|
||||
|
|
@ -325,10 +324,13 @@ pub(crate) unsafe fn __memset_fallible(dst: *mut u8, value: u8, size: usize) ->
|
|||
|
||||
pub(crate) unsafe fn __atomic_load_fallible(ptr: *const u32) -> u64 {
|
||||
// TODO: Implement this fallible operation.
|
||||
unsafe { core::intrinsics::atomic_load_relaxed(ptr) as u64 }
|
||||
unsafe { core::intrinsics::atomic_load::<_, { Relaxed }>(ptr) as u64 }
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn __atomic_cmpxchg_fallible(ptr: *mut u32, old_val: u32, new_val: u32) -> u64 {
|
||||
// TODO: Implement this fallible operation.
|
||||
unsafe { core::intrinsics::atomic_cxchg_relaxed_relaxed(ptr, old_val, new_val).0 as u64 }
|
||||
unsafe {
|
||||
core::intrinsics::atomic_cxchg::<_, { Relaxed }, { Relaxed }>(ptr, old_val, new_val).0
|
||||
as u64
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ impl PageTableEntry {
|
|||
/// Parse a bit-flag bits `val` in the representation of `from` to `to` in bits.
|
||||
macro_rules! parse_flags {
|
||||
($val:expr, $from:expr, $to:expr) => {
|
||||
($val as usize & $from.bits() as usize) >> $from.bits().ilog2() << $to.bits().ilog2()
|
||||
(($val as usize & $from.bits() as usize) >> $from.bits().ilog2() << $to.bits().ilog2())
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -245,7 +245,6 @@ impl PageTableEntryTrait for PageTableEntry {
|
|||
}
|
||||
}
|
||||
|
||||
#[expect(clippy::precedence)]
|
||||
fn set_prop(&mut self, prop: PageProperty) {
|
||||
let mut flags = PageTableFlags::VALID.bits()
|
||||
| parse_flags!(prop.flags.bits(), PageFlags::R, PageTableFlags::READABLE)
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ pub enum SourceIdQualifier {
|
|||
|
||||
#[derive(Debug, TryFromInt)]
|
||||
#[repr(u32)]
|
||||
#[expect(dead_code)]
|
||||
enum DeliveryMode {
|
||||
FixedMode = 0b000,
|
||||
LowestPriority = 0b001,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ use crate::{
|
|||
pub type DynamicCpuLocal<T> = CpuLocal<T, DynamicStorage<T>>;
|
||||
|
||||
/// Statically-allocated CPU-local objects.
|
||||
pub type StaticCpuLocal<T> = CpuLocal<T, static_cpu_local::StaticStorage<T>>;
|
||||
pub type StaticCpuLocal<T> = CpuLocal<T, StaticStorage<T>>;
|
||||
|
||||
// These symbols are provided by the linker script.
|
||||
unsafe extern "C" {
|
||||
|
|
@ -180,10 +180,6 @@ unsafe impl<T: Send + 'static> Send for CpuLocal<T, DynamicStorage<T>> {}
|
|||
impl<T: 'static, S: AnyStorage<T>> !Copy for CpuLocal<T, S> {}
|
||||
impl<T: 'static, S: AnyStorage<T>> !Clone for CpuLocal<T, S> {}
|
||||
|
||||
// In general, it does not make any sense to send instances of static `CpuLocal`
|
||||
// to other tasks as they should live on other CPUs to make sending useful.
|
||||
impl<T: 'static> !Send for CpuLocal<T, StaticStorage<T>> {}
|
||||
|
||||
/// The static CPU-local areas for APs.
|
||||
static CPU_LOCAL_STORAGES: Once<&'static [Paddr]> = Once::new();
|
||||
|
||||
|
|
@ -227,8 +223,8 @@ pub(crate) unsafe fn copy_bsp_for_ap(num_cpus: usize) {
|
|||
unsafe { core::slice::from_raw_parts_mut(ptr, num_aps) }
|
||||
};
|
||||
|
||||
let bsp_base_va = __cpu_local_start as usize;
|
||||
let bsp_end_va = __cpu_local_end as usize;
|
||||
let bsp_base_va = __cpu_local_start as *const () as usize;
|
||||
let bsp_end_va = __cpu_local_end as *const () as usize;
|
||||
|
||||
// Allocate the CPU-local storage segments for APs.
|
||||
for res_addr_mut in res.iter_mut() {
|
||||
|
|
|
|||
|
|
@ -7,15 +7,12 @@
|
|||
#![feature(btree_cursors)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(iter_advance_by)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(linkage)]
|
||||
#![feature(macro_metavar_expr)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(negative_impls)]
|
||||
#![feature(ptr_metadata)]
|
||||
#![feature(sync_unsafe_cell)]
|
||||
#![feature(trait_upcasting)]
|
||||
#![feature(unbounded_shifts)]
|
||||
#![expect(internal_features)]
|
||||
#![no_std]
|
||||
#![warn(missing_docs)]
|
||||
|
|
@ -147,10 +144,10 @@ fn invoke_ffi_init_funcs() {
|
|||
fn __sinit_array();
|
||||
fn __einit_array();
|
||||
}
|
||||
let call_len = (__einit_array as usize - __sinit_array as usize) / 8;
|
||||
let call_len = (__einit_array as *const () as usize - __sinit_array as *const () as usize) / 8;
|
||||
for i in 0..call_len {
|
||||
unsafe {
|
||||
let function = (__sinit_array as usize + 8 * i) as *const fn();
|
||||
let function = (__sinit_array as *const () as usize + 8 * i) as *const fn();
|
||||
(*function)();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ impl VmSpace {
|
|||
return Err(Error::AccessDenied);
|
||||
}
|
||||
|
||||
if vaddr.checked_add(len).unwrap_or(usize::MAX) > MAX_USERSPACE_VADDR {
|
||||
if vaddr.saturating_add(len) > MAX_USERSPACE_VADDR {
|
||||
return Err(Error::AccessDenied);
|
||||
}
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ impl VmSpace {
|
|||
return Err(Error::AccessDenied);
|
||||
}
|
||||
|
||||
if vaddr.checked_add(len).unwrap_or(usize::MAX) > MAX_USERSPACE_VADDR {
|
||||
if vaddr.saturating_add(len) > MAX_USERSPACE_VADDR {
|
||||
return Err(Error::AccessDenied);
|
||||
}
|
||||
|
||||
|
|
@ -213,7 +213,7 @@ impl VmSpace {
|
|||
return Err(Error::AccessDenied);
|
||||
}
|
||||
|
||||
if vaddr.checked_add(len).unwrap_or(usize::MAX) > MAX_USERSPACE_VADDR {
|
||||
if vaddr.saturating_add(len) > MAX_USERSPACE_VADDR {
|
||||
return Err(Error::AccessDenied);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -599,14 +599,11 @@ impl Syscall<'_> {
|
|||
|
||||
/// Handles special cases for certain syscalls whose strace output is non-standard.
|
||||
fn handle_special_cases(mut syscall: Syscall) -> Syscall {
|
||||
match syscall.name {
|
||||
if syscall.name == "clone" {
|
||||
// For `clone`, strace removes the first and fourth arguments, just insert
|
||||
// ignored args.
|
||||
"clone" => {
|
||||
syscall.args.insert(0, SyscallArg::Ignored);
|
||||
syscall.args.insert(3, SyscallArg::Ignored);
|
||||
}
|
||||
_ => {}
|
||||
syscall.args.insert(0, SyscallArg::Ignored);
|
||||
syscall.args.insert(3, SyscallArg::Ignored);
|
||||
}
|
||||
|
||||
syscall
|
||||
|
|
|
|||
Loading…
Reference in New Issue