On 30.09.2019 15:32, Roger Pau Monne wrote:
> --- a/xen/arch/x86/hvm/ioreq.c
> +++ b/xen/arch/x86/hvm/ioreq.c
> @@ -485,6 +485,38 @@ static int hvm_add_ioreq_gfn(struct hvm_ioreq_server *s, 
> bool buf)
>      return rc;
>  }
>  
> +int hvm_set_ioreq_handler(struct domain *d, ioservid_t id,
> +                          int (*handler)(ioreq_t *, void *),
> +                          void *data)
> +{
> +    struct hvm_ioreq_server *s;
> +    int rc = 0;
> +
> +    if ( !hvm_ioreq_is_internal(id) )
> +        return -EINVAL;

Isn't BUG_ON() more applicable here?

> +    spin_lock_recursive(&d->arch.hvm.ioreq_server.lock);
> +    s = get_ioreq_server(d, id);
> +    if ( !s )
> +    {
> +        rc = -ENOENT;
> +        goto out;
> +    }
> +    if ( s->enabled )
> +    {
> +        rc = -EBUSY;
> +        goto out;
> +    }
> +
> +    s->handler = handler;
> +    s->data = data;

Is it really intended to blindly replace a disabled handler?
Wouldn't the s->enabled check better be evaluating s->handler?

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to