From: caijian caijian11@h-partners.com
Patch#1 Fix VSYNC referencing an unmapped VPE on GIC v4.1 Patch#2 Fix VSYNC referencing an unmapped VPE on GIC v4.0
Nianyao Tang (1): irqchip/gic-v3-its: Fix VSYNC referencing an unmapped VPE on GIC v4.1
Zhou Wang (1): irqchip/gic-v3-its: Fix VSYNC referencing an unmapped VPE on GIC v4.0
drivers/irqchip/irq-gic-v3-its.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
From: Nianyao Tang tangnianyao@huawei.com
mainline inclusion from mainline-v6.9-rc4 commit 80e9963fb3b5509dfcabe9652d56bf4b35542055 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IARQ2V
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
---------------------------------------------------------------------------
As per the GICv4.1 spec (Arm IHI 0069H, 5.3.19):
"A VMAPP with {V, Alloc}=={0, x} is self-synchronizing, This means the ITS command queue does not show the command as consumed until all of its effects are completed."
Furthermore, VSYNC is allowed to deliver an SError when referencing a non existent VPE.
By these definitions, a VMAPP followed by a VSYNC is a bug, as the later references a VPE that has been unmapped by the former.
Fix it by eliding the VSYNC in this scenario.
Fixes: 64edfaa9a234 ("irqchip/gic-v4.1: Implement the v4.1 flavour of VMAPP") Signed-off-by: Nianyao Tang tangnianyao@huawei.com Signed-off-by: Thomas Gleixner tglx@linutronix.de Reviewed-by: Marc Zyngier maz@kernel.org Reviewed-by: Zenghui Yu yuzenghui@huawei.com Link: https://lore.kernel.org/r/20240406022737.3898763-1-tangnianyao@huawei.com Signed-off-by: Zhou Wang wangzhou1@hisilicon.com --- drivers/irqchip/irq-gic-v3-its.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 89b31199d005..30b1dca42659 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1096,6 +1096,7 @@ static struct its_vpe *its_build_vmapp_cmd(struct its_node *its, struct its_cmd_block *cmd, struct its_cmd_desc *desc) { + struct its_vpe *vpe = valid_vpe(its, desc->its_vmapp_cmd.vpe); unsigned long vpt_addr, vconf_addr; u64 target; bool alloc; @@ -1108,6 +1109,11 @@ static struct its_vpe *its_build_vmapp_cmd(struct its_node *its, if (is_v4_1(its)) { alloc = !atomic_dec_return(&desc->its_vmapp_cmd.vpe->vmapp_count); its_encode_alloc(cmd, alloc); + /* + * Unmapping a VPE is self-synchronizing on GICv4.1, + * no need to issue a VSYNC. + */ + vpe = NULL; }
goto out; @@ -1142,7 +1148,7 @@ static struct its_vpe *its_build_vmapp_cmd(struct its_node *its, out: its_fixup_cmd(cmd);
- return valid_vpe(its, desc->its_vmapp_cmd.vpe); + return vpe; }
static struct its_vpe *its_build_vmapti_cmd(struct its_node *its,
virt inclusion category: other bugzilla: https://gitee.com/openeuler/kernel/issues/IARQ2V
-------------------------------------------------------------------------
A VMAPP followed by a VSYNC is a bug, as the later references a VPE that has been unmapped by the former.
Fix it by eliding the VSYNC in this scenario.
NOTE:
Mainline already has related patch[1], but missing code to handle GICv4.0 case. Mainline is waiting GIC spec to be modified, then add a patch like this one.
[1] https://lore.kernel.org/r/20240406022737.3898763-1-tangnianyao@huawei.com
Signed-off-by: Zhou Wang wangzhou1@hisilicon.com --- drivers/irqchip/irq-gic-v3-its.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 30b1dca42659..7d656615b271 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1114,6 +1114,8 @@ static struct its_vpe *its_build_vmapp_cmd(struct its_node *its, * no need to issue a VSYNC. */ vpe = NULL; + } else if (is_v4(its)) { + vpe = NULL; }
goto out;