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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C1B01C433F5 for ; Wed, 23 Feb 2022 02:29:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5IrQ87IR2nQFFD19tf7uAtxQ8YNFTe7jqRAeSBFLjnc=; b=T9w7cJG8IFZHFe QP8XYEy/a0pxr0ghWruN4Xhik4QiOg0rIDCYATKser0j0cyAVcSc0s+SJB9+e/02HqXEy/2ftMc8C nEYP98DcHKCxAx3nKzYHTiMIf4T0SmgL0jXgWDg1zRVUkllGVxREZeL96PBguC/x7ltosbC5v2bDP vDGdrwgVqTC7mhJ5M+fnylGapBq+f22bvGaOCVbJnZVcLokogB9RaeWQumzXP1fFaNnFZctmISHH4 vZZAPbGLVJZQCi3Y9d6B5R8Qwi4z1M7qI0RJ3p28Dcw5qSLurGwjGoREHkmfxLSGT0NHCV2X6mUsX RBhju9fMaMY0FlcsOe0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMhOc-00CIHL-Bl; Wed, 23 Feb 2022 02:28:50 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMhOY-00CIG9-MD for linux-arm-kernel@lists.infradead.org; Wed, 23 Feb 2022 02:28:48 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 54B71B81E0B; Wed, 23 Feb 2022 02:28:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D395CC36AE5; Wed, 23 Feb 2022 02:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645583324; bh=pJlFBvjxuJ7foblMFzRm/Bg/OJGdmZY6qGEQYa19W1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IofOm66rkQxCSeQ8Zud04dSEVnvdTJtGsRowFl8AOXdL/oZFj8I7W2kRZdpUTvo9X k2/MM9w/UyrB8NPvOhTTsfuGhZ0ilwy52LjyJOK5eVg4wk5mmpTqob338FUUimW2Bu KEyB0mnC4xn+BEQjP5+P/z1JbKgSwDTRlHf5VHmpXTdWpZkDKRVSyUcI7UP/6zySxF s1kYzuGPbp2BksR5DTqKtIDG4vb6YHLP9P3RQHEX4r51DOIglHeu6Iab0o0bwO+KlT zyezhQrZ1MbVfDM9t5+7v9tq8HKSD7fUaDjrgPpTK3XJLNRySZ5vt0tOrcip8b3x95 Bkyp1THeQnD1g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Marc Zyngier , Ricardo Koller , Sasha Levin , catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, rikard.falkeborn@gmail.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Subject: [PATCH AUTOSEL 5.16 11/30] KVM: arm64: vgic: Read HW interrupt pending state from the HW Date: Tue, 22 Feb 2022 21:28:00 -0500 Message-Id: <20220223022820.240649-11-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220223022820.240649-1-sashal@kernel.org> References: <20220223022820.240649-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220222_182846_905712_2637E327 X-CRM114-Status: GOOD ( 14.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Marc Zyngier [ Upstream commit 5bfa685e62e9ba93c303a9a8db646c7228b9b570 ] It appears that a read access to GIC[DR]_I[CS]PENDRn doesn't always result in the pending interrupts being accurately reported if they are mapped to a HW interrupt. This is particularily visible when acking the timer interrupt and reading the GICR_ISPENDR1 register immediately after, for example (the interrupt appears as not-pending while it really is...). This is because a HW interrupt has its 'active and pending state' kept in the *physical* distributor, and not in the virtual one, as mandated by the spec (this is what allows the direct deactivation). The virtual distributor only caries the pending and active *states* (note the plural, as these are two independent and non-overlapping states). Fix it by reading the HW state back, either from the timer itself or from the distributor if necessary. Reported-by: Ricardo Koller Tested-by: Ricardo Koller Reviewed-by: Ricardo Koller Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220208123726.3604198-1-maz@kernel.org Signed-off-by: Sasha Levin --- arch/arm64/kvm/vgic/vgic-mmio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/kvm/vgic/vgic-mmio.c b/arch/arm64/kvm/vgic/vgic-mmio.c index 48c6067fc5ecb..f972992682746 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio.c +++ b/arch/arm64/kvm/vgic/vgic-mmio.c @@ -248,6 +248,8 @@ unsigned long vgic_mmio_read_pending(struct kvm_vcpu *vcpu, IRQCHIP_STATE_PENDING, &val); WARN_RATELIMIT(err, "IRQ %d", irq->host_irq); + } else if (vgic_irq_is_mapped_level(irq)) { + val = vgic_get_phys_line_level(irq); } else { val = irq_is_pending(irq); } -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel