From patchwork Sun May 17 20:04:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 48658 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A7DBF21411 for ; Sun, 17 May 2015 20:07:42 +0000 (UTC) Received: by wixv7 with SMTP id v7sf15391066wix.0 for ; Sun, 17 May 2015 13:07:42 -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=EXnXCIXPDrOFABOZmFh0BJxCy85adDhUr73t5qZVASY=; b=iozfGEwLNfQl1fM+zO/kDEMBo+H6CNTBNoxyWCaUx+bOusPYfP2J1dh4lcQNjXZXIT 4byFJy7e6L9nDJfzV+FAsSs2pAClMsLvZSqW4a0HvSIUs6CNkGHqAUZiZj7oFAuifu2G /oNY1U0MVlNbhgwT2kgQSHTOsnnpgLgQKgPAA27dfm+6r8Muvq6IoerqzQOOMHqoPQpQ Q1I41jlzkNyudwzRbsqSP3ZTxdL/3LWJ+LUJH+dbDsC/TmX9mnBciGMge1jcw1qJDedC vBzNCOeEaBZ2AzcivFSmId3JMEUo8BEjL5V9Ezr6Oi9xAqQrDoSFe834+shQRWajhLWc mjqQ== X-Gm-Message-State: ALoCoQlyJqRv+wLXwrerxEZOjLsPVZW1sRP5aeizn+GLG4wqyU50BDj4kj+7sJyKMWkbn0hLF9SP X-Received: by 10.112.142.170 with SMTP id rx10mr15210185lbb.12.1431893261799; Sun, 17 May 2015 13:07:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.30.37 with SMTP id p5ls707456lah.9.gmail; Sun, 17 May 2015 13:07:41 -0700 (PDT) X-Received: by 10.112.210.103 with SMTP id mt7mr14494622lbc.27.1431893261655; Sun, 17 May 2015 13:07:41 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id i6si5318065laa.144.2015.05.17.13.07.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 May 2015 13:07:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by labbd9 with SMTP id bd9so191543598lab.2 for ; Sun, 17 May 2015 13:07:41 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr15235210lbc.32.1431893261548; Sun, 17 May 2015 13:07:41 -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 hn6csp3508400lbb; Sun, 17 May 2015 13:07:40 -0700 (PDT) X-Received: by 10.53.0.201 with SMTP id ba9mr17654909vdd.57.1431893260052; Sun, 17 May 2015 13:07:40 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id qv4si8676624vdb.83.2015.05.17.13.07.39 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 17 May 2015 13:07:40 -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 1Yu4pp-000448-Ky; Sun, 17 May 2015 20:06:53 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yu4po-00041i-GT for xen-devel@lists.xen.org; Sun, 17 May 2015 20:06:52 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id A1/B7-02782-BD4F8555; Sun, 17 May 2015 20:06:51 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-11.tower-206.messagelabs.com!1431893207!7008996!1 X-Originating-IP: [209.85.220.46] 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 18293 invoked from network); 17 May 2015 20:06:48 -0000 Received: from mail-pa0-f46.google.com (HELO mail-pa0-f46.google.com) (209.85.220.46) by server-11.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 17 May 2015 20:06:48 -0000 Received: by pabts4 with SMTP id ts4so119816686pab.3 for ; Sun, 17 May 2015 13:06:46 -0700 (PDT) X-Received: by 10.67.4.138 with SMTP id ce10mr38319569pad.102.1431893206817; Sun, 17 May 2015 13:06:46 -0700 (PDT) Received: from localhost.localdomain ([117.247.24.139]) by mx.google.com with ESMTPSA id j9sm7838401pdm.53.2015.05.17.13.06.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 May 2015 13:06:46 -0700 (PDT) From: Parth Dixit To: xen-devel@lists.xen.org Date: Mon, 18 May 2015 01:34:03 +0530 Message-Id: <1431893048-5214-37-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 36/41] arm : acpi pass rsdp and memory via efi table 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.53 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: Create EFI table and populate it with DOM0 memory and address of RSDP. Fix device tree with correct addresses of EFI table and start of memory descriptor address. Signed-off-by: Parth Dixit --- xen/arch/arm/domain_build.c | 106 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 0ad70c1..2ce30bf 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1260,6 +1260,111 @@ static uint32_t xz_crc32(uint8_t *buf, size_t size, uint32_t crc) return ~crc; } +static int prepare_efi_table(struct domain *d, + const struct kernel_info *kinfo, + struct membank tbl_add[]) +{ + u64 fdt_val64; + u32 fdt_val32; + int size; + int i,offset; + unsigned long res; + int node; + u16 *fw_vendor; + u8 *base_ptr; + struct efi_memory_desc *memory_map; + struct efi_config_table *acpi_ect; + struct efi_system_table *sys_tbl; + void * __user tbl_virt = (void * __user)(register_t)kinfo->acpi_paddr; + struct efi_system_table *efi_sys_tbl = ( struct efi_system_table *) + maddr_to_virt(efi.est); + + xz_crc32_init(); + /* Fix up linux,uefi-system-table and linux,mmap-size in /chosen */ + node = fdt_path_offset(kinfo->fdt, "/chosen"); + if ( node < 0 ) + panic("Cannot find the /chosen node"); + + size = tbl_add[TBL_EFIT].size + + tbl_add[TBL_MMAP].size; + + tbl_virt += get_acpi_size(); + base_ptr = xzalloc_bytes(size); + sys_tbl = (struct efi_system_table *)base_ptr; + memcpy( (struct efi_table_hdr*)&(sys_tbl->hdr), + (struct efi_table_hdr*)&(efi_sys_tbl->hdr), + sizeof(struct efi_table_hdr) ); + sys_tbl->hdr.headersize = tbl_add[TBL_EFIT].size; + + sys_tbl->fw_revision = efi_sys_tbl->fw_revision; + sys_tbl->nr_tables = 1; + fdt_val64 = cpu_to_fdt64((u64)(uintptr_t)tbl_virt); + res = fdt_setprop_inplace(kinfo->fdt, node, "linux,uefi-system-table", + &fdt_val64, sizeof(fdt_val64)); + if ( res ) + return res; + offset = sizeof(struct efi_system_table); + + size = sizeof(XEN_EFI_FW_VENDOR); + fw_vendor = (u16 *)(base_ptr+offset); + memcpy(fw_vendor, XEN_EFI_FW_VENDOR, size); + sys_tbl->fw_vendor = (u64)(tbl_virt+offset); + offset+=size; + + size = sizeof(struct efi_config_table); + acpi_ect = (struct efi_config_table *)(base_ptr+offset); + acpi_ect->guid = ACPI_20_TBL_GUID; + acpi_ect->table = efi.acpi20; + sys_tbl->tables = (u64)(tbl_virt+offset); + offset += size; + sys_tbl->hdr.crc32 = xz_crc32((uint8_t *)sys_tbl, sys_tbl->hdr.headersize, 0); + + size = tbl_add[TBL_MMAP].size; + memory_map = (struct efi_memory_desc *)(base_ptr+offset); + fdt_val64 = cpu_to_fdt64((u64)(uintptr_t)(tbl_virt+offset)); + res = fdt_setprop_inplace(kinfo->fdt, node, "linux,uefi-mmap-start", + &fdt_val64, sizeof(fdt_val64)); + if ( res ) + return res; + + fdt_val32 = cpu_to_fdt32(size); + res = fdt_setprop_inplace(kinfo->fdt, node, "linux,uefi-mmap-size", + &fdt_val32, sizeof(fdt_val32)); + size += offset; + + for( i=0; i < kinfo->mem.nr_banks ; i++) + { + memory_map[i].type = EFI_CONVENTIONAL_MEMORY; + memory_map[i].phys_addr = kinfo->mem.bank[i].start; + memory_map[i].num_pages = kinfo->mem.bank[i].size/PAGE_SIZE; + memory_map[i].attribute |= EFI_MEMORY_ATT_WB; + } + offset = kinfo->mem.nr_banks; + for( i=0; i < acpi_mem.nr_banks ; i++,offset++) + { + memory_map[offset].type = EFI_ACPI_RECLAIM_MEMORY; + memory_map[offset].phys_addr = acpi_mem.bank[i].start; + memory_map[offset].num_pages = acpi_mem.bank[i].size/PAGE_SIZE; + } + + for( i=0; i < TBL_MMAX; i++, offset++ ) + { + memory_map[offset].type = EFI_ACPI_RECLAIM_MEMORY; + memory_map[offset].phys_addr = tbl_add[i].start; + memory_map[offset].num_pages =tbl_add[i].size/PAGE_SIZE; + memory_map[i].attribute |= EFI_MEMORY_ATT_WB; + } + + res = raw_copy_to_guest_flush_dcache(tbl_virt, base_ptr, size); + if ( res != 0 ) + panic("Unable to copy the stao to dom0 memory (left = %lu bytes)", res); + size += get_acpi_size(); + set_acpi_size(size); + + xfree(base_ptr); + return res; +} + static int create_xen_acpi_tables(struct kernel_info *kinfo, struct domain *d, struct membank tbl_add[]) { @@ -1375,6 +1480,7 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo, struct memb rsdp_tbl->xsdt_physical_address = tbl_add[TBL_XSDT].start; acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp) ); + prepare_efi_table(d, kinfo, tbl_add); /* map rsdp table */ size = sizeof(struct acpi_table_rsdp);