Fix a bunch of warnings.

This commit is contained in:
4lDO2
2024-07-08 13:01:25 +02:00
parent c86f107344
commit 5e7db80285
52 changed files with 105 additions and 166 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ blank_lines_lower_bound = 0
blank_lines_upper_bound = 1
brace_style = "SameLineWhere"
disable_all_formatting = false
edition = "2018"
edition = "2021"
empty_item_single_line = true
fn_single_line = false
force_explicit_abi = true
+3 -4
View File
@@ -6,10 +6,9 @@ use alloc::{boxed::Box, string::String, vec::Vec};
use hashbrown::HashMap;
use spin::{Once, RwLock};
use crate::{
log::info,
paging::{KernelMapper, PageFlags, PhysicalAddress, RmmA, RmmArch},
};
use log::info;
use crate::paging::{KernelMapper, PageFlags, PhysicalAddress, RmmA, RmmArch};
use self::{hpet::Hpet, madt::Madt, rsdp::RSDP, rsdt::Rsdt, rxsdt::Rxsdt, sdt::Sdt, xsdt::Xsdt};
+1 -1
View File
@@ -1,4 +1,4 @@
use crate::log::{debug, info};
use log::{debug, info};
use alloc::boxed::Box;
use crate::{
+2 -4
View File
@@ -3,10 +3,8 @@ use core::ptr::{read_volatile, write_volatile};
use byteorder::{ByteOrder, BE};
use fdt::{DeviceTree, Node};
use crate::{
init::device_tree::find_compatible_node,
log::{debug, info},
};
use crate::init::device_tree::find_compatible_node;
use log::{debug, info};
use syscall::{
error::{Error, EINVAL},
Result,
+2 -4
View File
@@ -4,10 +4,8 @@ use core::{arch::asm, ptr::{read_volatile, write_volatile}};
use byteorder::{ByteOrder, BE};
use fdt::{DeviceTree, Node};
use crate::{
init::device_tree::find_compatible_node,
log::{debug, info},
};
use crate::init::device_tree::find_compatible_node;
use log::{debug, info};
use super::gic::GicDistIf;
use syscall::{
error::{Error, EINVAL},
@@ -5,10 +5,9 @@ use crate::arch::device::irqchip::IRQ_CHIP;
use byteorder::{ByteOrder, BE};
use fdt::{DeviceTree, Node};
use crate::{
init::device_tree::find_compatible_node,
log::{debug, error, info},
};
use crate::init::device_tree::find_compatible_node;
use log::{debug, error, info};
use syscall::{
error::{Error, EINVAL},
Result,
@@ -6,10 +6,9 @@ use core::{
use byteorder::{ByteOrder, BE};
use fdt::{DeviceTree, Node};
use crate::{
init::device_tree::find_compatible_node,
log::{debug, info},
};
use crate::init::device_tree::find_compatible_node;
use log::{debug, info};
use syscall::{
error::{Error, EINVAL},
Result,
+2 -4
View File
@@ -7,10 +7,8 @@ use byteorder::{ByteOrder, BE};
use fdt::DeviceTree;
use syscall::Result;
use crate::{
init::device_tree::travel_interrupt_ctrl,
log::{debug, error},
};
use crate::init::device_tree::travel_interrupt_ctrl;
use log::{debug, error};
mod gic;
mod gicv3;
+1 -1
View File
@@ -2,10 +2,10 @@ use core::arch::asm;
use crate::{
dtb::DTB_BINARY,
log::info,
memory::Frame,
paging::{KernelMapper, Page, PageFlags, PhysicalAddress, VirtualAddress},
};
use log::info;
pub mod cpu;
pub mod generic_timer;
+1 -1
View File
@@ -5,8 +5,8 @@ use crate::{
device::uart_pl011::SerialPort,
init::device_tree,
interrupt::irq::trigger,
log::{debug, info},
};
use log::{debug, info};
use super::irqchip::{register_irq, InterruptHandler, IRQ_CHIP};
use crate::{dtb::DTB_BINARY, init::device_tree::find_compatible_node};
+11 -4
View File
@@ -2,13 +2,20 @@ extern crate byteorder;
extern crate fdt;
use self::byteorder::{ByteOrder, BE};
use crate::{
log::{debug, info},
memory::MemoryArea,
};
use core::slice;
use fdt::Node;
use log::{info, debug};
#[derive(Copy, Clone, Debug, Default)]
#[repr(C)]
pub struct MemoryArea {
pub base_addr: u64,
pub length: u64,
pub _type: u32,
pub acpi: u32,
}
pub static mut MEMORY_MAP: [MemoryArea; 512] = [MemoryArea {
base_addr: 0,
length: 0,
+3 -3
View File
@@ -16,9 +16,9 @@ use crate::{
allocator, device, dtb,
init::device_tree,
interrupt,
log::{self, info},
paging::{self, KernelMapper},
};
use log::info;
/// Test of zero values in BSS.
static BSS_TEST_ZERO: usize = 0;
@@ -81,7 +81,7 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! {
//graphical_debug::init(env);
// Initialize logger
log::init_logger(|r| {
crate::log::init_logger(|r| {
use core::fmt::Write;
let _ = write!(
crate::debug::Writer::new(),
@@ -176,7 +176,7 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! {
//graphical_debug::init_heap();
// Activate memory logging
log::init();
crate::log::init();
dtb::init(Some((crate::PHYS_OFFSET + args.dtb_base, args.dtb_size)));
+3 -3
View File
@@ -13,11 +13,11 @@ use crate::{
allocator,
arch::{flags::*, pti},
device, gdt, idt, interrupt,
log::{self, info},
memory,
paging::{self, KernelMapper, PhysicalAddress, RmmA, RmmArch, TableKind},
cpu_set::LogicalCpuId,
};
use log::info;
/// Test of zero values in BSS.
static BSS_TEST_ZERO: usize = 0;
@@ -89,7 +89,7 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! {
device::system76_ec::init();
// Initialize logger
log::init_logger(|r| {
crate::log::init_logger(|r| {
use core::fmt::Write;
let _ = writeln!(
super::debug::Writer::new(),
@@ -183,7 +183,7 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! {
idt::init_paging_post_heap(LogicalCpuId::BSP);
// Activate memory logging
log::init();
crate::log::init();
// Initialize devices
device::init();
+1 -2
View File
@@ -1,7 +1,6 @@
//! Global descriptor table
use core::{cell::{Cell, RefCell}, convert::TryInto, mem::{self, size_of}};
use core::sync::atomic::AtomicBool;
use core::{convert::TryInto, mem::size_of};
use crate::{
cpu_set::LogicalCpuId,
-2
View File
@@ -1,5 +1,3 @@
use core::mem;
use crate::{memory::ArchIntCtx, syscall::IntRegisters};
use super::super::flags::*;
+1 -1
View File
@@ -1,6 +1,6 @@
use crate::{
arch::{gdt, interrupt::InterruptStack},
context, ptrace, syscall,
ptrace, syscall,
syscall::flag::{PTRACE_FLAG_IGNORE, PTRACE_STOP_POST_SYSCALL, PTRACE_STOP_PRE_SYSCALL},
};
use core::mem::offset_of;
-1
View File
@@ -1,5 +1,4 @@
pub use crate::arch::x86_shared::*;
use crate::cpu_set::LogicalCpuId;
pub mod alternative;
+1 -1
View File
@@ -6,7 +6,7 @@ use core::fmt::Debug;
use x86::msr;
pub use super::CurrentRmmArch as RmmA;
pub use rmm::{Arch as RmmArch, Flusher, PageFlags, PhysicalAddress, TableKind, VirtualAddress};
pub use rmm::{Arch as RmmArch, PageFlags, PhysicalAddress, TableKind, VirtualAddress};
pub type PageMapper = rmm::PageMapper<RmmA, crate::memory::TheFrameAllocator>;
pub use crate::rmm::KernelMapper;
+1 -2
View File
@@ -4,10 +4,9 @@ use core::{
sync::atomic::{self, AtomicUsize, Ordering},
};
use rmm::{
Arch, BumpAllocator, FrameAllocator, FrameCount, FrameUsage, MemoryArea, PageFlags, PageMapper,
Arch, BumpAllocator, MemoryArea, PageFlags, PageMapper,
PhysicalAddress, TableKind, VirtualAddress, KILOBYTE, MEGABYTE,
};
use spin::Mutex;
use crate::{cpu_set::LogicalCpuId, memory::TheFrameAllocator};
+5 -5
View File
@@ -5,6 +5,8 @@
use core::slice;
use core::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering};
use log::info;
#[cfg(feature = "acpi")]
use crate::acpi;
@@ -12,11 +14,9 @@ use crate::acpi;
use crate::devices::graphical_debug;
use crate::{
allocator,
arch::{flags::*, pti},
cpu_set::LogicalCpuId,
device, gdt, idt, interrupt,
log::{self, info},
memory, misc,
misc,
paging::{self, PhysicalAddress, RmmA, RmmArch, TableKind},
};
@@ -90,7 +90,7 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! {
device::system76_ec::init();
// Initialize logger
log::init_logger(|r| {
crate::log::init_logger(|r| {
use core::fmt::Write;
let _ = writeln!(
super::debug::Writer::new(),
@@ -190,7 +190,7 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! {
idt::init_paging_post_heap(LogicalCpuId::BSP);
// Activate memory logging
log::init();
crate::log::init();
// Initialize miscellaneous processor features
misc::init(LogicalCpuId::BSP);
+1 -2
View File
@@ -11,7 +11,6 @@ use crate::{
memory::Frame,
paging::{
entry::EntryFlags, KernelMapper, Page, PageFlags, PhysicalAddress, RmmA, RmmArch,
VirtualAddress,
},
};
@@ -237,7 +236,7 @@ pub unsafe fn handle_ioapic(mapper: &mut KernelMapper, madt_ioapic: &'static Mad
let frame = Frame::containing_address(PhysicalAddress::new(madt_ioapic.address as usize));
#[cfg(target_arch = "x86")]
let page = Page::containing_address(VirtualAddress::new(crate::IOAPIC_OFFSET));
let page = Page::containing_address(rmm::VirtualAddress::new(crate::IOAPIC_OFFSET));
#[cfg(target_arch = "x86_64")]
let page = Page::containing_address(RmmA::phys_to_virt(frame.start_address()));
+2 -2
View File
@@ -4,7 +4,7 @@ use core::{
};
use x86::msr::*;
use crate::{paging::{KernelMapper, PageFlags, PhysicalAddress, RmmA, RmmArch, VirtualAddress}, ipi::IpiKind};
use crate::{paging::{KernelMapper, PageFlags, PhysicalAddress, RmmA, RmmArch}, ipi::IpiKind};
use crate::arch::cpuid::cpuid;
@@ -50,7 +50,7 @@ impl LocalApic {
let physaddr = PhysicalAddress::new(rdmsr(IA32_APIC_BASE) as usize & 0xFFFF_0000);
#[cfg(target_arch = "x86")]
let virtaddr = VirtualAddress::new(crate::LAPIC_OFFSET);
let virtaddr = rmm::VirtualAddress::new(crate::LAPIC_OFFSET);
#[cfg(target_arch = "x86_64")]
let virtaddr = RmmA::phys_to_virt(physaddr);
+1 -1
View File
@@ -311,10 +311,10 @@ pub unsafe fn init_generic(cpu_id: LogicalCpuId, idt: &mut Idt) {
idt.set_reserved_mut(IpiKind::Switch as u8, true);
idt.set_reserved_mut(IpiKind::Tlb as u8, true);
idt.set_reserved_mut(IpiKind::Pit as u8, true);
let current_idt = &mut idt.entries;
#[cfg(target_arch = "x86")]
{
let current_idt = &mut idt.entries;
// Set syscall function
current_idt[0x80].set_func(syscall::syscall);
current_idt[0x80].set_flags(IdtFlags::PRESENT | IdtFlags::RING_3 | IdtFlags::INTERRUPT);
-4
View File
@@ -1,7 +1,3 @@
use core::sync::atomic::Ordering;
use x86::tlb;
use crate::percpu::PercpuBlock;
use crate::{context, device::local_apic::LOCAL_APIC};
-3
View File
@@ -16,9 +16,6 @@ unsafe impl<T: ?Sized> Send for Unique<T> {}
unsafe impl<T: ?Sized> Sync for Unique<T> {}
impl<T: ?Sized> Unique<T> {
pub fn new(ptr: *mut T) -> Self {
Self(NonNull::new(ptr).expect("Did not expect pointer to be null"))
}
pub unsafe fn new_unchecked(ptr: *mut T) -> Self {
Self(NonNull::new_unchecked(ptr))
}
-2
View File
@@ -23,8 +23,6 @@ pub static CONTEXT_SWITCH_LOCK: AtomicBool = AtomicBool::new(false);
// 512 bytes for registers, extra bytes for fpcr and fpsr
pub const KFX_ALIGN: usize = 16;
pub const KSTACK_SIZE: usize = 65536;
pub const KSTACK_ALIGN: usize = 16;
#[derive(Clone, Debug)]
pub struct Context {
-2
View File
@@ -21,8 +21,6 @@ pub static CONTEXT_SWITCH_LOCK: AtomicBool = AtomicBool::new(false);
const ST_RESERVED: u128 = 0xFFFF_FFFF_FFFF_0000_0000_0000_0000_0000;
pub const KFX_ALIGN: usize = 16;
pub const KSTACK_SIZE: usize = 65536;
pub const KSTACK_ALIGN: usize = 16;
#[derive(Clone, Debug)]
#[repr(C)]
+1 -5
View File
@@ -22,12 +22,8 @@ pub const KFX_ALIGN: usize = 16;
#[cfg(not(cpu_feature_never = "xsave"))]
pub const KFX_ALIGN: usize = 64;
pub const KSTACK_SIZE: usize = 65536;
// Why not, helps with guarding etc.
// TODO: Unmap the 63rd page, for stack guarding! Then re-map it onto the kernel heap when freeing.
// Use a RAII guard.
pub const KSTACK_ALIGN: usize = 4096;
// TODO: stack guarding?
#[derive(Clone, Debug)]
#[repr(C)]
+2 -11
View File
@@ -1,10 +1,10 @@
use alloc::{borrow::Cow, sync::Arc, vec::Vec};
use syscall::{SigProcControl, Sigcontrol, SIGKILL, SIGSTOP, AtomicU64};
use syscall::{SigProcControl, Sigcontrol};
use core::{cmp::Ordering, mem::{self, size_of}, num::NonZeroUsize};
use spin::RwLock;
use crate::{
arch::{interrupt::InterruptStack, paging::PAGE_SIZE}, common::aligned_box::AlignedBox, context::{self, arch, file::FileDescriptor, memory::AddrSpace}, cpu_set::{LogicalCpuId, LogicalCpuSet}, ipi::{ipi, IpiKind, IpiTarget}, memory::{allocate_p2frame, deallocate_p2frame, Enomem, Frame, RaiiFrame}, paging::{RmmA, RmmArch}, percpu::PercpuBlock, scheme::{CallerCtx, FileHandle, SchemeNamespace}, sync::WaitMap,
arch::{interrupt::InterruptStack, paging::PAGE_SIZE}, common::aligned_box::AlignedBox, context::{self, arch, file::FileDescriptor}, cpu_set::{LogicalCpuId, LogicalCpuSet}, ipi::{ipi, IpiKind, IpiTarget}, memory::{allocate_p2frame, deallocate_p2frame, Enomem, Frame, RaiiFrame}, paging::{RmmA, RmmArch}, percpu::PercpuBlock, scheme::{CallerCtx, FileHandle, SchemeNamespace}, sync::WaitMap,
};
use crate::syscall::error::{Error, Result, EAGAIN, ESRCH};
@@ -592,15 +592,6 @@ impl Kstack {
}
}
const _: () = {
if PAGE_SIZE << 4 != arch::KSTACK_SIZE {
panic!();
}
if arch::KSTACK_ALIGN > (PAGE_SIZE << 4) {
panic!();
}
};
impl Drop for Kstack {
fn drop(&mut self) {
unsafe {
+1 -1
View File
@@ -2,7 +2,7 @@
use crate::{
event,
scheme::{self, SchemeId, SchemeNamespace},
scheme::{self, SchemeId},
syscall::error::{Error, Result, EBADF},
};
use alloc::sync::Arc;
+1 -1
View File
@@ -106,7 +106,7 @@ impl ContextList {
/// Spawn a context from a function.
pub fn spawn(&mut self, userspace_allowed: bool, func: extern "C" fn()) -> Result<&Arc<RwSpinlock<Context>>> {
let mut stack = Kstack::new()?;
let stack = Kstack::new()?;
let context_lock = self.new_context()?;
{
+5 -2
View File
@@ -490,12 +490,15 @@ impl AddrSpaceWrapper {
frame
};
match get_page_info(frame).expect("missing page info for Allocated grant").add_ref(RefKind::Shared) {
let frame = match get_page_info(frame).expect("missing page info for Allocated grant").add_ref(RefKind::Shared) {
Ok(_) => Ok(unsafe { RaiiFrame::new_unchecked(frame) }),
Err(AddRefError::RcOverflow) => Err(Error::new(ENOMEM)),
Err(AddRefError::SharedToCow) => unreachable!(),
Err(AddRefError::CowToShared) => unreachable!("if it was CoW, it was read-only, but in that case we already called correct_inner"),
}
};
drop(guard);
frame
}
}
impl AddrSpace {
+7 -19
View File
@@ -1,19 +1,7 @@
use alloc::sync::Arc;
use core::{mem::size_of, sync::atomic::Ordering};
use syscall::{
flag::{
PTRACE_FLAG_IGNORE, PTRACE_STOP_SIGNAL, SIGCHLD, SIGCONT, SIGKILL, SIGSTOP, SIGTERM, SIGTSTP, SIGTTIN, SIGTTOU
},
ptrace_event, IntRegisters, SigcontrolFlags,
};
use core::sync::atomic::Ordering;
use crate::{
context::{self, switch, Status, WaitpidKey},
ptrace,
syscall::usercopy::UserSlice, stop::{kstop, kreset},
};
use super::ContextId;
use crate::context;
use crate::syscall::flag::{SIGKILL, SigcontrolFlags};
pub fn signal_handler() {
let context_lock = context::current().expect("running signal handler outside of context");
@@ -31,7 +19,7 @@ pub fn signal_handler() {
.and_then(|_| ptrace::next_breakpoint().map(|f| f.contains(PTRACE_FLAG_IGNORE)));*/
// TODO: thumbs_down
let Some((thread_ctl, proc_ctl, st)) = context.sigcontrol() else {
let Some((thread_ctl, _proc_ctl, st)) = context.sigcontrol() else {
// Discard signal if sigcontrol is unset.
log::trace!("no sigcontrol, returning");
return;
@@ -75,11 +63,11 @@ pub fn signal_handler() {
thread_ctl.control_flags.store((control_flags | SigcontrolFlags::INHIBIT_DELIVERY).bits(), Ordering::Release);
}
pub fn excp_handler(signal: usize) {
pub fn excp_handler(_signal: usize) {
let current = context::current().expect("CPU exception but not inside of context!");
let mut context = current.write();
let context = current.write();
let Some(eh) = context.sig.as_ref().and_then(|s| s.excp_handler) else {
let Some(_eh) = context.sig.as_ref().and_then(|s| s.excp_handler) else {
drop(context);
crate::syscall::process::exit(SIGKILL << 8);
};
+1 -1
View File
@@ -8,7 +8,7 @@ use crate::{
context::{arch, contexts, Context}, cpu_set::LogicalCpuId, interrupt, percpu::PercpuBlock, ptrace, time
};
use super::{ContextId, Status};
use super::ContextId;
enum UpdateResult {
CanSwitch,
-2
View File
@@ -73,5 +73,3 @@ static mut LOGGER: RedoxLogger = RedoxLogger {
log_func: |_| {},
initialized: AtomicBool::new(false),
};
pub use log::{debug, error, info, set_max_level, warn};
+4 -3
View File
@@ -72,16 +72,16 @@ mod common;
/// Architecture-dependent stuff
#[macro_use]
#[allow(dead_code)] // TODO
mod arch;
use crate::arch::*;
use crate::log::info;
/// Heap allocators
mod allocator;
/// ACPI table parsing
#[cfg(all(feature = "acpi", any(target_arch = "x86", target_arch = "x86_64")))]
#[allow(dead_code)] // TODO
mod acpi;
#[cfg(all(any(target_arch = "aarch64")))]
@@ -111,6 +111,7 @@ mod externs;
/// Logging
mod log;
use ::log::info;
/// Memory management
mod memory;
@@ -263,7 +264,7 @@ pub fn ksignal(signal: usize) {
{
let contexts = context::contexts();
if let Some(context_lock) = contexts.current() {
let mut context = context_lock.write();
let context = context_lock.read();
info!("NAME {}", context.name);
}
}
+1 -11
View File
@@ -19,16 +19,6 @@ use rmm::{
};
use crate::syscall::error::{ENOMEM, Error};
/// A memory map area
#[derive(Copy, Clone, Debug, Default)]
#[repr(packed)]
pub struct MemoryArea {
pub base_addr: u64,
pub length: u64,
pub _type: u32,
pub acpi: u32,
}
/// Get the number of frames available
pub fn free_frames() -> usize {
total_frames() - used_frames()
@@ -125,7 +115,7 @@ pub unsafe fn deallocate_p2frame(orig_frame: Frame, order: u32) {
let sibling = Frame::containing_address(PhysicalAddress::new(current.start_address().data() ^ (PAGE_SIZE << merge_order)));
let Some(_) = get_page_info(current) else {
let Some(_cur_info) = get_page_info(current) else {
unreachable!("attempting to free non-allocator-owned page");
};
+3 -3
View File
@@ -17,9 +17,9 @@ use crate::syscall::{
error::{Error, Result, EACCES, EBADF, EBADFD, EINTR, EINVAL, EISDIR, ENOENT, ENOTDIR, EROFS},
flag::{
EventFlags, EVENT_READ, MODE_CHR, MODE_DIR, MODE_FILE, O_ACCMODE, O_CREAT, O_DIRECTORY,
O_EXCL, O_RDONLY, O_STAT, O_SYMLINK, SEEK_CUR, SEEK_END, SEEK_SET,
O_EXCL, O_RDONLY, O_STAT, O_SYMLINK,
},
usercopy::{UserSliceRo, UserSliceWo},
usercopy::UserSliceWo,
};
use super::{CallerCtx, GlobalSchemes, KernelScheme, OpenResult};
@@ -186,7 +186,7 @@ impl KernelScheme for AcpiScheme {
}
Ok(())
}
fn kreadoff(&self, id: usize, dst_buf: UserSliceWo, offset: u64, flags: u32, stored_flags: u32) -> Result<usize> {
fn kreadoff(&self, id: usize, dst_buf: UserSliceWo, offset: u64, _flags: u32, _stored_flags: u32) -> Result<usize> {
let Ok(offset) = usize::try_from(offset) else {
return Ok(0);
};
+2 -2
View File
@@ -7,7 +7,7 @@ use crate::{
scheme::*,
sync::WaitQueue,
syscall::{
flag::{EventFlags, EVENT_READ, F_GETFL, F_SETFL, O_ACCMODE, O_NONBLOCK},
flag::{EventFlags, EVENT_READ, O_NONBLOCK},
usercopy::{UserSliceRo, UserSliceWo},
},
};
@@ -95,7 +95,7 @@ impl KernelScheme for DebugScheme {
Ok(())
}
fn kread(&self, id: usize, buf: UserSliceWo, flags: u32, _stored_flags: u32) -> Result<usize> {
let handle = {
let _handle = {
let handles = HANDLES.read();
*handles.get(&id).ok_or(Error::new(EBADF))?
};
+1 -1
View File
@@ -41,7 +41,7 @@ impl KernelScheme for EventScheme {
queue.read(buf, flags & O_NONBLOCK as u32 == 0)
}
fn kwrite(&self, id: usize, buf: UserSliceRo, flags: u32, _stored_flags: u32) -> Result<usize> {
fn kwrite(&self, id: usize, buf: UserSliceRo, _flags: u32, _stored_flags: u32) -> Result<usize> {
let id = EventQueueId::from(id);
let queue = {
+1 -1
View File
@@ -353,7 +353,7 @@ impl crate::scheme::KernelScheme for IrqScheme {
buf.copy_common_bytes_from_slice(&scheme_path)
}
fn kreadoff(&self, file: usize, buffer: UserSliceWo, offset: u64, flags: u32, _stored_flags: u32) -> Result<usize> {
fn kreadoff(&self, file: usize, buffer: UserSliceWo, offset: u64, _flags: u32, _stored_flags: u32) -> Result<usize> {
let handles_guard = HANDLES.read();
let handle = handles_guard.get(&file).ok_or(Error::new(EBADF))?;
+1 -1
View File
@@ -10,7 +10,7 @@ use alloc::{boxed::Box, collections::BTreeMap, string::ToString, sync::Arc, vec:
use core::sync::atomic::AtomicUsize;
use hashbrown::HashMap;
use spin::{Once, RwLock, RwLockReadGuard, RwLockWriteGuard};
use syscall::{EventFlags, MunmapFlags, SendFdFlags, SEEK_CUR, SEEK_END, SEEK_SET};
use syscall::{EventFlags, MunmapFlags, SendFdFlags};
use crate::{
context::{file::{FileDescription, InternalFlags}, memory::AddrSpaceWrapper},
+2 -2
View File
@@ -10,9 +10,9 @@ use spin::{Mutex, RwLock};
use crate::{
context::file::InternalFlags, event, sync::WaitCondition, syscall::{
data::Stat,
error::{Error, Result, EAGAIN, EBADF, EINTR, EINVAL, ENOENT, EPIPE, ESPIPE},
error::{Error, Result, EAGAIN, EBADF, EINTR, EINVAL, ENOENT, EPIPE},
flag::{
EventFlags, EVENT_READ, EVENT_WRITE, F_GETFL, F_SETFL, MODE_FIFO, O_ACCMODE, O_NONBLOCK,
EventFlags, EVENT_READ, EVENT_WRITE, MODE_FIFO, O_NONBLOCK,
},
usercopy::{UserSliceRo, UserSliceWo},
}
+3 -5
View File
@@ -1,7 +1,7 @@
use crate::{
arch::paging::{Page, RmmA, RmmArch, VirtualAddress},
context::{
self, context::{HardBlockedReason, SignalState}, file::{FileDescriptor, InternalFlags}, memory::{handle_notify_files, AddrSpace, AddrSpaceWrapper, Grant, PageSpan}, Context, ContextId, Status
self, context::{HardBlockedReason, SignalState}, file::{FileDescriptor, InternalFlags}, memory::{handle_notify_files, AddrSpaceWrapper, Grant, PageSpan}, Context, ContextId, Status
},
memory::PAGE_SIZE,
ptrace,
@@ -729,7 +729,7 @@ impl<const FULL: bool> KernelScheme for ProcScheme<FULL> {
_ => Err(Error::new(EBADF)),
}
}
fn kreadoff(&self, id: usize, buf: UserSliceWo, offset: u64, read_flags: u32, _stored_flags: u32) -> Result<usize> {
fn kreadoff(&self, id: usize, buf: UserSliceWo, offset: u64, _read_flags: u32, _stored_flags: u32) -> Result<usize> {
// Don't hold a global lock during the context switch later on
let info = {
let handles = HANDLES.read();
@@ -943,7 +943,7 @@ impl<const FULL: bool> KernelScheme for ProcScheme<FULL> {
_ => Err(Error::new(EBADF)),
}
}
fn kwriteoff(&self, id: usize, buf: UserSliceRo, _offset: u64, fcntl_flags: u32, _stored_flags: u32) -> Result<usize> {
fn kwriteoff(&self, id: usize, buf: UserSliceRo, _offset: u64, _fcntl_flags: u32, _stored_flags: u32) -> Result<usize> {
// TODO: offset
// Don't hold a global lock during the context switch later on
@@ -1138,8 +1138,6 @@ impl<const FULL: bool> KernelScheme for ProcScheme<FULL> {
}
let state = if data.thread_control_addr != 0 && data.proc_control_addr != 0 {
let offset = u16::try_from(data.thread_control_addr % PAGE_SIZE).unwrap();
let validate_off = |addr, sz| {
let off = addr % PAGE_SIZE;
if off % mem::align_of::<usize>() == 0 && off + sz <= PAGE_SIZE {
+1 -1
View File
@@ -5,7 +5,7 @@ use core::{
sync::atomic::{AtomicUsize, Ordering},
};
use hashbrown::HashMap;
use spin::{Mutex, RwLock};
use spin::RwLock;
use crate::{
context::{self, file::InternalFlags},
+1 -1
View File
@@ -12,7 +12,7 @@ use crate::{
scheme::*,
sync::WaitQueue,
syscall::{
flag::{EventFlags, EVENT_READ, F_GETFL, F_SETFL, O_ACCMODE, O_NONBLOCK},
flag::{EventFlags, EVENT_READ, O_NONBLOCK},
usercopy::UserSliceWo,
},
};
+6 -7
View File
@@ -11,18 +11,17 @@ use core::{
sync::atomic::{AtomicBool, Ordering},
usize,
};
use hashbrown::hash_map::{Entry, HashMap};
use spin::{Mutex, RwLock};
use spinning_top::RwSpinlock;
use syscall::{
schemev2::{Cqe, CqeOpcode, Opcode, Sqe, SqeFlags}, FobtainFdFlags, MunmapFlags, SendFdFlags, F_SETFL, KSMSG_CANCEL, MAP_FIXED_NOREPLACE, SIGKILL, SKMSG_FOBTAINFD, SKMSG_FRETURNFD, SKMSG_PROVIDE_MMAP
schemev2::{Cqe, CqeOpcode, Opcode, Sqe, SqeFlags}, FobtainFdFlags, MunmapFlags, SendFdFlags, F_SETFL, KSMSG_CANCEL, MAP_FIXED_NOREPLACE, SKMSG_FOBTAINFD, SKMSG_FRETURNFD, SKMSG_PROVIDE_MMAP
};
use crate::{
context::{
self, context::HardBlockedReason, file::{FileDescription, FileDescriptor, InternalFlags}, memory::{
AddrSpace, AddrSpaceWrapper, BorrowedFmapSource, Grant, GrantFileRef, MmapMode, PageSpan, DANGLING
}, BorrowedHtBuf, Context, ContextId, Status
}, BorrowedHtBuf, Context, Status
},
event,
memory::Frame,
@@ -620,7 +619,7 @@ impl UserInner {
dst.copy_exactly(&self.translate_sqe_to_packet(&sqe)?)?;
bytes_read += size_of::<Packet>();
}
Err(error) if bytes_read > 0 => return Ok(bytes_read),
Err(_error) if bytes_read > 0 => return Ok(bytes_read),
Err(Error { errno: EAGAIN }) if self.unmounting.load(Ordering::SeqCst) => return Ok(bytes_read),
Err(error) => return Err(error),
}
@@ -740,7 +739,7 @@ impl UserInner {
pub fn request_fmap(
&self,
id: usize,
offset: u64,
_offset: u64,
required_page_count: usize,
flags: MapFlags,
) -> Result<()> {
@@ -1200,7 +1199,7 @@ impl KernelScheme for UserScheme {
let address = inner.copy_and_capture_tail(path.as_bytes())?;
match inner.call_extended(ctx, None, Opcode::Open, [address.base(), address.len(), flags])? {
Response::Regular(code, fl) => Ok({
let fd = Error::demux(code)?;
let _ = Error::demux(code)?;
OpenResult::SchemeLocal(code, InternalFlags::from_extra0(fl).ok_or(Error::new(EINVAL))?)
}),
Response::Fd(desc) => Ok(OpenResult::External(desc)),
@@ -1401,7 +1400,7 @@ impl KernelScheme for UserScheme {
number: usize,
desc: Arc<RwLock<FileDescription>>,
flags: SendFdFlags,
arg: u64,
_arg: u64,
) -> Result<usize> {
let inner = self.inner.upgrade().ok_or(Error::new(ENODEV))?;
+1 -1
View File
@@ -6,7 +6,7 @@ use spin::RwLock;
use crate::{
context::{self, file::{FileDescription, FileDescriptor, InternalFlags}, memory::{AddrSpace, PageSpan}},
paging::{Page, VirtualAddress, PAGE_SIZE},
scheme::{self, CallerCtx, FileHandle, KernelScheme, OpenResult, SchemeId},
scheme::{self, CallerCtx, FileHandle, KernelScheme, OpenResult},
syscall::{data::Stat, error::*, flag::*},
};
+4 -4
View File
@@ -7,7 +7,7 @@ use syscall::EINTR;
use core::sync::atomic::{AtomicU32, Ordering};
use rmm::Arch;
use spin::RwLock;
use spinning_top::{guard::RwSpinlockUpgradableReadGuard, RwSpinlock};
use spinning_top::RwSpinlock;
use crate::{
context::{self, memory::{AddrSpace, AddrSpaceWrapper}, Context},
@@ -18,8 +18,8 @@ use crate::{
use crate::syscall::{
data::TimeSpec,
error::{Error, Result, EAGAIN, EFAULT, EINVAL, ESRCH, ETIMEDOUT},
flag::{FUTEX_REQUEUE, FUTEX_WAIT, FUTEX_WAIT64, FUTEX_WAKE},
error::{Error, Result, EAGAIN, EFAULT, EINVAL, ETIMEDOUT},
flag::{FUTEX_WAIT, FUTEX_WAIT64, FUTEX_WAKE},
};
use super::usercopy::UserSlice;
@@ -60,7 +60,7 @@ fn validate_and_translate_virt(space: &AddrSpace, addr: VirtualAddress) -> Optio
Some(frame.add(off))
}
pub fn futex(addr: usize, op: usize, val: usize, val2: usize, addr2: usize) -> Result<usize> {
pub fn futex(addr: usize, op: usize, val: usize, val2: usize, _addr2: usize) -> Result<usize> {
let current_addrsp = AddrSpace::current()?;
// Keep the address space locked so we can safely read from the physical address. Unlock it
+2 -2
View File
@@ -16,7 +16,7 @@ pub use self::{
use self::{
data::{Map, TimeSpec},
error::{Error, Result, EINTR, EOVERFLOW, ENOSYS},
error::{Error, Result, EOVERFLOW, ENOSYS},
flag::{EventFlags, MapFlags, WaitFlags},
number::*,
usercopy::UserSlice,
@@ -66,7 +66,7 @@ pub fn syscall(
d: usize,
e: usize,
f: usize,
stack: &mut InterruptStack,
_stack: &mut InterruptStack,
) -> usize {
#[inline(always)]
fn inner(
+5 -5
View File
@@ -6,7 +6,7 @@ use rmm::Arch;
use spin::RwLock;
use crate::context::{
memory::{AddrSpace, Grant, PageSpan}, switch::SwitchResult, ContextId, WaitpidKey
memory::{AddrSpace, Grant, PageSpan}, ContextId, WaitpidKey
};
use crate::{
@@ -24,7 +24,7 @@ use crate::{
Bootstrap, CurrentRmmArch,
};
use super::usercopy::{UserSliceRo, UserSliceWo, UserSlice};
use super::usercopy::UserSliceWo;
pub fn exit(status: usize) -> ! {
ptrace::breakpoint_callback(
@@ -106,7 +106,7 @@ pub fn exit(status: usize) -> ! {
ptrace::close_tracee(pid);
}
let _ = unsafe { context::switch() };
let _ = context::switch();
unreachable!();
}
@@ -187,7 +187,7 @@ pub fn kill(pid: ContextId, sig: usize, parent_sigchld: bool) -> Result<usize> {
// will additionally ignore, defer, or handle that signal.
context.status = context::Status::Runnable;
if let Some((tctl, pctl, st)) = context.sigcontrol() {
if let Some((tctl, pctl, _st)) = context.sigcontrol() {
if !pctl.signal_will_ign(SIGCONT, false) {
tctl.word[0].fetch_or(sig_bit(SIGCONT), Ordering::Relaxed);
}
@@ -212,7 +212,7 @@ pub fn kill(pid: ContextId, sig: usize, parent_sigchld: bool) -> Result<usize> {
// exit() will signal the parent, rather than immediately in kill()
SendResult::Succeeded
} else if let Some((tctl, pctl, st)) = context.sigcontrol() && !pctl.signal_will_ign(sig, parent_sigchld) {
} else if let Some((tctl, pctl, _st)) = context.sigcontrol() && !pctl.signal_will_ign(sig, parent_sigchld) {
let _was_new = tctl.word[sig_group].fetch_or(sig_bit(sig), Ordering::Relaxed);
if (tctl.word[sig_group].load(Ordering::Relaxed) >> 32) & sig_bit(sig) != 0 {
context.unblock();
-6
View File
@@ -192,12 +192,6 @@ impl<const READ: bool> UserSlice<READ, true> {
.copy_from_slice(&int.to_ne_bytes())?;
Ok(())
}
pub fn write_u64(self, int: u64) -> Result<()> {
self.limit(core::mem::size_of::<u64>())
.ok_or(Error::new(EINVAL))?
.copy_from_slice(&int.to_ne_bytes())?;
Ok(())
}
}
impl UserSliceRo {