From patchwork Tue May 24 09:09:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 68445 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp519536qge; Tue, 24 May 2016 02:12:25 -0700 (PDT) X-Received: by 10.98.58.77 with SMTP id h74mr1526542pfa.156.1464081145138; Tue, 24 May 2016 02:12:25 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id q74si27418218pfa.246.2016.05.24.02.12.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 May 2016 02:12:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org 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 1b58N9-0000SQ-Bu; Tue, 24 May 2016 09:11:31 +0000 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b58MJ-000847-6k for linux-arm-kernel@lists.infradead.org; Tue, 24 May 2016 09:10:40 +0000 Received: by mail-wm0-x233.google.com with SMTP id a136so62253195wme.0 for ; Tue, 24 May 2016 02:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=e/NWBQTyHg3hF3gqpMJhCzxbNznCmMc0j7wz26vZwQE=; b=PkYGGnANJalCuXGg9sf2tr9wIgMVOxVUqbICc4jprP32PybN9Yn827jnUPWXD/Fp8r 9xZ7jwtzIVqkeD75TTEB5ryZ+8HOjy8QyogP90Pi96+9TVOCPxrZtN2f30QPTdZMsARn A+OHUEUBHiJqklVLebujl6czdl0X+3EAGMfjw= 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=e/NWBQTyHg3hF3gqpMJhCzxbNznCmMc0j7wz26vZwQE=; b=gPBRmIEsM4uVpnTcoNaNO0eKU7fJa0TZACdT8AdXCNBS1RFfpccjLpyOZzT4Ulq3E6 nckXp64VRLu97q+1MlwnWCjBb22n+BtGzghKTB1aNVTb4ox5Ovto5wRTu3lGfuRJ7WVT MbeAmkE0HKocBJycegrPFp6gTAfZACikcadpMhGtnOjNDQwisWWMDMwWxcDMeg3PV7cD 4Q9K8vtTzsWYlYVR0sSO8Xku5Y445c2MEJNunrfGBnOMl11npt0GQ63tMEQwNOXkUG5r M5ULzr8CKbrE/dlPZjpgDIONDRdCYWfS/FxelCEM8qWoUYeKayvXYMc3SGCbR60/rZUp IJNg== X-Gm-Message-State: ALyK8tL4Kr+9TwsripVB4QQ8Jdj6RTMVheQ1gO1et53Nw7oRcaMt95fOhUY52xtO+RFlboaJ X-Received: by 10.28.144.133 with SMTP id s127mr2346909wmd.12.1464081018825; Tue, 24 May 2016 02:10:18 -0700 (PDT) Received: from localhost.localdomain ([94.18.191.146]) by smtp.gmail.com with ESMTPSA id f11sm18163246wmf.22.2016.05.24.02.10.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 May 2016 02:10:18 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 23/59] KVM: arm/arm64: vgic-new: Implement kvm_vgic_vcpu_pending_irq Date: Tue, 24 May 2016 11:09:17 +0200 Message-Id: <1464080993-10884-24-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.1.2.330.g565301e.dirty In-Reply-To: <1464080993-10884-1-git-send-email-christoffer.dall@linaro.org> References: <1464080993-10884-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160524_021039_470241_D952FAEE X-CRM114-Status: GOOD ( 12.38 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:233 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: kvm@vger.kernel.org, Eric Auger , Marc Zyngier , Andre Przywara , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org From: Eric Auger Tell KVM whether a particular VCPU has an IRQ that needs handling in the guest. This is used to decide whether a VCPU is runnable. Signed-off-by: Eric Auger Signed-off-by: Andre Przywara Reviewed-by: Christoffer Dall Reviewed-by: Marc Zyngier --- include/kvm/vgic/vgic.h | 2 ++ virt/kvm/arm/vgic/vgic.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) -- 2.1.2.330.g565301e.dirty _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/include/kvm/vgic/vgic.h b/include/kvm/vgic/vgic.h index 9506267..f663288 100644 --- a/include/kvm/vgic/vgic.h +++ b/include/kvm/vgic/vgic.h @@ -184,6 +184,8 @@ struct vgic_cpu { int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int intid, bool level); +int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu); + #define irqchip_in_kernel(k) (!!((k)->arch.vgic.in_kernel)) #define vgic_initialized(k) (false) #define vgic_ready(k) ((k)->arch.vgic.ready) diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index 0bf0d20..7e01008 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -520,3 +520,28 @@ void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu) vgic_flush_lr_state(vcpu); spin_unlock(&vcpu->arch.vgic_cpu.ap_list_lock); } + +int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu) +{ + struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; + struct vgic_irq *irq; + bool pending = false; + + if (!vcpu->kvm->arch.vgic.enabled) + return false; + + spin_lock(&vgic_cpu->ap_list_lock); + + list_for_each_entry(irq, &vgic_cpu->ap_list_head, ap_list) { + spin_lock(&irq->irq_lock); + pending = irq->pending && irq->enabled; + spin_unlock(&irq->irq_lock); + + if (pending) + break; + } + + spin_unlock(&vgic_cpu->ap_list_lock); + + return pending; +}