From: Kyle Hale Date: Tue, 29 May 2012 18:20:38 +0000 (-0500) Subject: Added user-space utilities for controlling the selective syscall exiting utility X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=f82905971510d5b2f1e2155f89711ade381de628;p=palacios.releases.git Added user-space utilities for controlling the selective syscall exiting utility --- diff --git a/linux_usr/Makefile b/linux_usr/Makefile index f69af46..232ee09 100644 --- a/linux_usr/Makefile +++ b/linux_usr/Makefile @@ -40,7 +40,8 @@ EXAMPLE_EXECS = v3_user_host_dev_example \ EXPERIMENTAL_EXECS = v3_simulate \ v3_inject_ecc_scrubber_mce \ v3_top_inject \ - v3_env_inject + v3_env_inject \ + v3_syscall diff --git a/linux_usr/v3_syscall.c b/linux_usr/v3_syscall.c new file mode 100644 index 0000000..5127219 --- /dev/null +++ b/linux_usr/v3_syscall.c @@ -0,0 +1,85 @@ +/* + * V3 Selective System Call Exiting Control + * (c) Kyle C. Hale, 2012 + * + */ + + +#include +#include +#include +#include +#include +#include +#include + +#include "iface-syscall.h" + +#define CMD_MAX 10 +#define SYSCALL_MAX 256 + +static void usage () { + fprintf(stderr, "\nUsage: v3_syscall \n"); + exit(0); +} + + +int main (int argc, char * argv[]) { + + int vm_fd, ret, syscall_nr; + char * vm_dev = NULL; + struct v3_syscall_cmd syscall_cmd; + + if (argc < 4 || argc > 4) { + fprintf(stderr, "Invalid number of arguments.\n"); + usage(); + } + + vm_dev = argv[1]; + syscall_nr = strtol(argv[2], NULL, 0); + + if (strncmp(argv[3], "on", CMD_MAX) == 0) { + syscall_cmd.cmd = SYSCALL_ON; + } else if (strncmp(argv[3], "off", CMD_MAX) == 0) { + syscall_cmd.cmd = SYSCALL_OFF; + } else if (strncmp(argv[3], "status", CMD_MAX) == 0) { + syscall_cmd.cmd = SYSCALL_STAT; + } else { + fprintf(stderr, "Invalid command.\n"); + usage(); + } + + if (syscall_nr < 0 || syscall_nr > SYSCALL_MAX) { + fprintf(stderr, "Invalid syscall number.\n"); + return -1; + } + + syscall_cmd.syscall_nr = syscall_nr; + + vm_fd = open(vm_dev, O_RDONLY); + + if (vm_fd < 0) { + fprintf(stderr, "Error opening VM device: %s\n", vm_dev); + return -1; + } + + ret = ioctl(vm_fd, V3_VM_SYSCALL_CTRL, &syscall_cmd); + + if (ret < 0) { + fprintf(stderr, "Error with syscall control\n"); + return -1; + } + + if (syscall_cmd.cmd == SYSCALL_STAT) { + if (ret == SYSCALL_ON) + printf("Selective exiting for syscall #%d is currently ON\n", syscall_cmd.syscall_nr); + else if (ret == SYSCALL_OFF) + printf("Selective exiting for syscall #%d is currently OFF\n", syscall_cmd.syscall_nr); + } else if (syscall_cmd.cmd == SYSCALL_ON) { + printf("Selective exiting for syscall #%d ACTIVATED\n", syscall_cmd.syscall_nr); + } else if (syscall_cmd.cmd == SYSCALL_OFF) { + printf("Selective exiting for syscall #%d DEACTIVATED\n", syscall_cmd.syscall_nr); + } + + return 0; +}