From patchwork Fri Feb 23 16:47:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 129465 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp814122lja; Fri, 23 Feb 2018 08:50:19 -0800 (PST) X-Google-Smtp-Source: AG47ELt3WPkkn5E9TwXFUFzujwXyepEJ8OUYGtQa/XpzkUcqvV5U71+7BKtiwYIQmKW6uIvM33wc X-Received: by 10.107.183.76 with SMTP id h73mr2481035iof.201.1519404619804; Fri, 23 Feb 2018 08:50:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519404619; cv=none; d=google.com; s=arc-20160816; b=cJXmJypv3cXGXTTQyp7Eijjty6kx+5z5zr59YMsquuEQqD/mBlvBv73e0sO3znrNnL fQmwJJpsKyiQks6AdIjhrYc25QmEwJxCkekzgCfWx75gOAubP+KehkpHeFNl3PEGczlP mu+ZY/mQrYr4xFWSv9Zbb265fT9kxnFt3oEzSci4MDz856OjjOn3f5PP0ki1oFbKuGVx 5dcX0qY6aTF3fvQ9SzoFK4y/UHOYMYDISxAhay7TbXnUOuLqwa/Ybt5owXCuiAoYADKN nnmxFzbjxhyeyl77blacH5M59hjjbFpYUXNw1McQKwJcQjaEkNmEfISeeBcU6XBWa7N8 3RYg== 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=zr/c9WoQdsMIjrG5E2R0VY9hIoZooIANEfaHS7aXUH0=; b=iKu5PUJR773pvOHXNOtaMmlof8gvDgi/SqtfMr778GIY9fzugYr/TJM3ujzb2AHcPP mh/imYpv1WdHlXyWvOyPIrZL8MahE17jTV9r5VRl6gcF8jELWEmU5poyEEjJW5aqpFad Ko/o8wBwiIzzX4DZff6izEF2F6e6u2/6p2ofCCKXqAwuv6ETSmSeX9qpzwBoNaw8Q5BU j+FN5SEJCGqHGQAzr6IYpq1bvr8Bm0mBsSH3+WjBNmkbS6iMJR8FM0swuykzRxvbtL6H qtrcZ0kX4TONIxSzKNmvlYIVoXtsyg7sYtg2IRXg8iwTthVrjOoSZVrguQnHuaF57+mm tvmw== 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 204si1462069itm.128.2018.02.23.08.50.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 08:50:19 -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 1epGW9-0003Vl-Iv; Fri, 23 Feb 2018 16:48:17 +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 1epGW8-0003Qb-EV for xen-devel@lists.xen.org; Fri, 23 Feb 2018 16:48:16 +0000 X-Inumbo-ID: 918d180d-18b9-11e8-b9b1-635ca7ef6cff Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 918d180d-18b9-11e8-b9b1-635ca7ef6cff; Fri, 23 Feb 2018 16:49:52 +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 4B88E15AD; Fri, 23 Feb 2018 08:48:09 -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 18D453F25C; Fri, 23 Feb 2018 08:48:07 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 23 Feb 2018 16:47:37 +0000 Message-Id: <20180223164753.27311-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180223164753.27311-1-julien.grall@arm.com> References: <20180223164753.27311-1-julien.grall@arm.com> Cc: Volodymyr Babchuk , Julien Grall , sstabellini@kernel.org, volodymyr_babchuk@epam.com, andre.przywara@linaro.org Subject: [Xen-devel] [PATCH v4 03/19] xen/arm: vsmc: Implement SMCCC 1.1 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" The new SMC Calling Convention (v1.1) allows for a reduced overhead when calling into the firmware, and provides a new feature discovery mechanism. See "Firmware interfaces for mitigating CVE-2017-5715" ARM DEN 00070A. Signed-off-by: Julien Grall Reviewed-by: Volodymyr Babchuk Acked-by: Stefano Stabellini --- Changes in v4: - Add Volodymyr's reviewed-by - Add Stefano's acked-by Changes in v3: - Use ARM_SMCCC_NOT_SUPPORTED rather than hardcoded return Changes in v2: - Add a humand readable name for the specification --- xen/arch/arm/vpsci.c | 1 + xen/arch/arm/vsmc.c | 23 +++++++++++++++++++++++ xen/include/asm-arm/smccc.h | 18 +++++++++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/vpsci.c b/xen/arch/arm/vpsci.c index e82b62db1a..19ee7caeb4 100644 --- a/xen/arch/arm/vpsci.c +++ b/xen/arch/arm/vpsci.c @@ -212,6 +212,7 @@ static int32_t do_psci_1_0_features(uint32_t psci_func_id) case PSCI_0_2_FN32_SYSTEM_OFF: case PSCI_0_2_FN32_SYSTEM_RESET: case PSCI_1_0_FN32_PSCI_FEATURES: + case ARM_SMCCC_VERSION_FID: return 0; default: return PSCI_NOT_SUPPORTED; diff --git a/xen/arch/arm/vsmc.c b/xen/arch/arm/vsmc.c index 3d3bd95fee..7ec492741b 100644 --- a/xen/arch/arm/vsmc.c +++ b/xen/arch/arm/vsmc.c @@ -81,6 +81,26 @@ static bool fill_function_call_count(struct cpu_user_regs *regs, uint32_t cnt) return true; } +/* SMCCC interface for ARM Architecture */ +static bool handle_arch(struct cpu_user_regs *regs) +{ + uint32_t fid = (uint32_t)get_user_reg(regs, 0); + + switch ( fid ) + { + case ARM_SMCCC_VERSION_FID: + set_user_reg(regs, 0, ARM_SMCCC_VERSION_1_1); + return true; + + case ARM_SMCCC_ARCH_FEATURES_FID: + /* Nothing supported yet */ + set_user_reg(regs, 0, ARM_SMCCC_NOT_SUPPORTED); + return true; + } + + return false; +} + /* SMCCC interface for hypervisor. Tell about itself. */ static bool handle_hypervisor(struct cpu_user_regs *regs) { @@ -188,6 +208,9 @@ static bool vsmccc_handle_call(struct cpu_user_regs *regs) { switch ( smccc_get_owner(funcid) ) { + case ARM_SMCCC_OWNER_ARCH: + handled = handle_arch(regs); + break; case ARM_SMCCC_OWNER_HYPERVISOR: handled = handle_hypervisor(regs); break; diff --git a/xen/include/asm-arm/smccc.h b/xen/include/asm-arm/smccc.h index 62b3a8cdf5..629cc5150b 100644 --- a/xen/include/asm-arm/smccc.h +++ b/xen/include/asm-arm/smccc.h @@ -16,6 +16,9 @@ #ifndef __ASM_ARM_SMCCC_H__ #define __ASM_ARM_SMCCC_H__ +#define ARM_SMCCC_VERSION_1_0 0x10000 +#define ARM_SMCCC_VERSION_1_1 0x10001 + /* * This file provides common defines for ARM SMC Calling Convention as * specified in @@ -100,8 +103,21 @@ static inline uint32_t smccc_get_owner(register_t funcid) ARM_SMCCC_OWNER_##owner, \ 0xFF03) -/* Only one error code defined in SMCCC */ +#define ARM_SMCCC_VERSION_FID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_CONV_32, \ + ARM_SMCCC_OWNER_ARCH, \ + 0x0) \ + +#define ARM_SMCCC_ARCH_FEATURES_FID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_CONV_32, \ + ARM_SMCCC_OWNER_ARCH, \ + 0x1) + +/* 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