From patchwork Tue Nov 17 09:40:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 7634461 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 627FB9F1C2 for ; Tue, 17 Nov 2015 09:47:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 71E6F20454 for ; Tue, 17 Nov 2015 09:47:42 +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 8C109203A5 for ; Tue, 17 Nov 2015 09:47:41 +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 1Zycpd-00014f-HN; Tue, 17 Nov 2015 09:45:45 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZycnL-0005vc-MS for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2015 09:43:29 +0000 Received: by wmww144 with SMTP id w144so145555995wmw.1 for ; Tue, 17 Nov 2015 01:43:02 -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=wiAYoyJflPLFM6WeYzbGZM7osjI+BXECFZnB9pMm1Fo=; b=AGvaMG34IUMgcsS0Dq1x4PX2vPytJ4gpRCZ2AeWeRQCzrPybCZo42T6nVQjZI7I1pN MuB74Goth8jBuonydJleaDniA9X1CDofHIQTN19rmgxqlI8dqrRsboW+FCx4LrdN8T8b iJeZLY+3LLrPHtah9SHmwOtsTYSvAqNiRzCabkPgJBIvmuWuvFDpD/NZ27BELGsah4SL ZGpUmo9Rfpyn6YXlRPWpIWnV3ZqDwS1Q61/E6UsMs4zYho5oG6CsdPo7ClSbUY0E8heY saQpjRlTa4icyhiguJs4+7c19HXmdmQaDp+ru1q31QJlCC4F5cd442aMWF3rYGThV1KZ 73lg== 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=wiAYoyJflPLFM6WeYzbGZM7osjI+BXECFZnB9pMm1Fo=; b=UyYehPW1Vrm6x+ouwcU7atbQ/FMM/FHgZdoKCQ1ynOVaHrqDvJK/ooWH2kqO/Rw7gC RXB5Qd9Y4b/dAKhQhZqiAwBN/+l37f0hyhD7+7omEGE2pxOt8oOyMRtbOCt//suw88Yi vqIIsU4dF+NCCBIBVprFLrb8uQW1xQMddLiWVIdLe11vw/ZqyvYiRYrDGE0zF8nat+j3 AhrxngyGXovgRZDceOvZ9ibUU81RQw6TO+kvSRK1AUrSp++6BNARuoy/QaTbWKYU8OaS IPoQglkviBM0p1HGNT5Hhw8OEtOaQWf5ckqbjQWYQf2qfTijqgBdAODQ61834VJKKyNK btNw== X-Gm-Message-State: ALoCoQkZS1eajKR4KQpHqgCaCJs4uHfyUXKHMtJWzZ4og5g77l2VTIUkLhRfXYPztHEcFWKvTjpv X-Received: by 10.28.137.211 with SMTP id l202mr1521523wmd.90.1447753381950; Tue, 17 Nov 2015 01:43:01 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id u4sm32634554wjz.4.2015.11.17.01.42.58 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:43:01 -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 13/62] arm/acpi: Parse FADT table and get PSCI flags Date: Tue, 17 Nov 2015 17:40:12 +0800 Message-Id: <1447753261-7552-14-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_014324_427769_507088F7 X-CRM114-Status: GOOD ( 14.37 ) 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 There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set, the former signals to the OS that the hardware is PSCI compliant. The latter selects the appropriate conduit for PSCI calls by toggling between Hypervisor Calls (HVC) and Secure Monitor Calls (SMC). FADT table contains such information, parse FADT to get the flags for furture usage. At the same time, only ACPI 5.1 or higher verison supports PSCI, and FADT Major.Minor version was introduced in ACPI 5.1, but for Xen it needs FADT hypervisor_id introduced by ACPI 6.0 to tell Dom0 that it runs on Xen hypervisor, so we will check the version and only parse FADT table with version >= 6.0. If firmware provides ACPI tables with ACPI version less than 6.0, OS will be messed up with those information, so disable ACPI if we get an FADT table with version less that 6.0. Signed-off-by: Hanjun Guo Signed-off-by: Naresh Bhat Signed-off-by: Parth Dixit Signed-off-by: Shannon Zhao --- xen/arch/arm/acpi/boot.c | 31 +++++++++++++++++++++++++++++++ xen/arch/arm/acpi/lib.c | 12 ++++++++++++ xen/include/asm-arm/acpi.h | 9 +++++++++ 3 files changed, 52 insertions(+) diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c index ad51afc..0fabe7d 100644 --- a/xen/arch/arm/acpi/boot.c +++ b/xen/arch/arm/acpi/boot.c @@ -27,9 +27,33 @@ #include #include +#include +#include +#include #include +static int __init acpi_parse_fadt(struct acpi_table_header *table) +{ + struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table; + + /* + * Revision in table header is the FADT Major revision, and there + * is a minor revision of FADT which was introduced by ACPI 6.0, + * we only deal with ACPI 6.0 or newer revision to get GIC and SMP + * boot protocol configuration data, or we will disable ACPI. + */ + if ( table->revision > 6 + || (table->revision == 6 && fadt->minor_revision >= 0) ) + return 0; + + printk("Unsupported FADT revision %d.%d, should be 6.0+, will disable ACPI\n", + table->revision, fadt->minor_revision); + disable_acpi(); + + return -EINVAL; +} + /* * acpi_boot_table_init() called from setup_arch(), always. * 1. find RSDP and get its address, and then find XSDT @@ -58,5 +82,12 @@ int __init acpi_boot_table_init(void) return error; } + if ( acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt) ) + { + /* disable ACPI if no FADT is found */ + disable_acpi(); + printk("Can't find FADT\n"); + } + return 0; } diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c index b68623b..d8b7635 100644 --- a/xen/arch/arm/acpi/lib.c +++ b/xen/arch/arm/acpi/lib.c @@ -31,3 +31,15 @@ arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size) { return __va(phys); } + +/* 1 to indicate PSCI 0.2+ is implemented */ +bool_t __init acpi_psci_present(void) +{ + return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT; +} + +/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ +bool_t __init acpi_psci_hvc_present(void) +{ + return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC; +} diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h index e41e03b..65f80b1 100644 --- a/xen/include/asm-arm/acpi.h +++ b/xen/include/asm-arm/acpi.h @@ -29,6 +29,15 @@ #define COMPILER_DEPENDENT_UINT64 unsigned long long extern bool_t acpi_disabled; + +#ifdef CONFIG_ACPI +bool_t __init acpi_psci_present(void); +bool_t __init acpi_psci_hvc_present(void); +#else +static inline bool_t acpi_psci_present(void) { return false; } +static inline bool_t acpi_psci_hvc_present(void) {return false; } +#endif /* CONFIG_ACPI */ + /* Basic configuration for ACPI */ static inline void disable_acpi(void) {