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
-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,