From patchwork Mon Aug 25 13:27:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 35910 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f70.google.com (mail-qa0-f70.google.com [209.85.216.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 652E020565 for ; Mon, 25 Aug 2014 13:28:39 +0000 (UTC) Received: by mail-qa0-f70.google.com with SMTP id j7sf39010353qaq.9 for ; Mon, 25 Aug 2014 06:28:37 -0700 (PDT) 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=qQLgnraAsF2lnbqu7lf5Ty2/uMVO8fQYFXLVKxjrj8w=; b=Cmlu8efQVoRDIvE4eeIa17dmnMd8cwvlGaA4jrUtNu82zIbiwdFu2fwCwpXGUOIosB eG57f2oBxsTnSZQRCEQqIyQjUiX9OmFR5NBqjwhMvxlXm59HLI+NGb9MtmGjMEXDokr7 A+zug548OmrMY7UQEqR8QNJrdDv2fYysPxW1oGTohklUzCzqrheMc89nBhI6f3MhM52+ Rf6/oufH49sS9Nyg7PQo9zwtx6hfZSt19J5Zbgooc7PBBLcKx82IpCZslHI2TgZqM9h8 7yETG4mheMgo1G4VzQHJ0jTBGXtNCLqoWE7ZVZnv8NtzJ1ziVjOMboSWIfkTNOFNeNCJ YoQw== X-Gm-Message-State: ALoCoQlMyb41oBvfOrwGoYzLMf8bFLud9MFySj611XWKPiYoxKNnL13+yranNs381DWd6dqU2KUg X-Received: by 10.236.7.14 with SMTP id 14mr14176829yho.34.1408973317533; Mon, 25 Aug 2014 06:28:37 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.132 with SMTP id z4ls2009280qgd.99.gmail; Mon, 25 Aug 2014 06:28:37 -0700 (PDT) X-Received: by 10.220.192.196 with SMTP id dr4mr1012242vcb.70.1408973317415; Mon, 25 Aug 2014 06:28:37 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id xl3si17289812vdb.37.2014.08.25.06.28.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 06:28:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ik5so14939790vcb.20 for ; Mon, 25 Aug 2014 06:28:37 -0700 (PDT) X-Received: by 10.220.118.136 with SMTP id v8mr5621620vcq.50.1408973317324; Mon, 25 Aug 2014 06:28:37 -0700 (PDT) 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.221.45.67 with SMTP id uj3csp117315vcb; Mon, 25 Aug 2014 06:28:36 -0700 (PDT) X-Received: by 10.194.119.193 with SMTP id kw1mr9223579wjb.82.1408973316350; Mon, 25 Aug 2014 06:28:36 -0700 (PDT) Received: from mail-we0-f174.google.com (mail-we0-f174.google.com [74.125.82.174]) by mx.google.com with ESMTPS id pv8si27957780wjc.166.2014.08.25.06.28.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 06:28:36 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.174 as permitted sender) client-ip=74.125.82.174; Received: by mail-we0-f174.google.com with SMTP id x48so13300890wes.19 for ; Mon, 25 Aug 2014 06:28:36 -0700 (PDT) X-Received: by 10.180.99.4 with SMTP id em4mr15499698wib.8.1408973315926; Mon, 25 Aug 2014 06:28:35 -0700 (PDT) Received: from gnx2579.gnb.st.com (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id co6sm100101595wjb.31.2014.08.25.06.28.34 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 06:28:35 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, alex.williamson@redhat.com, joel.schopp@amd.com, kim.phillips@freescale.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, will.deacon@arm.com, a.motakis@virtualopensystems.com, a.rigo@virtualopensystems.com, john.liuli@huawei.com Subject: [RFC 1/9] KVM: ARM: VGIC: fix multiple injection of level sensitive forwarded IRQ Date: Mon, 25 Aug 2014 15:27:36 +0200 Message-Id: <1408973264-30384-2-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408973264-30384-1-git-send-email-eric.auger@linaro.org> References: <1408973264-30384-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.220.175 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: , Fix multiple injection of level sensitive forwarded IRQs. With current code, the second injection fails since the state bitmaps are not reset (process_maintenance is not called anymore). New implementation consists in fully bypassing the vgic state management for forwarded IRQ (checks are ignored in vgic_update_irq_pending). This obviously assumes the forwarded IRQ is injected from kernel side. --- It was attempted to reset the states in __kvm_vgic_sync_hwstate, checking the emptied LR of forwarded IRQ. However surprisingly this solution does not seem to work. Some times, a new forwarded IRQ injection is observed while the LR of the previous instance was not observed as empty. Signed-off-by: Eric Auger --- include/kvm/arm_vgic.h | 1 + virt/kvm/arm/vgic.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index 743020f..3da244f 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -177,6 +177,7 @@ struct vgic_dist { unsigned long irq_pending_on_cpu; struct rb_root irq_phys_map; + spinlock_t rb_tree_lock; #endif }; diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 0007300..195c10c 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1517,14 +1517,18 @@ static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid, int edge_triggered, level_triggered; int enabled; bool ret = true; + bool is_forwarded; spin_lock(&dist->lock); vcpu = kvm_get_vcpu(kvm, cpuid); + is_forwarded = (vgic_get_phys_irq(vcpu, irq_num) >0); + edge_triggered = vgic_irq_is_edge(vcpu, irq_num); level_triggered = !edge_triggered; - if (!vgic_validate_injection(vcpu, irq_num, level)) { + if (!is_forwarded && + !vgic_validate_injection(vcpu, irq_num, level)) { ret = false; goto out; } @@ -1557,7 +1561,8 @@ static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid, goto out; } - if (level_triggered && vgic_irq_is_queued(vcpu, irq_num)) { + if (!is_forwarded && + level_triggered && vgic_irq_is_queued(vcpu, irq_num)) { /* * Level interrupt in progress, will be picked up * when EOId.