Add interface for setting iopl.

This commit is contained in:
4lDO2 2025-03-07 23:52:04 +01:00
parent 2815800164
commit b4b2ac312b
No known key found for this signature in database
GPG Key ID: 4EEF2FB4486F9457
1 changed files with 32 additions and 11 deletions

View File

@ -11,12 +11,11 @@ use crate::{
ptrace,
scheme::{self, FileHandle, KernelScheme},
syscall::{
self,
data::{GrantDesc, Map, PtraceEvent, SenderInfo, SetSighandlerData, Stat},
data::{GrantDesc, Map, SetSighandlerData, Stat},
error::*,
flag::*,
usercopy::{UserSliceRo, UserSliceWo},
EnvRegisters, FloatRegisters, IntRegisters, KillMode,
usercopy::{UserSliceRo, UserSliceRw, UserSliceWo},
EnvRegisters, FloatRegisters, IntRegisters,
},
};
@ -25,7 +24,7 @@ use ::syscall::{ProcSchemeAttrs, SigProcControl, Sigcontrol};
use alloc::{
boxed::Box,
collections::{btree_map::Entry, BTreeMap},
string::{String, ToString},
string::String,
sync::{Arc, Weak},
vec::Vec,
};
@ -145,12 +144,6 @@ struct Handle {
context: Arc<RwSpinlock<Context>>,
kind: ContextHandle,
}
#[derive(Clone, Copy, PartialEq, Eq)]
enum Attr {
Uid,
Gid,
// TODO: namespace, tid, etc.
}
pub struct ProcScheme;
static NEXT_ID: AtomicUsize = AtomicUsize::new(1);
@ -507,6 +500,34 @@ impl KernelScheme for ProcScheme {
Handle { context, kind } => kind.kreadoff(id, context, buf, offset),
}
}
fn kcall(
&self,
id: usize,
_payload: UserSliceRw,
_flags: CallFlags,
metadata: &[u64],
) -> Result<usize> {
// TODO: simplify
let handle = {
let mut handles = HANDLES.write();
let handle = handles.get_mut(&id).ok_or(Error::new(EBADF))?;
handle.clone()
};
let ContextHandle::OpenViaDup = handle.kind else {
return Err(Error::new(EBADF));
};
let verb: u8 = (*metadata.get(0).ok_or(Error::new(EINVAL))?)
.try_into()
.map_err(|_| Error::new(EINVAL))?;
let verb = ProcSchemeVerb::try_from_raw(verb).ok_or(Error::new(EINVAL))?;
match verb {
ProcSchemeVerb::Iopl => context::current().write().set_userspace_io_allowed(true),
}
Ok(0)
}
fn kwriteoff(
&self,
id: usize,