From patchwork Tue Mar 29 13:01:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 64596 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1997641lbc; Tue, 29 Mar 2016 06:03:05 -0700 (PDT) X-Received: by 10.98.64.144 with SMTP id f16mr3185934pfd.159.1459256585151; Tue, 29 Mar 2016 06:03:05 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id r75si6293233pfi.85.2016.03.29.06.03.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Mar 2016 06:03:05 -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 1aktHX-0007r3-RV; Tue, 29 Mar 2016 13:02:03 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aktHU-0007jC-2r for linux-arm-kernel@lists.infradead.org; Tue, 29 Mar 2016 13:02:02 +0000 Received: by mail-wm0-x231.google.com with SMTP id 20so25184972wmh.1 for ; Tue, 29 Mar 2016 06:01:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sfuzqmz4zCHSX3ziaMkOFaKS4OqlaN5kogiwKcvGc0E=; b=H/bsDKtY/2XSwtl5c7JH2yZ8/idIppMyLktgVRQRFmMntlY9N3eg19JweOophbSqOy gRQKe2tzCEFcI7BMpFVg/hYiZxhjvfdKnEw5LAN/KH/tKqvCf6Et7WC0xifgO1O3ZfA+ iBnzqg7YYxGtaph4aBo1bKcJ42bs1+UHDN/sU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=sfuzqmz4zCHSX3ziaMkOFaKS4OqlaN5kogiwKcvGc0E=; b=jQ0M60EC+F/mwMmTD80yPqtJS+SLcLKIntsNRBXz3zs/zLMHoswWbE7q+w4i9mz6wc PH2nqmP5pR2epB8BIBtDtdizLrxfEcdtMYw1hKciaeCeuAxeWOQ8WR5iOY7ooQoCChiv 2IVpsQYE9kuJepCCWYo+rnlE55ugLy14T6oiRygrzKf68oobWZlFUDboLWMz19tzjNHO hDc60o3WwuBWlkaCVfMty47hjS/C/cd3/HbxGlFkDUMUzffsnrLvaJH+MIHG2gjroZyY H9/tw/NZXvWxeE0tarOT+VgC3r8CTsn/kGoMIOJuSpZMfVnq7wstkgPaNzYlF7qkbaK9 WMqQ== X-Gm-Message-State: AD7BkJIpTbV1RI6y9gQK7OuflYvShTEHlqTYaZdqm7gtiHIkbY3hgdX9g1XFl8qfMX81Q1Xg X-Received: by 10.28.72.138 with SMTP id v132mr3050626wma.37.1459256497423; Tue, 29 Mar 2016 06:01:37 -0700 (PDT) Received: from localhost ([94.18.191.146]) by smtp.gmail.com with ESMTPSA id j18sm14726692wmd.2.2016.03.29.06.01.36 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 29 Mar 2016 06:01:36 -0700 (PDT) Date: Tue, 29 Mar 2016 15:01:35 +0200 From: Christoffer Dall To: Andre Przywara Subject: Re: [RFC PATCH 03/45] KVM: arm/arm64: arch_timer: rework VGIC <-> timer interface Message-ID: <20160329130135.GD4126@cbox> References: <1458871508-17279-1-git-send-email-andre.przywara@arm.com> <1458871508-17279-4-git-send-email-andre.przywara@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1458871508-17279-4-git-send-email-andre.przywara@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160329_060200_421039_4D24EF29 X-CRM114-Status: GOOD ( 23.60 ) 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:231 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -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 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 , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Eric Auger Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org On Fri, Mar 25, 2016 at 02:04:26AM +0000, Andre Przywara wrote: > Adapt the interface between the virtualized arch timer and the > emulated VGIC to avoid the phys_map when possible. > This prepares the arch timer to go with both the existing VGIC > implementation and the new version later without too many code > changes. > > Signed-off-by: Andre Przywara > --- > include/kvm/arm_vgic.h | 7 ++++--- > virt/kvm/arm/arch_timer.c | 11 +++++------ > virt/kvm/arm/vgic.c | 18 +++++++++--------- > 3 files changed, 18 insertions(+), 18 deletions(-) > > diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h > index 2b89e27..7656a46 100644 > --- a/include/kvm/arm_vgic.h > +++ b/include/kvm/arm_vgic.h > @@ -345,13 +345,14 @@ void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu); > int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num, > bool level); > int kvm_vgic_inject_mapped_irq(struct kvm *kvm, int cpuid, > - struct irq_phys_map *map, bool level); > + int virt_irq, bool level); > void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg); > 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); > +int kvm_vgic_unmap_phys_irq(struct kvm_vcpu *vcpu, struct irq_phys_map *map, > + int virt_irq); I don't understand the benefit of this change. You're now passing the virt_irq in both the struct and as a parameter. If you want to get rid of the irq_phys_map structure, just replace all occurences of it with two parameters/arguments instead, int virt_irq, int phys_irq, both of which are INTIDs. You don't need to pass the Linux IRQ number from outside the vgic to the vgic anymore, and it's just there for historical reasons, so you can remove that with a separate patch if you want. If you want me to send a patch removing the IRQ field, let me know. It looks something like this: _______________________________________________ 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/arm_vgic.h b/include/kvm/arm_vgic.h index 281caf8..9ffe29c 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -157,7 +157,6 @@ struct vgic_io_device { struct irq_phys_map { u32 virt_irq; u32 phys_irq; - u32 irq; }; struct irq_phys_map_entry { @@ -345,7 +344,7 @@ int kvm_vgic_inject_mapped_irq(struct kvm *kvm, int cpuid, void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg); 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 virt_irq, int phys_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); diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index a9ad4fe..73ca3e5 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -274,7 +274,7 @@ void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu) if (timer->active_cleared_last && !phys_active) return; - ret = irq_set_irqchip_state(timer->map->irq, + ret = irq_set_irqchip_state(host_vtimer_irq, IRQCHIP_STATE_ACTIVE, phys_active); WARN_ON(ret); @@ -307,6 +307,9 @@ int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu, { struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; struct irq_phys_map *map; + struct irq_desc *desc; + struct irq_data *data; + int phys_irq; /* * The vcpu timer irq number cannot be determined in @@ -326,10 +329,25 @@ int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu, kvm_timer_update_state(vcpu); /* + * Find the physical IRQ number corresponding to the host_vtimer_irq + */ + desc = irq_to_desc(host_vtimer_irq); + if (!desc) { + kvm_err("%s: no interrupt descriptor\n", __func__); + return -EINVAL; + } + + data = irq_desc_get_irq_data(desc); + while (data->parent_data) + data = data->parent_data; + + phys_irq = data->hwirq; + + /* * Tell the VGIC that the virtual interrupt is tied to a * physical interrupt. We do that once per VCPU. */ - map = kvm_vgic_map_phys_irq(vcpu, irq->irq, host_vtimer_irq); + map = kvm_vgic_map_phys_irq(vcpu, irq->irq, phys_irq); if (WARN_ON(IS_ERR(map))) return PTR_ERR(map); diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 00429b3..012f428 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1724,27 +1724,13 @@ static struct list_head *vgic_get_irq_phys_map_list(struct kvm_vcpu *vcpu, * Returns a valid pointer on success, and an error pointer otherwise */ struct irq_phys_map *kvm_vgic_map_phys_irq(struct kvm_vcpu *vcpu, - int virt_irq, int irq) + int virt_irq, int phys_irq) { struct vgic_dist *dist = &vcpu->kvm->arch.vgic; struct list_head *root = vgic_get_irq_phys_map_list(vcpu, virt_irq); struct irq_phys_map *map; struct irq_phys_map_entry *entry; - struct irq_desc *desc; - struct irq_data *data; - int phys_irq; - desc = irq_to_desc(irq); - if (!desc) { - kvm_err("%s: no interrupt descriptor\n", __func__); - return ERR_PTR(-EINVAL); - } - - data = irq_desc_get_irq_data(desc); - while (data->parent_data) - data = data->parent_data; - - phys_irq = data->hwirq; /* Create a new mapping */ entry = kzalloc(sizeof(*entry), GFP_KERNEL); @@ -1757,8 +1743,7 @@ struct irq_phys_map *kvm_vgic_map_phys_irq(struct kvm_vcpu *vcpu, map = vgic_irq_map_search(vcpu, virt_irq); if (map) { /* Make sure this mapping matches */ - if (map->phys_irq != phys_irq || - map->irq != irq) + if (map->phys_irq != phys_irq) map = ERR_PTR(-EINVAL); /* Found an existing, valid mapping */ @@ -1768,7 +1753,6 @@ struct irq_phys_map *kvm_vgic_map_phys_irq(struct kvm_vcpu *vcpu, map = &entry->map; map->virt_irq = virt_irq; map->phys_irq = phys_irq; - map->irq = irq; list_add_tail_rcu(&entry->entry, root);