From patchwork Sat Oct 17 20:30:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 55160 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id E5EAB22FFA for ; Sat, 17 Oct 2015 20:32:18 +0000 (UTC) Received: by wibzt1 with SMTP id zt1sf12469417wib.0 for ; Sat, 17 Oct 2015 13:32:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=D5qCEtaXVIJSW5SUtBfCPWkbuTYxBdret4/cH9HLE3w=; b=aN1PRioLFbKev51lSQRMoStrBVprrRI7O5fttzE3BBT0pGknKQhM3Cn+5mYVM5T79W tBTQuZBe7INkDe4Pa/vUDW9dDhJ4SFefYelx4sGRzmv91AKmkK2mGql9JY+IcEs2cUo/ Dn0v4yQB3/t17z+I8SdJe8KP/fHONnYPmEybpvzOR7GESdBFaYvnox7bQ46d+6Cb9vTm xmst2TOxQC7PrjtkMLRfq41GzGtRYJsj2s1H6VT1fRENJJOoMRKjCPiXlGIqmBccX6au K0llWO4iNOQLSzYclV9g1C5DUHMh9UDCOe/3AjJiqqBw1bpFYqc/MdWGbp2CYUqBpCIz 4cpw== X-Gm-Message-State: ALoCoQn/RKebd3ZlZTuxbAlgTP5geXjUJwwxt/gJvI2vcLJx7PpOf5IMQH2HiFqMYRJOIsr0z6qq X-Received: by 10.112.190.74 with SMTP id go10mr5430725lbc.9.1445113938187; Sat, 17 Oct 2015 13:32:18 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.152.7 with SMTP id a7ls446136lfe.100.gmail; Sat, 17 Oct 2015 13:32:18 -0700 (PDT) X-Received: by 10.112.188.168 with SMTP id gb8mr1423608lbc.6.1445113938055; Sat, 17 Oct 2015 13:32:18 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id n18si17212986lfn.65.2015.10.17.13.32.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Oct 2015 13:32:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbcao8 with SMTP id ao8so119329205lbc.3 for ; Sat, 17 Oct 2015 13:32:18 -0700 (PDT) X-Received: by 10.112.129.202 with SMTP id ny10mr10984337lbb.112.1445113937936; Sat, 17 Oct 2015 13:32:17 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp658865lbq; Sat, 17 Oct 2015 13:32:17 -0700 (PDT) X-Received: by 10.68.91.193 with SMTP id cg1mr24699770pbb.98.1445113936901; Sat, 17 Oct 2015 13:32:16 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id mm1si12014159pbc.116.2015.10.17.13.32.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Oct 2015 13:32:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; 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 1ZnY8I-0008Ao-9U; Sat, 17 Oct 2015 20:31:14 +0000 Received: from mail-lb0-f171.google.com ([209.85.217.171]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZnY81-00081m-PX for linux-arm-kernel@lists.infradead.org; Sat, 17 Oct 2015 20:30:58 +0000 Received: by lbcao8 with SMTP id ao8so119318775lbc.3 for ; Sat, 17 Oct 2015 13:30:36 -0700 (PDT) X-Received: by 10.112.171.69 with SMTP id as5mr10976519lbc.111.1445113835938; Sat, 17 Oct 2015 13:30:35 -0700 (PDT) Received: from localhost.localdomain (0187900153.0.fullrate.dk. [2.110.55.193]) by smtp.gmail.com with ESMTPSA id rs1sm3876234lbb.21.2015.10.17.13.30.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 17 Oct 2015 13:30:35 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] arm/arm64: KVM: Fix disabled distributor operation Date: Sat, 17 Oct 2015 22:30:22 +0200 Message-Id: <1445113822-7831-4-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.1.2.330.g565301e.dirty In-Reply-To: <1445113822-7831-1-git-send-email-christoffer.dall@linaro.org> References: <1445113822-7831-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151017_133058_043432_474CA295 X-CRM114-Status: GOOD ( 16.49 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.217.171 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.217.171 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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: Marc Zyngier , Paolo Bonzini , Christoffer Dall MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@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.182 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 We currently do a single update of the vgic state when the distrbutor enable/disable control register is accessed and then bypass updating the state for as long as the distributor remains disabled. This is incorrect, because updating the state does not consider the distributor enable bit, and this you can end up in a situation where an interrupt is marked as pending on the CPU interface, but not pending on the distributor, which is an impossible state to be in, and triggers a warning. Consider for example the following sequence of events: 1. An interrupt is marked as pending on the distributor - the interrupt is also forwarded to the CPU interface 2. The guest turns off the distributor (it's about to do a reboot) - we stop updating the CPU interface state from now on 3. The guest disables the pending interrupt - we remove the pending state from the distributor, but don't touch the CPU interface, see point 2. Since the distributor disable bit really means that no interrupts should be forwarded to the CPU interface, we modify the code to keep updating the internal VGIC state, but always set the CPU interface pending bits to zero when the distributor is disabled. Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 58b1256..66c6616 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1012,6 +1012,12 @@ static int compute_pending_for_cpu(struct kvm_vcpu *vcpu) pend_percpu = vcpu->arch.vgic_cpu.pending_percpu; pend_shared = vcpu->arch.vgic_cpu.pending_shared; + if (!dist->enabled) { + bitmap_zero(pend_percpu, VGIC_NR_PRIVATE_IRQS); + bitmap_zero(pend_shared, nr_shared); + return 0; + } + pending = vgic_bitmap_get_cpu_map(&dist->irq_pending, vcpu_id); enabled = vgic_bitmap_get_cpu_map(&dist->irq_enabled, vcpu_id); bitmap_and(pend_percpu, pending, enabled, VGIC_NR_PRIVATE_IRQS); @@ -1039,11 +1045,6 @@ void vgic_update_state(struct kvm *kvm) struct kvm_vcpu *vcpu; int c; - if (!dist->enabled) { - set_bit(0, dist->irq_pending_on_cpu); - return; - } - kvm_for_each_vcpu(c, vcpu, kvm) { if (compute_pending_for_cpu(vcpu)) set_bit(c, dist->irq_pending_on_cpu);