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: 9133127 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A1DB607D3 for ; Tue, 24 May 2016 09:13:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32B9E28258 for ; Tue, 24 May 2016 09:13:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2774728288; Tue, 24 May 2016 09:13:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD7E028258 for ; Tue, 24 May 2016 09:13:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932434AbcEXJKX (ORCPT ); Tue, 24 May 2016 05:10:23 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:36255 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932424AbcEXJKU (ORCPT ); Tue, 24 May 2016 05:10:20 -0400 Received: by mail-wm0-f41.google.com with SMTP id n129so118545238wmn.1 for ; Tue, 24 May 2016 02:10:19 -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=JOtmqoLi0OlPZBj45Qj0fvCfsd8zwxlty9pMoBEOI3PvAtSCJdqBsgp+z68tQIgZhz fDYYkig7YGaVMP8mD6DYLRK4hFStxpNoMvsEWGbnpa2YbS3WIov3Otj5k4Ua5jsCa7Fy mQ4pj/+M52Ck9wbjknxWvhnGg+xefmFT26qI1YDPnDQfLjsHIGHUnX4R0d0/ahhhvWVK DKRHUc/sXsBdL//jQIHTQ0C0D39bX8eRVQHVyO5oSnyOZV8Wzb6XZZxreY4Qi8uxodQK iG2OB9UYLALC4ZoEztMMlbGCzVjKY1fh3lFQoyeN+yTcKUb8tpLu9o8oEINIgY5AGZBM fSbw== X-Gm-Message-State: ALyK8tKb6F4wb8nvNJ5anYmpAkqKe5jfRVXyzJ5OYzaJGJyLQck0ZITuhP/SdK6YQwXEBeRP 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?= Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Marc Zyngier , Eric Auger , Andre Przywara 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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; +}