Null-check ihk_os_t and mcctrl_usrdata pointers
Change-Id: I941c58d4ab6a0c1ce6bd53c24b552218a1716750 Refs: #1216
This commit is contained in:
committed by
Dominique Martinet
parent
bdf5175d4c
commit
366e95856c
@ -101,6 +101,12 @@ static long mcexec_prepare_image(ihk_os_t os,
|
||||
int num_sections;
|
||||
int free_ikc_pointers = 1;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
ret = -EINVAL;
|
||||
goto free_out;
|
||||
}
|
||||
|
||||
desc = kmalloc(sizeof(*desc), GFP_KERNEL);
|
||||
if (!desc) {
|
||||
printk("%s: error: allocating program_load_desc\n",
|
||||
@ -334,7 +340,15 @@ struct mcos_handler_info *new_mcos_handler_info(ihk_os_t os, struct file *file)
|
||||
return NULL;
|
||||
}
|
||||
memset(info, '\0', sizeof(struct mcos_handler_info));
|
||||
|
||||
info->ud = ihk_host_os_get_usrdata(os);
|
||||
if (!info->ud) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
kfree(info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
info->file = file;
|
||||
return info;
|
||||
}
|
||||
@ -414,6 +428,11 @@ static long mcexec_start_image(ihk_os_t os,
|
||||
struct mcos_handler_info *info;
|
||||
int ret = 0;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
desc = kmalloc(sizeof(*desc), GFP_KERNEL);
|
||||
if (!desc) {
|
||||
printk("%s: error: allocating program_load_desc\n",
|
||||
@ -478,6 +497,11 @@ static long mcexec_send_signal(ihk_os_t os, struct signal_desc *sigparam)
|
||||
struct mcctrl_signal *msigp;
|
||||
int rc, do_free;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (copy_from_user(&sig, sigparam, sizeof(struct signal_desc))) {
|
||||
return -EFAULT;
|
||||
}
|
||||
@ -534,8 +558,15 @@ static long mcexec_get_nodes(ihk_os_t os)
|
||||
{
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
|
||||
if (!usrdata || !usrdata->mem_info)
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!usrdata->mem_info) {
|
||||
pr_err("%s: error: mem_info not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return usrdata->mem_info->n_numa_nodes;
|
||||
}
|
||||
@ -566,6 +597,7 @@ static long mcexec_get_cpuset(ihk_os_t os, unsigned long arg)
|
||||
struct process_list_item *pli_iter;
|
||||
|
||||
if (!udp) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -979,6 +1011,7 @@ int mcctrl_get_num_pool_threads(ihk_os_t os)
|
||||
int nr_threads = 0;
|
||||
|
||||
if (!ud) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -1284,6 +1317,11 @@ int mcexec_wait_syscall(ihk_os_t os, struct syscall_wait_desc *__user req)
|
||||
struct mcctrl_per_proc_data *ppd;
|
||||
struct mcctrl_per_thread_data *ptd = NULL;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Get a reference to per-process structure */
|
||||
ppd = mcctrl_get_per_proc_data(usrdata, task_tgid_vnr(current));
|
||||
|
||||
@ -1552,6 +1590,11 @@ long mcexec_ret_syscall(ihk_os_t os, struct syscall_ret_desc *__user arg)
|
||||
struct mcctrl_per_thread_data *ptd;
|
||||
int error = 0;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (copy_from_user(&ret, arg, sizeof(struct syscall_ret_desc))) {
|
||||
return -EFAULT;
|
||||
}
|
||||
@ -1686,6 +1729,11 @@ int mcexec_create_per_process_data(ihk_os_t os,
|
||||
struct rpgtable_desc krpt;
|
||||
long ret;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (rpt &&
|
||||
copy_from_user(&krpt, rpt, sizeof(krpt))) {
|
||||
return -EFAULT;
|
||||
@ -1759,6 +1807,12 @@ int mcexec_destroy_per_process_data(ihk_os_t os, int pid)
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
struct mcctrl_per_proc_data *ppd = NULL;
|
||||
|
||||
/* destroy_ikc_channels could have destroyed usrdata */
|
||||
if (!usrdata) {
|
||||
pr_warn("%s: warning: mcctrl_usrdata not found\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ppd = mcctrl_get_per_proc_data(usrdata, pid);
|
||||
|
||||
if (ppd) {
|
||||
@ -2039,6 +2093,11 @@ long mcctrl_perf_num(ihk_os_t os, unsigned long arg)
|
||||
{
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
usrdata->perf_event_num = arg;
|
||||
|
||||
return 0;
|
||||
@ -2068,6 +2127,11 @@ long mcctrl_perf_set(ihk_os_t os, struct ihk_perf_event_attr *__user arg)
|
||||
int num_registered = 0;
|
||||
int err = 0;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 0; i < usrdata->perf_event_num; i++) {
|
||||
ret = copy_from_user(&attr, &arg[i],
|
||||
sizeof(struct ihk_perf_event_attr));
|
||||
@ -2136,6 +2200,11 @@ long mcctrl_perf_get(ihk_os_t os, unsigned long *__user arg)
|
||||
int i = 0, j = 0;
|
||||
int need_free;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 0; i < usrdata->perf_event_num; i++) {
|
||||
perf_desc = kmalloc(sizeof(struct mcctrl_perf_ctrl_desc),
|
||||
GFP_KERNEL);
|
||||
@ -2192,6 +2261,11 @@ long mcctrl_perf_enable(ihk_os_t os)
|
||||
int i = 0, j = 0;
|
||||
int need_free;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 0; i < usrdata->perf_event_num; i++) {
|
||||
cntr_mask |= 1UL << (i + ARCH_PERF_COUNTER_START);
|
||||
}
|
||||
@ -2245,6 +2319,11 @@ long mcctrl_perf_disable(ihk_os_t os)
|
||||
int i = 0, j = 0;
|
||||
int need_free;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 0; i < usrdata->perf_event_num; i++) {
|
||||
cntr_mask |= 1UL << (i + ARCH_PERF_COUNTER_START);
|
||||
}
|
||||
@ -2423,6 +2502,12 @@ long mcexec_uti_save_fs(ihk_os_t os, struct uti_save_fs_desc __user *udesc, stru
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
struct mcctrl_per_proc_data *ppd;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
rc = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(copy_from_user(&desc, udesc, sizeof(struct uti_save_fs_desc))) {
|
||||
printk("%s: Error: copy_from_user failed\n", __FUNCTION__);
|
||||
rc = -EFAULT;
|
||||
@ -2502,6 +2587,11 @@ static long mcexec_terminate_thread_unsafe(ihk_os_t os, int pid, int tid, long c
|
||||
|
||||
dprintk("%s: target pid=%d,tid=%d,code=%lx,task=%p\n", __FUNCTION__, pid, tid, code, tsk);
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
goto no_ppd;
|
||||
}
|
||||
|
||||
ppd = mcctrl_get_per_proc_data(usrdata, pid);
|
||||
if (!ppd) {
|
||||
kprintf("%s: ERROR: no per-process structure for PID %d??\n",
|
||||
@ -2683,11 +2773,9 @@ long mcexec_syscall_thread(ihk_os_t os, unsigned long arg, struct file *file)
|
||||
if (copy_from_user(¶m, uparam, sizeof param)) {
|
||||
return -EFAULT;
|
||||
}
|
||||
#if 0 /* debug */
|
||||
if (param.number == __NR_futex) {
|
||||
#else
|
||||
if (0) {
|
||||
#endif
|
||||
|
||||
/* debug */
|
||||
if (0 && param.number == __NR_futex) {
|
||||
struct uti_futex_resp resp = {
|
||||
.done = 0
|
||||
};
|
||||
@ -2707,22 +2795,35 @@ long mcexec_syscall_thread(ihk_os_t os, unsigned long arg, struct file *file)
|
||||
param.args[3], param.args[4], param.args[5], param.uti_clv, (void *)&resp, (void *)uti_wait_event, (void *)uti_printk, (void *)uti_clock_gettime);
|
||||
param.ret = rc;
|
||||
} else {
|
||||
dprintk("%s: syscall_backward, SC %d, tid %d\n", __FUNCTION__, param.number, task_tgid_vnr(current));
|
||||
rc = syscall_backward(ihk_host_os_get_usrdata(os), param.number,
|
||||
param.args[0], param.args[1], param.args[2],
|
||||
param.args[3], param.args[4], param.args[5],
|
||||
¶m.ret);
|
||||
switch (param.number) {
|
||||
case __NR_munmap:
|
||||
//printk("%s: syscall_backward, munmap,addr=%lx,len=%lx,tid=%d\n", __FUNCTION__, param.args[0], param.args[1], task_tgid_vnr(current));
|
||||
break;
|
||||
case __NR_mmap:
|
||||
//printk("%s: syscall_backward, mmap,ret=%lx,tid=%d\n", __FUNCTION__, param.ret, task_tgid_vnr(current));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dprintk("%s: syscall_backward, SC %d, tid %d\n",
|
||||
__func__, param.number, task_tgid_vnr(current));
|
||||
rc = syscall_backward(usrdata, param.number,
|
||||
param.args[0], param.args[1],
|
||||
param.args[2], param.args[3],
|
||||
param.args[4], param.args[5],
|
||||
¶m.ret);
|
||||
switch (param.number) {
|
||||
case __NR_munmap:
|
||||
dprintk("%s: syscall_backward, munmap,addr=%lx,len=%lx,tid=%d\n",
|
||||
__func__, param.args[0], param.args[1],
|
||||
task_tgid_vnr(current));
|
||||
break;
|
||||
case __NR_mmap:
|
||||
dprintk("%s: syscall_backward, mmap,ret=%lx,tid=%d\n",
|
||||
__func__, param.ret, task_tgid_vnr(current));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (copy_to_user(&uparam->ret, ¶m.ret, sizeof(unsigned long))) {
|
||||
return -EFAULT;
|
||||
}
|
||||
@ -2885,6 +2986,13 @@ mcexec_uti_attr(ihk_os_t os, struct uti_attr_desc __user *_desc)
|
||||
int rc = 0;
|
||||
int mask_size = cpumask_size();
|
||||
|
||||
if (!ud) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
rc = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((rc = uti_attr_init())) {
|
||||
pr_err("%s: error: uti_attr_init (%d)\n",
|
||||
__func__, rc);
|
||||
@ -3236,7 +3344,8 @@ int mcctrl_get_request_os_cpu(ihk_os_t os, int *ret_cpu)
|
||||
/* Look up per-OS mcctrl structure */
|
||||
usrdata = ihk_host_os_get_usrdata(os);
|
||||
if (!usrdata) {
|
||||
printk("%s: ERROR: no usrdata found for OS %p\n", __FUNCTION__, os);
|
||||
pr_err("%s: ERROR: mcctrl_usrdata not found for OS %p\n",
|
||||
__func__, os);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
||||
@ -91,6 +91,13 @@ static void mcctrl_wakeup_cb(ihk_os_t os, struct ikc_scd_packet *packet)
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
unsigned long flags;
|
||||
|
||||
/* destroy_ikc_channels must have cleaned up descs */
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
return;
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&usrdata->wakeup_descs_lock, flags);
|
||||
mcctrl_wakeup_desc_cleanup(os, desc);
|
||||
spin_unlock_irqrestore(&usrdata->wakeup_descs_lock, flags);
|
||||
@ -100,6 +107,7 @@ static void mcctrl_wakeup_cb(ihk_os_t os, struct ikc_scd_packet *packet)
|
||||
wake_up_interruptible(&desc->wq);
|
||||
}
|
||||
|
||||
/* do_frees: 1 when caller should free free_addrs[], 0 otherwise */
|
||||
int mcctrl_ikc_send_wait(ihk_os_t os, int cpu, struct ikc_scd_packet *pisp,
|
||||
long int timeout, struct mcctrl_wakeup_desc *desc,
|
||||
int *do_frees, int free_addrs_count, ...)
|
||||
@ -153,6 +161,13 @@ int mcctrl_ikc_send_wait(ihk_os_t os, int cpu, struct ikc_scd_packet *pisp,
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
unsigned long flags;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
ret = ret < 0 ? ret : -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&usrdata->wakeup_descs_lock, flags);
|
||||
list_add(&desc->chain, &usrdata->wakeup_descs_list);
|
||||
spin_unlock_irqrestore(&usrdata->wakeup_descs_lock, flags);
|
||||
@ -162,6 +177,7 @@ int mcctrl_ikc_send_wait(ihk_os_t os, int cpu, struct ikc_scd_packet *pisp,
|
||||
}
|
||||
|
||||
ret = READ_ONCE(desc->err);
|
||||
out:
|
||||
if (alloc_desc)
|
||||
kfree(desc);
|
||||
return ret;
|
||||
@ -172,10 +188,17 @@ int mcctrl_ikc_send_wait(ihk_os_t os, int cpu, struct ikc_scd_packet *pisp,
|
||||
static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||
void *__packet, void *__os)
|
||||
{
|
||||
int ret = 0;
|
||||
struct ikc_scd_packet *pisp = __packet;
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(__os);
|
||||
int msg = pisp->msg;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (msg) {
|
||||
case SCD_MSG_INIT_CHANNEL:
|
||||
mcctrl_ikc_init(__os, pisp->ref, pisp->arg, c);
|
||||
@ -236,6 +259,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||
break;
|
||||
}
|
||||
|
||||
out:
|
||||
/*
|
||||
* SCD_MSG_SYSCALL_ONESIDE holds the packet and frees is it
|
||||
* mcexec_ret_syscall(), for the rest, free it here.
|
||||
@ -243,7 +267,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||
if (msg != SCD_MSG_SYSCALL_ONESIDE) {
|
||||
ihk_ikc_release_packet((struct ihk_ikc_free_packet *)__packet);
|
||||
}
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dummy_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||
@ -258,12 +282,12 @@ int mcctrl_ikc_send(ihk_os_t os, int cpu, struct ikc_scd_packet *pisp)
|
||||
{
|
||||
struct mcctrl_usrdata *usrdata;
|
||||
|
||||
if (cpu < 0 || os == NULL) {
|
||||
if (!os || cpu < 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
usrdata = ihk_host_os_get_usrdata(os);
|
||||
if (usrdata == NULL || cpu >= usrdata->num_channels ||
|
||||
if (!usrdata || cpu >= usrdata->num_channels ||
|
||||
!usrdata->channels[cpu].c) {
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -273,9 +297,15 @@ int mcctrl_ikc_send(ihk_os_t os, int cpu, struct ikc_scd_packet *pisp)
|
||||
int mcctrl_ikc_send_msg(ihk_os_t os, int cpu, int msg, int ref, unsigned long arg)
|
||||
{
|
||||
struct ikc_scd_packet packet;
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
struct mcctrl_usrdata *usrdata;
|
||||
|
||||
if (cpu < 0 || cpu >= usrdata->num_channels || !usrdata->channels[cpu].c) {
|
||||
if (!os) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
usrdata = ihk_host_os_get_usrdata(os);
|
||||
if (!usrdata || cpu < 0 || cpu >= usrdata->num_channels ||
|
||||
!usrdata->channels[cpu].c) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -288,7 +318,17 @@ int mcctrl_ikc_send_msg(ihk_os_t os, int cpu, int msg, int ref, unsigned long ar
|
||||
|
||||
int mcctrl_ikc_set_recv_cpu(ihk_os_t os, int cpu)
|
||||
{
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
struct mcctrl_usrdata *usrdata;
|
||||
|
||||
if (!os) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
usrdata = ihk_host_os_get_usrdata(os);
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ihk_ikc_channel_set_cpu(usrdata->channels[cpu].c,
|
||||
ihk_ikc_get_processor_id());
|
||||
@ -297,9 +337,15 @@ int mcctrl_ikc_set_recv_cpu(ihk_os_t os, int cpu)
|
||||
|
||||
int mcctrl_ikc_is_valid_thread(ihk_os_t os, int cpu)
|
||||
{
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
struct mcctrl_usrdata *usrdata;
|
||||
|
||||
if (cpu < 0 || cpu >= usrdata->num_channels || !usrdata->channels[cpu].c) {
|
||||
if (!os) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
usrdata = ihk_host_os_get_usrdata(os);
|
||||
if (!usrdata || cpu < 0 || cpu >= usrdata->num_channels ||
|
||||
!usrdata->channels[cpu].c) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
@ -308,12 +354,25 @@ int mcctrl_ikc_is_valid_thread(ihk_os_t os, int cpu)
|
||||
|
||||
static void mcctrl_ikc_init(ihk_os_t os, int cpu, unsigned long rphys, struct ihk_ikc_channel_desc *c)
|
||||
{
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
struct mcctrl_usrdata *usrdata;
|
||||
struct ikc_scd_packet packet;
|
||||
struct mcctrl_channel *pmc = usrdata->channels + cpu;
|
||||
struct mcctrl_channel *pmc;
|
||||
|
||||
if (!os) {
|
||||
pr_err("%s: error: os not found\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
usrdata = ihk_host_os_get_usrdata(os);
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->port == 502) {
|
||||
pmc = usrdata->channels + usrdata->num_channels - 1;
|
||||
} else {
|
||||
pmc = usrdata->channels + cpu;
|
||||
}
|
||||
|
||||
if (!pmc) {
|
||||
@ -335,6 +394,11 @@ static int connect_handler_ikc2linux(struct ihk_ikc_channel_info *param)
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
int linux_cpu;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
c = param->channel;
|
||||
linux_cpu = c->send.queue->write_cpu;
|
||||
if (linux_cpu > nr_cpu_ids) {
|
||||
@ -357,6 +421,11 @@ static int connect_handler_ikc2mckernel(struct ihk_ikc_channel_info *param)
|
||||
ihk_os_t os = param->channel->remote_os;
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n", __func__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
c = param->channel;
|
||||
mck_cpu = c->send.queue->read_cpu;
|
||||
|
||||
@ -486,7 +555,8 @@ void destroy_ikc_channels(ihk_os_t os)
|
||||
struct mcctrl_wakeup_desc *mwd_entry, *mwd_next;
|
||||
|
||||
if (!usrdata) {
|
||||
printk("%s: WARNING: no mcctrl_usrdata found\n", __FUNCTION__);
|
||||
kprintf("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -214,10 +214,18 @@ static int __notify_syscall_requester(ihk_os_t os, struct ikc_scd_packet *packet
|
||||
struct syscall_response *res)
|
||||
{
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
struct ihk_ikc_channel_desc *c = (usrdata->channels + packet->ref)->c;
|
||||
struct ihk_ikc_channel_desc *c;
|
||||
struct ikc_scd_packet r_packet;
|
||||
int ret = 0;
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
c = (usrdata->channels + packet->ref)->c;
|
||||
|
||||
/* If spinning, no need for IKC message */
|
||||
if (__sync_bool_compare_and_swap(&res->req_thread_status,
|
||||
IHK_SCD_REQ_THREAD_SPINNING,
|
||||
@ -1530,6 +1538,12 @@ static int pager_req_map(ihk_os_t os, int fd, size_t len, off_t off,
|
||||
|
||||
dprintk("pager_req_map(%p,%d,%lx,%lx,%lx)\n", os, fd, len, off, result_rpa);
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ppd = mcctrl_get_per_proc_data(usrdata, task_tgid_vnr(current));
|
||||
if (unlikely(!ppd)) {
|
||||
kprintf("%s: ERROR: no per-process structure for PID %d??\n",
|
||||
@ -1800,6 +1814,12 @@ static int pager_req_unmap(ihk_os_t os, uintptr_t handle)
|
||||
|
||||
dprintk("pager_req_unmap(%p,%lx)\n", os, handle);
|
||||
|
||||
if (!usrdata) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ppd = mcctrl_get_per_proc_data(usrdata, task_tgid_vnr(current));
|
||||
if (unlikely(!ppd)) {
|
||||
kprintf("%s: ERROR: no per-process structure for PID %d??\n",
|
||||
|
||||
@ -1236,7 +1236,7 @@ sysfsm_cleanup(ihk_os_t os)
|
||||
struct sysfsm_node *np;
|
||||
|
||||
if (!udp) {
|
||||
printk("%s: WARNING: no mcctrl_usrdata found\n", __FUNCTION__);
|
||||
pr_warn("%s: warning: mcctrl_usrdata not found\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1277,11 +1277,21 @@ sysfsm_setup(ihk_os_t os, void *buf, long buf_pa, size_t bufsize)
|
||||
struct device *dev = ihk_os_get_linux_device(os);
|
||||
struct sysfsm_node *np = NULL;
|
||||
struct mcctrl_usrdata *udp = ihk_host_os_get_usrdata(os);
|
||||
struct sysfsm_data *sdp = &udp->sysfsm_data;
|
||||
struct sysfsm_req *req = &sdp->sysfs_req;
|
||||
struct sysfsm_data *sdp;
|
||||
struct sysfsm_req *req;
|
||||
|
||||
dprintk("mcctrl:sysfsm_setup(%p)\n", os);
|
||||
|
||||
if (!udp) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
error = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
sdp = &udp->sysfsm_data;
|
||||
req = &sdp->sysfs_req;
|
||||
|
||||
req->busy = 0;
|
||||
init_waitqueue_head(&req->wq);
|
||||
|
||||
@ -1637,6 +1647,13 @@ sysfsm_req_create(void *os, long param_rpa)
|
||||
}
|
||||
}
|
||||
|
||||
if (!udp) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
error = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
np = sysfsm_create(&udp->sysfsm_data, param->path, param->mode,
|
||||
ops, param->client_ops, cinstance);
|
||||
if (IS_ERR(np)) {
|
||||
@ -1672,6 +1689,13 @@ sysfsm_req_mkdir(void *os, long param_rpa)
|
||||
param_pa = ihk_device_map_memory(dev, param_rpa, sizeof(*param));
|
||||
param = ihk_device_map_virtual(dev, param_pa, sizeof(*param), NULL, 0);
|
||||
|
||||
if (!udp) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
error = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
np = sysfsm_mkdir(&udp->sysfsm_data, param->path);
|
||||
if (IS_ERR(np)) {
|
||||
error = PTR_ERR(np);
|
||||
@ -1704,6 +1728,13 @@ sysfsm_req_symlink(void *os, long param_rpa)
|
||||
param_pa = ihk_device_map_memory(dev, param_rpa, sizeof(*param));
|
||||
param = ihk_device_map_virtual(dev, param_pa, sizeof(*param), NULL, 0);
|
||||
|
||||
if (!udp) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
error = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
np = sysfsm_symlink(&udp->sysfsm_data, (void *)param->target,
|
||||
param->path);
|
||||
if (IS_ERR(np)) {
|
||||
@ -1735,6 +1766,13 @@ sysfsm_req_lookup(void *os, long param_rpa)
|
||||
param_pa = ihk_device_map_memory(dev, param_rpa, sizeof(*param));
|
||||
param = ihk_device_map_virtual(dev, param_pa, sizeof(*param), NULL, 0);
|
||||
|
||||
if (!udp) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
error = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
np = sysfsm_lookup(&udp->sysfsm_data, param->path);
|
||||
if (IS_ERR(np)) {
|
||||
error = PTR_ERR(np);
|
||||
@ -1766,6 +1804,13 @@ sysfsm_req_unlink(void *os, long param_rpa)
|
||||
param_pa = ihk_device_map_memory(dev, param_rpa, sizeof(*param));
|
||||
param = ihk_device_map_virtual(dev, param_pa, sizeof(*param), NULL, 0);
|
||||
|
||||
if (!udp) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
error = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
error = sysfsm_unlink(&udp->sysfsm_data, param->path, param->flags);
|
||||
if (error) {
|
||||
goto out;
|
||||
@ -2244,6 +2289,13 @@ sysfsm_createf(ihk_os_t os, struct sysfsm_ops *ops, void *instance, int mode,
|
||||
special = 1;
|
||||
}
|
||||
|
||||
if (!udp) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
error = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
np = sysfsm_create(&udp->sysfsm_data, param->path, param->mode, &local_ops,
|
||||
param->client_ops, param->client_instance);
|
||||
if (IS_ERR(np)) {
|
||||
@ -2303,6 +2355,13 @@ sysfsm_mkdirf(ihk_os_t os, sysfs_handle_t *dirhp, const char *fmt, ...)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!udp) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
error = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
np = sysfsm_mkdir(&udp->sysfsm_data, param->path);
|
||||
if (IS_ERR(np)) {
|
||||
error = PTR_ERR(np);
|
||||
@ -2364,6 +2423,13 @@ sysfsm_symlinkf(ihk_os_t os, sysfs_handle_t targeth, const char *fmt, ...)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!udp) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
error = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
np = sysfsm_symlink(&udp->sysfsm_data, (void *)targeth.handle,
|
||||
param->path);
|
||||
if (IS_ERR(np)) {
|
||||
@ -2421,6 +2487,13 @@ sysfsm_lookupf(ihk_os_t os, sysfs_handle_t *objhp, const char *fmt, ...)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!udp) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
error = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
np = sysfsm_lookup(&udp->sysfsm_data, param->path);
|
||||
if (IS_ERR(np)) {
|
||||
error = PTR_ERR(np);
|
||||
@ -2480,6 +2553,13 @@ sysfsm_unlinkf(ihk_os_t os, int flags, const char *fmt, ...)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!udp) {
|
||||
pr_err("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
error = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
error = sysfsm_unlink(&udp->sysfsm_data, param->path, flags);
|
||||
if (error) {
|
||||
eprintk("mcctrl:sysfsm_unlinkf:sysfsm_unlink failed. %d\n",
|
||||
|
||||
@ -99,6 +99,11 @@ void setup_local_snooping_files(ihk_os_t os)
|
||||
int i;
|
||||
int error;
|
||||
|
||||
if (!udp) {
|
||||
panic("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
}
|
||||
|
||||
memset(udp->cpu_online, 0, sizeof(udp->cpu_online));
|
||||
for (i = 0; i < udp->cpu_info->n_cpus; i++) {
|
||||
set_bit(i, udp->cpu_online);
|
||||
@ -195,7 +200,7 @@ void free_topology_info(ihk_os_t os)
|
||||
struct mcctrl_usrdata *udp = ihk_host_os_get_usrdata(os);
|
||||
|
||||
if (!udp) {
|
||||
printk("%s: WARNING: no mcctrl_usrdata found\n", __FUNCTION__);
|
||||
pr_warn("%s: warning: mcctrl_usrdata not found\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1136,6 +1141,11 @@ void setup_sysfs_files(ihk_os_t os)
|
||||
struct sysfs_handle handle;
|
||||
struct mcctrl_usrdata *udp = ihk_host_os_get_usrdata(os);
|
||||
|
||||
if (!udp) {
|
||||
panic("%s: error: mcctrl_usrdata not found\n",
|
||||
__func__);
|
||||
}
|
||||
|
||||
error = sysfsm_mkdirf(os, NULL, "/sys/test/x.dir");
|
||||
if (error) {
|
||||
panic("sysfsm_mkdir(x.dir)");
|
||||
|
||||
Reference in New Issue
Block a user