From patchwork Fri Mar 25 13:48:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 8671591 Return-Path: X-Original-To: patchwork-xen-devel@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 BD825C0554 for ; Fri, 25 Mar 2016 13:51:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D618320384 for ; Fri, 25 Mar 2016 13:51:39 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD0B22034A for ; Fri, 25 Mar 2016 13:51:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ajS7P-00013m-6d; Fri, 25 Mar 2016 13:49:39 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ajS7N-000135-6e for xen-devel@lists.xen.org; Fri, 25 Mar 2016 13:49:37 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 8B/A4-07120-0F145F65; Fri, 25 Mar 2016 13:49:36 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-7.tower-21.messagelabs.com!1458913774!5998960!1 X-Originating-IP: [209.85.192.173] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 32857 invoked from network); 25 Mar 2016 13:49:35 -0000 Received: from mail-pf0-f173.google.com (HELO mail-pf0-f173.google.com) (209.85.192.173) by server-7.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 25 Mar 2016 13:49:35 -0000 Received: by mail-pf0-f173.google.com with SMTP id n5so83041344pfn.2 for ; Fri, 25 Mar 2016 06:49:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d3ePQ5Q/ETKUatiIMFTHsCgZLnQmkJ4YvGazSWqJnug=; b=X0VBQ0pRS0pNPTrctDHY54Cei9SCw78JG/s0L6tKyFe8Tx5DStBX6eo0JzXCFbsoyH 3SSvjV3Rc0Fc7sPFY+LG1JZEBGO7NsHXlNM05+den/TB92HFkQA2DLGvIKZ5KKO9Nk+7 Dze/ZLSGlT0vm9K49MX4YX3/HtWE/8JMKzbrE= 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=d3ePQ5Q/ETKUatiIMFTHsCgZLnQmkJ4YvGazSWqJnug=; b=LrdS/ROiScn9+/8FgSFxmodmtiRg9v+0ZmxxyIm6u1OiXJqhpyeBoGl1vBOmihbUlF 05Q8MqlU6SV0L0Vhw0URaDNPIVnG2ky7yU+9coOBZfqPb+NUAk89dvQsI8rqMQi3fVql Ta3Pdlw0sVyzKjkrbc/ulhFLWGLooB9HbUGQRUFPMd6AK9BvKa66fD5WM9RyEqcGLqV2 zeWMmjvSnZQXvsINQjgpMvgwxgK+PSgLFrNHxcgNlSowvACcpChUcVhoxtqaBdh6UMCK xESIRtUS09CPad2Bl1IlI8w8i49upWQQF1jmOD8InH1YZNCxb2evE/lCh2Po01rUUbj4 View== X-Gm-Message-State: AD7BkJIMuU2DtfFdiCDqpkcEb/t6/ZFjQUsjXw4ZY6GzIzl3oDX/4I0k66/TI5b8dnTa4mwj X-Received: by 10.98.42.4 with SMTP id q4mr20992996pfq.23.1458913774363; Fri, 25 Mar 2016 06:49:34 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.2]) by smtp.gmail.com with ESMTPSA id w20sm16744178pfi.31.2016.03.25.06.49.30 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Mar 2016 06:49:33 -0700 (PDT) From: Shannon Zhao To: xen-devel@lists.xen.org Date: Fri, 25 Mar 2016 21:48:38 +0800 Message-Id: <1458913735-2678-6-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458913735-2678-1-git-send-email-shannon.zhao@linaro.org> References: <1458913735-2678-1-git-send-email-shannon.zhao@linaro.org> Cc: julien.grall@arm.com, shannon.zhao@linaro.org, stefano.stabellini@citrix.com, peter.huangpeng@huawei.com, zhaoshenglong@huawei.com Subject: [Xen-devel] [PATCH v7 05/22] arm/acpi: Prepare MADT table for Dom0 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, 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 Copy main MADT table contents and distributor subtable from physical ACPI MADT table. Make other subtables through the callback of gic_hw_ops. Signed-off-by: Shannon Zhao Reviewed-by: Stefano Stabellini Acked-by: Julien Grall --- xen/arch/arm/domain_build.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 0e44e10..86fc3e0 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1357,6 +1357,62 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) } #ifdef CONFIG_ACPI +static int acpi_create_madt(struct domain *d, struct membank tbl_add[]) +{ + struct acpi_table_header *table = NULL; + struct acpi_table_madt *madt = NULL; + struct acpi_subtable_header *header; + struct acpi_madt_generic_distributor *gicd; + u32 table_size = sizeof(struct acpi_table_madt); + u32 offset = acpi_get_table_offset(tbl_add, TBL_MADT); + int ret; + acpi_status status; + u8 *base_ptr, checksum; + + status = acpi_get_table(ACPI_SIG_MADT, 0, &table); + + if ( ACPI_FAILURE(status) ) + { + const char *msg = acpi_format_exception(status); + + printk("Failed to get MADT table, %s\n", msg); + return -EINVAL; + } + + base_ptr = d->arch.efi_acpi_table + offset; + ACPI_MEMCPY(base_ptr, table, table_size); + + /* Add Generic Distributor. */ + header = acpi_table_get_entry_madt(ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0); + if ( !header ) + { + printk("Can't get GICD entry\n"); + return -EINVAL; + } + gicd = container_of(header, struct acpi_madt_generic_distributor, header); + ACPI_MEMCPY(base_ptr + table_size, gicd, + sizeof(struct acpi_madt_generic_distributor)); + table_size += sizeof(struct acpi_madt_generic_distributor); + + /* Add other subtables. */ + ret = gic_make_hwdom_madt(d, offset + table_size); + if ( ret < 0 ) + { + printk("Failed to get other subtables\n"); + return -EINVAL; + } + table_size += ret; + + madt = (struct acpi_table_madt *)base_ptr; + madt->header.length = table_size; + checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, madt), table_size); + madt->header.checksum -= checksum; + + tbl_add[TBL_MADT].start = d->arch.efi_acpi_gpa + offset; + tbl_add[TBL_MADT].size = table_size; + + return 0; +} static int acpi_create_fadt(struct domain *d, struct membank tbl_add[]) { @@ -1484,6 +1540,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) if ( rc != 0 ) return rc; + rc = acpi_create_madt(d, tbl_add); + if ( rc != 0 ) + return rc; + return 0; } #else