From patchwork Wed Feb 1 10:22:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9549267 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 8AE3D60236 for ; Wed, 1 Feb 2017 10:23:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C25D27BA5 for ; Wed, 1 Feb 2017 10:23:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70B6A283B3; Wed, 1 Feb 2017 10:23:01 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 CB1D727BA5 for ; Wed, 1 Feb 2017 10:23:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751408AbdBAKW6 (ORCPT ); Wed, 1 Feb 2017 05:22:58 -0500 Received: from mail-lf0-f47.google.com ([209.85.215.47]:35403 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751202AbdBAKW5 (ORCPT ); Wed, 1 Feb 2017 05:22:57 -0500 Received: by mail-lf0-f47.google.com with SMTP id n124so225497462lfd.2 for ; Wed, 01 Feb 2017 02:22:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=uN34/beC0X8LTQm2/DW3z4Zr3RAK6FwbLy0y9BzN7ns=; b=NxYHh1FWIa61hvBWkGGEfXyOemA7fynUW3BZFop9kN5AKmE7g4FcleSChsfyaEguxu 2Jy7n/hh1BbG9SAynGtPnv2KGiT1YA8aFM85rKeRvSAM1MH3WgHswRC3vQsDe9t9o/hS NoQtFmQ6KO2leaaAu6wIWU1qYLmgIFhrNT3sM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uN34/beC0X8LTQm2/DW3z4Zr3RAK6FwbLy0y9BzN7ns=; b=dxl0Re8dm8DKqRHmb0vRpwMSLlahP2arAGP08Vvbd/ycaLAQb8FOpd5hEUz1jJGof/ 6bAaqp2jIKjxNfFvL5q733DQa70vPppM9zRqORCE+dyE459k0KtUxEMmfxwvam2ON6Ux 8byFBjlo1dllvI/SHRyN4bZ6aDeGuTRbROSFjVofMcHw6e82v4oqwcNUJR6d9TsBUnae /Kj0PMJxxNtRCzzo24P2fnKjoJzmNOubM08A8e4q9gMN59Pb/2b1fNAYDQVhxnQ9r2Sb fhjHNDEGOExwH4olxn1xL9lyJolbZs7YnoTBkJCNBMHFJxbT8k3skev8Vr9tQEZHcDoR +EwA== X-Gm-Message-State: AIkVDXL1geasjf/ZfZpSwv0YpwJ+mC+eMnp1TtAFnH89sW+HVzFpXGibG/pRYekQyV5IWtfI X-Received: by 10.25.154.2 with SMTP id c2mr748208lfe.71.1485944565704; Wed, 01 Feb 2017 02:22:45 -0800 (PST) Received: from localhost.localdomain (94.191.187.220.mobile.3.dk. [94.191.187.220]) by smtp.gmail.com with ESMTPSA id s6sm5582861ljd.6.2017.02.01.02.22.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Feb 2017 02:22:45 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Cc: kvm@vger.kernel.org, Marc Zyngier , Andre Przywara , Jintack Lim , Eric Auger , Christoffer Dall Subject: [PATCH] KVM: arm/arm64: Remove kvm_vgic_inject_mapped_irq Date: Wed, 1 Feb 2017 11:22:40 +0100 Message-Id: <20170201102240.29985-1-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.9.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The only benefit of having kvm_vgic_inject_mapped_irq separate from kvm_vgic_inject_irq is that we pass a boolean that we use for error checking on the injection path. While this could potentially help in some aspect of robustness, it's also a little bit of a defensive move, and arguably callers into the vgic should have make sure they have marked their virtual IRQs as mapped if required. Signed-off-by: Christoffer Dall Acked-by: Marc Zyngier Reviewed-by: Andre Przywara --- virt/kvm/arm/arch_timer.c | 3 ++- virt/kvm/arm/vgic/vgic.c | 50 +++++++++++++++-------------------------------- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 6a084cd..91ecf48 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -175,7 +175,8 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level) timer->irq.level = new_level; trace_kvm_timer_update_irq(vcpu->vcpu_id, timer->irq.irq, timer->irq.level); - ret = kvm_vgic_inject_mapped_irq(vcpu->kvm, vcpu->vcpu_id, + + ret = kvm_vgic_inject_irq(vcpu->kvm, vcpu->vcpu_id, timer->irq.irq, timer->irq.level); WARN_ON(ret); diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index dea12df..654dfd4 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -335,9 +335,22 @@ bool vgic_queue_irq_unlock(struct kvm *kvm, struct vgic_irq *irq) return true; } -static int vgic_update_irq_pending(struct kvm *kvm, int cpuid, - unsigned int intid, bool level, - bool mapped_irq) +/** + * kvm_vgic_inject_irq - Inject an IRQ from a device to the vgic + * @kvm: The VM structure pointer + * @cpuid: The CPU for PPIs + * @intid: The INTID to inject a new state to. + * @level: Edge-triggered: true: to trigger the interrupt + * false: to ignore the call + * Level-sensitive true: raise the input signal + * false: lower the input signal + * + * The VGIC is not concerned with devices being active-LOW or active-HIGH for + * level-sensitive interrupts. You can think of the level parameter as 1 + * being HIGH and 0 being LOW and all devices being active-HIGH. + */ +int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int intid, + bool level) { struct kvm_vcpu *vcpu; struct vgic_irq *irq; @@ -357,11 +370,6 @@ static int vgic_update_irq_pending(struct kvm *kvm, int cpuid, if (!irq) return -EINVAL; - if (irq->hw != mapped_irq) { - vgic_put_irq(kvm, irq); - return -EINVAL; - } - spin_lock(&irq->irq_lock); if (!vgic_validate_injection(irq, level)) { @@ -382,32 +390,6 @@ static int vgic_update_irq_pending(struct kvm *kvm, int cpuid, return 0; } -/** - * kvm_vgic_inject_irq - Inject an IRQ from a device to the vgic - * @kvm: The VM structure pointer - * @cpuid: The CPU for PPIs - * @intid: The INTID to inject a new state to. - * @level: Edge-triggered: true: to trigger the interrupt - * false: to ignore the call - * Level-sensitive true: raise the input signal - * false: lower the input signal - * - * The VGIC is not concerned with devices being active-LOW or active-HIGH for - * level-sensitive interrupts. You can think of the level parameter as 1 - * being HIGH and 0 being LOW and all devices being active-HIGH. - */ -int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int intid, - bool level) -{ - return vgic_update_irq_pending(kvm, cpuid, intid, level, false); -} - -int kvm_vgic_inject_mapped_irq(struct kvm *kvm, int cpuid, unsigned int intid, - bool level) -{ - return vgic_update_irq_pending(kvm, cpuid, intid, level, true); -} - int kvm_vgic_map_phys_irq(struct kvm_vcpu *vcpu, u32 virt_irq, u32 phys_irq) { struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, virt_irq);