From patchwork Sun May 17 20:03:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 48666 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F0E4221411 for ; Sun, 17 May 2015 20:08:10 +0000 (UTC) Received: by wgyu3 with SMTP id u3sf23651876wgy.3 for ; Sun, 17 May 2015 13:08:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=UaGyjAeeQ94AVjgievGhy3hUePW0kbF2/3jR2DrCL50=; b=fqmoJ8pCP4I3cqkqhqQcORa0CyXr8BOwXNjC/FfqS1u0ipXNQn57YYNp4oCvEq9Fkn TZei0xJlh4/Zv1Hu5CKFf1R6mIUYtpH1ADc6MnZTeqEiUaqoveynMGF5+O154ICHLcIm 5yiAu0hL6XbiSq3EGD2Le2+lh2rGZIFeo/fzXCZAIKVB8MJPDNE7QR26rebH4kmIPaKM v8w4Y+YdM3L57CLre3XFnHDNt+33fl2xoOVHaEc0kutJTn7N6mgnXfMF7wsM9lilv6xk XsPAV+qm+lkPm7KhLoD5UOTlW1ISePxghC+nTa9NTyFuFNdGMsxwt1o5G8loJp+4vZdd CBXg== X-Gm-Message-State: ALoCoQlSWdN3MnvkYVjIwaLklQdijH837CdNBhSVEkrs1NPlFNxfBuq6Zrw06flzyTNgugh0Id5A X-Received: by 10.112.83.172 with SMTP id r12mr4071120lby.23.1431893290283; Sun, 17 May 2015 13:08:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.42 with SMTP id u10ls626944laz.64.gmail; Sun, 17 May 2015 13:08:10 -0700 (PDT) X-Received: by 10.112.168.72 with SMTP id zu8mr15020048lbb.54.1431893290141; Sun, 17 May 2015 13:08:10 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id l8si5336516lah.54.2015.05.17.13.08.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 May 2015 13:08:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by labbd9 with SMTP id bd9so191551716lab.2 for ; Sun, 17 May 2015 13:08:10 -0700 (PDT) X-Received: by 10.152.9.66 with SMTP id x2mr14807602laa.36.1431893290039; Sun, 17 May 2015 13:08:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp3508610lbb; Sun, 17 May 2015 13:08:08 -0700 (PDT) X-Received: by 10.140.235.16 with SMTP id g16mr26668694qhc.55.1431893287478; Sun, 17 May 2015 13:08:07 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id h199si5573751qhc.33.2015.05.17.13.08.06 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 17 May 2015 13:08:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yu4pV-0003V9-ES; Sun, 17 May 2015 20:06:33 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yu4pT-0003R7-Gh for xen-devel@lists.xen.org; Sun, 17 May 2015 20:06:31 +0000 Received: from [193.109.254.147] by server-4.bemta-14.messagelabs.com id 37/3B-03245-6C4F8555; Sun, 17 May 2015 20:06:30 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-15.tower-27.messagelabs.com!1431893187!18256897!1 X-Originating-IP: [209.85.220.53] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.15; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14719 invoked from network); 17 May 2015 20:06:29 -0000 Received: from mail-pa0-f53.google.com (HELO mail-pa0-f53.google.com) (209.85.220.53) by server-15.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 17 May 2015 20:06:29 -0000 Received: by pabru16 with SMTP id ru16so119887026pab.1 for ; Sun, 17 May 2015 13:06:27 -0700 (PDT) X-Received: by 10.70.54.164 with SMTP id k4mr38400783pdp.61.1431893187610; Sun, 17 May 2015 13:06:27 -0700 (PDT) Received: from localhost.localdomain ([117.247.24.139]) by mx.google.com with ESMTPSA id j9sm7838401pdm.53.2015.05.17.13.06.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 May 2015 13:06:27 -0700 (PDT) From: Parth Dixit To: xen-devel@lists.xen.org Date: Mon, 18 May 2015 01:33:58 +0530 Message-Id: <1431893048-5214-32-git-send-email-parth.dixit@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> References: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> Cc: keir@xen.org, ian.campbell@citrix.com, andrew.cooper3@citrix.com, tim@xen.org, julien.grall@citrix.com, stefano.stabellini@citrix.com, jbeulich@suse.com, parth.dixit@linaro.org, christoffer.dall@linaro.org Subject: [Xen-devel] [PATCH v2 31/41] arm : acpi estimate memory required for acpi/efi tables X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: 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 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: parth.dixit@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Estimate the memory required for loading acpi/efi tablee in DOM0. Initialize the size of acpi/efi tables. Signed-off-by: Parth Dixit --- xen/arch/arm/domain_build.c | 54 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 9d98f64..f2ca525 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -69,6 +69,9 @@ struct meminfo __initdata acpi_mem; #ifdef CONFIG_ACPI /* Reserve DOM0 FDT size in ACPI case only */ #define DOM0_FDT_MIN_SIZE 4096 +#define NR_NEW_XEN_TABLES 2 +/* Constant to indicate "Xen" in unicode u16 format */ +static const u16 XEN_EFI_FW_VENDOR[] ={0x0058,0x0065,0x006E,0x0000}; #endif struct vcpu *__init alloc_dom0_vcpu0(struct domain *dom0) @@ -1222,6 +1225,51 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, return res; } #ifdef CONFIG_ACPI +static int estimate_acpi_size(struct domain *d,struct kernel_info *kinfo, struct membank tbl_add[]) +{ + int size = 0; + u64 addr; + struct acpi_table_header *table; + struct acpi_table_rsdp *rsdp_tbl; + + set_acpi_size(size); + tbl_add[TBL_EFIT].size = sizeof(struct efi_system_table) + + sizeof(struct efi_config_table) + + sizeof(XEN_EFI_FW_VENDOR); + + tbl_add[TBL_MMAP].size = sizeof(struct efi_memory_desc) + *(kinfo->mem.nr_banks + acpi_mem.nr_banks + TBL_MMAX); + tbl_add[TBL_XENV].size = sizeof(struct acpi_table_xenv); + tbl_add[TBL_STAO].size = sizeof(struct acpi_table_stao); + + addr = acpi_os_get_root_pointer(); + if( !addr ) + return -ENODEV; + + rsdp_tbl = acpi_os_map_memory(addr, sizeof(struct acpi_table_rsdp)); + if( !rsdp_tbl ) + return -ENOMEM; + + table = acpi_os_map_memory(rsdp_tbl->xsdt_physical_address, + sizeof(struct acpi_table_header)); + if ( !table ) + return -ENOMEM; + + tbl_add[TBL_XSDT].size = table->length + +( NR_NEW_XEN_TABLES*sizeof(acpi_native_uint) ); + tbl_add[TBL_XSDT].start = rsdp_tbl->xsdt_physical_address; + acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); + acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp)); + size = tbl_add[TBL_EFIT].size + + tbl_add[TBL_MMAP].size + + tbl_add[TBL_XENV].size + + tbl_add[TBL_STAO].size + + tbl_add[TBL_XSDT].size; + + set_acpi_size(size); + return 0; +} + /* * Create place holder for efi values. * Actual values will be replaced later @@ -1365,7 +1413,11 @@ static int create_acpi_dtb(struct domain *d, struct kernel_info *kinfo, struct m if ( ret < 0 ) goto err; - return 0; + ret = estimate_acpi_size(d, kinfo, tbl_add); + if ( ret < 0 ) + goto err; + + return 0; err: printk("Device tree generation failed (%d).\n", ret);