[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH V6 11/13] xen/vm_event: Relocate memop checks



Hi,

At 01:11 +0100 on 18 Feb (1424218301), Tamas K Lengyel wrote:
> -int mem_paging_memop(struct domain *d, xen_mem_paging_op_t *mpo)
> +int mem_paging_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_paging_op_t) arg)
>  {
> -    int rc = -ENODEV;
> -    if ( unlikely(!d->vm_event->paging.ring_page) )
> +    int rc;
> +    xen_mem_paging_op_t mpo;
> +    struct domain *d;
> +    bool_t copyback = 0;
> +
> +    rc = -EFAULT;
> +    if ( copy_from_guest(&mpo, arg, 1) )
>          return rc;

ISTR Jan suggested that you just 'return -EFAULT' here since you won't
be reusing the rc.

> -    switch( mpo->op )
> +    rc = rcu_lock_live_remote_domain_by_id(mpo.domain, &d);
> +    if ( rc )
> +        goto out;

This one should be a return too; you only need the goto out if this
succeeded.

> +    rc = xsm_vm_event_op(XSM_DM_PRIV, d, XENMEM_paging_op);
> +    if ( rc )
> +        goto out;
> +
> +    rc = -ENODEV;
> +    if ( unlikely(!d->vm_event->paging.ring_page) )
> +        goto out;
> +
> +    switch( mpo.op )
>      {
>      case XENMEM_paging_op_nominate:
> -        rc = p2m_mem_paging_nominate(d, mpo->gfn);
> +        rc = p2m_mem_paging_nominate(d, mpo.gfn);
>          break;
>  
>      case XENMEM_paging_op_evict:
> -        rc = p2m_mem_paging_evict(d, mpo->gfn);
> +        rc = p2m_mem_paging_evict(d, mpo.gfn);
>          break;
>  
>      case XENMEM_paging_op_prep:
> -        rc = p2m_mem_paging_prep(d, mpo->gfn, mpo->buffer);
> +    {

I don't think these braces are needed.

[...]
>      /* Only HAP is supported */
> +    rc = -ENODEV;
>      if ( !hap_enabled(d) || !d->arch.hvm_domain.mem_sharing_enabled )
> -         return -ENODEV;
> +         rc = -ENODEV;
>

You need a 'goto out' here, or the rc gets overwritten immediately.

Cheers,

Tim.

> -    switch(mec->op)
> +    rc = xsm_vm_event_op(XSM_DM_PRIV, d, XENMEM_sharing_op);
> +    if ( rc )
> +        goto out;


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.