irqchip/gic-v3-its: Fix VSYNC referencing an unmapped VPE on GIC v4.1
authorNianyao Tang <tangnianyao@huawei.com>
Sat, 6 Apr 2024 02:27:37 +0000 (02:27 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 9 Apr 2024 09:11:18 +0000 (11:11 +0200)
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
drivers/irqchip/irq-gic-v3-its.c

index fca888b36680df813c952d8d29e1cf74cd81e167..2a537cbfcb077246c0aee43a5b9f1885a3e0b5f2 100644 (file)
@@ -786,6 +786,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;
@@ -798,6 +799,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;
@@ -832,7 +838,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,