Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3184783pxf; Sun, 21 Mar 2021 23:04:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNcghCnxSDkx48sGbIGhXbR/ecLzwpsiIOojR5exvuuQzVAS/CHsl+bYFjB4OLNK7YvLmJ X-Received: by 2002:a17:907:9152:: with SMTP id l18mr17242139ejs.376.1616393076926; Sun, 21 Mar 2021 23:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616393076; cv=none; d=google.com; s=arc-20160816; b=HdO2bt9U7JaFqSAag7FuE9EnTkE85d/PdHkmSgm60RE06YVuJ6A9Xx6kxEA0m/LkzU pYbXECo5cFx7or9kiaGfC0t4vXcLrPWdyJIw4lhxuoqVqY7Nai1biu9u1GbT7O+3TKl8 YDPZN1VUZuiNL/zu0RoNw7zfS20RhHC7AF1vkDWfvs81De0ovnKb10dA9UGYB00AHVXD +1AKWa3emnINaU9DqKwVpsQ8KAqCWdBFgJXXyXakbVG1NDpj6vPze2EzdS/8sTe3IkzH RiqU/0Er+ROA3lZn2xxTqbIp9B4IERF6oMHwudjbPGIW8WFI7z3DAXr+lebu94hXwrzE MH4w== 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=9sCS5E+SKRPKDEzQg3t/YMdpvFBFaCKS1/+A6QYnp7s=; b=DVc12tAbX+tSzmmlEmDHGLXCxjfksfr4pwQu+SF5hvf69050vC3tJUeCr4FanzNxqw 3uD+fNnpm1runJNOflmLqJFQuWK1VBHi+yv8LFZwTgVBYmlOuLreDaHRK3TsonNSIT1l klF1eCNRtzhesVFr4/JHCT/YBP+O1uKIcn0GZZygpCEQaC58dK14cE05HS5+4TZKqzEV YNfnIMHhVcBdY4wVW+coRkJmRCwiy5QyU3HzWoHmX9DITWPImeL7rOfYNLRtqt01FwIL ep8NW4RwicCyuDWZoqd9sG7dTbW8AilmdQ43Dk2TCxgNNhqA7EQ5VPEin6a4N3RIplQA hl8Q== 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 qu2si10096290ejb.373.2021.03.21.23.04.14; Sun, 21 Mar 2021 23:04:36 -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 S230151AbhCVGDU (ORCPT + 99 others); Mon, 22 Mar 2021 02:03:20 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:14050 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230018AbhCVGCk (ORCPT ); Mon, 22 Mar 2021 02:02:40 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4F3kP41QwnzNq3Y; 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:31 +0800 From: Shenming Lu To: Marc Zyngier , Eric Auger , "Will Deacon" , , , , CC: Alex Williamson , Cornelia Huck , Lorenzo Pieralisi , , , Subject: [PATCH v5 5/6] KVM: arm64: GICv4.1: Restore VLPI pending state to physical side Date: Mon, 22 Mar 2021 14:01:57 +0800 Message-ID: <20210322060158.1584-6-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-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.184.135] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zenghui Yu When setting the forwarding path of a VLPI (switch to the HW mode), we can also transfer the pending state from irq->pending_latch to VPT (especially in migration, the pending states of VLPIs are restored into kvm’s vgic first). And we currently send "INT+VSYNC" to trigger a VLPI to pending. Signed-off-by: Zenghui Yu Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v4.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c index ac029ba3d337..c1845d8f5f7e 100644 --- a/arch/arm64/kvm/vgic/vgic-v4.c +++ b/arch/arm64/kvm/vgic/vgic-v4.c @@ -404,6 +404,7 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq, struct vgic_its *its; struct vgic_irq *irq; struct its_vlpi_map map; + unsigned long flags; int ret; if (!vgic_supports_direct_msis(kvm)) @@ -449,6 +450,24 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq, irq->host_irq = virq; atomic_inc(&map.vpe->vlpi_count); + /* Transfer pending state */ + raw_spin_lock_irqsave(&irq->irq_lock, flags); + if (irq->pending_latch) { + ret = irq_set_irqchip_state(irq->host_irq, + IRQCHIP_STATE_PENDING, + irq->pending_latch); + WARN_RATELIMIT(ret, "IRQ %d", irq->host_irq); + + /* + * Clear pending_latch and communicate this state + * change via vgic_queue_irq_unlock. + */ + irq->pending_latch = false; + vgic_queue_irq_unlock(kvm, irq, flags); + } else { + raw_spin_unlock_irqrestore(&irq->irq_lock, flags); + } + out: mutex_unlock(&its->its_lock); return ret; -- 2.19.1