From patchwork Tue May 24 09:08:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9133173 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 D98BA607D3 for ; Tue, 24 May 2016 09:15:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3898D27BF0 for ; Tue, 24 May 2016 09:15:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DA542824F; Tue, 24 May 2016 09:15:12 +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 BCF4727BF0 for ; Tue, 24 May 2016 09:15:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932372AbcEXJKF (ORCPT ); Tue, 24 May 2016 05:10:05 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:35886 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932332AbcEXJKA (ORCPT ); Tue, 24 May 2016 05:10:00 -0400 Received: by mail-wm0-f42.google.com with SMTP id n129so118529432wmn.1 for ; Tue, 24 May 2016 02:09:59 -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=5D+6hoJATKxY5utXthVwqYQuK8HahrbIaC6xbTzljGg=; b=OljmwX4kT0yqOGQ9M70Q9tS0zHbkI5R6FuqeZlFIoRNoYa4EbxBjdMh2Iz5NjdMdve DhQTMclm521tDbKJ2QmBPHoCbWQcFeDPor06tEsiHFrqSN4YRceGntpb512Exo80lhI4 ldwU3lPfYZ0SxgOAf6w8m6xtDrbBQRIUP5cPw= 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=5D+6hoJATKxY5utXthVwqYQuK8HahrbIaC6xbTzljGg=; b=ZLU3fxKzQWVUwHKJPZH1pg/ivKeNMQTBKds/fND0LZbKEy3bjBU2ymtb7qyypMAc6N doAvc/qDmcsfm9KIoHjoqsIOYLQ27QyB3I3+zd46P3lqoO20CxUc0JGtGjq7v2wM28cY fDclaNsUxBHt2ZnssRNXcjWN8wODIU5krCWjvDdnsXmnKg9s0vzWIKPgUYb2iqdeclto Mr1AEtlbAnt1xlA9795V6XBGlYtMF3EanF2ilRk+CBA243cEP8iz5JTIGTi+syiI99Hg cCWymAAcUcp2An7aNB5ASxU+82ZncG6r8hQfiQOCQGtBd1yKMXh3XQb9CFyrP21b0pov DybQ== X-Gm-Message-State: ALyK8tKuKDiHwosYRjA9x2tBySqUK/0fs2cQlVqQjOvf4vP4PDK9nU3wzLGtLFTZaDDTHXpi X-Received: by 10.194.84.74 with SMTP id w10mr3075284wjy.118.1464080998923; Tue, 24 May 2016 02:09:58 -0700 (PDT) Received: from localhost.localdomain ([94.18.191.146]) by smtp.gmail.com with ESMTPSA id f11sm18163246wmf.22.2016.05.24.02.09.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 May 2016 02:09:58 -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 , Andre Przywara Subject: [PULL 04/59] KVM: arm/arm64: vgic: avoid map in kvm_vgic_map_is_active() Date: Tue, 24 May 2016 11:08:58 +0200 Message-Id: <1464080993-10884-5-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: Andre Przywara For getting the active state of a mapped IRQ, we actually only need the virtual IRQ number, not the pointer to the mapping entry. Pass the virtual IRQ number from the arch timer to the VGIC directly. Signed-off-by: Andre Przywara Reviewed-by: Eric Auger Reviewed-by: Christoffer Dall --- include/kvm/arm_vgic.h | 2 +- virt/kvm/arm/arch_timer.c | 6 ++---- virt/kvm/arm/vgic.c | 6 +++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index e22f015..9830232 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -348,7 +348,7 @@ int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu); struct irq_phys_map *kvm_vgic_map_phys_irq(struct kvm_vcpu *vcpu, int virt_irq, int irq); int kvm_vgic_unmap_phys_irq(struct kvm_vcpu *vcpu, struct irq_phys_map *map); -bool kvm_vgic_map_is_active(struct kvm_vcpu *vcpu, struct irq_phys_map *map); +bool kvm_vgic_map_is_active(struct kvm_vcpu *vcpu, unsigned int virt_irq); #define irqchip_in_kernel(k) (!!((k)->arch.vgic.in_kernel)) #define vgic_initialized(k) (!!((k)->arch.vgic.nr_cpus)) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index a9c6c1c..37f82c1 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -274,10 +274,8 @@ void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu) * to ensure that hardware interrupts from the timer triggers a guest * exit. */ - if (timer->irq.level || kvm_vgic_map_is_active(vcpu, timer->map)) - phys_active = true; - else - phys_active = false; + phys_active = timer->irq.level || + kvm_vgic_map_is_active(vcpu, timer->map->virt_irq); /* * We want to avoid hitting the (re)distributor as much as diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 81c557c..2fd43a6 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1102,18 +1102,18 @@ static bool dist_active_irq(struct kvm_vcpu *vcpu) return test_bit(vcpu->vcpu_id, dist->irq_active_on_cpu); } -bool kvm_vgic_map_is_active(struct kvm_vcpu *vcpu, struct irq_phys_map *map) +bool kvm_vgic_map_is_active(struct kvm_vcpu *vcpu, unsigned int virt_irq) { int i; for (i = 0; i < vcpu->arch.vgic_cpu.nr_lr; i++) { struct vgic_lr vlr = vgic_get_lr(vcpu, i); - if (vlr.irq == map->virt_irq && vlr.state & LR_STATE_ACTIVE) + if (vlr.irq == virt_irq && vlr.state & LR_STATE_ACTIVE) return true; } - return vgic_irq_is_active(vcpu, map->virt_irq); + return vgic_irq_is_active(vcpu, virt_irq); } /*