From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 755ABC43331 for ; Tue, 31 Mar 2020 03:13:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 37A952072D for ; Tue, 31 Mar 2020 03:13:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UBXwgWRu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37A952072D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=oDR+NTgolGXxFKgoLcnIRnZEG6IBC+nof8vwW+S7qrk=; b=UBXwgWRuhQsZ+o JM3fq/XGT8JMliyRgo9Q/3cvXYuoBhYgyWSAVANhbjw7A/zx+OVWqswiFIQekSrNy+7i9l3cB/3j5 BuzgLIZTsPcIpTXLblKQNU4tWAgsPBz4vviaS8LSax8cxnp3adfWbZ/6ZaZmwtC313u7ISQTldHJn mEeH+w5PA4M5Ah3sGJxiSguQPMJ3O4Iq42FZBE8uf+bPgtNfMJNtQckN/7uLYDuQ3eGpdh0hpuQFs f9yJVITLUXwnDI6qr5+oXpacexe37m12SxvSZBrlWaujHYfnBRV8Tv1YI8Q/YJpFYAtjjeEO1a7x3 VlfsZfyzB1259cwYV8wQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jJ7L4-00025b-Lk; Tue, 31 Mar 2020 03:13:18 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jJ7L1-00024O-Kr for linux-arm-kernel@lists.infradead.org; Tue, 31 Mar 2020 03:13:17 +0000 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id D69B58F96A35E84F5A46; Tue, 31 Mar 2020 11:12:59 +0800 (CST) Received: from DESKTOP-8RFUVS3.china.huawei.com (10.173.222.27) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Tue, 31 Mar 2020 11:12:52 +0800 From: Zenghui Yu To: Subject: [PATCH] KVM: arm64: vgic-v3: Clear pending bit in guest memory after synchronization Date: Tue, 31 Mar 2020 11:12:45 +0800 Message-ID: <20200331031245.1562-1-yuzenghui@huawei.com> X-Mailer: git-send-email 2.23.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.173.222.27] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200330_201315_852263_532689DF X-CRM114-Status: GOOD ( 11.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: suzuki.poulose@arm.com, maz@kernel.org, linux-kernel@vger.kernel.org, eric.auger@redhat.com, james.morse@arm.com, linux-arm-kernel@lists.infradead.org, andre.przywara@arm.com, Zenghui Yu , wanghaibin.wang@huawei.com, julien.thierry.kdev@gmail.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org When LPI support is enabled at redistributor level, VGIC will potentially load the correspond LPI penging table and sync it into the pending_latch. To avoid keeping the 'consumed' pending bits lying around in guest memory (though they're not used), let's clear them after synchronization. The similar work had been done in vgic_v3_lpi_sync_pending_status(). Signed-off-by: Zenghui Yu --- virt/kvm/arm/vgic/vgic-its.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index d53d34a33e35..905760bfa404 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -435,6 +435,7 @@ static int its_sync_lpi_pending_table(struct kvm_vcpu *vcpu) for (i = 0; i < nr_irqs; i++) { int byte_offset, bit_nr; + bool status; byte_offset = intids[i] / BITS_PER_BYTE; bit_nr = intids[i] % BITS_PER_BYTE; @@ -447,22 +448,32 @@ static int its_sync_lpi_pending_table(struct kvm_vcpu *vcpu) ret = kvm_read_guest_lock(vcpu->kvm, pendbase + byte_offset, &pendmask, 1); - if (ret) { - kfree(intids); - return ret; - } + if (ret) + goto out; last_byte_offset = byte_offset; } + status = pendmask & (1 << bit_nr); + irq = vgic_get_irq(vcpu->kvm, NULL, intids[i]); raw_spin_lock_irqsave(&irq->irq_lock, flags); - irq->pending_latch = pendmask & (1U << bit_nr); + irq->pending_latch = status; vgic_queue_irq_unlock(vcpu->kvm, irq, flags); vgic_put_irq(vcpu->kvm, irq); + + if (status) { + /* clear consumed data */ + pendmask &= ~(1 << bit_nr); + ret = kvm_write_guest_lock(vcpu->kvm, + pendbase + byte_offset, + &pendmask, 1); + if (ret) + goto out; + } } +out: kfree(intids); - return ret; } -- 2.19.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel