Add granular FK: progress markers throughout fork_inner to pinpoint EOPNOTSUPP
This commit is contained in:
@@ -999,6 +999,7 @@ pub fn fork_inner(initial_rsp: *mut usize, args: &ForkArgs) -> Result<usize> {
|
|||||||
thr_fd,
|
thr_fd,
|
||||||
pid,
|
pid,
|
||||||
} = new_child_process(args)?;
|
} = new_child_process(args)?;
|
||||||
|
let _ = syscall::write(1, b"FK:N1\n");
|
||||||
new_proc_fd = proc_fd;
|
new_proc_fd = proc_fd;
|
||||||
new_thr_fd = thr_fd;
|
new_thr_fd = thr_fd;
|
||||||
new_pid = pid;
|
new_pid = pid;
|
||||||
@@ -1010,10 +1011,12 @@ pub fn fork_inner(initial_rsp: *mut usize, args: &ForkArgs) -> Result<usize> {
|
|||||||
let _ = syscall::write(1, b"FK:FB\n");
|
let _ = syscall::write(1, b"FK:FB\n");
|
||||||
e
|
e
|
||||||
})?;
|
})?;
|
||||||
|
let _ = syscall::write(1, b"FK:F1\n");
|
||||||
new_filetable_fd = cur_filetable_fd.dup_into_upper(b"copy").map_err(|e| {
|
new_filetable_fd = cur_filetable_fd.dup_into_upper(b"copy").map_err(|e| {
|
||||||
let _ = syscall::write(1, b"FK:CP\n");
|
let _ = syscall::write(1, b"FK:CP\n");
|
||||||
e
|
e
|
||||||
})?;
|
})?;
|
||||||
|
let _ = syscall::write(1, b"FK:F2\n");
|
||||||
|
|
||||||
// This must be done before the address space is copied.
|
// This must be done before the address space is copied.
|
||||||
let proc_fd = new_proc_fd.as_ref().map_or(usize::MAX, |p| p.as_raw_fd());
|
let proc_fd = new_proc_fd.as_ref().map_or(usize::MAX, |p| p.as_raw_fd());
|
||||||
@@ -1047,15 +1050,18 @@ pub fn fork_inner(initial_rsp: *mut usize, args: &ForkArgs) -> Result<usize> {
|
|||||||
let _ = syscall::write(1, b"FK:CA\n");
|
let _ = syscall::write(1, b"FK:CA\n");
|
||||||
e
|
e
|
||||||
})?;
|
})?;
|
||||||
|
let _ = syscall::write(1, b"FK:A0\n");
|
||||||
|
|
||||||
let cur_addr_space_fd = cur_thr_fd.dup_into_upper(b"addrspace").map_err(|e| {
|
let cur_addr_space_fd = cur_thr_fd.dup_into_upper(b"addrspace").map_err(|e| {
|
||||||
let _ = syscall::write(1, b"FK:AS\n");
|
let _ = syscall::write(1, b"FK:AS\n");
|
||||||
e
|
e
|
||||||
})?;
|
})?;
|
||||||
|
let _ = syscall::write(1, b"FK:A1\n");
|
||||||
let new_addr_space_fd = cur_addr_space_fd.dup_into_upper(b"exclusive").map_err(|e| {
|
let new_addr_space_fd = cur_addr_space_fd.dup_into_upper(b"exclusive").map_err(|e| {
|
||||||
let _ = syscall::write(1, b"FK:EX\n");
|
let _ = syscall::write(1, b"FK:EX\n");
|
||||||
e
|
e
|
||||||
})?;
|
})?;
|
||||||
|
let _ = syscall::write(1, b"FK:A2\n");
|
||||||
|
|
||||||
let mut grant_desc_buf = [GrantDesc::default(); 16];
|
let mut grant_desc_buf = [GrantDesc::default(); 16];
|
||||||
loop {
|
loop {
|
||||||
@@ -1116,6 +1122,7 @@ pub fn fork_inner(initial_rsp: *mut usize, args: &ForkArgs) -> Result<usize> {
|
|||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let _ = syscall::write(1, b"FK:A3\n");
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
target_arch = "x86_64",
|
target_arch = "x86_64",
|
||||||
target_arch = "aarch64",
|
target_arch = "aarch64",
|
||||||
@@ -1134,6 +1141,7 @@ pub fn fork_inner(initial_rsp: *mut usize, args: &ForkArgs) -> Result<usize> {
|
|||||||
initial_rsp as usize,
|
initial_rsp as usize,
|
||||||
);
|
);
|
||||||
new_addr_space_sel_fd.write(&buf)?;
|
new_addr_space_sel_fd.write(&buf)?;
|
||||||
|
let _ = syscall::write(1, b"FK:A4\n");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Reuse the same sigaltstack and signal entry (all memory will be re-mapped CoW later).
|
// Reuse the same sigaltstack and signal entry (all memory will be re-mapped CoW later).
|
||||||
@@ -1142,7 +1150,9 @@ pub fn fork_inner(initial_rsp: *mut usize, args: &ForkArgs) -> Result<usize> {
|
|||||||
// reference to the TCB and whatever pages stores the signal proc control struct.
|
// reference to the TCB and whatever pages stores the signal proc control struct.
|
||||||
{
|
{
|
||||||
let new_sighandler_fd = new_thr_fd.dup_into_upper(b"sighandler")?;
|
let new_sighandler_fd = new_thr_fd.dup_into_upper(b"sighandler")?;
|
||||||
|
let _ = syscall::write(1, b"FK:S0\n");
|
||||||
new_sighandler_fd.write(&crate::signal::current_setsighandler_struct())?;
|
new_sighandler_fd.write(&crate::signal::current_setsighandler_struct())?;
|
||||||
|
let _ = syscall::write(1, b"FK:S1\n");
|
||||||
}
|
}
|
||||||
if let Some(ref proc_fd) = new_proc_fd {
|
if let Some(ref proc_fd) = new_proc_fd {
|
||||||
proc_call(
|
proc_call(
|
||||||
@@ -1151,37 +1161,47 @@ pub fn fork_inner(initial_rsp: *mut usize, args: &ForkArgs) -> Result<usize> {
|
|||||||
CallFlags::empty(),
|
CallFlags::empty(),
|
||||||
&[ProcCall::SyncSigPctl as u64],
|
&[ProcCall::SyncSigPctl as u64],
|
||||||
)?;
|
)?;
|
||||||
|
let _ = syscall::write(1, b"FK:P1\n");
|
||||||
thread_call(
|
thread_call(
|
||||||
new_thr_fd.as_raw_fd(),
|
new_thr_fd.as_raw_fd(),
|
||||||
&mut [],
|
&mut [],
|
||||||
CallFlags::empty(),
|
CallFlags::empty(),
|
||||||
&[ThreadCall::SyncSigTctl as u64],
|
&[ThreadCall::SyncSigTctl as u64],
|
||||||
)?;
|
)?;
|
||||||
|
let _ = syscall::write(1, b"FK:T1\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Copy environment registers.
|
// Copy environment registers.
|
||||||
let cur_env_regs_fd = cur_thr_fd.dup_into_upper(b"regs/env")?;
|
let cur_env_regs_fd = cur_thr_fd.dup_into_upper(b"regs/env")?;
|
||||||
|
let _ = syscall::write(1, b"FK:E0\n");
|
||||||
let new_env_regs_fd = new_thr_fd.dup_into_upper(b"regs/env")?;
|
let new_env_regs_fd = new_thr_fd.dup_into_upper(b"regs/env")?;
|
||||||
|
let _ = syscall::write(1, b"FK:E1\n");
|
||||||
|
|
||||||
let mut env_regs = syscall::EnvRegisters::default();
|
let mut env_regs = syscall::EnvRegisters::default();
|
||||||
cur_env_regs_fd.read(&mut env_regs)?;
|
cur_env_regs_fd.read(&mut env_regs)?;
|
||||||
new_env_regs_fd.write(&env_regs)?;
|
new_env_regs_fd.write(&env_regs)?;
|
||||||
|
let _ = syscall::write(1, b"FK:E2\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// TODO: Use file descriptor forwarding or something similar to avoid copying the file
|
// TODO: Use file descriptor forwarding or something similar to avoid copying the file
|
||||||
// table in the kernel.
|
// table in the kernel.
|
||||||
let new_filetable_sel_fd = new_thr_fd.dup_into_upper(b"current-filetable")?;
|
let new_filetable_sel_fd = new_thr_fd.dup_into_upper(b"current-filetable")?;
|
||||||
|
let _ = syscall::write(1, b"FK:FT0\n");
|
||||||
new_filetable_sel_fd.write(&usize::to_ne_bytes(new_filetable_fd.as_raw_fd()))?;
|
new_filetable_sel_fd.write(&usize::to_ne_bytes(new_filetable_fd.as_raw_fd()))?;
|
||||||
|
let _ = syscall::write(1, b"FK:FT1\n");
|
||||||
}
|
}
|
||||||
new_filetable_fd.call_wo(
|
new_filetable_fd.call_wo(
|
||||||
&new_filetable_fd.as_raw_fd().to_ne_bytes(),
|
&new_filetable_fd.as_raw_fd().to_ne_bytes(),
|
||||||
syscall::CallFlags::FD | syscall::CallFlags::FD_CLONE,
|
syscall::CallFlags::FD | syscall::CallFlags::FD_CLONE,
|
||||||
&[new_filetable_fd.as_raw_fd() as u64],
|
&[new_filetable_fd.as_raw_fd() as u64],
|
||||||
)?;
|
)?;
|
||||||
|
let _ = syscall::write(1, b"FK:FT2\n");
|
||||||
let start_fd = new_thr_fd.dup_into_upper(b"start")?;
|
let start_fd = new_thr_fd.dup_into_upper(b"start")?;
|
||||||
|
let _ = syscall::write(1, b"FK:ST0\n");
|
||||||
start_fd.write(&[0])?;
|
start_fd.write(&[0])?;
|
||||||
|
let _ = syscall::write(1, b"FK:ST1\n");
|
||||||
Ok(new_pid)
|
Ok(new_pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user