2 * Linux interface for control of the fast system call
5 * (c) Kyle C. Hale 2012
9 #include <linux/uaccess.h>
10 #include <linux/module.h>
12 #include <gears/syscall_hijack.h>
16 #include "linux-exts.h"
18 #include "iface-syscall.h"
21 static int vm_syscall_ctrl (struct v3_guest * guest, unsigned int cmd, unsigned long arg, void * priv_data) {
22 struct v3_syscall_cmd syscall_cmd;
25 if (copy_from_user(&syscall_cmd, (void __user *)arg, sizeof(struct v3_syscall_cmd))) {
26 ERROR("palacios: error copying syscall command from userspace\n");
30 switch (syscall_cmd.cmd) {
33 ret = v3_syscall_off(guest->v3_ctx, syscall_cmd.syscall_nr);
35 ERROR("palacios: error deactivating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr);
40 ret = v3_syscall_on(guest->v3_ctx, syscall_cmd.syscall_nr);
42 ERROR("palacios: error activating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr);
47 ret = v3_syscall_stat(guest->v3_ctx, syscall_cmd.syscall_nr);
48 if (ret == SYSCALL_OFF)
49 INFO("palacios: exiting for syscall #%d is OFF\n", syscall_cmd.syscall_nr);
50 else if (ret == SYSCALL_ON)
51 INFO("palacios: exiting for syscall #%d is ON\n", syscall_cmd.syscall_nr);
53 INFO("palacios: error stating syscall nr: %d\n", syscall_cmd.syscall_nr);
57 ERROR("palacios: error - invalid syscall command\n");
65 static int init_syscall_ctrl (void) {
70 static int deinit_syscall_ctrl (void) {
75 static int guest_init_syscall_ctrl (struct v3_guest * guest, void ** vm_data) {
76 add_guest_ctrl(guest, V3_VM_SYSCALL_CTRL, vm_syscall_ctrl, NULL);
81 static int guest_deinit_syscall_ctrl (struct v3_guest * guest, void * vm_data) {
86 static struct linux_ext syscall_ctrl_ext = {
87 .name = "SYSCALL_CTRL",
88 .init = init_syscall_ctrl,
89 .deinit = deinit_syscall_ctrl,
90 .guest_init = guest_init_syscall_ctrl,
91 .guest_deinit = guest_deinit_syscall_ctrl
94 register_extension(&syscall_ctrl_ext);