From patchwork Mon Sep 1 12:52:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 36356 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 21A822032B for ; Mon, 1 Sep 2014 12:53:33 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id l13sf29983228iga.2 for ; Mon, 01 Sep 2014 05:53:32 -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=I/k/8AvQNuLYcQjcZw5E6HURFjri1uAVg8goS3/LE5A=; b=RLab8Ee63Lq5vfQBlxGRUfKFtlEwx6jzHbjcb90BxSjY5+NYGM1Lh6hk7n5/0Y1foe 2/UaTvtcSll/u8NG9qnSvditd+tcqx9g1SKPZgUCqNWLZAvFPwn8iIlBMG0IXHho5E7M cVB1bCtsenmNIyJ2conejExArdvO7Ed3PzgJ085PBKFd+5XNgDDya7kF1pDyurLie5Rc r4DBDLMjCSxEywyfe4dQRbPd8kkN41xrOt8rRVSIAT9nMS8iYi+T2qDwo3hbwohBsn4p LR9n3XCX0CXNarKmCwEIopmfUtGe/zm17t9R3GSi1mw3Fm88haZ21+1QoA6wfCYd1I1N 6Rww== X-Gm-Message-State: ALoCoQngWvv1G0d7zoAR7sR+OKkuuVUc/8EnkAnoawF0FSVCLgJmtgnOB15FC8yZqEhzV/PYla4m X-Received: by 10.182.60.135 with SMTP id h7mr16474611obr.18.1409576012735; Mon, 01 Sep 2014 05:53:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.34 with SMTP id c31ls738617qge.92.gmail; Mon, 01 Sep 2014 05:53:32 -0700 (PDT) X-Received: by 10.53.12.225 with SMTP id et1mr20735783vdd.5.1409576012642; Mon, 01 Sep 2014 05:53:32 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id vx5si316613vcb.0.2014.09.01.05.53.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Sep 2014 05:53:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id im17so5508646vcb.13 for ; Mon, 01 Sep 2014 05:53:32 -0700 (PDT) X-Received: by 10.52.106.168 with SMTP id gv8mr109832vdb.80.1409576012348; Mon, 01 Sep 2014 05:53:32 -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 uj3csp383122vcb; Mon, 1 Sep 2014 05:53:31 -0700 (PDT) X-Received: by 10.180.73.235 with SMTP id o11mr21642512wiv.41.1409576011059; Mon, 01 Sep 2014 05:53:31 -0700 (PDT) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id hi5si985527wjc.140.2014.09.01.05.53.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Sep 2014 05:53:31 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.50 as permitted sender) client-ip=74.125.82.50; Received: by mail-wg0-f50.google.com with SMTP id x12so5266037wgg.21 for ; Mon, 01 Sep 2014 05:53:30 -0700 (PDT) X-Received: by 10.180.210.163 with SMTP id mv3mr21750185wic.15.1409576010552; Mon, 01 Sep 2014 05:53:30 -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 y5sm1928678wje.32.2014.09.01.05.53.28 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Sep 2014 05:53:29 -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, paulus@samba.org, gleb@kernel.org, pbonzini@redhat.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 v2 1/9] KVM: ARM: VGIC: fix multiple injection of level sensitive forwarded IRQ Date: Mon, 1 Sep 2014 14:52:40 +0200 Message-Id: <1409575968-5329-2-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409575968-5329-1-git-send-email-eric.auger@linaro.org> References: <1409575968-5329-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.182 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. Signed-off-by: Eric Auger --- 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. v1 -> v2: - fix vgic state bypass in vgic_queue_hwirq --- virt/kvm/arm/vgic.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 0007300..8ef495b 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1259,7 +1259,9 @@ static bool vgic_queue_sgi(struct kvm_vcpu *vcpu, int irq) static bool vgic_queue_hwirq(struct kvm_vcpu *vcpu, int irq) { - if (vgic_irq_is_queued(vcpu, irq)) + bool is_forwarded = (vgic_get_phys_irq(vcpu, irq) > 0); + + if (vgic_irq_is_queued(vcpu, irq) && !is_forwarded) return true; /* level interrupt, already queued */ if (vgic_queue_irq(vcpu, 0, irq)) { @@ -1517,14 +1519,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 +1563,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.