From patchwork Wed Feb 11 08:20:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 44556 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5B9E92151F for ; Wed, 11 Feb 2015 08:23:37 +0000 (UTC) Received: by labge10 with SMTP id ge10sf989946lab.3 for ; Wed, 11 Feb 2015 00:23:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=7KZU1PeW8/PKSX37B6r6mLls0XBoauifKbe34KAtAqg=; b=kcmB8bIkWLBzdbX/6y5DvxL6zDJsjXbpfHS28CddmwCBGYyUjO2vqanghECq0zfBh3 HCFWNKdy/g0WRwfq8KaGij5tW7kg/Z+c0rWM4vqn0OBiCRhEaHzzeuWz12AZjbmLW1UF Xu5Nj0UmV05f4ma/za9J88YrX8DhqgMa8lQtZGzFpvZTEgmrDULDbGl3v1zia1ZEs3ou ORHanLwHa5Zh6p1108mBUAGFSwXjcuRwzz+I3NOxheF8fL3RqowQaAfpIY1dZkrx5G5c vP44EbqtKon93D6ernFb6keE7YwEALaeL0E4FnhOuIZ5+veQnHS6s6OqtmCkGUHcHhdF 8RWg== X-Gm-Message-State: ALoCoQlxcHrxw2dm43pEZOFZfTbiosUf99Je2iI1HQDKjvnxHuQSIL83fWj+PKMEfh/N/MubeVm7 X-Received: by 10.113.5.167 with SMTP id cn7mr3238363lbd.21.1423643016348; Wed, 11 Feb 2015 00:23:36 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.102 with SMTP id ud6ls29317lac.26.gmail; Wed, 11 Feb 2015 00:23:36 -0800 (PST) X-Received: by 10.112.220.36 with SMTP id pt4mr26838443lbc.15.1423643016144; Wed, 11 Feb 2015 00:23:36 -0800 (PST) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id le11si30938lac.102.2015.02.11.00.23.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Feb 2015 00:23:36 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id p9so1785699lbv.0 for ; Wed, 11 Feb 2015 00:23:36 -0800 (PST) X-Received: by 10.112.54.167 with SMTP id k7mr26434923lbp.72.1423643016028; Wed, 11 Feb 2015 00:23:36 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1105428lbj; Wed, 11 Feb 2015 00:23:35 -0800 (PST) X-Received: by 10.50.44.43 with SMTP id b11mr2231749igm.30.1423643014907; Wed, 11 Feb 2015 00:23:34 -0800 (PST) Received: from mail-ig0-f178.google.com (mail-ig0-f178.google.com. [209.85.213.178]) by mx.google.com with ESMTPS id th10si1231206igb.54.2015.02.11.00.23.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Feb 2015 00:23:34 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.213.178 as permitted sender) client-ip=209.85.213.178; Received: by mail-ig0-f178.google.com with SMTP id hl2so2886636igb.5 for ; Wed, 11 Feb 2015 00:23:34 -0800 (PST) X-Received: by 10.42.88.9 with SMTP id a9mr1876427icm.34.1423643014145; Wed, 11 Feb 2015 00:23:34 -0800 (PST) Received: from gnx2579.solutionip.com ([113.28.134.59]) by mx.google.com with ESMTPSA id g11sm56703iod.28.2015.02.11.00.23.29 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Feb 2015 00:23:33 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, andre.przywara@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, alex.williamson@redhat.com Cc: patches@linaro.org, a.motakis@virtualopensystems.com, a.rigo@virtualopensystems.com, b.reynal@virtualopensystems.com Subject: [RFC v2 4/4] KVM: arm: vgic: cleanup forwarded IRQs on destroy Date: Wed, 11 Feb 2015 09:20:57 +0100 Message-Id: <1423642857-24240-5-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1423642857-24240-1-git-send-email-eric.auger@linaro.org> References: <1423642857-24240-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When the VGIC is destroyed it must take care of - restoring the forwarded IRQs in non forwarded state, - deactivating the IRQ in case the guest left without doing it - cleaning nodes of the phys_map rbtree Signed-off-by: Eric Auger --- v1 -> v2: - remove vgic_clean_irq_phys_map call in kvm_vgic_destroy (useless since already called in kvm_vgic_vcpu_destroy) --- virt/kvm/arm/vgic.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index dd72ca2..ace8e46 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -32,6 +32,7 @@ #include #include #include +#include /* * How the whole thing works (courtesy of Christoffer Dall): @@ -103,6 +104,8 @@ static struct vgic_lr vgic_get_lr(const struct kvm_vcpu *vcpu, int lr); static void vgic_set_lr(struct kvm_vcpu *vcpu, int lr, struct vgic_lr lr_desc); static void vgic_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr); static void vgic_set_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr); +static void vgic_clean_irq_phys_map(struct kvm_vcpu *vcpu, + struct rb_root *root); static const struct vgic_ops *vgic_ops; static const struct vgic_params *vgic; @@ -1819,6 +1822,36 @@ static struct irq_phys_map *vgic_irq_map_search(struct kvm_vcpu *vcpu, return NULL; } +static void vgic_clean_irq_phys_map(struct kvm_vcpu *vcpu, + struct rb_root *root) +{ + unsigned long flags; + + while (1) { + struct rb_node *node = rb_first(root); + struct irq_phys_map *map; + struct irq_desc *desc; + struct irq_data *d; + struct irq_chip *chip; + + if (!node) + break; + + map = container_of(node, struct irq_phys_map, node); + desc = irq_to_desc(map->phys_irq); + + raw_spin_lock_irqsave(&desc->lock, flags); + d = &desc->irq_data; + chip = desc->irq_data.chip; + irqd_clr_irq_forwarded(d); + chip->irq_eoi(d); + raw_spin_unlock_irqrestore(&desc->lock, flags); + + rb_erase(node, root); + kfree(map); + } +} + int vgic_get_phys_irq(struct kvm_vcpu *vcpu, int virt_irq) { struct irq_phys_map *map; @@ -1861,6 +1894,7 @@ void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu) { struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; + vgic_clean_irq_phys_map(vcpu, &vgic_cpu->irq_phys_map); kfree(vgic_cpu->pending_shared); kfree(vgic_cpu->vgic_irq_lr_map); vgic_cpu->pending_shared = NULL;