3 * Module to be injected into guest kernel to enable
4 * selective system call exiting
6 #include <linux/module.h>
7 #include <linux/kernel.h>
8 #include <linux/slab.h>
11 #include "syscall_decode.h"
13 #define AUTHOR "Kyle C. Hale <kh@u.northwestern.edu>"
14 #define INFO "This kernel module is a paravirtualized module that will"\
15 "reroute system calls to a handler stub. This stub will decide"\
16 "based on a VMM-mapped vector whether or not the particular system call"\
17 "should trap to the VMM."
20 extern void syscall_stub(void);
22 uint64_t * state_save_area;
23 uint8_t * syscall_map;
25 int init_module (void) {
28 state_save_area = kmalloc(sizeof(uint64_t)*(PAGE_SIZE), GFP_KERNEL);
29 if (!state_save_area){
30 printk("Problem allocating sate save area\n");
33 memset(state_save_area, 0, sizeof(uint64_t)*(PAGE_SIZE));
35 syscall_map = kmalloc(NUM_SYSCALLS, GFP_KERNEL);
37 printk("Problem allocating syscall map\n");
40 memset(syscall_map, 0, NUM_SYSCALLS);
42 // vmm will return -1 on error, address of syscall_entry on success
43 asm volatile ("vmmcall"
45 : "0" (SYSCALL_SETUP_HCALL), "b" (syscall_stub), "c" (syscall_map),
46 "d" (state_save_area));
49 printk("syscall_decode: problem initing selective syscall exiting\n");
52 state_save_area[NUM_SAVE_REGS] = ret;
55 printk("syscall_decode: inited\n");
60 void cleanup_module (void) {
62 kfree(state_save_area);
64 /* tell Palacios to restore the original system call entry point */
65 asm volatile ("vmmcall"
67 : "0"(SYSCALL_CLEANUP_HCALL));
69 printk("syscall_decode: problem deiniting selective syscall exiting\n");
72 printk("syscall_page: deinited\n");
75 MODULE_LICENSE("GPL");
76 MODULE_AUTHOR(AUTHOR);
77 MODULE_VERSION("0.2");
78 MODULE_DESCRIPTION(INFO);