12 #include <linux/sched.h>
15 #include <linux/slab.h>
16 #include <linux/export.h>
54 for (i = 0; i < map->
num; i++) {
90 static int add_eventfd(
struct lguest *lg,
unsigned long addr,
int fd)
105 new =
kmalloc(
sizeof(*
new) +
sizeof(new->map[0]) * (old->
num + 1),
115 new->map[
new->num].addr =
addr;
117 if (IS_ERR(new->map[new->num].event)) {
118 int err = PTR_ERR(new->map[new->num].event);
153 static int attach_eventfd(
struct lguest *lg,
const unsigned long __user *
input)
170 err = add_eventfd(lg, addr, fd);
180 static int user_send_irq(
struct lg_cpu *
cpu,
const unsigned long __user *input)
226 if (IS_ERR(lg->
dead))
227 return PTR_ERR(lg->
dead);
244 return run_guest(cpu, (
unsigned long __user *)user);
251 static int lg_cpu_start(
struct lg_cpu *cpu,
unsigned id,
unsigned long start_ip)
317 static int initialize(
struct file *file,
const unsigned long __user *input)
322 unsigned long args[3];
358 err = lg_cpu_start(&lg->
cpus[0], 0, args[2]);
402 size_t size, loff_t *off)
409 const unsigned long __user *input = (
const unsigned long __user *)in;
412 unsigned int cpu_id = *off;
421 if (!lg || (cpu_id >= lg->
nr_cpus))
434 return user_send_irq(cpu, input);
436 return attach_eventfd(lg, input);
451 static int close(
struct inode *
inode,
struct file *file)
469 for (i = 0; i < lg->
nr_cpus; i++) {
482 for (i = 0; i < lg->
eventfds->num; i++)
490 if (!IS_ERR(lg->
dead))
531 .fops = &lguest_fops,