From patchwork Sun May 17 20:03:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 48631 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2DC3021411 for ; Sun, 17 May 2015 20:05:54 +0000 (UTC) Received: by wgtl5 with SMTP id l5sf46762918wgt.1 for ; Sun, 17 May 2015 13:05:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=XaZrsle9BnhmOXTG5ta1u1dQ5hDWyex9fl2W9aahO48=; b=l+zjapgHyMiQbO8xFlq8i05//ghznPTFgytuiuI7KTiqU9ualsE3xWZ1UDhaP8gHfy RvXdQ7M6hCKiybU9Thwe/al/JrS6cCEg3HGKCYWc/LI2o8ID/t1YkwVo4t6bys1n4PVR Rtf6WOC3YOaGq6NsA09w6oZbPwheW8ang/HsA6dvDgmAsTpzur95r/1Zp4fgTLmcWaFp DCL1EbE7JenxulKwFxopJvjuMBjzYu1XJgt7GdwP2hV+DnaZMogyHkRXNT+E4RtJoJLh T7Iu+27bTM541HkZQ4zXrLdWAqqJDMSzTvg+LVx/vc+sMd+T8XNT//mOkMrLqzG00pa6 50Ig== X-Gm-Message-State: ALoCoQmTT5chRIhzoWmjLK2AcIx8M1bt4O8t86k9ARh1JwBI8qn4DjmGAZVn0Hh0Aw2ONT9CeJ/m X-Received: by 10.112.13.200 with SMTP id j8mr15276768lbc.14.1431893153222; Sun, 17 May 2015 13:05:53 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.40 with SMTP id q8ls64164lag.67.gmail; Sun, 17 May 2015 13:05:52 -0700 (PDT) X-Received: by 10.152.3.161 with SMTP id d1mr14701394lad.70.1431893152876; Sun, 17 May 2015 13:05:52 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id y4si5327928lbn.101.2015.05.17.13.05.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 May 2015 13:05:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lagv1 with SMTP id v1so191310173lag.3 for ; Sun, 17 May 2015 13:05:52 -0700 (PDT) X-Received: by 10.152.21.136 with SMTP id v8mr7076624lae.19.1431893152742; Sun, 17 May 2015 13:05:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp3507665lbb; Sun, 17 May 2015 13:05:51 -0700 (PDT) X-Received: by 10.55.55.72 with SMTP id e69mr41528631qka.78.1431893143613; Sun, 17 May 2015 13:05:43 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id q15si8263881qha.77.2015.05.17.13.05.43 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 17 May 2015 13:05:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yu4nz-0001W4-Pz; Sun, 17 May 2015 20:04:59 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yu4nx-0001U0-MN for xen-devel@lists.xen.org; Sun, 17 May 2015 20:04:58 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id CC/5D-02789-864F8555; Sun, 17 May 2015 20:04:56 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-15.tower-206.messagelabs.com!1431893094!7779838!1 X-Originating-IP: [209.85.220.50] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.15; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25066 invoked from network); 17 May 2015 20:04:55 -0000 Received: from mail-pa0-f50.google.com (HELO mail-pa0-f50.google.com) (209.85.220.50) by server-15.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 17 May 2015 20:04:55 -0000 Received: by pacwv17 with SMTP id wv17so119734536pac.2 for ; Sun, 17 May 2015 13:04:54 -0700 (PDT) X-Received: by 10.70.47.68 with SMTP id b4mr38111231pdn.33.1431893093942; Sun, 17 May 2015 13:04:53 -0700 (PDT) Received: from localhost.localdomain ([117.247.24.139]) by mx.google.com with ESMTPSA id j9sm7838401pdm.53.2015.05.17.13.04.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 May 2015 13:04:53 -0700 (PDT) From: Parth Dixit To: xen-devel@lists.xen.org Date: Mon, 18 May 2015 01:33:35 +0530 Message-Id: <1431893048-5214-9-git-send-email-parth.dixit@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> References: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> Cc: keir@xen.org, ian.campbell@citrix.com, andrew.cooper3@citrix.com, tim@xen.org, julien.grall@citrix.com, stefano.stabellini@citrix.com, jbeulich@suse.com, parth.dixit@linaro.org, christoffer.dall@linaro.org Subject: [Xen-devel] [PATCH v2 08/41] 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: 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 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: parth.dixit@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: 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, so we will check the version and only parse FADT table with version >= 5.1. If firmware provides ACPI tables with ACPI version less than 5.1, OS will be messed up with those information, so disable ACPI if we get an FADT table with version less that 5.1. Modify FADT table before passing it to Dom0. Set PSCI_COMPLIANT and PSCI_USE_HVC. Signed-off-by: Hanjun Guo Signed-off-by: Naresh Bhat Signed-off-by: Parth Dixit --- xen/arch/arm/acpi/boot.c | 38 ++++++++++++++++++++++++++++++++++++++ xen/arch/arm/acpi/lib.c | 11 +++++++++++ xen/include/asm-arm/acpi.h | 11 +++++++++++ 3 files changed, 60 insertions(+) diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c index 8dc69d5..57eb33c 100644 --- a/xen/arch/arm/acpi/boot.c +++ b/xen/arch/arm/acpi/boot.c @@ -24,9 +24,40 @@ #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; + u8 checksum; + + /* + * Revision in table header is the FADT Major revision, and there + * is a minor revision of FADT which was introduced by ACPI 5.1, + * we only deal with ACPI 5.1 or newer revision to get GIC and SMP + * boot protocol configuration data, or we will disable ACPI. + */ + if ( table->revision > 5 || + ( table->revision == 5 && fadt->minor_revision >= 1 ) ) + { + fadt->arm_boot_flags |= ( ACPI_FADT_PSCI_COMPLIANT | ACPI_FADT_PSCI_USE_HVC ); + checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, fadt), fadt->header.length); + fadt->header.checksum -= checksum; + clean_dcache_va_range(fadt, sizeof(struct acpi_table_fadt)); + return 0; + } + + printk("Unsupported FADT revision %d.%d, should be 5.1+, 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 @@ -51,6 +82,13 @@ 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 650beed..fd9bfa4 100644 --- a/xen/arch/arm/acpi/lib.c +++ b/xen/arch/arm/acpi/lib.c @@ -6,3 +6,14 @@ acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) { return __va(phys); } +/* 1 to indicate PSCI 0.2+ is implemented */ +inline bool_t 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 */ +inline bool_t 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 f771056..058f343 100644 --- a/xen/include/asm-arm/acpi.h +++ b/xen/include/asm-arm/acpi.h @@ -29,6 +29,17 @@ #define COMPILER_DEPENDENT_UINT64 unsigned long long extern bool_t acpi_disabled; + +#ifdef CONFIG_ACPI +/* 1 to indicate PSCI 0.2+ is implemented */ +bool_t acpi_psci_present(void); +/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */ +bool_t 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) {