From patchwork Mon Feb 5 13:20:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 126866 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1967443ljc; Mon, 5 Feb 2018 05:22:46 -0800 (PST) X-Google-Smtp-Source: AH8x227eiM8MEmL8YXN/GzAMOBDjHOp6Y43E3w1ceQrooieyq4WcLyupbsIfka40HIhwQdH0u1El X-Received: by 10.107.201.193 with SMTP id z184mr57408461iof.111.1517836966844; Mon, 05 Feb 2018 05:22:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517836966; cv=none; d=google.com; s=arc-20160816; b=gKWAE95MbxryFIjB+A2rCmRer39U24HkGs9eWpQyRKdFT970iXhTv5uFlrv4N4WYlo lnwKy0MVf6knJ+8t7DUXmFg6a4G+jJp9UJIDNJfR8qYco8DxsP3L//AoS7zFwt+5WrEk FA3IB0S/JKbPbaobg72wr0uiW5jxa9Rvl169HBwxu92jWc24jI5Pa1Lv3VfUCeA7p0SM 0cC+mgLCq21ROC253qMirww6B90dKF/Y4HyO+zRcJnwDOLbQX2HvhpWTL0w3aKkUxiOw 1vR7y+jMXe15dfmb+OBrM+fcjg2IUhm7d2UyzAOa6N0JQSWHdKOZz37RqarKJVI0BgiM cLRA== 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=lcTkH6RhiGM8Cjo58VN4Re85ymhgYfUiDzvNUUXSM48=; b=Hs543rV7QANj7vMepQyq5G9OcGKWwWinDZnY1mxyqnyrTYJPTiJSpGQqRzdIIbw/h9 +YoxsNBFQFe6i6S1WsW83jB+Nd5mYUqAmBBoxiCYDXvdNwnmXinrbEyZzmDvuUfy1EwD VlFE4PQSWtHuN9wMH2jWM5ulbybhGU+FMBbEIXIPaJdLPU/ouEliDC/Xlca6A85rUJiz htLqCJ8TlcMoUT5kVnIg5KwYbC5EQYymtorrRW/zTdOVgD/h7m9KtY29dRX+Li4WUAyK sZZ/I4ft/ociuwFKab+ROQ0uPQAhxdzeCIIwRpYxRouurTtVR6tGDlVa6vOcTeiVDOtr rGqw== 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 k7si688355iti.48.2018.02.05.05.22.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 05:22:46 -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 1eigh8-0007LL-Oa; Mon, 05 Feb 2018 13:20:26 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eigh6-0007Kt-W4 for xen-devel@lists.xen.org; Mon, 05 Feb 2018 13:20:25 +0000 X-Inumbo-ID: 4588b3dd-0a77-11e8-ba59-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 4588b3dd-0a77-11e8-ba59-bc764e045a96; Mon, 05 Feb 2018 14:20:01 +0100 (CET) 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 A1D511529; Mon, 5 Feb 2018 05:20: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 B61003F24D; Mon, 5 Feb 2018 05:20:22 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 5 Feb 2018 13:20:06 +0000 Message-Id: <20180205132011.27996-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180205132011.27996-1-julien.grall@arm.com> References: <20180205132011.27996-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, andre.przywara@linaro.org Subject: [Xen-devel] [PATCH 4/7] 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 ARM DEN 00070A. Signed-off-by: Julien Grall --- xen/arch/arm/vpsci.c | 1 + xen/arch/arm/vsmc.c | 23 +++++++++++++++++++++++ xen/include/asm-arm/smccc.h | 15 +++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/xen/arch/arm/vpsci.c b/xen/arch/arm/vpsci.c index 025250a119..e40ba5c5ad 100644 --- a/xen/arch/arm/vpsci.c +++ b/xen/arch/arm/vpsci.c @@ -215,6 +215,7 @@ static int32_t do_psci_1_0_features(uint32_t psci_func_id) case PSCI_0_2_FN32_AFFINITY_INFO: case PSCI_0_2_FN64_AFFINITY_INFO: 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..a708aa5e81 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, -1); + 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..431389c118 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,6 +103,18 @@ static inline uint32_t smccc_get_owner(register_t funcid) ARM_SMCCC_OWNER_##owner, \ 0xFF03) +#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) + /* Only one error code defined in SMCCC */ #define ARM_SMCCC_ERR_UNKNOWN_FUNCTION (-1)