lkml.org 
[lkml]   [2021]   [Jan]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH v2 1/4] KVM: arm64: GICv4.1: Add function to get VLPI state
    Date
    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>
    ---
    arch/arm64/kvm/vgic/vgic-v4.c | 24 ++++++++++++++++++++++++
    arch/arm64/kvm/vgic/vgic.h | 1 +
    2 files changed, 25 insertions(+)

    diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c
    index 66508b03094f..f211a7c32704 100644
    --- a/arch/arm64/kvm/vgic/vgic-v4.c
    +++ b/arch/arm64/kvm/vgic/vgic-v4.c
    @@ -203,6 +203,30 @@ 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.
    + */
    +int 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;
    +
    + if (!irq->hw || !kvm_vgic_global_state.has_gicv4_1)
    + return -EINVAL;
    +
    + va = page_address(vpe->vpt_page);
    + ptr = va + irq->intid / BITS_PER_BYTE;
    +
    + *val = !!(*ptr & mask);
    +
    + return 0;
    +}
    +
    /**
    * vgic_v4_init - Initialize the GICv4 data structures
    * @kvm: Pointer to the VM being initialized
    diff --git a/arch/arm64/kvm/vgic/vgic.h b/arch/arm64/kvm/vgic/vgic.h
    index 64fcd7511110..9c9b43e0d0b0 100644
    --- a/arch/arm64/kvm/vgic/vgic.h
    +++ b/arch/arm64/kvm/vgic/vgic.h
    @@ -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);
    +int vgic_v4_get_vlpi_state(struct vgic_irq *irq, bool *val);

    #endif
    --
    2.19.1
    \
     
     \ /
      Last update: 2021-01-04 09:20    [W:2.494 / U:0.140 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site