From patchwork Fri Mar 25 13:48:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 64466 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp183227lbc; Fri, 25 Mar 2016 06:50:47 -0700 (PDT) X-Received: by 10.140.82.146 with SMTP id h18mr17834020qgd.26.1458913847218; Fri, 25 Mar 2016 06:50:47 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id a126si10782042qkb.100.2016.03.25.06.50.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Mar 2016 06:50:47 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ajS7K-00011n-VX; Fri, 25 Mar 2016 13:49:34 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ajS7J-00010s-7Y for xen-devel@lists.xen.org; Fri, 25 Mar 2016 13:49:33 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id DB/9A-29237-CE145F65; Fri, 25 Mar 2016 13:49:32 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-8.tower-21.messagelabs.com!1458913770!5871688!1 X-Originating-IP: [209.85.192.178] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29535 invoked from network); 25 Mar 2016 13:49:31 -0000 Received: from mail-pf0-f178.google.com (HELO mail-pf0-f178.google.com) (209.85.192.178) by server-8.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 25 Mar 2016 13:49:31 -0000 Received: by mail-pf0-f178.google.com with SMTP id u190so83476919pfb.3 for ; Fri, 25 Mar 2016 06:49:31 -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=CFLeaSr8a12qijVt8BS+zX0A9UckF6IXUD33gM0JZt0=; b=VkccXbHw/lMy94Fzp7ABvV/GapFc9VgX/GIenOcG8KL0VNVVRhXG0jO1hgXA4Y8JKd Tw+8Iv2vmHYSK8R5UpBdFMmxc2HP0FZtjiktawm32vWFuJ2+Jia+xZ9/4xa14aK5khyy flp2a9GFzuXJ1PpTG99ykmJY3MExZx8wH4wuM= 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=CFLeaSr8a12qijVt8BS+zX0A9UckF6IXUD33gM0JZt0=; b=PIHRhW+ppVzkqNpAOshzKTyU6vF9bdbkC0FHmypkdaJVWR360nmHH9TeTMIxPoMPaR V9J5zTlF8T/Y2m1TD0L+41y0eWnOQuQ97jOFQpKpI1q7KP8SJizxjFGP6dXS5/a9S95s xHDGgvpl8KOppBIlXfrtgp/8aNDWFjIjE+kEgY5wJPua3eg2K9KxE+Ojsm630Ba65AcH IOLgM84KVvf5MbsGnyBvZtFx/BSfmAvgYRdse81OpvgKrJJ2Wg+V7xFbHQaXm/tDG0Td c06pDmrAt4icdAi9AqOO6l/bIx0PuUG8xIKf7QLzQUk1WzkOSKTo//v4cHPoSpNHcjmd Jc4Q== X-Gm-Message-State: AD7BkJIZ0G82t/4ykxn6fPT3YBEJVgVdjNpRaYYncwEoXsLJssJwWWELzh3YSubvhIY4jBXr X-Received: by 10.98.19.195 with SMTP id 64mr21125459pft.62.1458913769991; Fri, 25 Mar 2016 06:49:29 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.2]) by smtp.gmail.com with ESMTPSA id w20sm16744178pfi.31.2016.03.25.06.49.26 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Mar 2016 06:49:29 -0700 (PDT) From: Shannon Zhao To: xen-devel@lists.xen.org Date: Fri, 25 Mar 2016 21:48:37 +0800 Message-Id: <1458913735-2678-5-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458913735-2678-1-git-send-email-shannon.zhao@linaro.org> References: <1458913735-2678-1-git-send-email-shannon.zhao@linaro.org> Cc: julien.grall@arm.com, shannon.zhao@linaro.org, stefano.stabellini@citrix.com, peter.huangpeng@huawei.com, zhaoshenglong@huawei.com Subject: [Xen-devel] [PATCH v7 04/22] arm/gic: Add a new callback for creating MADT table for Dom0 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Add a new member in gic_hw_operations which is used to create MADT table for Dom0. Signed-off-by: Shannon Zhao Reviewed-by: Stefano Stabellini Acked-by: Julien Grall --- v7: make other fields of GICC zero --- xen/arch/arm/gic-v2.c | 42 +++++++++++++++++++++++++++++++++++ xen/arch/arm/gic-v3.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/gic.c | 5 +++++ xen/include/asm-arm/gic.h | 3 +++ 4 files changed, 106 insertions(+) diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index 0fcb894..38e3216 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -685,6 +685,43 @@ static void __init gicv2_dt_init(void) } #ifdef CONFIG_ACPI +static int gicv2_make_hwdom_madt(const struct domain *d, u32 offset) +{ + struct acpi_subtable_header *header; + struct acpi_madt_generic_interrupt *host_gicc, *gicc; + u32 i, size, table_len = 0; + u8 *base_ptr = d->arch.efi_acpi_table + offset; + + header = acpi_table_get_entry_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0); + if ( !header ) + { + printk("Can't get GICC entry"); + return -EINVAL; + } + + host_gicc = container_of(header, struct acpi_madt_generic_interrupt, + header); + size = sizeof(struct acpi_madt_generic_interrupt); + /* Add Generic Interrupt */ + for ( i = 0; i < d->max_vcpus; i++ ) + { + gicc = (struct acpi_madt_generic_interrupt *)(base_ptr + table_len); + ACPI_MEMCPY(gicc, host_gicc, size); + gicc->cpu_interface_number = i; + gicc->uid = i; + gicc->flags = ACPI_MADT_ENABLED; + gicc->arm_mpidr = vcpuid_to_vaffinity(i); + gicc->parking_version = 0; + gicc->performance_interrupt = 0; + gicc->gicv_base_address = 0; + gicc->gich_base_address = 0; + gicc->vgic_interrupt = 0; + table_len += size; + } + + return table_len; +} + static int __init gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header, const unsigned long end) @@ -776,6 +813,10 @@ static void __init gicv2_acpi_init(void) } #else static void __init gicv2_acpi_init(void) { } +static int gicv2_make_hwdom_madt(const struct domain *d, u32 offset) +{ + return 0; +} #endif static int __init gicv2_init(void) @@ -868,6 +909,7 @@ const static struct gic_hw_operations gicv2_ops = { .read_vmcr_priority = gicv2_read_vmcr_priority, .read_apr = gicv2_read_apr, .make_hwdom_dt_node = gicv2_make_hwdom_dt_node, + .make_hwdom_madt = gicv2_make_hwdom_madt, }; /* Set up the GIC */ diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index f83fd88..52ee23c 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1236,6 +1236,57 @@ static void __init gicv3_dt_init(void) } #ifdef CONFIG_ACPI +static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset) +{ + struct acpi_subtable_header *header; + struct acpi_madt_generic_interrupt *host_gicc, *gicc; + struct acpi_madt_generic_redistributor *gicr; + u8 *base_ptr = d->arch.efi_acpi_table + offset; + u32 i, table_len = 0, size; + + /* Add Generic Interrupt */ + header = acpi_table_get_entry_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0); + if ( !header ) + { + printk("Can't get GICC entry"); + return -EINVAL; + } + + host_gicc = container_of(header, struct acpi_madt_generic_interrupt, + header); + size = sizeof(struct acpi_madt_generic_interrupt); + for ( i = 0; i < d->max_vcpus; i++ ) + { + gicc = (struct acpi_madt_generic_interrupt *)(base_ptr + table_len); + ACPI_MEMCPY(gicc, host_gicc, size); + gicc->cpu_interface_number = i; + gicc->uid = i; + gicc->flags = ACPI_MADT_ENABLED; + gicc->arm_mpidr = vcpuid_to_vaffinity(i); + gicc->parking_version = 0; + gicc->performance_interrupt = 0; + gicc->gicv_base_address = 0; + gicc->gich_base_address = 0; + gicc->gicr_base_address = 0; + gicc->vgic_interrupt = 0; + table_len += size; + } + + /* Add Generic Redistributor */ + size = sizeof(struct acpi_madt_generic_redistributor); + for ( i = 0; i < d->arch.vgic.nr_regions; i++ ) + { + gicr = (struct acpi_madt_generic_redistributor *)(base_ptr + table_len); + gicr->header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR; + gicr->header.length = size; + gicr->base_address = d->arch.vgic.rdist_regions[i].base; + gicr->length = d->arch.vgic.rdist_regions[i].size; + table_len += size; + } + + return table_len; +} + static int __init gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header, const unsigned long end) @@ -1380,6 +1431,10 @@ static void __init gicv3_acpi_init(void) } #else static void __init gicv3_acpi_init(void) { } +static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset) +{ + return 0; +} #endif /* Set up the GIC */ @@ -1474,6 +1529,7 @@ static const struct gic_hw_operations gicv3_ops = { .read_apr = gicv3_read_apr, .secondary_init = gicv3_secondary_cpu_init, .make_hwdom_dt_node = gicv3_make_hwdom_dt_node, + .make_hwdom_madt = gicv3_make_hwdom_madt, }; static int __init gicv3_dt_preinit(struct dt_device_node *node, const void *data) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index fbbe37f..b3c1eb3 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -739,6 +739,11 @@ int gic_make_hwdom_dt_node(const struct domain *d, return gic_hw_ops->make_hwdom_dt_node(d, gic, fdt); } +int gic_make_hwdom_madt(const struct domain *d, u32 offset) +{ + return gic_hw_ops->make_hwdom_madt(d, offset); +} + /* * Local variables: * mode: C diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 7bd06e1..8130136 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -358,12 +358,15 @@ struct gic_hw_operations { /* Create GIC node for the hardware domain */ int (*make_hwdom_dt_node)(const struct domain *d, const struct dt_device_node *gic, void *fdt); + /* Create MADT table for the hardware domain */ + int (*make_hwdom_madt)(const struct domain *d, u32 offset); }; void register_gic_ops(const struct gic_hw_operations *ops); int gic_make_hwdom_dt_node(const struct domain *d, const struct dt_device_node *gic, void *fdt); +int gic_make_hwdom_madt(const struct domain *d, u32 offset); #endif /* __ASSEMBLY__ */ #endif