From patchwork Fri Mar 25 13:48:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 8671711 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 630B79F36E for ; Fri, 25 Mar 2016 13:52:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7511620351 for ; Fri, 25 Mar 2016 13:52:00 +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 2632A20340 for ; Fri, 25 Mar 2016 13:51:59 +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 1ajS7F-0000zD-NO; Fri, 25 Mar 2016 13:49:29 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ajS7E-0000z5-Qp for xen-devel@lists.xen.org; Fri, 25 Mar 2016 13:49:28 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 2E/5E-04060-8E145F65; Fri, 25 Mar 2016 13:49:28 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-7.tower-31.messagelabs.com!1458913766!23923401!1 X-Originating-IP: [209.85.192.182] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50083 invoked from network); 25 Mar 2016 13:49:27 -0000 Received: from mail-pf0-f182.google.com (HELO mail-pf0-f182.google.com) (209.85.192.182) by server-7.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 25 Mar 2016 13:49:27 -0000 Received: by mail-pf0-f182.google.com with SMTP id n5so83039117pfn.2 for ; Fri, 25 Mar 2016 06:49:27 -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=J32540eCly0JXgvyOTJOMPDBwSjcy8UE1v+bD+Pa56g=; b=UKKbTaZ+8yKKjtGi8bmNQdQc1SZpNYMVnOaQhZbWtHMXfCRz++mD77OBxAdSdsVzvD FdXIOcj3iiyoEAlOqDPdvUL/qI8pbhON3RdajqmSDGDc4ctZ98vNTpu1ht3LDiHtAXLH myDHD0zZ5Q3c97tw1/c/fFfbOPrT2B4FN+0VY= 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=J32540eCly0JXgvyOTJOMPDBwSjcy8UE1v+bD+Pa56g=; b=k2uTQENkggV8erCk863Da20PKO9vTGlLJn+9yoh/sZHgDhwK0QkbisM7lpf5X2MzLn MG3wonVx+IkHbht0XzLg2t5CiEI6sAF0oMHTnevcxf6miDFYh0zbNi+l+7cHM6XqM9FM CyzapiKJbyEspt1B77vlqDwk5DhVyhrTj6wgYoCti46bg6AALpkM/Q5gJr+wWudaS9q4 BbaRkQXVCgdV9JiFcb/kUEVdSmm2ocLwRGIHNdPO+v4G0LyKkys9spIGsHF4E7HD0q+a 4OpanwpNxPgmUka917UKjvcA5+TwlCh/+nxuBU3S7Rv7C82OXxEQeWG3GTCtasMjoCi5 5/iw== X-Gm-Message-State: AD7BkJJp1YBNclrO7jzyxGMI+OpPg9Yx5p4cIim+NBlN/Xb15tT7MiR1Pf13VPDWz2M3jSWt X-Received: by 10.98.80.206 with SMTP id g75mr21254088pfj.127.1458913765794; Fri, 25 Mar 2016 06:49:25 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.2]) by smtp.gmail.com with ESMTPSA id w20sm16744178pfi.31.2016.03.25.06.49.21 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Mar 2016 06:49:24 -0700 (PDT) From: Shannon Zhao To: xen-devel@lists.xen.org Date: Fri, 25 Mar 2016 21:48:36 +0800 Message-Id: <1458913735-2678-4-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 03/22] arm/acpi: Prepare FADT 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 and modify FADT table before passing it to Dom0. Set PSCI_COMPLIANT and PSCI_USE_HVC. Signed-off-by: Shannon Zhao Reviewed-by: Stefano Stabellini Acked-by: Julien Grall --- xen/arch/arm/domain_build.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 13027ea..0e44e10 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1357,6 +1357,44 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) } #ifdef CONFIG_ACPI + +static int acpi_create_fadt(struct domain *d, struct membank tbl_add[]) +{ + struct acpi_table_header *table = NULL; + struct acpi_table_fadt *fadt = NULL; + u64 table_size; + acpi_status status; + u8 *base_ptr; + u8 checksum; + + status = acpi_get_table(ACPI_SIG_FADT, 0, &table); + + if ( ACPI_FAILURE(status) ) + { + const char *msg = acpi_format_exception(status); + + printk("Failed to get FADT table, %s\n", msg); + return -EINVAL; + } + + table_size = table->length; + base_ptr = d->arch.efi_acpi_table + + acpi_get_table_offset(tbl_add, TBL_FADT); + ACPI_MEMCPY(base_ptr, table, table_size); + fadt = (struct acpi_table_fadt *)base_ptr; + + /* Set PSCI_COMPLIANT and PSCI_USE_HVC */ + fadt->arm_boot_flags |= (ACPI_FADT_PSCI_COMPLIANT | ACPI_FADT_PSCI_USE_HVC); + checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, fadt), table_size); + fadt->header.checksum -= checksum; + + tbl_add[TBL_FADT].start = d->arch.efi_acpi_gpa + + acpi_get_table_offset(tbl_add, TBL_FADT); + tbl_add[TBL_FADT].size = table_size; + + return 0; +} + static int estimate_acpi_efi_size(struct domain *d, struct kernel_info *kinfo) { size_t efi_size, acpi_size, madt_size; @@ -1415,6 +1453,7 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) { int rc = 0; int order; + struct membank tbl_add[TBL_MMAX] = {}; rc = estimate_acpi_efi_size(d, kinfo); if ( rc != 0 ) @@ -1441,6 +1480,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) return -EINVAL; } + rc = acpi_create_fadt(d, tbl_add); + if ( rc != 0 ) + return rc; + return 0; } #else