From: Kyle Hale Date: Tue, 29 May 2012 18:19:07 +0000 (-0500) Subject: Added host interface for selective system call exiting utility X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=c64dbfd9f9f0cd80a659c82b52d73918aa975d53;p=palacios.releases.git Added host interface for selective system call exiting utility --- diff --git a/linux_module/Makefile b/linux_module/Makefile index b2e73df..98416cb 100644 --- a/linux_module/Makefile +++ b/linux_module/Makefile @@ -40,6 +40,8 @@ v3vee-$(V3_CONFIG_VNET) += palacios-vnet.o \ v3vee-$(V3_CONFIG_HOST_HYPERCALL) += iface-host-hypercall.o v3vee-$(V3_CONFIG_EXT_CODE_INJECT) += iface-code-inject.o v3vee-$(V3_CONFIG_EXT_ENV_INJECT) += iface-env-inject.o +v3vee-$(V3_CONFIG_EXT_SELECTIVE_SYSCALL_EXIT) += iface-syscall.o + v3vee-objs := $(v3vee-y) ../libv3vee.a obj-m := v3vee.o diff --git a/linux_module/iface-syscall.c b/linux_module/iface-syscall.c new file mode 100644 index 0000000..0ed6231 --- /dev/null +++ b/linux_module/iface-syscall.c @@ -0,0 +1,94 @@ +/* + * Linux interface for control of the fast system call + * exiting utility + * + * (c) Kyle C. Hale 2012 + * + */ + +#include +#include + +#include + +#include "palacios.h" +#include "vm.h" +#include "linux-exts.h" + +#include "iface-syscall.h" + + +static int vm_syscall_ctrl (struct v3_guest * guest, unsigned int cmd, unsigned long arg, void * priv_data) { + struct v3_syscall_cmd syscall_cmd; + int ret; + + if (copy_from_user(&syscall_cmd, (void __user *)arg, sizeof(struct v3_syscall_cmd))) { + printk("Palacios: error copying syscall command from userspace\n"); + return -EFAULT; + } + + switch (syscall_cmd.cmd) { + + case SYSCALL_OFF: { + ret = v3_syscall_off(guest->v3_ctx, syscall_cmd.syscall_nr); + if (ret < 0) { + printk("Palacios: error deactivating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr); + } + break; + } + case SYSCALL_ON: { + ret = v3_syscall_on(guest->v3_ctx, syscall_cmd.syscall_nr); + if (ret < 0) { + printk("Palacios: error activating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr); + } + break; + } + case SYSCALL_STAT: { + ret = v3_syscall_stat(guest->v3_ctx, syscall_cmd.syscall_nr); + if (ret == SYSCALL_OFF) + printk("Palacios: exiting for syscall #%d is OFF\n", syscall_cmd.syscall_nr); + else if (ret == SYSCALL_ON) + printk("Palacios: exiting for syscall #%d is ON\n", syscall_cmd.syscall_nr); + else + printk("Palacios: error stating syscall nr: %d\n", syscall_cmd.syscall_nr); + break; + } + default: + printk("Palacios: error - invalid syscall command\n"); + return -1; + } + + return ret; +} + + +static int init_syscall_ctrl (void) { + return 0; +} + + +static int deinit_syscall_ctrl (void) { + return 0; +} + + +static int guest_init_syscall_ctrl (struct v3_guest * guest, void ** vm_data) { + add_guest_ctrl(guest, V3_VM_SYSCALL_CTRL, vm_syscall_ctrl, NULL); + return 0; +} + + +static int guest_deinit_syscall_ctrl (struct v3_guest * guest, void * vm_data) { + return 0; +} + + +static struct linux_ext syscall_ctrl_ext = { + .name = "SYSCALL_CTRL", + .init = init_syscall_ctrl, + .deinit = deinit_syscall_ctrl, + .guest_init = guest_init_syscall_ctrl, + .guest_deinit = guest_deinit_syscall_ctrl +}; + +register_extension(&syscall_ctrl_ext); diff --git a/linux_module/iface-syscall.h b/linux_module/iface-syscall.h new file mode 100644 index 0000000..8118235 --- /dev/null +++ b/linux_module/iface-syscall.h @@ -0,0 +1,16 @@ +#ifndef __IFACE_SYSCALL_H__ +#define __IFACE_SYSCALL_H__ + +#define SYSCALL_OFF 0 +#define SYSCALL_ON 1 +#define SYSCALL_STAT 2 + +#define V3_VM_SYSCALL_CTRL 0x5CA11 + +struct v3_syscall_cmd { + int cmd; + int syscall_nr; +}; + + +#endif diff --git a/linux_module/ioctls.txt b/linux_module/ioctls.txt index 322dd5a..661a2fe 100644 --- a/linux_module/ioctls.txt +++ b/linux_module/ioctls.txt @@ -30,3 +30,4 @@ VM Commands (/dev/v3-vm*) 13125 -- (EXT) Inject Environment Variables into Guest Process +5CA11 -- (EXT) Get/Set System call exiting status