]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
KVM: arm64: GICv4.1: Add function to get VLPI state
authorShenming Lu <lushenming@huawei.com>
Mon, 22 Mar 2021 06:01:55 +0000 (14:01 +0800)
committerMarc Zyngier <maz@kernel.org>
Wed, 24 Mar 2021 18:12:20 +0000 (18:12 +0000)
With GICv4.1 and the vPE unmapped, which indicates the invalidation
of any VPT caches associated with the vPE, we can get the VLPI state
by peeking at the VPT. So we add a function for this.

Signed-off-by: Shenming Lu <lushenming@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210322060158.1584-4-lushenming@huawei.com
arch/arm64/kvm/vgic/vgic-v4.c
arch/arm64/kvm/vgic/vgic.h

index 66508b03094f2f3beb061c47bbcf1bbb821d5e77..ac029ba3d3376910e5cabe10e3698f33f192f8dd 100644 (file)
@@ -203,6 +203,25 @@ void vgic_v4_configure_vsgis(struct kvm *kvm)
        kvm_arm_resume_guest(kvm);
 }
 
+/*
+ * Must be called with GICv4.1 and the vPE unmapped, which
+ * indicates the invalidation of any VPT caches associated
+ * with the vPE, thus we can get the VLPI state by peeking
+ * at the VPT.
+ */
+void vgic_v4_get_vlpi_state(struct vgic_irq *irq, bool *val)
+{
+       struct its_vpe *vpe = &irq->target_vcpu->arch.vgic_cpu.vgic_v3.its_vpe;
+       int mask = BIT(irq->intid % BITS_PER_BYTE);
+       void *va;
+       u8 *ptr;
+
+       va = page_address(vpe->vpt_page);
+       ptr = va + irq->intid / BITS_PER_BYTE;
+
+       *val = !!(*ptr & mask);
+}
+
 /**
  * vgic_v4_init - Initialize the GICv4 data structures
  * @kvm:       Pointer to the VM being initialized
index 64fcd75111108c6b7b3b5b74e434339138c44a57..d8cfd360838c789299746e81d5b0f3a83b1efebb 100644 (file)
@@ -317,5 +317,6 @@ bool vgic_supports_direct_msis(struct kvm *kvm);
 int vgic_v4_init(struct kvm *kvm);
 void vgic_v4_teardown(struct kvm *kvm);
 void vgic_v4_configure_vsgis(struct kvm *kvm);
+void vgic_v4_get_vlpi_state(struct vgic_irq *irq, bool *val);
 
 #endif