mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-14 17:35:42 +00:00
lguest: add infrastructure for userspace to deliver a trap to the guest.
This is required for instruction emulation to move to userspace. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
69a09dc174
commit
8ed313001a
@ -243,6 +243,23 @@ static int user_send_irq(struct lg_cpu *cpu, const unsigned long __user *input)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*L:053
|
||||||
|
* Deliver a trap: this is used by the Launcher if it can't emulate
|
||||||
|
* an instruction.
|
||||||
|
*/
|
||||||
|
static int trap(struct lg_cpu *cpu, const unsigned long __user *input)
|
||||||
|
{
|
||||||
|
unsigned long trapnum;
|
||||||
|
|
||||||
|
if (get_user(trapnum, input) != 0)
|
||||||
|
return -EFAULT;
|
||||||
|
|
||||||
|
if (!deliver_trap(cpu, trapnum))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*L:040
|
/*L:040
|
||||||
* Once our Guest is initialized, the Launcher makes it run by reading
|
* Once our Guest is initialized, the Launcher makes it run by reading
|
||||||
* from /dev/lguest.
|
* from /dev/lguest.
|
||||||
@ -487,6 +504,8 @@ static ssize_t write(struct file *file, const char __user *in,
|
|||||||
return getreg_setup(cpu, input);
|
return getreg_setup(cpu, input);
|
||||||
case LHREQ_SETREG:
|
case LHREQ_SETREG:
|
||||||
return setreg(cpu, input);
|
return setreg(cpu, input);
|
||||||
|
case LHREQ_TRAP:
|
||||||
|
return trap(cpu, input);
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ enum lguest_req
|
|||||||
LHREQ_EVENTFD, /* + address, fd. */
|
LHREQ_EVENTFD, /* + address, fd. */
|
||||||
LHREQ_GETREG, /* + offset within struct pt_regs (then read value). */
|
LHREQ_GETREG, /* + offset within struct pt_regs (then read value). */
|
||||||
LHREQ_SETREG, /* + offset within struct pt_regs, value. */
|
LHREQ_SETREG, /* + offset within struct pt_regs, value. */
|
||||||
|
LHREQ_TRAP, /* + trap number to deliver to guest. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user