diff --git a/executer/include/uprotocol.h b/executer/include/uprotocol.h index 9892a0ac..5bd5ddc0 100644 --- a/executer/include/uprotocol.h +++ b/executer/include/uprotocol.h @@ -191,6 +191,7 @@ struct syscall_response { long ret; unsigned long fault_address; unsigned long fault_reason; + void *private_data; }; struct syscall_ret_desc { diff --git a/executer/kernel/mcctrl/syscall.c b/executer/kernel/mcctrl/syscall.c index f06ec042..d4d62f1a 100644 --- a/executer/kernel/mcctrl/syscall.c +++ b/executer/kernel/mcctrl/syscall.c @@ -2065,6 +2065,17 @@ void __return_syscall(ihk_os_t os, struct ikc_scd_packet *packet, /* Map response structure and notify offloading thread */ res->ret = ret; res->stid = stid; + res->private_data = 0; + + /* Special case for open() to return private_data */ + if (packet->req.number == __NR_open && ret > 0) { + struct fd f; + f = fdget(ret); + if (f.file) { + res->private_data = f.file->private_data; + fdput(f); + } + } if (__notify_syscall_requester(os, packet, res) < 0) { printk("%s: WARNING: failed to notify PID %d\n", diff --git a/kernel/include/syscall.h b/kernel/include/syscall.h index c85f5038..eadf7e8d 100644 --- a/kernel/include/syscall.h +++ b/kernel/include/syscall.h @@ -294,6 +294,7 @@ struct syscall_response { long ret; unsigned long fault_address; unsigned long fault_reason; + void *private_data; }; struct syscall_post { diff --git a/kernel/syscall.c b/kernel/syscall.c index 11d76411..4142ae40 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -268,6 +268,7 @@ long do_syscall(struct syscall_request *req, int cpu, int pid) req->rtid = cpu_local_var(current)->tid; req->ttid = 0; res.req_thread_status = IHK_SCD_REQ_THREAD_SPINNING; + res.private_data = NULL; #ifdef POSTK_DEBUG_TEMP_FIX_26 /* do_syscall arg pid is not targetpid */ send_syscall(req, cpu, target_pid, &res); #else /* POSTK_DEBUG_TEMP_FIX_26 */ @@ -477,6 +478,13 @@ long do_syscall(struct syscall_request *req, int cpu, int pid) } #endif // PROFILE_ENABLE + if (req->number == __NR_open && rc > 0) { + if (res.private_data) { + kprintf("%s: open fd: %d, private_data: 0x%lx\n", + __FUNCTION__, rc, res.private_data); + } + } + monitor->status = mstatus; monitor->counter++; return rc;