From patchwork Tue Nov 17 09:40:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 7635291 Return-Path: X-Original-To: patchwork-linux-arm@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 8A7A9BF90C for ; Tue, 17 Nov 2015 10:25:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9FC59203B5 for ; Tue, 17 Nov 2015 10:25:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BABF32025A for ; Tue, 17 Nov 2015 10:25:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZydQE-0002su-OS; Tue, 17 Nov 2015 10:23:34 +0000 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zycsd-0003PY-2F for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2015 09:48:59 +0000 Received: by wmww144 with SMTP id w144so145752584wmw.1 for ; Tue, 17 Nov 2015 01:48:29 -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=z8zRbvcWFeWZJoDb1KWRPT4YuiNzozQTEjgGNR+g9gA=; b=l08YUq+ItIrZFSY3n/VMVvZffmkgHpHDEEsSKTqU0MBpO9MQXgp/KOVz0yz23PIpEJ +nhTTVPA2SmEbsHve4IKeVOINE9/TQeZX+JMa2FX1abQ4NpcnOeNxt5Wxf5uW020eaOh m7SS95pGzqRy4Oi9ZJ1hzERvAFAc8ynJk8yaPq64XmNid5Ufq4UBtCCOUm7mWPS0hWlj khsET+FFcaUea4fxyDU3tf0XXKJCM5RIw/z6kVDY3wlfaGfFKvDzzQoTgCTRVyrFwSLv vDMyPCZaNpHNUlOCodYtYoVlfb7iYtEhXH/30GcU6Uy63vG+5CxBYHUj7vSynuT8yJDR t9bw== 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=z8zRbvcWFeWZJoDb1KWRPT4YuiNzozQTEjgGNR+g9gA=; b=WPa2gm4wrLcLDVL+FBB3+zxGu9S5EU/AyyDZhwFPvfLtBzf1nKBwIuTBsYQk2TJcLO xeNlHusuvuYGgotVu/IiIDyElKmJPYRhUqffuCVepMgL8+6DOSjO1QfRJ0RUIaZsadfT 2lZmCkmg1ZowyRhemtGfU2EuaH0yrgcavVk8U3Z78YVT8qkqq4hYRJtuiP7gDKeRL/iZ IxUN3ejsG0up8wmXccRBEiXQTyOjp2WVfzdlny/AapxItsoH5dEKKkFUgVUsV6d/aGX4 k8ZTzc6wwSryVBL6jTBsuCpqXGc2I2FxcKlANEIdNKfwWxSE9MvdnUp0OFnsHeA3edKn jkjQ== X-Gm-Message-State: ALoCoQmqyOk1/h7pJRuvRFpQ8ZmuwbfCW4nNda3qHBEuX/FF9ob9cd+haxSeMN6bcBXdPHKetryB X-Received: by 10.28.23.211 with SMTP id 202mr1419167wmx.81.1447753709593; Tue, 17 Nov 2015 01:48:29 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id z66sm9811172wmz.7.2015.11.17.01.48.26 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:48:28 -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 Subject: [PATCH v3 51/62] arm/acpi: Prepare EFI system table for Dom0 Date: Tue, 17 Nov 2015 17:40:50 +0800 Message-Id: <1447753261-7552-52-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151117_014851_801010_1C416783 X-CRM114-Status: GOOD ( 12.35 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 From: Shannon Zhao Signed-off-by: Parth Dixit Signed-off-by: Shannon Zhao --- xen/arch/arm/domain_build.c | 2 ++ xen/common/efi/boot.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/setup.h | 3 +++ 3 files changed, 69 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index da4e271..9d667ea 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1735,6 +1735,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) return rc; acpi_map_rest_tables(d); + acpi_create_efi_system_table(d->arch.efi_acpi_gpa, d->arch.efi_acpi_table, + tbl_add); return 0; } diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 6a48624..75835ae 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1192,6 +1192,70 @@ int __init estimate_efi_size(int mem_nr_banks) return size; } + +static uint32_t __init xz_crc32(uint8_t *buf, size_t size, uint32_t crc) +{ + uint32_t xz_crc32_table[256]; + const uint32_t poly = 0xEDB88320; + uint32_t i; + uint32_t j; + uint32_t r; + + for (i = 0; i < 256; ++i) { + r = i; + for (j = 0; j < 8; ++j) + r = (r >> 1) ^ (poly & ~((r & 1) - 1)); + + xz_crc32_table[i] = r; + } + + crc = ~crc; + while (size != 0) { + crc = xz_crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8); + --size; + } + + return ~crc; +} + +void __init acpi_create_efi_system_table(paddr_t paddr, void *efi_acpi_table, + struct membank tbl_add[]) +{ + u64 table_addr, table_size, offset = 0; + u8 *base_ptr; + EFI_CONFIGURATION_TABLE *efi_conf_tbl; + EFI_SYSTEM_TABLE *efi_sys_tbl; + EFI_SYSTEM_TABLE *est = (EFI_SYSTEM_TABLE *)maddr_to_virt(efi.est); + + table_addr = paddr + acpi_get_table_offset(tbl_add, TBL_EFIT); + table_size = sizeof(EFI_SYSTEM_TABLE) + sizeof(EFI_CONFIGURATION_TABLE) + + sizeof(XEN_EFI_FW_VENDOR); + base_ptr = efi_acpi_table + acpi_get_table_offset(tbl_add, TBL_EFIT); + efi_sys_tbl = (EFI_SYSTEM_TABLE *)base_ptr; + + memcpy((EFI_TABLE_HEADER *)&(efi_sys_tbl->Hdr), + (EFI_TABLE_HEADER *)&(est->Hdr), sizeof(EFI_TABLE_HEADER)); + efi_sys_tbl->Hdr.HeaderSize = table_size; + + efi_sys_tbl->FirmwareRevision = est->FirmwareRevision; + efi_sys_tbl->NumberOfTableEntries = 1; + offset += sizeof(EFI_SYSTEM_TABLE); + memcpy((u16 *)(base_ptr + offset), XEN_EFI_FW_VENDOR, + sizeof(XEN_EFI_FW_VENDOR)); + efi_sys_tbl->FirmwareVendor = (CHAR16 *)(table_addr + offset); + + offset += sizeof(XEN_EFI_FW_VENDOR); + efi_conf_tbl = (EFI_CONFIGURATION_TABLE *)(base_ptr + offset); + efi_conf_tbl->VendorGuid = (EFI_GUID)ACPI_20_TABLE_GUID; + efi_conf_tbl->VendorTable = (VOID *)tbl_add[TBL_RSDP].start; + efi_sys_tbl->ConfigurationTable = (EFI_CONFIGURATION_TABLE *)(table_addr + + offset); + efi_sys_tbl->Hdr.CRC32 = xz_crc32((uint8_t *)efi_sys_tbl, + efi_sys_tbl->Hdr.HeaderSize, 0); + + tbl_add[TBL_EFIT].start = table_addr; + tbl_add[TBL_EFIT].size = table_size; +} #endif #ifndef CONFIG_ARM /* TODO - runtime service support */ diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h index b759813..2d65796 100644 --- a/xen/include/asm-arm/setup.h +++ b/xen/include/asm-arm/setup.h @@ -53,6 +53,9 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len); int estimate_efi_size(int mem_nr_banks); +void acpi_create_efi_system_table(paddr_t paddr, void *efi_acpi_table, + struct membank tbl_add[]); + int construct_dom0(struct domain *d); void discard_initial_modules(void);