From patchwork Wed Jun 10 04:16:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 6576451 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 05C1FC0020 for ; Wed, 10 Jun 2015 04:17:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 26F1E205C1 for ; Wed, 10 Jun 2015 04:17:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2AEB420595 for ; Wed, 10 Jun 2015 04:17:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751431AbbFJEQy (ORCPT ); Wed, 10 Jun 2015 00:16:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43996 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751686AbbFJEQt (ORCPT ); Wed, 10 Jun 2015 00:16:49 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 216C434F3A1; Wed, 10 Jun 2015 04:16:49 +0000 (UTC) Received: from apm-mustang-ev3-34.khw.lab.eng.bos.redhat.com (apm-mustang-ev3-34.khw.lab.eng.bos.redhat.com [10.16.184.128]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5A4GhmD009605; Wed, 10 Jun 2015 00:16:48 -0400 From: Wei Huang To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, marc.zyngier@arm.com, christoffer.dall@linaro.org, pbonzini@redhat.com, drjones@redhat.com, a.spyridakis@virtualopensystems.com, hanjun.guo@linaro.org, wei@redhat.com Subject: [PATCH V2 4/5] kvm: arm64: Implement ACPI probing code for GICv2 Date: Wed, 10 Jun 2015 00:16:06 -0400 Message-Id: <1433909767-12189-5-git-send-email-wei@redhat.com> In-Reply-To: <1433909767-12189-1-git-send-email-wei@redhat.com> References: <1433909767-12189-1-git-send-email-wei@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patches enables ACPI support for KVM virtual GICv2. KVM parses ACPI table for virt GIC related information and initializes resources. Signed-off-by: Alexander Spyridaki Signed-off-by: Wei Huang --- virt/kvm/arm/vgic-v2.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/virt/kvm/arm/vgic-v2.c b/virt/kvm/arm/vgic-v2.c index 711de82..f6e56e9 100644 --- a/virt/kvm/arm/vgic-v2.c +++ b/virt/kvm/arm/vgic-v2.c @@ -264,6 +264,54 @@ int vgic_v2_acpi_probe(struct acpi_madt_generic_interrupt *vgic_acpi, const struct vgic_ops **ops, const struct vgic_params **params) { - return -EINVAL; + struct vgic_params *vgic = &vgic_v2_params; + int irq_mode, ret; + + /* IRQ trigger mode */ + irq_mode = (vgic_acpi->flags & ACPI_MADT_VGIC_IRQ_MODE) ? + ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; + vgic->maint_irq = acpi_register_gsi(NULL, vgic_acpi->vgic_interrupt, + irq_mode, ACPI_ACTIVE_HIGH); + if (!vgic->maint_irq) { + kvm_err("Cannot register VGIC ACPI maintenance irq\n"); + ret = -ENXIO; + goto out; + } + + /* GICH resource */ + vgic->vctrl_base = ioremap(vgic_acpi->gich_base_address, SZ_8K); + if (!vgic->vctrl_base) { + kvm_err("cannot ioremap GICH memory\n"); + ret = -ENOMEM; + goto out; + } + + vgic->nr_lr = readl_relaxed(vgic->vctrl_base + GICH_VTR); + vgic->nr_lr = (vgic->nr_lr & 0x3f) + 1; + + ret = create_hyp_io_mappings(vgic->vctrl_base, + vgic->vctrl_base + SZ_8K, + vgic_acpi->gich_base_address); + if (ret) { + kvm_err("Cannot map GICH into hyp\n"); + goto out; + } + + vgic->vcpu_base = vgic_acpi->gicv_base_address; + vgic->can_emulate_gicv2 = true; + kvm_register_device_ops(&kvm_arm_vgic_v2_ops, KVM_DEV_TYPE_ARM_VGIC_V2); + + kvm_info("GICH base=0x%llx, GICV base=0x%llx, IRQ=%d\n", + (unsigned long long)vgic_acpi->gich_base_address, + (unsigned long long)vgic_acpi->gicv_base_address, + vgic->maint_irq); + + vgic->type = VGIC_V2; + vgic->max_gic_vcpus = VGIC_V2_MAX_CPUS; + *ops = &vgic_v2_ops; + *params = vgic; + +out: + return ret; } #endif /* CONFIG_ACPI */