diff --git a/arch/x86/kernel/cpu.c b/arch/x86/kernel/cpu.c index e91872d0..2b99e2fd 100644 --- a/arch/x86/kernel/cpu.c +++ b/arch/x86/kernel/cpu.c @@ -1831,7 +1831,7 @@ mod_nmi_ctx(void *nmi_ctx, void (*func)()) } int arch_cpu_read_write_register( - struct mcctrl_os_cpu_register *desc, + struct ihk_os_cpu_register *desc, enum mcctrl_os_cpu_operation op) { if (op == MCCTRL_OS_CPU_READ_REGISTER) { diff --git a/executer/kernel/mcctrl/control.c b/executer/kernel/mcctrl/control.c index 55af3160..458d2de2 100644 --- a/executer/kernel/mcctrl/control.c +++ b/executer/kernel/mcctrl/control.c @@ -40,7 +40,6 @@ #include #include "../../config.h" #include "mcctrl.h" -#include "mcctrl_public.h" #include //#define DEBUG @@ -1938,6 +1937,7 @@ void mcexec_prepare_ack(ihk_os_t os, unsigned long arg, int err) mcctrl_put_per_proc_data(ppd); } + /* Per-CPU register manipulation functions */ struct mcctrl_os_cpu_response { int done; @@ -1945,21 +1945,15 @@ struct mcctrl_os_cpu_response { wait_queue_head_t wq; }; -int mcctrl_get_request_os_cpu(ihk_os_t *ret_os, int *ret_cpu) +int mcctrl_get_request_os_cpu(ihk_os_t os, int *ret_cpu) { - ihk_os_t os; struct mcctrl_usrdata *usrdata; struct mcctrl_per_proc_data *ppd; struct ikc_scd_packet *packet; struct ihk_ikc_channel_desc *ch; int ret = 0; - /* Look up IHK OS structure - * TODO: iterate all possible indeces, currently only for OS 0 - */ - os = ihk_host_find_os(0, NULL); if (!os) { - printk("%s: ERROR: no OS found for index 0\n", __FUNCTION__); return -EINVAL; } @@ -1987,7 +1981,6 @@ int mcctrl_get_request_os_cpu(ihk_os_t *ret_os, int *ret_cpu) goto out_put_ppd; } - *ret_os = os; /* TODO: define a new IHK query function instead of * accessing internals directly */ ch = (usrdata->channels + packet->ref)->c; @@ -2002,8 +1995,6 @@ out_put_ppd: return ret; } -EXPORT_SYMBOL(mcctrl_get_request_os_cpu); - void mcctrl_os_read_write_cpu_response(ihk_os_t os, struct ikc_scd_packet *pisp) { @@ -2022,7 +2013,7 @@ void mcctrl_os_read_write_cpu_response(ihk_os_t os, } int __mcctrl_os_read_write_cpu_register(ihk_os_t os, int cpu, - struct mcctrl_os_cpu_register *desc, + struct ihk_os_cpu_register *desc, enum mcctrl_os_cpu_operation op) { struct ikc_scd_packet isp; @@ -2057,7 +2048,7 @@ int __mcctrl_os_read_write_cpu_register(ihk_os_t os, int cpu, desc->val = resp.val; } - printk("%s: MCCTRL_OS_CPU_%s_REGISTER: reg: 0x%lx, val: 0x%lx\n", + dprintk("%s: MCCTRL_OS_CPU_%s_REGISTER: reg: 0x%lx, val: 0x%lx\n", __FUNCTION__, (op == MCCTRL_OS_CPU_READ_REGISTER ? "READ" : "WRITE"), desc->addr, desc->val); @@ -2067,20 +2058,16 @@ out: } int mcctrl_os_read_cpu_register(ihk_os_t os, int cpu, - struct mcctrl_os_cpu_register *desc) + struct ihk_os_cpu_register *desc) { return __mcctrl_os_read_write_cpu_register(os, cpu, desc, MCCTRL_OS_CPU_READ_REGISTER); } -EXPORT_SYMBOL(mcctrl_os_read_cpu_register); - int mcctrl_os_write_cpu_register(ihk_os_t os, int cpu, - struct mcctrl_os_cpu_register *desc) + struct ihk_os_cpu_register *desc) { return __mcctrl_os_read_write_cpu_register(os, cpu, desc, MCCTRL_OS_CPU_WRITE_REGISTER); } -EXPORT_SYMBOL(mcctrl_os_write_cpu_register); - diff --git a/executer/kernel/mcctrl/driver.c b/executer/kernel/mcctrl/driver.c index c3d15420..f849e0b6 100644 --- a/executer/kernel/mcctrl/driver.c +++ b/executer/kernel/mcctrl/driver.c @@ -46,6 +46,12 @@ extern void rus_page_hash_put_pages(void); extern void binfmt_mcexec_init(void); extern void binfmt_mcexec_exit(void); +extern int mcctrl_os_read_cpu_register(ihk_os_t os, int cpu, + struct ihk_os_cpu_register *desc); +extern int mcctrl_os_write_cpu_register(ihk_os_t os, int cpu, + struct ihk_os_cpu_register *desc); +extern int mcctrl_get_request_os_cpu(ihk_os_t os, int *cpu); + static long mcctrl_ioctl(ihk_os_t os, unsigned int request, void *priv, unsigned long arg, struct file *file) { @@ -83,6 +89,12 @@ static struct ihk_os_user_call_handler mcctrl_uchs[] = { { .request = IHK_OS_AUX_PERF_DESTROY, .func = mcctrl_ioctl }, }; +static struct ihk_os_kernel_call_handler mcctrl_kernel_handlers = { + .get_request_cpu = mcctrl_get_request_os_cpu, + .read_cpu_register = mcctrl_os_read_cpu_register, + .write_cpu_register = mcctrl_os_write_cpu_register, +}; + static struct ihk_os_user_call mcctrl_uc_proto = { .num_handlers = sizeof(mcctrl_uchs) / sizeof(mcctrl_uchs[0]), .handlers = mcctrl_uchs, @@ -117,12 +129,16 @@ int mcctrl_os_boot_notifier(int os_index) memcpy(mcctrl_uc + os_index, &mcctrl_uc_proto, sizeof mcctrl_uc_proto); + rc = ihk_os_set_kernel_call_handlers(os[os_index], &mcctrl_kernel_handlers); + if (rc < 0) { + printk("mcctrl: error: setting kernel callbacks for OS %d\n", os_index); + goto error_cleanup_channels; + } + rc = ihk_os_register_user_call_handlers(os[os_index], mcctrl_uc + os_index); if (rc < 0) { - destroy_ikc_channels(os[os_index]); printk("mcctrl: error: registering callbacks for OS %d\n", os_index); - - goto error_cleanup_channels; + goto error_clear_kernel_handlers; } procfs_init(os_index); @@ -130,6 +146,8 @@ int mcctrl_os_boot_notifier(int os_index) return 0; +error_clear_kernel_handlers: + ihk_os_clear_kernel_call_handlers(os[os_index]); error_cleanup_channels: destroy_ikc_channels(os[os_index]); @@ -143,6 +161,7 @@ int mcctrl_os_shutdown_notifier(int os_index) sysfsm_cleanup(os[os_index]); free_topology_info(os[os_index]); ihk_os_unregister_user_call_handlers(os[os_index], mcctrl_uc + os_index); + ihk_os_clear_kernel_call_handlers(os[os_index]); destroy_ikc_channels(os[os_index]); procfs_exit(os_index); } diff --git a/executer/kernel/mcctrl/mcctrl.h b/executer/kernel/mcctrl/mcctrl.h index f38acb3c..ee497163 100644 --- a/executer/kernel/mcctrl/mcctrl.h +++ b/executer/kernel/mcctrl/mcctrl.h @@ -44,7 +44,6 @@ #include #include #include "sysfs.h" -#include "mcctrl_public.h" #define SCD_MSG_PREPARE_PROCESS 0x1 #define SCD_MSG_PREPARE_PROCESS_ACKED 0x2 @@ -144,7 +143,7 @@ struct ikc_scd_packet { /* SCD_MSG_CPU_RW_REG */ struct { - struct mcctrl_os_cpu_register desc; + struct ihk_os_cpu_register desc; enum mcctrl_os_cpu_operation op; void *resp; }; diff --git a/executer/kernel/mcctrl/mcctrl_public.h b/executer/kernel/mcctrl/mcctrl_public.h deleted file mode 100644 index 7a5ba71f..00000000 --- a/executer/kernel/mcctrl/mcctrl_public.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __MCCTRL_PUBLIC_H -#define __MCCTRL_PUBLIC_H - -#include -#include - -struct mcctrl_os_cpu_register { - unsigned long addr; - unsigned long val; - unsigned long addr_ext; -}; - -int mcctrl_os_read_cpu_register(ihk_os_t os, int cpu, - struct mcctrl_os_cpu_register *desc); -int mcctrl_os_write_cpu_register(ihk_os_t os, int cpu, - struct mcctrl_os_cpu_register *desc); -int mcctrl_get_request_os_cpu(ihk_os_t *os, int *cpu); - - -#endif // __MCCTRL_PUBLIC_H diff --git a/kernel/host.c b/kernel/host.c index d1e6c6db..75c04a65 100644 --- a/kernel/host.c +++ b/kernel/host.c @@ -652,11 +652,11 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c, pckt.msg = SCD_MSG_CPU_RW_REG_RESP; memcpy(&pckt.desc, &packet->desc, - sizeof(struct mcctrl_os_cpu_register)); + sizeof(struct ihk_os_cpu_register)); pckt.resp = packet->resp; - pckt.err = arch_cpu_read_write_register(&pckt.desc, pckt.op); + pckt.err = arch_cpu_read_write_register(&pckt.desc, packet->op); - ihk_ikc_send(c, &pckt, 0); + ihk_ikc_send(resp_channel, &pckt, 0); break; default: diff --git a/kernel/include/syscall.h b/kernel/include/syscall.h index 8f9a6259..e54bf783 100644 --- a/kernel/include/syscall.h +++ b/kernel/include/syscall.h @@ -213,7 +213,7 @@ struct syscall_request { unsigned long args[6]; }; -struct mcctrl_os_cpu_register { +struct ihk_os_cpu_register { unsigned long addr; unsigned long val; unsigned long addr_ext; @@ -253,7 +253,7 @@ struct ikc_scd_packet { /* SCD_MSG_CPU_RW_REG */ struct { - struct mcctrl_os_cpu_register desc; + struct ihk_os_cpu_register desc; enum mcctrl_os_cpu_operation op; void *resp; }; @@ -434,7 +434,7 @@ int do_shmget(key_t key, size_t size, int shmflg); struct process_vm; int arch_map_vdso(struct process_vm *vm); /* arch dependent */ int arch_setup_vdso(void); -int arch_cpu_read_write_register(struct mcctrl_os_cpu_register *desc, +int arch_cpu_read_write_register(struct ihk_os_cpu_register *desc, enum mcctrl_os_cpu_operation op); #define VDSO_MAXPAGES 2