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: 56726 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1825541lbb; Tue, 17 Nov 2015 01:44:31 -0800 (PST) X-Received: by 10.31.161.78 with SMTP id k75mr2429565vke.10.1447753468584; Tue, 17 Nov 2015 01:44:28 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [50.57.142.19]) by mx.google.com with ESMTPS id o142si2019006vkf.15.2015.11.17.01.44.28 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 17 Nov 2015 01:44:28 -0800 (PST) Received-SPF: neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=50.57.142.19; Authentication-Results: mx.google.com; spf=neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Zycn2-0002tV-Gk; Tue, 17 Nov 2015 09:43:04 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Zycn1-0002sU-CA for xen-devel@lists.xen.org; Tue, 17 Nov 2015 09:43:03 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 13/2E-01748-6A6FA465; Tue, 17 Nov 2015 09:43:02 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-15.tower-31.messagelabs.com!1447753382!4196668!1 X-Originating-IP: [74.125.82.42] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.19.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 42152 invoked from network); 17 Nov 2015 09:43:02 -0000 Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by server-15.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Nov 2015 09:43:02 -0000 Received: by wmdw130 with SMTP id w130so146648745wmd.0 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=bGUZ94Ye65g270x5xNU7K5LdOzE0leLekkXhLg4EVNbYiX5vjeh0HxRdvmRx2Am89s NVsz2JSrqwn+yMiNdIb4tyhVi6kXSyKiNPYZctTeATY5R0hZ9pQZ6HdlS0Kf7RvD5Tlk S0vtEhHGNDJBoSs0JF3EfdHGt6OUvd3/wLwyWYfkiDR2+L2cC5X3oG17KKQR/I2zUASK MNOcRiCeRNqubA/GyR5FiAWcE/weRRnOLB0zOa6mQQdV+JjCwom0gCJgzyrBI4ibbpyr uglZ0+NZ8GeRUP6e179/0Yfmk3BRBZPdHhuZ7VuYHIoQbKq59UHF8MqtS2MqMUjLByee DO/A== X-Gm-Message-State: ALoCoQnEv5n+xbbFsMyIUI+eG8KDgmIrUQD/wTUex6/C10C9IA30JPZlKBXZdq69GSkOMY//tbrj 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 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> 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 Subject: [Xen-devel] [PATCH v3 13/62] arm/acpi: Parse FADT table and get PSCI flags X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion 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 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(+) -- 2.1.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel 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) {