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

Re: [PATCH] x86/irq: Skip unmap_domain_pirq XSM during destruction


  • To: Jason Andryuk <jandryuk@xxxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 5 Apr 2022 10:18:09 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k7qlTFmxRuPfZaRPWud7AGTUFLNRrBgyDK50q6nKywY=; b=Dvb6XD7yPruZ/2Zt5mbx8vSV3OyrBF1S2UukiUTIm7BDjcJehcZd7wxgvur/0dG5grRIFy72zMq4h7HHVxEnvZ5ojU1xmpg4ESnidcY00Fa53wt8FDmf6veZN5jwFoeDyTSF6TPHD7ofRtfBMxDr4Q0F6ILquHg3cA4FerdLuikAEznATCagyW332rZWIzCYW+Y/VMC8KgNsGQj3UDQJlxCrkEE2X8tG16mwGK2//61wjSK65xmv5GDvqkE/8/JM9qGAf13N01OMvck+2rGH1J04OHJb675s2UYeL+oEeoWqPShIJbJiQGwRrylhfYq+vrFUH+Y4DxWSE3zPJjV9uw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CR7RrGZZKQWrPp3REe8iHygHYbZM1f1AtyyAl+z1Qpxf1yAxH201aOhYXzyHtHm2ClwhdDcLl/JWwJ0gvC7vUI957lEl9WH5yg6w4LJGrKd8XGzSmTNxSsKmPhnx2KxGObFqN8kRR0jvY36xrgJoenrvGTJtUkowVJIJ75MO0rH3SjNACw5QKn8mYju5YT1pXP6JSiCqT/oCPxAB/yE20qw8idPTqKCMpd9AKxZnxmbKJR2Mjra4oF5yWoLMoVk2euPmsooNr+0tlsJXBYr9h/XrH/nXgAfwRmJSFSlqWowaKs3E5sPSJfMu1A8sDPOoBNYloYLZ50EZ9isBbJ+KGA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 05 Apr 2022 08:18:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 30.03.2022 20:17, Jason Andryuk wrote:
> xsm_unmap_domain_irq was seen denying unmap_domain_pirq when called from
> complete_domain_destroy as an RCU callback.  The source context was an
> unexpected, random domain.  Since this is a xen-internal operation,
> we don't want the XSM hook denying the operation.
> 
> Check d->is_dying and skip the check when the domain is dead.  The RCU
> callback runs when a domain is in that state.

One question which has always been puzzling me (perhaps to Daniel): While
I can see why mapping of an IRQ needs to be subject to an XSM check, it's
not really clear to me why unmapping would need to be, at least as long
as it's the domain itself which requests the unmap (and which I would
view to extend to the domain being cleaned up). But maybe that's why it's
XSM_HOOK ...

> ---
> Dan wants to change current to point at DOMID_IDLE when the RCU callback
> runs.  I think Juergen's commit 53594c7bd197 "rcu: don't use
> stop_machine_run() for rcu_barrier()" may have changed this since it
> mentions stop_machine_run scheduled the idle vcpus to run the callbacks
> for the old code.
> 
> Would that be as easy as changing rcu_do_batch() to do:
> 
> +        /* Run as "Xen" not a random domain's vcpu. */
> +        vcpu = get_current();
> +        set_current(idle_vcpu[smp_processor_id()]);
>          list->func(list);
> +        set_current(vcpu);
> 
> or is using set_current() only acceptable as part of context_switch?

Indeed I would question any uses outside of context_switch() (and
system bringup).

> --- a/xen/arch/x86/irq.c
> +++ b/xen/arch/x86/irq.c
> @@ -2340,10 +2340,14 @@ int unmap_domain_pirq(struct domain *d, int pirq)
>          nr = msi_desc->msi.nvec;
>      }
>  
> -    ret = xsm_unmap_domain_irq(XSM_HOOK, d, irq,
> -                               msi_desc ? msi_desc->dev : NULL);
> -    if ( ret )
> -        goto done;
> +    /* When called by complete_domain_destroy via RCU, current is a random
> +     * domain.  Skip the XSM check since this is a Xen-initiated action. */

Comment style.

> +    if ( d->is_dying != DOMDYING_dead ) {

Please use !d->is_dying. Also please correct the placement of the brace.
Or you could avoid the need for a brace by leveraging that ret is zero
ahead of this if(), i.e. ...

> +        ret = xsm_unmap_domain_irq(XSM_HOOK, d, irq,
> +                                   msi_desc ? msi_desc->dev : NULL);
> +        if ( ret )
> +            goto done;
> +    }


    if ( !d->is_dying )
        ret = xsm_unmap_domain_irq(XSM_HOOK, d, irq,
                                   msi_desc ? msi_desc->dev : NULL);
    if ( ret )
        goto done;

Jan




 


Rackspace

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