* [PATCH] irqchip/gic-v4.1: Ensure accessing the correct RD when writing INVALLR
@ 2020-07-09 13:49 Zenghui Yu
2020-07-17 11:07 ` Marc Zyngier
0 siblings, 1 reply; 4+ messages in thread
From: Zenghui Yu @ 2020-07-09 13:49 UTC (permalink / raw)
To: linux-kernel, maz; +Cc: tglx, jason, wanghaibin.wang, Zenghui Yu
The GICv4.1 spec tells us that it's CONSTRAINED UNPREDICTABLE to issue a
register-based invalidation operation for a vPEID not mapped to that RD,
or another RD within the same CommonLPIAff group.
To follow this rule, commit f3a059219bc7 ("irqchip/gic-v4.1: Ensure mutual
exclusion between vPE affinity change and RD access") tried to address the
race between the RD accesses and the vPE affinity change, but somehow
forgot to take GICR_INVALLR into account. Let's take the vpe_lock before
evaluating vpe->col_idx to fix it.
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
---
drivers/irqchip/irq-gic-v3-its.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index da44bfa48bc2..50a04cca8207 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -4087,18 +4087,22 @@ static void its_vpe_4_1_deschedule(struct its_vpe *vpe,
static void its_vpe_4_1_invall(struct its_vpe *vpe)
{
void __iomem *rdbase;
+ unsigned long flags;
u64 val;
+ int cpu;
val = GICR_INVALLR_V;
val |= FIELD_PREP(GICR_INVALLR_VPEID, vpe->vpe_id);
/* Target the redistributor this vPE is currently known on */
- raw_spin_lock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
- rdbase = per_cpu_ptr(gic_rdists->rdist, vpe->col_idx)->rd_base;
+ cpu = vpe_to_cpuid_lock(vpe, &flags);
+ raw_spin_lock(&gic_data_rdist_cpu(cpu)->rd_lock);
+ rdbase = per_cpu_ptr(gic_rdists->rdist, cpu)->rd_base;
gic_write_lpir(val, rdbase + GICR_INVALLR);
wait_for_syncr(rdbase);
- raw_spin_unlock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
+ raw_spin_unlock(&gic_data_rdist_cpu(cpu)->rd_lock);
+ vpe_to_cpuid_unlock(vpe, flags);
}
static int its_vpe_4_1_set_vcpu_affinity(struct irq_data *d, void *vcpu_info)
--
2.19.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] irqchip/gic-v4.1: Ensure accessing the correct RD when writing INVALLR
2020-07-09 13:49 [PATCH] irqchip/gic-v4.1: Ensure accessing the correct RD when writing INVALLR Zenghui Yu
@ 2020-07-17 11:07 ` Marc Zyngier
2020-07-20 2:27 ` Zenghui Yu
0 siblings, 1 reply; 4+ messages in thread
From: Marc Zyngier @ 2020-07-17 11:07 UTC (permalink / raw)
To: Zenghui Yu; +Cc: linux-kernel, tglx, jason, wanghaibin.wang
On Thu, 09 Jul 2020 14:49:59 +0100,
Zenghui Yu <yuzenghui@huawei.com> wrote:
>
> The GICv4.1 spec tells us that it's CONSTRAINED UNPREDICTABLE to issue a
> register-based invalidation operation for a vPEID not mapped to that RD,
> or another RD within the same CommonLPIAff group.
>
> To follow this rule, commit f3a059219bc7 ("irqchip/gic-v4.1: Ensure mutual
> exclusion between vPE affinity change and RD access") tried to address the
> race between the RD accesses and the vPE affinity change, but somehow
> forgot to take GICR_INVALLR into account. Let's take the vpe_lock before
> evaluating vpe->col_idx to fix it.
>
> Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
Shouldn't this deserve a Fixes: tag?
Thanks,
M.
> ---
> drivers/irqchip/irq-gic-v3-its.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> index da44bfa48bc2..50a04cca8207 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -4087,18 +4087,22 @@ static void its_vpe_4_1_deschedule(struct its_vpe *vpe,
> static void its_vpe_4_1_invall(struct its_vpe *vpe)
> {
> void __iomem *rdbase;
> + unsigned long flags;
> u64 val;
> + int cpu;
>
> val = GICR_INVALLR_V;
> val |= FIELD_PREP(GICR_INVALLR_VPEID, vpe->vpe_id);
>
> /* Target the redistributor this vPE is currently known on */
> - raw_spin_lock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
> - rdbase = per_cpu_ptr(gic_rdists->rdist, vpe->col_idx)->rd_base;
> + cpu = vpe_to_cpuid_lock(vpe, &flags);
> + raw_spin_lock(&gic_data_rdist_cpu(cpu)->rd_lock);
> + rdbase = per_cpu_ptr(gic_rdists->rdist, cpu)->rd_base;
> gic_write_lpir(val, rdbase + GICR_INVALLR);
>
> wait_for_syncr(rdbase);
> - raw_spin_unlock(&gic_data_rdist_cpu(vpe->col_idx)->rd_lock);
> + raw_spin_unlock(&gic_data_rdist_cpu(cpu)->rd_lock);
> + vpe_to_cpuid_unlock(vpe, flags);
> }
>
> static int its_vpe_4_1_set_vcpu_affinity(struct irq_data *d, void *vcpu_info)
> --
> 2.19.1
>
>
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] irqchip/gic-v4.1: Ensure accessing the correct RD when writing INVALLR
2020-07-17 11:07 ` Marc Zyngier
@ 2020-07-20 2:27 ` Zenghui Yu
2020-07-20 7:41 ` Marc Zyngier
0 siblings, 1 reply; 4+ messages in thread
From: Zenghui Yu @ 2020-07-20 2:27 UTC (permalink / raw)
To: Marc Zyngier; +Cc: linux-kernel, tglx, jason, wanghaibin.wang
Hi Marc,
On 2020/7/17 19:07, Marc Zyngier wrote:
> On Thu, 09 Jul 2020 14:49:59 +0100,
> Zenghui Yu <yuzenghui@huawei.com> wrote:
>>
>> The GICv4.1 spec tells us that it's CONSTRAINED UNPREDICTABLE to issue a
>> register-based invalidation operation for a vPEID not mapped to that RD,
>> or another RD within the same CommonLPIAff group.
>>
>> To follow this rule, commit f3a059219bc7 ("irqchip/gic-v4.1: Ensure mutual
>> exclusion between vPE affinity change and RD access") tried to address the
>> race between the RD accesses and the vPE affinity change, but somehow
>> forgot to take GICR_INVALLR into account. Let's take the vpe_lock before
>> evaluating vpe->col_idx to fix it.
>>
>> Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
>
> Shouldn't this deserve a Fixes: tag?
Yes, I think a
Fixes: f3a059219bc7 ("irqchip/gic-v4.1: Ensure mutual exclusion between
vPE affinity change and RD access")
should be enough. Should I resend a version with the tag added?
Thanks,
Zenghui
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] irqchip/gic-v4.1: Ensure accessing the correct RD when writing INVALLR
2020-07-20 2:27 ` Zenghui Yu
@ 2020-07-20 7:41 ` Marc Zyngier
0 siblings, 0 replies; 4+ messages in thread
From: Marc Zyngier @ 2020-07-20 7:41 UTC (permalink / raw)
To: Zenghui Yu; +Cc: linux-kernel, tglx, jason, wanghaibin.wang
Hi Zenghui,
On 2020-07-20 03:27, Zenghui Yu wrote:
> Hi Marc,
>
> On 2020/7/17 19:07, Marc Zyngier wrote:
>> On Thu, 09 Jul 2020 14:49:59 +0100,
>> Zenghui Yu <yuzenghui@huawei.com> wrote:
>>>
>>> The GICv4.1 spec tells us that it's CONSTRAINED UNPREDICTABLE to
>>> issue a
>>> register-based invalidation operation for a vPEID not mapped to that
>>> RD,
>>> or another RD within the same CommonLPIAff group.
>>>
>>> To follow this rule, commit f3a059219bc7 ("irqchip/gic-v4.1: Ensure
>>> mutual
>>> exclusion between vPE affinity change and RD access") tried to
>>> address the
>>> race between the RD accesses and the vPE affinity change, but somehow
>>> forgot to take GICR_INVALLR into account. Let's take the vpe_lock
>>> before
>>> evaluating vpe->col_idx to fix it.
>>>
>>> Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
>>
>> Shouldn't this deserve a Fixes: tag?
>
> Yes, I think a
>
> Fixes: f3a059219bc7 ("irqchip/gic-v4.1: Ensure mutual exclusion
> between vPE affinity change and RD access")
>
> should be enough. Should I resend a version with the tag added?
Yes, please, together with a Cc: stable@vger.kernel.org, as the
original patch is in 5.7 and I intend to take it via the 5.9
branch.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-07-20 7:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 13:49 [PATCH] irqchip/gic-v4.1: Ensure accessing the correct RD when writing INVALLR Zenghui Yu
2020-07-17 11:07 ` Marc Zyngier
2020-07-20 2:27 ` Zenghui Yu
2020-07-20 7:41 ` Marc Zyngier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.