Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3184800pxf; Sun, 21 Mar 2021 23:04:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbylQDj8VSFM/DEwrH4rkjmWIW3fBenMeX1PISI9g5Gw4CTTvMQFcR3qpOdW2qt4JkQ5yf X-Received: by 2002:aa7:c5c4:: with SMTP id h4mr22846409eds.375.1616393079379; Sun, 21 Mar 2021 23:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616393079; cv=none; d=google.com; s=arc-20160816; b=jZOOOOIzy/GHwJloEak0qr5GUxherMwrAsFS4P9yqx7JJXZe7viTyn7JxCL+DHQksA DD9q1gtcJbgiUjIsrYEElMyU8Th4kLQR050AuOW7//qGjouAsvRMncapBpSNgAAjEpxA j2S+vCVTMgEJN28Q+aR8uGAIMA+EtTEnyS8QHF/dgIg5C2f6mfSPRqPOZhlP7q8rLCyL jv3yENAl8g8jf3+99l+676/fITHbOSfdSojMuQW5kD2KngPngw37EPUp3HWNsPS9wr2g wK2yYBV5IDpmMDPCJbQ6UDE1qydgQ+OuBNbVK7U0pCGxv+0p+HrNNPM/M8Nq9ySCu564 tJyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Av8mzn2RSBR273muWN1JQxZLSfwScmd8bpznN+SsGDQ=; b=CJcAmCDzc3mm8IH2M7ZBJmeTPqgzMNbxHz9LxGThHwUTyuOVlKw0zBJ2ABOIw4xeF7 QFLtqtvscSovdoWD5ytqrXdAreJujd+uFR7fm7q0Cb2P/zIQxC+AAr07X29o+GQ0LgMD a/GK2yFJ9VMerpQz6eIo9mkaozBfG2bAVqs9nve+55wDnbZqEwL6nWFntK1WVcVOpso7 ul/kNi2MdV52skBz8DH7qt9UiZxWgjvRjpptdh8orelNzQgMQCF4kqSXFzGen90EB6dP egHV979oBp4cuxNWH9MleHJ225BJ4Loy8XOrgdEaXPHebF0HDHxc52EMXL5Dx0uweTBe tSUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h17si10493152edr.331.2021.03.21.23.04.17; Sun, 21 Mar 2021 23:04:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230165AbhCVGDW (ORCPT + 99 others); Mon, 22 Mar 2021 02:03:22 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:14049 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbhCVGCj (ORCPT ); Mon, 22 Mar 2021 02:02:39 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4F3kP42JNRzNq3x; Mon, 22 Mar 2021 14:00:08 +0800 (CST) Received: from DESKTOP-7FEPK9S.china.huawei.com (10.174.184.135) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.498.0; Mon, 22 Mar 2021 14:02:29 +0800 From: Shenming Lu To: Marc Zyngier , Eric Auger , "Will Deacon" , , , , CC: Alex Williamson , Cornelia Huck , Lorenzo Pieralisi , , , Subject: [PATCH v5 3/6] KVM: arm64: GICv4.1: Add function to get VLPI state Date: Mon, 22 Mar 2021 14:01:55 +0800 Message-ID: <20210322060158.1584-4-lushenming@huawei.com> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20210322060158.1584-1-lushenming@huawei.com> References: <20210322060158.1584-1-lushenming@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.184.135] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/arm64/kvm/vgic/vgic-v4.c | 19 +++++++++++++++++++ arch/arm64/kvm/vgic/vgic.h | 1 + 2 files changed, 20 insertions(+) diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c index 66508b03094f..ac029ba3d337 100644 --- a/arch/arm64/kvm/vgic/vgic-v4.c +++ b/arch/arm64/kvm/vgic/vgic-v4.c @@ -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 diff --git a/arch/arm64/kvm/vgic/vgic.h b/arch/arm64/kvm/vgic/vgic.h index 64fcd7511110..d8cfd360838c 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); +void vgic_v4_get_vlpi_state(struct vgic_irq *irq, bool *val); #endif -- 2.19.1