From patchwork Tue Nov 17 09:40:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 7634901 Return-Path: X-Original-To: patchwork-linux-arm@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 31CE89F2EC for ; Tue, 17 Nov 2015 10:01:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7989220499 for ; Tue, 17 Nov 2015 10:01:28 +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 9FB3920494 for ; Tue, 17 Nov 2015 10:01:27 +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 1Zyd2g-0007DV-5y; Tue, 17 Nov 2015 09:59:14 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZycrS-0002V8-H9 for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2015 09:47:41 +0000 Received: by wmec201 with SMTP id c201so218080696wme.0 for ; Tue, 17 Nov 2015 01:47:17 -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=qyGFSAU+8Y/JGL67l3zseFylsC238XkRUUje8V8X4fI=; b=D99FZl3qa6bJc9vq1aGTJhWmr1Zk3j6vPhres6c0dEdIf8ytrGlH1WU1yZ2eBn0nVU WubKaEAGX+ym2ga/Ogy+fBZ2Az026V4O36A6MrljDxHiLUAyMRrqUtIQu85nFi9i8TGQ Vi5R16uPpkvlHbE7N8wHJn66RsduEgrSgr237BbjTlTMPUfEQG0O0F8AylD3mCr1/srl YUfhvx7uBr0lK3xhzvG4UuaxJOj+cebaxkeSEofplmRDo+hhZCrygNWsf0VYhc+ZQPJR a9BHgVfXFpkeHCYdyDnVGRkoUSkuiNNhy2LxkuWHMcR8qayYL0ZrzsJTByoQ6pMP7yiH YFIw== 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=qyGFSAU+8Y/JGL67l3zseFylsC238XkRUUje8V8X4fI=; b=jH2pOB1huubnWr31SV4JVht5Jf1SqQDHLKPobTiVM4K0hSQWqT49pw9RXRXm2W6LqQ iL1W/FjnRUbtaBwiisvsmHE5BP7U2UDsyaPqs6wWa4/GO3PdEoWu+x1NmUoMelfrCP5a ADs/Tt1Xn09rgqSgtQxQ3ycp70wZ0L6BqIOrLQ58nSc1hPuHe2sq5wCYt60vbxPvNm7g Mzup8AM0wMM2IOpz4v3LkGyqxF+Z8Zuw0oRx3q+gYtAghU2kk+xyHazpF3ZeOaSwQvOK Hq0p/FpnzQMFeSaz/QGNY0U0AuvhshzYOX+NRU0YrNy+ajS/gE+wtJ3ND7EWaCAQMd+g LmDQ== X-Gm-Message-State: ALoCoQnzAdEf/L8tJ1cCzNifrX9me978GNig1lGFByAd6NH+WO0O5+732JXGrcRutRfBBJumaSLo X-Received: by 10.28.7.8 with SMTP id 8mr1390829wmh.45.1447753637180; Tue, 17 Nov 2015 01:47:17 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id jh4sm38925400wjb.33.2015.11.17.01.47.15 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:47:16 -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 42/62] arm/acpi: Prepare FADT table for Dom0 Date: Tue, 17 Nov 2015 17:40:41 +0800 Message-Id: <1447753261-7552-43-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_014739_006519_C25016E7 X-CRM114-Status: GOOD ( 12.43 ) 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 Copy and modify FADT table before passing it to Dom0. Set PSCI_COMPLIANT and PSCI_USE_HVC. Signed-off-by: Shannon Zhao --- xen/arch/arm/domain_build.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index b5ed44c..5d03dc0 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1357,6 +1357,46 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) } #ifdef CONFIG_ACPI +#define XEN_HYPERVISOR_ID 0x000058656E564D4D /* "XenVMM" */ + +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); + fadt->hypervisor_id = XEN_HYPERVISOR_ID; + 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) { u64 efi_size, acpi_size = 0, addr; @@ -1400,6 +1440,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 ) @@ -1418,6 +1459,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) * region. So we use it as the ACPI table mapped address. */ d->arch.efi_acpi_gpa = kinfo->gnttab_start; + rc = acpi_create_fadt(d, tbl_add); + if ( rc != 0 ) + return rc; + return 0; } #else