From patchwork Thu Feb 8 19:21:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 127739 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1794025ljc; Thu, 8 Feb 2018 11:24:41 -0800 (PST) X-Google-Smtp-Source: AH8x227DCrKScBFmfVDU582HBzqvt/iQC8uFwGoqzvSYj1KN+iK7bgXxwsYuqmwoNPxsrhjfc5YZ X-Received: by 10.36.7.209 with SMTP id f200mr293473itf.124.1518117881359; Thu, 08 Feb 2018 11:24:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518117881; cv=none; d=google.com; s=arc-20160816; b=020pAm7/Q5LA98u1TOMlfzITLFVAIsah4FpezefDBk6K45DivzmCClonSYABcUiQun sy1O+cWjoO9nVX7z4pdjAX682B0qI6G6rWZUbvJM/8bmsZDm8NPuUYYlQ9fmA7mgNI1l idcz5/eeuu0/xoyUQPl5sS06QF+9duvO3aAeJxJ1wgtMXa9s44uoJDvLH8mxLURC0azX sn2/96WPDoqbY8paJ4rkHbUkFMzSY/OZSmbbIVIV3nSLnWCQKaxb0xBp6ZOT2rdjRMvG IUXpHjPjpYS7GnT3CHUx9B1ulzRZ0EA0MIH1Dt6s4HAPtbgFo+Lfl7ONmhqp43tE9BRt X1DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=nGBXJ5BobD7ElPmgoA83o31UMx6h3h/koQOPQD1ZnUo=; b=QbiX5vkspYT141ixNFLgDKe4pcN6OBHA0P8XC0r0wiTvYXh1abAxG4sMxhU32GAxoo NLe+1nrZJGHhYFFRl5sgO5hOC6u2XpiBCwLhaJG17205ei8hd/mAY0qeqW8leHgREMKa dZUSpBShwyOgO2OnmS+FYU4JbJlCIxVSFyXFKzs+sSMToM/onq48Y/28uL41Espd+aYR 3U93/3Xci7c6nJWptoIK70mMso3kY27qIUdk1lH3fGykNbrkRzk6ckuWfBKfXx7zR415 f7tp6l/ckbuXsj4Ofqh9Rj8aQDkJ4Xy5g4vhJfdlwHXlmK2c+nuU+UHDKlVkEab7s2Si ofRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v188si442496itb.98.2018.02.08.11.24.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Feb 2018 11:24:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejrmW-0006qI-Im; Thu, 08 Feb 2018 19:22:52 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejrmU-0006k3-Tj for xen-devel@lists.xen.org; Thu, 08 Feb 2018 19:22:50 +0000 X-Inumbo-ID: 85255858-0d05-11e8-b9b1-635ca7ef6cff Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 85255858-0d05-11e8-b9b1-635ca7ef6cff; Thu, 08 Feb 2018 19:23:19 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ACE0680D; Thu, 8 Feb 2018 11:22:23 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9DC303F24D; Thu, 8 Feb 2018 11:22:22 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 8 Feb 2018 19:21:57 +0000 Message-Id: <20180208192203.9556-10-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180208192203.9556-1-julien.grall@arm.com> References: <20180208192203.9556-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, volodymyr_babchuk@epam.com, andre.przywara@linaro.org Subject: [Xen-devel] [PATCH v2 09/15] xen/arm: psci: Detect SMCCC version X-BeenThere: xen-devel@lists.xenproject.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.xenproject.org Sender: "Xen-devel" PSCI 1.0 and later allows the SMCCC version to be (indirectly) probed via PSCI_FEATURES. If the PSCI_FEATURES does not exist (PSCI 0.2 or earlier) and the function return an error, then we considered SMCCC 1.0 is implemented. Signed-off-by: Julien Grall --- Changes in v2: - Patch added --- xen/arch/arm/psci.c | 34 +++++++++++++++++++++++++++++++++- xen/include/asm-arm/smccc.h | 5 ++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c index 5dda35cd7c..bc7b2260e8 100644 --- a/xen/arch/arm/psci.c +++ b/xen/arch/arm/psci.c @@ -37,6 +37,7 @@ #endif uint32_t psci_ver; +uint32_t smccc_ver; static uint32_t psci_cpu_on_nr; @@ -57,6 +58,14 @@ void call_psci_system_reset(void) call_smc(PSCI_0_2_FN32_SYSTEM_RESET, 0, 0, 0); } +static int __init psci_features(uint32_t psci_func_id) +{ + if ( psci_ver < PSCI_VERSION(1, 0) ) + return PSCI_NOT_SUPPORTED; + + return call_smc(PSCI_1_0_FN32_PSCI_FEATURES, psci_func_id, 0, 0); +} + int __init psci_is_smc_method(const struct dt_device_node *psci) { int ret; @@ -82,6 +91,24 @@ int __init psci_is_smc_method(const struct dt_device_node *psci) return 0; } +static void __init psci_init_smccc(void) +{ + /* PSCI is using at least SMCC 1.0 calling convention. */ + smccc_ver = ARM_SMCCC_VERSION_1_0; + + if ( psci_features(ARM_SMCCC_VERSION_FID) != PSCI_NOT_SUPPORTED ) + { + uint32_t ret; + + ret = call_smc(ARM_SMCCC_VERSION_FID, 0, 0, 0); + if ( ret != ARM_SMCCC_NOT_SUPPORTED ) + smccc_ver = ret; + } + + printk(XENLOG_INFO "Using SMC Calling Convention v%u.%u\n", + SMCCC_VERSION_MAJOR(smccc_ver), SMCCC_VERSION_MINOR(smccc_ver)); +} + int __init psci_init_0_1(void) { int ret; @@ -173,7 +200,12 @@ int __init psci_init(void) if ( ret ) ret = psci_init_0_1(); - return ret; + if ( ret ) + return ret; + + psci_init_smccc(); + + return 0; } /* diff --git a/xen/include/asm-arm/smccc.h b/xen/include/asm-arm/smccc.h index caa2c9cc1b..bc067892c7 100644 --- a/xen/include/asm-arm/smccc.h +++ b/xen/include/asm-arm/smccc.h @@ -52,6 +52,8 @@ #ifndef __ASSEMBLY__ +extern uint32_t smccc_ver; + /* Check if this is fast call. */ static inline bool smccc_is_fast_call(register_t funcid) { @@ -137,8 +139,9 @@ static inline uint32_t smccc_get_owner(register_t funcid) ARM_SMCCC_OWNER_ARCH, \ 0x8000) -/* Only one error code defined in SMCCC */ +/* SMCCC error codes */ #define ARM_SMCCC_ERR_UNKNOWN_FUNCTION (-1) +#define ARM_SMCCC_NOT_SUPPORTED (-1) /* SMCCC function identifier range which is reserved for existing APIs */ #define ARM_SMCCC_RESERVED_RANGE_START 0x0