From patchwork Thu Nov 19 14:54:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 7658021 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 67702BF90C for ; Thu, 19 Nov 2015 14:58:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E51AA2063C for ; Thu, 19 Nov 2015 14:58:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0F9F6204D9 for ; Thu, 19 Nov 2015 14:58:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZzQde-0004Xs-W2; Thu, 19 Nov 2015 14:56:43 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZzQbp-0001Uj-9w for linux-arm-kernel@lists.infradead.org; Thu, 19 Nov 2015 14:54:52 +0000 Received: by wmww144 with SMTP id w144so241837209wmw.1 for ; Thu, 19 Nov 2015 06:54:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oLG+83z6NxzGRKIFV/fB55sjIM62LPF3MXRvO8aZ5fg=; b=fQiKBjhM8xSmhEbzij87RfR4wPfHzQQ/HqOL2YSU4IR+7rWcNBuxDirdguR83HOGau SyhpVnBzpKGW2OaurB00XY+q2CnHfpdni3c6LV3Noe//Zh2sHtXRN8HZBV4aPMCfwScN iZ0LQxc6rm2uFY0C36xCq26OF3kYMh5lK3sN6yc9vfAwsUfv3sjGkh11ZC1olZ2+FaA+ etmRMFWSq9o4Z+HJ+Ffhz9OtecRyH5RJ4pZJw5For1xp1lkerVjk+oQPi4zCSiCX8y62 w52FTmDyWJWe+y+pp3yqFs4s+9z8XM/SVskB8v/5ZYOUgmuxq1XFPO2m4o2qHU0aJMd8 SaLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oLG+83z6NxzGRKIFV/fB55sjIM62LPF3MXRvO8aZ5fg=; b=CDq8hJMy8yQRbkkjbnJwiG3ew0N/TmwFhmxSFjqtJtYpOy3uPv7OGc9I17vhIlhIh8 mxPtJO7kgVEsJQhm2w1hj0TVbE5Hr1UhG4Fke2iGn62ITmgQVsUyJ0gcC7AqCdvpAvB6 iBh5NzFQXgKzktsgwUzHOq20Hypw6A469sKIchNwUXMBsDF0Gt2UB1qMVnojzmu7BqKo GW4Y3PNtf0Z37AZDgnbWpR7hAYxvpk0xLFb0cRgwMstVb429ucSdfuER1n9YvFLXilI5 ZTGUv/UGKRTls+cRCmVRm9aMHRcWk+L1gBBYvffQ2feKQnAqC0qf1yA9nJK1YPIu8oS2 mAZQ== X-Gm-Message-State: ALoCoQk2DXRePjUyiF7ZvvNE8wpiUBLCaCJzKOrhv4zW+ZNm23YZ1kAAp3+9mcAQdMfvsY8FiEDs X-Received: by 10.28.0.149 with SMTP id 143mr17534274wma.48.1447944870678; Thu, 19 Nov 2015 06:54:30 -0800 (PST) Received: from new-host-3.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id h67sm34493865wmf.17.2015.11.19.06.54.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Nov 2015 06:54:29 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, alex.williamson@redhat.com, b.reynal@virtualopensystems.com, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH v4 12/13] KVM: arm/arm64: vgic: implement clear pending for non shared mapped IRQ Date: Thu, 19 Nov 2015 14:54:02 +0000 Message-Id: <1447944843-17731-13-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447944843-17731-1-git-send-email-eric.auger@linaro.org> References: <1447944843-17731-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151119_065449_810724_812DEE14 X-CRM114-Status: GOOD ( 15.80 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andre.przywara@arm.com, linux-kernel@vger.kernel.org, patches@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch implements the clear of a pending non shared mapped IRQ. In case of an edge IRQ, we deactivate the physical IRQ that will never be deactivated by the guest. In case of a level sensitive IRQ we check the level of the input signal. If it is asserted we leave the virtual IRQ pending. In the opposite, we remove the pending state and deactivate the IRQ. Signed-off-by: Eric Auger --- virt/kvm/arm/vgic.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 98ae15f..4be5972 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -550,20 +550,50 @@ bool vgic_handle_clear_pending_reg(struct kvm *kvm, phys_addr_t offset, int vcpu_id) { u32 *level_active; - u32 *reg, orig; + u32 *reg, orig, cleared; int mode = ACCESS_READ_VALUE | ACCESS_WRITE_CLEARBIT; + unsigned int i; struct vgic_dist *dist = &kvm->arch.vgic; + struct kvm_vcpu *vcpu = kvm_get_vcpu(kvm, vcpu_id); reg = vgic_bitmap_get_reg(&dist->irq_pending, vcpu_id, offset); orig = *reg; vgic_reg_access(mmio, reg, offset, mode); if (mmio->is_write) { - /* Re-set level triggered level-active interrupts */ level_active = vgic_bitmap_get_reg(&dist->irq_level, vcpu_id, offset); + cleared = orig ^ *reg; + + /* Re-set level triggered level-active interrupts */ reg = vgic_bitmap_get_reg(&dist->irq_pending, vcpu_id, offset); *reg |= *level_active; + for (i = 0; i < 32; i++) { + struct irq_phys_map *map; + bool phys_pending; + unsigned int irq_num; + + if (!(cleared && (1 << i))) + continue; + irq_num = (offset * 8) + i; + map = vgic_irq_map_search(vcpu, irq_num); + if (!map || (map && map->shared)) + continue; + /* check whether the signal is asserted */ + irq_get_irqchip_state(map->irq, + IRQCHIP_STATE_PENDING, + &phys_pending); + if (!vgic_irq_is_edge(vcpu, irq_num) && phys_pending) { + vgic_dist_irq_set_pending(vcpu, irq_num); + continue; + } + + vgic_dist_irq_clear_pending(vcpu, irq_num); + irq_set_irqchip_state(map->irq, + IRQCHIP_STATE_ACTIVE, + false); + } + /* Ignore writes to SGIs */ if (offset < 2) { *reg &= ~0xffff;