From patchwork Tue Nov 17 09:40:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 56745 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1827475lbb; Tue, 17 Nov 2015 01:48:58 -0800 (PST) X-Received: by 10.31.190.208 with SMTP id o199mr2641117vkf.90.1447753738380; Tue, 17 Nov 2015 01:48:58 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [50.57.142.19]) by mx.google.com with ESMTPS id k76si2029142vke.17.2015.11.17.01.48.58 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 17 Nov 2015 01:48:58 -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 1Zycrg-0007CL-TR; Tue, 17 Nov 2015 09:47:52 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Zycrf-00079t-8v for xen-devel@lists.xen.org; Tue, 17 Nov 2015 09:47:51 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id F3/DA-18107-6C7FA465; Tue, 17 Nov 2015 09:47:50 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-11.tower-206.messagelabs.com!1447753670!4241683!1 X-Originating-IP: [74.125.82.52] 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 60456 invoked from network); 17 Nov 2015 09:47:50 -0000 Received: from mail-wm0-f52.google.com (HELO mail-wm0-f52.google.com) (74.125.82.52) by server-11.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Nov 2015 09:47:50 -0000 Received: by wmec201 with SMTP id c201so218102730wme.0 for ; Tue, 17 Nov 2015 01:47:50 -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=dM+pUq+xbSB+GtDvO64Hujqmv3AnViVoimnRhQ1JP9I=; b=Qc2iPzsw/C08HHvkNenjVI14zR47e7RyEyJ7fVoEP9LWpexySMSOjyovT9vjweocxY rCWjDV2+c760Xw/F4u3yxE0JgV5fza3LKd68SCpT0UC3vxqj0/PwoyA66oUYwPNjHl9x 47fIZD479k+UrR1cBQZN6aD0bIdQlbRHNf5/iEP+pPodX6U38DKQxwV2ncl0mL2+prDD h8Ew5x2ZYhgOJKaNbcVbFpA7vG2pxRiDtezuwLWV9pLi8C9tIIzO/+yxGGp1QmI8yxAA XdAJIwhSxAKR4E/pGJbUnYvJ0wUdsHylrC9oWPtkitBJHSpFLHZUhDphloAmpWz3KbOc 9NWw== 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=dM+pUq+xbSB+GtDvO64Hujqmv3AnViVoimnRhQ1JP9I=; b=ZbJwB7UAy6d3PWeLqJJ4Rjiztk2A1s/xsuXcX6Y6hWftyS0qvJEw1x2NE2NLOzHz55 aDOH9c9wItfO9IIEJhx1fyrG3OumHBqcQnoWaQ6gmgJCTRGBGmdGfY9DpbCpDNN1BneY 2hO8vIoKt3U1DJ9+2Niqd5EgeSIWj6UQclqPnmgDs/+HeYEVhdLIkT+6FrQx7U9WwDUL EG/OlR21pwBC8GMObziLNb3S9BUutReZa4SGKExnoQVHybPuppav+S3sYc1866ejG/ov v+yXbXbYDyZoMhmKq/0w94F7ZtAvc4HH0P9OXlh2HIw7OXrxj9HIyZYQ2y6FFd9csZPO 5OTQ== X-Gm-Message-State: ALoCoQlSgNhV3C0VwTHUq98zdpCUX7NR/qxoWmYAGr/TvpSPNiMPWIe2bTIEHoptlI/0QFhAUeWV X-Received: by 10.28.23.141 with SMTP id 135mr1554176wmx.84.1447753669906; Tue, 17 Nov 2015 01:47:49 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id 69sm23062316wmw.0.2015.11.17.01.47.46 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:47:47 -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:45 +0800 Message-Id: <1447753261-7552-47-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 46/62] arm/acpi: Prepare XSDT 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 XSDT table before passing it to Dom0. Repalce the entry value of the copied table. Add a new entry for STAO table as well. And keep entry value of other reused tables unchanged. Signed-off-by: Shannon Zhao --- xen/arch/arm/domain_build.c | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 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 fb3f150..894328f 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1359,6 +1359,73 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) #ifdef CONFIG_ACPI #define XEN_HYPERVISOR_ID 0x000058656E564D4D /* "XenVMM" */ +static void acpi_xsdt_modify_entry(u64 entry[], unsigned long entry_count, + char *signature, u64 addr) +{ + int i; + struct acpi_table_header *table; + u64 size = sizeof(struct acpi_table_header); + + for( i = 0; i < entry_count; i++ ) + { + table = acpi_os_map_memory(entry[i], size); + if ( ACPI_COMPARE_NAME(table->signature, signature) ) + { + entry[i] = addr; + acpi_os_unmap_memory(table, size); + break; + } + acpi_os_unmap_memory(table, size); + } +} + +static int acpi_create_xsdt(struct domain *d, struct membank tbl_add[]) +{ + struct acpi_table_header *table = NULL; + struct acpi_table_rsdp *rsdp_tbl; + struct acpi_table_xsdt *xsdt = NULL; + u64 table_size, addr; + unsigned long entry_count; + u8 *base_ptr; + u8 checksum; + + addr = acpi_os_get_root_pointer(); + if ( !addr ) + { + printk("Unable to get acpi root pointer\n"); + return -EINVAL; + } + rsdp_tbl = acpi_os_map_memory(addr, sizeof(struct acpi_table_rsdp)); + table = acpi_os_map_memory(rsdp_tbl->xsdt_physical_address, + sizeof(struct acpi_table_header)); + + table_size = table->length + sizeof(u64); /* Add place for STAO table */ + entry_count = (table->length - sizeof(struct acpi_table_header)) + / sizeof(u64); + base_ptr = d->arch.efi_acpi_table + + acpi_get_table_offset(tbl_add, TBL_XSDT); + ACPI_MEMCPY(base_ptr, table, table->length); + acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); + acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp)); + + xsdt = (struct acpi_table_xsdt *)base_ptr; + acpi_xsdt_modify_entry(xsdt->table_offset_entry, entry_count, + ACPI_SIG_FADT, tbl_add[TBL_FADT].start); + acpi_xsdt_modify_entry(xsdt->table_offset_entry, entry_count, + ACPI_SIG_MADT, tbl_add[TBL_MADT].start); + xsdt->table_offset_entry[entry_count] = tbl_add[TBL_STAO].start; + + xsdt->header.length = table_size; + checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, xsdt), table_size); + xsdt->header.checksum -= checksum; + + tbl_add[TBL_XSDT].start = d->arch.efi_acpi_gpa + + acpi_get_table_offset(tbl_add, TBL_XSDT); + tbl_add[TBL_XSDT].size = table_size; + + return 0; +} + static int acpi_create_stao(struct domain *d, struct membank tbl_add[]) { struct acpi_table_header *table = NULL; @@ -1604,6 +1671,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) if ( rc != 0 ) return rc; + rc = acpi_create_xsdt(d, tbl_add); + if ( rc != 0 ) + return rc; + return 0; } #else