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

Re: [Xen-devel] [PATCH 11/28] ARM: GICv3: forward pending LPIs to guests



>>> On 02.03.17 at 21:56, <julien.grall@xxxxxxx> wrote:
> Ping? I'd like the question to be sorted out before Andre is sending a 
> new version.
> 
> On 02/15/2017 09:25 PM, Stefano Stabellini wrote:
>> On Wed, 15 Feb 2017, Julien Grall wrote:
>>> Hi Stefano,
>>>
>>> On 14/02/17 21:00, Stefano Stabellini wrote:
>>>> On Mon, 30 Jan 2017, Andre Przywara wrote:
>>>>> +/*
>>>>> + * Handle incoming LPIs, which are a bit special, because they are
>>>>> potentially
>>>>> + * numerous and also only get injected into guests. Treat them specially
>>>>> here,
>>>>> + * by just looking up their target vCPU and virtual LPI number and hand
>>>>> it
>>>>> + * over to the injection function.
>>>>> + */
>>>>> +void do_LPI(unsigned int lpi)
>>>>> +{
>>>>> +    struct domain *d;
>>>>> +    union host_lpi *hlpip, hlpi;
>>>>> +    struct vcpu *vcpu;
>>>>> +
>>>>> +    WRITE_SYSREG32(lpi, ICC_EOIR1_EL1);
>>>>> +
>>>>> +    hlpip = gic_get_host_lpi(lpi);
>>>>> +    if ( !hlpip )
>>>>> +        return;
>>>>> +
>>>>> +    hlpi.data = read_u64_atomic(&hlpip->data);
>>>>> +
>>>>> +    /* We may have mapped more host LPIs than the guest actually asked
>>>>> for. */
>>>>> +    if ( !hlpi.virt_lpi )
>>>>> +        return;
>>>>> +
>>>>> +    d = get_domain_by_id(hlpi.dom_id);
>>>>> +    if ( !d )
>>>>> +        return;
>>>>> +
>>>>> +    if ( hlpi.vcpu_id >= d->max_vcpus )
>>>>> +    {
>>>>> +        put_domain(d);
>>>>> +        return;
>>>>> +    }
>>>>> +
>>>>> +    vcpu = d->vcpu[hlpi.vcpu_id];
>>>>> +
>>>>> +    put_domain(d);
>>>>> +
>>>>> +    vgic_vcpu_inject_irq(vcpu, hlpi.virt_lpi);
>>>>
>>>> put_domain should be here
>>>
>>> Why? I don't even understand why we would need to take a reference on the
>>> domain for LPIs. Would not it be enough to use rcu_lock_domain_by_id here?
>>
>> I think that rcu_lock_domain_by_id would also work, but similarly we
>> would need to call rcu_unlock here.
>>
>> To be honest, I don't know exactly in which cases get_domain should be
>> used instead of rcu_lock_domain_by_id.

Aiui get_domain() is needed when you want to retain the reference
across an operation that may involved blocking/scheduling. The RCU
variant should be sufficient whenever you only need to make sure
the domain won't go away for the duration of (a portion of) a
function, since final domain destruction gets carried out from an
RCU callback.

Jan


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

 


Rackspace

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