On Thu, Sep 03, 2020 at 08:41:51PM +0800, [email protected] wrote:
> From: Shuo Liu <[email protected]>
> 
> A virtual CPU of User VM has different context due to the different
> registers state. ACRN userspace needs to set the virtual CPU
> registers state (e.g. giving a initial registers state to a virtual
> BSP of a User VM).
> 
> HSM provides an ioctl ACRN_IOCTL_SET_VCPU_REGS to do the virtual CPU
> registers state setting. The ioctl passes the registers state from ACRN
> userspace to the hypervisor directly.
> 
> Signed-off-by: Shuo Liu <[email protected]>
> Reviewed-by: Zhi Wang <[email protected]>
> Reviewed-by: Reinette Chatre <[email protected]>
> Cc: Zhi Wang <[email protected]>
> Cc: Zhenyu Wang <[email protected]>
> Cc: Yu Wang <[email protected]>
> Cc: Reinette Chatre <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> ---
>  drivers/virt/acrn/hsm.c       | 14 +++++++
>  drivers/virt/acrn/hypercall.h | 13 +++++++
>  include/uapi/linux/acrn.h     | 71 +++++++++++++++++++++++++++++++++++
>  3 files changed, 98 insertions(+)
> 
> diff --git a/drivers/virt/acrn/hsm.c b/drivers/virt/acrn/hsm.c
> index 6ec6aa9053d3..13df76d0206e 100644
> --- a/drivers/virt/acrn/hsm.c
> +++ b/drivers/virt/acrn/hsm.c
> @@ -12,6 +12,7 @@
>  #define pr_fmt(fmt) "acrn: " fmt
>  #define dev_fmt(fmt) "acrn: " fmt
>  
> +#include <linux/io.h>
>  #include <linux/miscdevice.h>
>  #include <linux/mm.h>
>  #include <linux/module.h>
> @@ -49,6 +50,7 @@ static long acrn_dev_ioctl(struct file *filp, unsigned int 
> cmd,
>  {
>       struct acrn_vm *vm = filp->private_data;
>       struct acrn_vm_creation *vm_param;
> +     struct acrn_vcpu_regs *cpu_regs;
>       int ret = 0;
>  
>       if (vm->vmid == ACRN_INVALID_VMID && cmd != ACRN_IOCTL_CREATE_VM) {
> @@ -96,6 +98,18 @@ static long acrn_dev_ioctl(struct file *filp, unsigned int 
> cmd,
>       case ACRN_IOCTL_DESTROY_VM:
>               ret = acrn_vm_destroy(vm);
>               break;
> +     case ACRN_IOCTL_SET_VCPU_REGS:
> +             cpu_regs = memdup_user((void __user *)ioctl_param,
> +                                    sizeof(struct acrn_vcpu_regs));
> +             if (IS_ERR(cpu_regs))
> +                     return PTR_ERR(cpu_regs);
> +
> +             ret = hcall_set_vcpu_regs(vm->vmid, virt_to_phys(cpu_regs));

No sanity checking of any arguments?

Wow, fuzzers are going to have a fun time with your hypervisor, good
luck!  :)

Reply via email to