Format
This commit is contained in:
parent
ac14b4ac2a
commit
98f665298c
@ -168,7 +168,10 @@ pub fn send_ipc_to(
|
||||
let from = if from_kernel {
|
||||
usize::MAX
|
||||
} else {
|
||||
#[expect(clippy::unwrap_used, reason="from_kernel=false is used from the send_ipc syscall, which can only be called in usermode where PIDs are always present")]
|
||||
#[expect(
|
||||
clippy::unwrap_used,
|
||||
reason = "from_kernel=false is used from the send_ipc syscall, which can only be called in usermode where PIDs are always present"
|
||||
)]
|
||||
TASKING.current_pid().unwrap()
|
||||
};
|
||||
#[cfg(feature = "log-rpc")]
|
||||
@ -192,10 +195,10 @@ pub fn send_ipc_to(
|
||||
clippy::arithmetic_side_effects,
|
||||
reason = "Can't overflow, as padded_len is no more than 4096 and 4096+24 < u32::MAX"
|
||||
)]
|
||||
let total_len = padded_len + 16 + (4 * 4);
|
||||
let total_len = padded_len + 16 + (4 * 4);
|
||||
SECOND_PORT.write_u32s(&[
|
||||
0x3, // SPB type
|
||||
total_len, // Total block length
|
||||
0x3, // SPB type
|
||||
total_len, // Total block length
|
||||
len.saturating_cast::<u32>().saturating_add(16), // Packet length
|
||||
]);
|
||||
SECOND_PORT.write_bytes(&pid.to_ne_bytes());
|
||||
@ -453,9 +456,8 @@ extern "C" fn syscall_handler() {
|
||||
retval = address_space;
|
||||
}
|
||||
5 => {
|
||||
TASKING.current_process(|process| {
|
||||
process.address_spaces().lock().remove(usize(regs.rcx))
|
||||
});
|
||||
TASKING
|
||||
.current_process(|process| process.address_spaces().lock().remove(usize(regs.rcx)));
|
||||
}
|
||||
6 => 'call6: {
|
||||
let Ok(page) = Page::from_start_address(VirtAddr::new(regs.rdx)) else {
|
||||
@ -468,7 +470,7 @@ extern "C" fn syscall_handler() {
|
||||
ACTIVE_SPACE.lock().map_assert_unused(page, num_pages, flags).is_err()
|
||||
} else {
|
||||
TASKING.current_process(|process| {
|
||||
let mut address_spaces = process.address_spaces().lock();
|
||||
let mut address_spaces = process.address_spaces().lock();
|
||||
if let Some(space) = address_spaces.get_mut(usize(regs.rcx)) {
|
||||
space.map_assert_unused(page, num_pages, flags).is_err()
|
||||
} else {
|
||||
@ -482,30 +484,34 @@ extern "C" fn syscall_handler() {
|
||||
if let Some(buffer) = get_buffer(regs.rdx) {
|
||||
let len = usize(regs.rdi);
|
||||
assert!(len <= buffer.len());
|
||||
let err = TASKING.current_process(|process| {
|
||||
let mut address_spaces = process.address_spaces().lock();
|
||||
if let Some(space) = address_spaces.get_mut(usize(regs.rcx)) {
|
||||
let buffer_num_pages = buffer.len() / 4096;
|
||||
let buffer_raw = Box::into_raw(buffer);
|
||||
let page = ACTIVE_SPACE
|
||||
.lock()
|
||||
.move_mappings_free(
|
||||
Page::from_start_address(VirtAddr::new(u64(
|
||||
buffer_raw.expose_provenance()
|
||||
))).map_err(|_| ())?,
|
||||
buffer_num_pages,
|
||||
space,
|
||||
).map_err(|_| ())?;
|
||||
space.run(|| unsafe {
|
||||
(ptr::with_exposed_provenance_mut::<u8>(usize(regs.rsi)))
|
||||
.copy_from(page.start_address().as_mut_ptr::<u8>(), len);
|
||||
});
|
||||
space.unmap(page, buffer_num_pages).map_err(|_| ())?;
|
||||
Ok(())
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}).is_err();
|
||||
let err = TASKING
|
||||
.current_process(|process| {
|
||||
let mut address_spaces = process.address_spaces().lock();
|
||||
if let Some(space) = address_spaces.get_mut(usize(regs.rcx)) {
|
||||
let buffer_num_pages = buffer.len() / 4096;
|
||||
let buffer_raw = Box::into_raw(buffer);
|
||||
let page = ACTIVE_SPACE
|
||||
.lock()
|
||||
.move_mappings_free(
|
||||
Page::from_start_address(VirtAddr::new(u64(
|
||||
buffer_raw.expose_provenance()
|
||||
)))
|
||||
.map_err(|_| ())?,
|
||||
buffer_num_pages,
|
||||
space,
|
||||
)
|
||||
.map_err(|_| ())?;
|
||||
space.run(|| unsafe {
|
||||
(ptr::with_exposed_provenance_mut::<u8>(usize(regs.rsi)))
|
||||
.copy_from(page.start_address().as_mut_ptr::<u8>(), len);
|
||||
});
|
||||
space.unmap(page, buffer_num_pages).map_err(|_| ())?;
|
||||
Ok(())
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
})
|
||||
.is_err();
|
||||
#[expect(clippy::as_conversions, reason = "Needed to convert bool to u64")]
|
||||
{
|
||||
retval = err as u64;
|
||||
@ -515,9 +521,8 @@ extern "C" fn syscall_handler() {
|
||||
}
|
||||
}
|
||||
8 => {
|
||||
let space = TASKING.current_process(|process| {
|
||||
process.address_spaces().lock().remove(usize(regs.rdx))
|
||||
});
|
||||
let space = TASKING
|
||||
.current_process(|process| process.address_spaces().lock().remove(usize(regs.rdx)));
|
||||
let res = TASKING.new_process(ptr::with_exposed_provenance(usize(regs.rcx)), space);
|
||||
if let Ok(pid) = res {
|
||||
retval = 0;
|
||||
@ -568,7 +573,9 @@ extern "C" fn syscall_handler() {
|
||||
reason = "The message queue only contains valid buffer IDs"
|
||||
)]
|
||||
let buffer_addr = u64(TASKING
|
||||
.current_process(|process| *process.data_buffers().lock().get(msg.buffer_idx).unwrap())
|
||||
.current_process(|process| {
|
||||
*process.data_buffers().lock().get(msg.buffer_idx).unwrap()
|
||||
})
|
||||
.expose_provenance());
|
||||
retval2 = u64(msg.len);
|
||||
retval = buffer_addr;
|
||||
@ -597,7 +604,7 @@ extern "C" fn syscall_handler() {
|
||||
ACTIVE_SPACE.lock().map_only_unused(page, num_pages, flags).is_err()
|
||||
} else {
|
||||
TASKING.current_process(|process| {
|
||||
let mut address_spaces = process.address_spaces().lock();
|
||||
let mut address_spaces = process.address_spaces().lock();
|
||||
if let Some(space) = address_spaces.get_mut(usize(regs.rcx)) {
|
||||
space.map_only_unused(page, num_pages, flags).is_err()
|
||||
} else {
|
||||
@ -665,7 +672,7 @@ extern "C" fn syscall_handler() {
|
||||
}
|
||||
} else {
|
||||
TASKING.current_process(|process| {
|
||||
let mut address_spaces = process.address_spaces().lock();
|
||||
let mut address_spaces = process.address_spaces().lock();
|
||||
if let Some(space) = address_spaces.get_mut(usize(regs.rcx)) {
|
||||
unsafe {
|
||||
space
|
||||
@ -695,7 +702,7 @@ extern "C" fn syscall_handler() {
|
||||
start_virt
|
||||
} else {
|
||||
TASKING.current_process(|process| {
|
||||
let mut address_spaces = process.address_spaces().lock();
|
||||
let mut address_spaces = process.address_spaces().lock();
|
||||
if let Some(space) = address_spaces.get_mut(usize(regs.rcx)) {
|
||||
let (start_virt, start_phys) = space
|
||||
.map_free_cont_phys(
|
||||
@ -722,7 +729,7 @@ extern "C" fn syscall_handler() {
|
||||
u64::from(ACTIVE_SPACE.lock().unmap(page, usize(regs.rsi)).is_err())
|
||||
} else {
|
||||
TASKING.current_process(|process| {
|
||||
let mut address_spaces = process.address_spaces().lock();
|
||||
let mut address_spaces = process.address_spaces().lock();
|
||||
if let Some(space) = address_spaces.get_mut(usize(regs.rcx)) {
|
||||
u64::from(space.unmap(page, usize(regs.rsi)).is_err())
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user