From patchwork Tue Nov 17 09:40:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 56743 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1827324lbb; Tue, 17 Nov 2015 01:48:36 -0800 (PST) X-Received: by 10.140.195.143 with SMTP id q137mr42859232qha.44.1447753716650; Tue, 17 Nov 2015 01:48:36 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [50.57.142.19]) by mx.google.com with ESMTPS id 18si29130526qhz.67.2015.11.17.01.48.36 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:48:36 -0800 (PST) Received-SPF: neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=50.57.142.19; Authentication-Results: mx.google.com; spf=neutral (google.com: 50.57.142.19 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; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZycrI-0006oE-27; Tue, 17 Nov 2015 09:47:28 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZycrG-0006mm-SM for xen-devel@lists.xen.org; Tue, 17 Nov 2015 09:47:27 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id B3/E7-23747-EA7FA465; Tue, 17 Nov 2015 09:47:26 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-4.tower-31.messagelabs.com!1447753645!4270624!1 X-Originating-IP: [74.125.82.49] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.19.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 45602 invoked from network); 17 Nov 2015 09:47:25 -0000 Received: from mail-wm0-f49.google.com (HELO mail-wm0-f49.google.com) (74.125.82.49) by server-4.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Nov 2015 09:47:25 -0000 Received: by wmec201 with SMTP id c201so17317972wme.1 for ; Tue, 17 Nov 2015 01:47:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ti27rU726zIfFdtiXAB/QNGt2Akz8/1glUdL8ak/7y4=; b=wGl/OOTaY8W2o6vB19q8h0Rf8+66B5OLcvIWvaNBN/RoCsRDQBf6Pkqa8vAlseRZdK GQ9YnV5YnzQlB/NGc3dDxc/69qYQ++CMT3y4MdX8jA6UsCk9RLee2uibB6FcbdVOF7tD KHo79d3j/mHeYxyYzNhDDoVKLl4CJHuNNgMjS4WGDGsP6WM7hfIIU5evlPyNJT22BugJ dtMVpOyM6UZLNVcNJJqyDhfj2ZULceDEvWwYLHmrodzX5ZTFdtlYCGFDT3Fj3f6Ri2sP vUgHU7KAcIZKNxTwYjc3QLPWAzBdMooDOC9WxmQD/wOit37SMcxTh3gtxk2z+jpFZBN2 GHjQ== 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=ti27rU726zIfFdtiXAB/QNGt2Akz8/1glUdL8ak/7y4=; b=m0A+62GOyI7UdENmEj3xuX3iHM1YCOk9uNxGpx7fnU41iRSIBRkRZWB5Bfy3j6fcSx tAfS8w1cSD9uAbX3+UDD5xP573LmfrpWTBsW5n68gM87FwoXNhPnS0t18ofPZaqFboOB ++39cBCG/QafBkYbhUe8ibb6pyC9vZCf+vr8Z/S7TxHQynzb+OhH3U9tl3D/2PxUPdeS E8YZhxzintQbcgLmASeJKY9ACeghgAv1qdeemLYqgRqOusdt0vRhkm+3Flxa9bLbmAHk RlhQx34FtteN3671+0bT6GfnSeat6xkFGQXer1ooBLa81BXGFFd6PTPUekylC4CVz2yR q4Cw== X-Gm-Message-State: ALoCoQl9h5c2qogqmCO0pBpiT8CCzMs8EJoHmXXuA4zEG0OiL5IDQcHNeeTdH3xgZz5Hl0q0lw7K X-Received: by 10.194.8.9 with SMTP id n9mr42956074wja.22.1447753645474; Tue, 17 Nov 2015 01:47:25 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id q6sm18452790wmd.8.2015.11.17.01.47.22 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:47:24 -0800 (PST) From: shannon.zhao@linaro.org To: ian.campbell@citrix.com, stefano.stabellini@citrix.com, keir@xen.org, jbeulich@suse.com, andrew.cooper3@citrix.com, julien.grall@citrix.com, xen-devel@lists.xen.org Date: Tue, 17 Nov 2015 17:40:42 +0800 Message-Id: <1447753261-7552-44-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> References: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> Cc: mark.rutland@arm.com, hangaohuai@huawei.com, ard.biesheuvel@linaro.org, shannon.zhao@linaro.org, christoffer.dall@linaro.org, peter.huangpeng@huawei.com, david.vrabel@citrix.com, zhaoshenglong@huawei.com, linux-arm-kernel@lists.infradead.org, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v3 43/62] arm/acpi: Prepare MADT table for Dom0 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org From: Shannon Zhao Copy and modify MADT table before passing it to Dom0. Copy dom0_max_vcpus of GICCs and GICD as well. Signed-off-by: Shannon Zhao --- xen/arch/arm/domain_build.c | 98 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) -- 2.1.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 5d03dc0..4591955 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1359,6 +1359,100 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) #ifdef CONFIG_ACPI #define XEN_HYPERVISOR_ID 0x000058656E564D4D /* "XenVMM" */ +static int acpi_create_madt(struct domain *d, struct membank tbl_add[]) +{ + struct acpi_table_header *table = NULL; + struct acpi_table_madt *madt = NULL; + struct acpi_madt_generic_distributor gicd; + u64 table_size = sizeof(struct acpi_table_madt); + acpi_status status; + int i; + u8 *base_ptr; + u8 checksum; + + status = acpi_get_table(ACPI_SIG_MADT, 0, &table); + + if ( ACPI_FAILURE(status) ) + { + const char *msg = acpi_format_exception(status); + + printk("Failed to get MADT table, %s\n", msg); + return -EINVAL; + } + + base_ptr = d->arch.efi_acpi_table + + acpi_get_table_offset(tbl_add, TBL_MADT); + ACPI_MEMCPY(base_ptr, table, table_size); + + /* Add Generic Distributor */ + memset(&gicd, 0, sizeof(gicd)); + gicd.header.type = ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR; + gicd.header.length = sizeof(gicd); + gicd.base_address = d->arch.vgic.dbase; + if ( d->arch.vgic.version == GIC_V2 ) + gicd.version = ACPI_MADT_GIC_VERSION_V2; + else if ( d->arch.vgic.version == GIC_V3 ) + gicd.version = ACPI_MADT_GIC_VERSION_V3; + else + gicd.version = ACPI_MADT_GIC_VERSION_NONE; + ACPI_MEMCPY(base_ptr + table_size, &gicd, sizeof(gicd)); + table_size += sizeof(gicd); + + if ( d->arch.vgic.version == GIC_V3 ) { + /* Add Generic Redistributor */ + for ( i = 0; i < d->arch.vgic.nr_regions; i++ ) { + struct acpi_madt_generic_redistributor gicr; + + memset(&gicr, 0, sizeof(gicr)); + gicr.header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR; + gicr.header.length = sizeof(gicr); + gicr.base_address = d->arch.vgic.rdist_regions[i].base; + gicr.length = d->arch.vgic.rdist_regions[i].size; + ACPI_MEMCPY(base_ptr + table_size, &gicr, sizeof(gicr)); + table_size += sizeof(gicr); + } + } else { + /* Add Generic Interrupt */ + for ( i = 0; i < d->max_vcpus; i++ ) + { + struct acpi_madt_generic_interrupt gicc; + u64 mpidr = 0; + u32 id = i, j = 0; + + memset(&gicc, 0, sizeof(gicc)); + gicc.header.type = ACPI_MADT_TYPE_GENERIC_INTERRUPT; + gicc.header.length = sizeof(gicc); + gicc.cpu_interface_number = i; + gicc.uid = i; + gicc.flags = ACPI_MADT_ENABLED; + gicc.base_address = d->arch.vgic.cbase; + + do { + mpidr |= (id % 4) << (8 * j); + j++; + if ( j ==3 ) + j++; + id = id / 4; + } while(id > 0); + gicc.arm_mpidr = mpidr; + + ACPI_MEMCPY(base_ptr + table_size, &gicc, sizeof(gicc)); + table_size += sizeof(gicc); + } + } + + madt = (struct acpi_table_madt *)base_ptr; + madt->header.length = table_size; + checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, madt), table_size); + madt->header.checksum -= checksum; + + tbl_add[TBL_MADT].start = d->arch.efi_acpi_gpa + + acpi_get_table_offset(tbl_add, TBL_MADT); + tbl_add[TBL_MADT].size = table_size; + + return 0; +} + static int acpi_create_fadt(struct domain *d, struct membank tbl_add[]) { struct acpi_table_header *table = NULL; @@ -1463,6 +1557,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) if ( rc != 0 ) return rc; + rc = acpi_create_madt(d, tbl_add); + if ( rc != 0 ) + return rc; + return 0; } #else