From patchwork Sun May 17 20:04:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 48654 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3D2A621411 for ; Sun, 17 May 2015 20:07:25 +0000 (UTC) Received: by wgwl7 with SMTP id l7sf1250497wgw.0 for ; Sun, 17 May 2015 13:07:24 -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=f0ZvSDVOPWxVGxRiOFM9gABRo2nIRaRa8hPsJvEDZH4=; b=h3XjkP5gNkPMlfm96hoX/9kKPYs47xxZOHEJMKfV2WgtrGjiN9bq3tePjTWXNg1ZMP lx6P2p3XcwtrJx4l1V1agNuXR8uleFFl7hryGA++Ao1Rhk2oprqeEmm1rLbRpTJVx+ao jjRMFiL58cW4qXYd19OoqrO+nGVvUPN8iNqv1qgbdSJ6vOl9ewzuUC5hN8/60ya1EaQW yf3ov4P/s4cyJ9K/2dV/Zs9vHNnYOxQXQYQ83mgr/5ADN0yf/dN8uwun+ky/xwuqe22U TxcKYu7udPT5GFrrDcFW0X0FTyVWzLOPircnbs70MlP0C5kdKFdjbHyLc35F/NsQqm9A fVSQ== X-Gm-Message-State: ALoCoQn9Ft+nnm3KCz2fh48b+I53OVkpo49NYlapy+SXZr4pi4ToCZtrMRsuH6v5mUC59dQeziYK X-Received: by 10.152.87.140 with SMTP id ay12mr15264578lab.8.1431893244461; Sun, 17 May 2015 13:07:24 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.30.74 with SMTP id q10ls702612lah.35.gmail; Sun, 17 May 2015 13:07:24 -0700 (PDT) X-Received: by 10.152.4.72 with SMTP id i8mr15233817lai.32.1431893244063; Sun, 17 May 2015 13:07:24 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id w12si5315956lbf.159.2015.05.17.13.07.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 May 2015 13:07:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lagr1 with SMTP id r1so109757197lag.0 for ; Sun, 17 May 2015 13:07:23 -0700 (PDT) X-Received: by 10.152.21.136 with SMTP id v8mr7079865lae.19.1431893243621; Sun, 17 May 2015 13:07:23 -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 hn6csp3508267lbb; Sun, 17 May 2015 13:07:22 -0700 (PDT) X-Received: by 10.140.236.73 with SMTP id h70mr26199256qhc.20.1431893242016; Sun, 17 May 2015 13:07:22 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id 14si8081851qht.82.2015.05.17.13.07.21 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 17 May 2015 13:07:22 -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 1Yu4pg-0003oT-EY; Sun, 17 May 2015 20:06:44 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yu4pf-0003lY-4b for xen-devel@lists.xen.org; Sun, 17 May 2015 20:06:43 +0000 Received: from [193.109.254.147] by server-5.bemta-14.messagelabs.com id 46/98-03206-2D4F8555; Sun, 17 May 2015 20:06:42 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-7.tower-27.messagelabs.com!1431893199!18222596!1 X-Originating-IP: [209.85.220.51] 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 15558 invoked from network); 17 May 2015 20:06:40 -0000 Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by server-7.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 17 May 2015 20:06:40 -0000 Received: by pabru16 with SMTP id ru16so119892758pab.1 for ; Sun, 17 May 2015 13:06:39 -0700 (PDT) X-Received: by 10.70.52.130 with SMTP id t2mr28039724pdo.34.1431893199285; Sun, 17 May 2015 13:06:39 -0700 (PDT) Received: from localhost.localdomain ([117.247.24.139]) by mx.google.com with ESMTPSA id j9sm7838401pdm.53.2015.05.17.13.06.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 May 2015 13:06:38 -0700 (PDT) From: Parth Dixit To: xen-devel@lists.xen.org Date: Mon, 18 May 2015 01:34:01 +0530 Message-Id: <1431893048-5214-35-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 34/41] arm : acpi create and map acpi 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.48 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: XSDT table cannot be passed as is to DOM0 because xen creates additional tables which have to be added to XSDT table entry. Copy existing XSDT and modify table to add new entries. Create status override table,xen environment table. Copy the tables to DOM0 memory. Signed-off-by: Parth Dixit --- xen/arch/arm/domain_build.c | 108 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 90bdd01..36b072b 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1225,16 +1226,123 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, return res; } #ifdef CONFIG_ACPI + +static int create_xen_acpi_tables(struct kernel_info *kinfo, struct domain *d, + struct membank tbl_add[]) +{ + unsigned long res; + int offset=0; + u64 size; + u8 checksum; + u64 *table_entry; + u64 addr; + u8 *base_ptr; + struct acpi_table_xenv *xenv=NULL; + struct acpi_table_stao *stao=NULL; + struct acpi_table_header *table; + void * __user tbl_virt = (void * __user)(register_t)kinfo->acpi_paddr; + + set_acpi_size(0); + addr = tbl_add[TBL_XSDT].start; + size = tbl_add[TBL_XSDT].size + - ( NR_NEW_XEN_TABLES*sizeof(acpi_native_uint) ); + + table = acpi_os_map_memory(addr, size); + size = tbl_add[TBL_XSDT].size + + tbl_add[TBL_XENV].size + + tbl_add[TBL_STAO].size; + + base_ptr = xzalloc_bytes(size); + if( base_ptr == NULL) + return -ENOMEM; + + res = vgic_allocate_ppi(d); + if ( res < 0 ) + panic("Unable to allocate a PPI for the event channel interrupt\n"); + + d->arch.evtchn_irq = res; + + printk("Allocating PPI %u for event channel interrupt\n", + d->arch.evtchn_irq); + + /* add xen env table */ + tbl_add[TBL_XENV].start =(u64)(base_ptr); + xenv = (struct acpi_table_xenv *)(tbl_add[TBL_XENV].start); + ACPI_MEMCPY((void *)xenv, table, sizeof(struct acpi_table_header)); + ACPI_MEMCPY(xenv->header.signature, ACPI_SIG_XENV, 4); + xenv->header.length = tbl_add[TBL_XENV].size; + ACPI_MEMCPY(xenv->header.oem_id, "XenVMM", 6); + xenv->header.revision = 1; + xenv->gnt_start = 0x00000010000000; + xenv->gnt_size = 0x20000; + xenv->evt_intr = d->arch.evtchn_irq; + xenv->evt_intr_flag = ( 0xff & EVT_CHN_INTR_TRIG ); + checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, xenv), tbl_add[TBL_XENV].size); + xenv->header.checksum = xenv->header.checksum - checksum; + tbl_add[TBL_XENV].start = (u64)(tbl_virt); + offset += tbl_add[TBL_XENV].size; + + /* add stao table */ + tbl_add[TBL_STAO].start =(u64)(base_ptr+offset); + stao = (struct acpi_table_stao *)(tbl_add[TBL_STAO].start); + ACPI_MEMCPY((void *)stao, table, sizeof(struct acpi_table_header)); + ACPI_MEMCPY(stao->header.signature,ACPI_SIG_STAO, 4); + stao->header.length = tbl_add[TBL_STAO].size; + stao->uart = 1; + checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, stao), tbl_add[TBL_STAO].size); + stao->header.checksum = stao->header.checksum - checksum; + tbl_add[TBL_STAO].start =(u64) (tbl_virt+offset); + offset += tbl_add[TBL_STAO].size; + + /* fix xsdt table */ + ACPI_MEMCPY(base_ptr+offset, table,table->length); + acpi_os_unmap_memory(table, table->length); + + table = (struct acpi_table_header *)(base_ptr+offset); + table->length = tbl_add[TBL_XSDT].size; + table_entry = ACPI_CAST_PTR(u64, + (base_ptr+offset + sizeof(struct acpi_table_header) ) ); + table_entry += + ( ( (table->length - sizeof(struct acpi_table_header) ) / + sizeof(acpi_native_uint) ) ); + + table_entry--; + *table_entry = tbl_add[TBL_XENV].start ; + + table_entry--; + *table_entry = tbl_add[TBL_STAO].start; + + checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), table->length); + table->checksum = table->checksum - checksum; + tbl_add[TBL_XSDT].start =(u64)(tbl_virt+offset); + + 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); + set_acpi_size(size); + + xfree(base_ptr); + + return 0; +} + static int prepare_acpi(struct domain *d, struct kernel_info *kinfo, struct membank tbl_add[]) { unsigned long res; u64 addr, size; int i = 0; + struct acpi_table_rsdp *rsdp_tbl; + create_xen_acpi_tables(kinfo, d, tbl_add); addr = acpi_os_get_root_pointer(); if( !addr ) return -ENODEV; + rsdp_tbl = acpi_os_map_memory(addr, sizeof(struct acpi_table_rsdp) ); + rsdp_tbl->xsdt_physical_address = tbl_add[TBL_XSDT].start; + acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp) ); + + /* map rsdp table */ size = sizeof(struct acpi_table_rsdp); res = map_regions(d,