Remove FEXEC_STEP diagnostic from proc.rs

This commit is contained in:
Red Bear OS
2026-07-12 15:17:50 +03:00
parent 5049c25a79
commit bb20fe9c76
-18
View File
@@ -69,8 +69,6 @@ pub struct ExtraInfo<'a> {
pub same_process: bool,
}
pub static mut FEXEC_STEP: usize = 0;
pub use crate::sys::register_external_fd;
#[expect(clippy::too_many_arguments)]
@@ -89,7 +87,6 @@ pub fn fexec_impl(
// some misalignments, and then switch address space.
let mut header_bytes = [0_u8; size_of::<Header>()];
unsafe { FEXEC_STEP = 1; }
pread_all(&image_file, 0, &mut header_bytes)?;
let header = Header::from_bytes(&header_bytes);
@@ -101,11 +98,9 @@ pub fn fexec_impl(
let grants_fd = if let Some(interp) = interp_override.as_ref() {
FdGuard::new(interp.grants_fd).to_upper()?
} else {
unsafe { FEXEC_STEP = 2; }
let current_addrspace_fd = thread_fd.dup_into_upper(b"addrspace")?;
current_addrspace_fd.dup_into_upper(b"empty")?
};
unsafe { FEXEC_STEP = 3; }
grants_fd.fcntl(syscall::F_SETFD, O_CLOEXEC)?;
// Never allow more than 1 MiB of program headers.
@@ -132,7 +127,6 @@ pub fn fexec_impl(
min_mmap_addr = cmp::max(min_mmap_addr, (addr + size).next_multiple_of(PAGE_SIZE));
};
unsafe { FEXEC_STEP = 4; }
pread_all(
&image_file,
#[expect(clippy::useless_conversion, reason = "could be 32bit Header")]
@@ -164,7 +158,6 @@ pub fn fexec_impl(
let span = span.expect("ELF executables must contain at least one `PT_LOAD` segment");
let span_size = (span.end - span.start).next_multiple_of(PAGE_SIZE);
unsafe { FEXEC_STEP = 5; } // mmap base
let base_addr = if header.e_type == ET_DYN {
// PIE
let addr = mmap_anon_remote(&grants_fd, 0, 0, span_size, MapFlags::PROT_NONE)?;
@@ -185,7 +178,6 @@ pub fn fexec_impl(
let mut phdrs_vaddr = 0;
let mut interpreter = None;
unsafe { FEXEC_STEP = 6; }
for ph_idx in 0..phnum {
let ph_bytes = &phs[ph_idx * phentsize..(ph_idx + 1) * phentsize];
let segment: &ProgramHeader =
@@ -205,7 +197,6 @@ pub fn fexec_impl(
match segment.p_type {
PT_INTERP => {
let mut interp = vec![0_u8; segment.p_filesz as usize];
unsafe { FEXEC_STEP = 60 + ph_idx * 10; }
pread_all(
&image_file,
#[expect(clippy::useless_conversion, reason = "could be 32bit ProgramHeader")]
@@ -226,7 +217,6 @@ pub fn fexec_impl(
return Err(Error::new(ENOEXEC));
}
unsafe { FEXEC_STEP = 61 + ph_idx * 10; }
mmap_anon_remote(
&grants_fd,
0,
@@ -243,7 +233,6 @@ pub fn fexec_impl(
}
if filesz > 0 {
unsafe { FEXEC_STEP = 62 + ph_idx * 10; }
let (_guard, dst_memory) = unsafe {
MmapGuard::map_mut_anywhere(
&grants_fd,
@@ -251,7 +240,6 @@ pub fn fexec_impl(
(voff + filesz).next_multiple_of(PAGE_SIZE),
)?
};
unsafe { FEXEC_STEP = 63 + ph_idx * 10; }
pread_all(
&image_file,
#[expect(
@@ -282,7 +270,6 @@ pub fn fexec_impl(
}));
}
unsafe { FEXEC_STEP = 7; }
mmap_anon_remote(
&grants_fd,
0,
@@ -332,7 +319,6 @@ pub fn fexec_impl(
Ok(())
};
unsafe { FEXEC_STEP = 9; }
push(0)?;
push(AT_NULL)?;
if let Some(ref r#override) = interp_override {
@@ -365,7 +351,6 @@ pub fn fexec_impl(
+ envs.iter().map(|env| env.len() + 1).sum::<usize>()
+ extrainfo.cwd.map_or(0, |s| s.len() + 1);
let args_envs_size_aligned = total_args_envs_auxvpointee_size.next_multiple_of(PAGE_SIZE);
unsafe { FEXEC_STEP = 8; } // args/env mmap
let target_args_env_address = mmap_anon_remote(
&grants_fd,
0,
@@ -491,7 +476,6 @@ pub fn fexec_impl(
let _ = mmap_min_fd.write(&usize::to_ne_bytes(min_mmap_addr));
}
unsafe { FEXEC_STEP = 10; }
let addrspace_selection_fd = thread_fd.dup_into_upper(b"current-addrspace")?;
let _ = addrspace_selection_fd.write(&create_set_addr_space_buf(
@@ -530,7 +514,6 @@ pub fn fexec_impl(
)
};
unsafe { FEXEC_STEP = 11; }
{
let filetable_fd = thread_fd.dup_into_upper(b"filetable-binary")?;
let _ = filetable_fd.call_wo(
@@ -546,7 +529,6 @@ pub fn fexec_impl(
}
}
unsafe { FEXEC_STEP = 12; }
unsafe {
deactivate_tcb(thread_fd)?;
}