From patchwork Mon Oct 1 12:46:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 147905 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3866670lji; Mon, 1 Oct 2018 05:49:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV60xrwBUj8W1raV+LThotIvE+jKNvxT+Z+iAulR8FlbfFZGSmGFXgEtZ/vOg9HuSsPRsia4I X-Received: by 2002:a6b:9082:: with SMTP id s124-v6mr6738970iod.249.1538398141874; Mon, 01 Oct 2018 05:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538398141; cv=none; d=google.com; s=arc-20160816; b=dHR3upzjTJqIRxVORrekgaPTlCxWG5DIGdfKxpO/Y3AusBcoITfkDp/WvwT2ZGJOkI 5KJtV17kvZHGtH7SYcm9JQB1TTTJsMVI+KbvQNXK9fFjRQ0+wBgx1q56qMSbswMhM2m1 R22vJslOqBJIl4SW+Wr3LD77RTC1pVrq/f2HxrDqCgf61DvPeaGPKgXUtxeDRYbFn+kl kDQnXHv20PLh87wbi5wtVoraJn9zfIU5Zxs8tdOBTxG8QganHG0WsN5J+X0Xx4pTp1jW djUo+pjCyA2eCxUv3sPpM3Q7j2e6YuOztMbNquQKLipQkYqEet71EVtW2Ktobeqtd/nn ay/A== 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:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=nYfUIVa8bingvgq9xHsxE+7rKKrKnKukOZ7I5Lpdyoo=; b=mAZp4Et240iY2Dr3CVO9nssV1QAK+R2YlViFZ1y9zoiENSxnaEAJM7DvpYdrTbqVN4 z42cOMqJHvc+QnJv7St4Y6hlTE1cinPqXyiEYQDpAB1kIvZDBrKeCWkkSTKjeyyoMsml 4awxMGUvlb2tnVDIlgLlhop5CM1XNuwPA/RADP8S7YUbltOlQsR/TkxroansSAY1LZE8 w8Qrv95JTgQ2nZ7l38MZeJVlxY/dfXVK9WZ+1EmqYQyjvSCTfDPXCiCBmtrk2Xa4MTxr WJbOnuLQdJc4emhbiKRAnVFXgFgcwoS0pTsHw1G1QxKDUK/3Ia7Lk09Gwo/blFqG31Ji B3bA== 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 r134-v6si6712367itc.66.2018.10.01.05.49.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Oct 2018 05:49:01 -0700 (PDT) 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.89) (envelope-from ) id 1g6xbD-0008Kq-3V; Mon, 01 Oct 2018 12:46:55 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1g6xbC-0008KG-8L for xen-devel@lists.xen.org; Mon, 01 Oct 2018 12:46:54 +0000 X-Inumbo-ID: 3c7636f1-c578-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 3c7636f1-c578-11e8-a6a9-d7ebe60f679a; Mon, 01 Oct 2018 12:48:03 +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 813AA15AD; Mon, 1 Oct 2018 05:46:52 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.emea.arm.com [10.4.12.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8D56F3F5A0; Mon, 1 Oct 2018 05:46:51 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 1 Oct 2018 13:46:39 +0100 Message-Id: <20181001124639.22885-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181001124639.22885-1-julien.grall@arm.com> References: <20181001124639.22885-1-julien.grall@arm.com> Subject: [Xen-devel] [[PATCH v3] 4/4] xen/arm: Replace call_smc with arm_smccc_smc X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , sstabellini@kernel.org, volodymyr_babchuk@epam.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" call_smc is a subset of arm_smccc_smc. Rather than having 2 methods to do SMCCC call, replace all call to the former by the later. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v3: - Use PSCI_RET where needed --- xen/arch/arm/Makefile | 1 - xen/arch/arm/platforms/exynos5.c | 3 ++- xen/arch/arm/platforms/seattle.c | 4 ++-- xen/arch/arm/psci.c | 37 +++++++++++++++++++++++++------------ xen/arch/arm/smc.S | 21 --------------------- xen/include/asm-arm/processor.h | 3 --- 6 files changed, 29 insertions(+), 40 deletions(-) delete mode 100644 xen/arch/arm/smc.S diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index b9b141dc84..37fa8268b3 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -39,7 +39,6 @@ obj-y += processor.o obj-y += psci.o obj-y += setup.o obj-y += shutdown.o -obj-y += smc.o obj-y += smp.o obj-y += smpboot.o obj-y += sysctl.o diff --git a/xen/arch/arm/platforms/exynos5.c b/xen/arch/arm/platforms/exynos5.c index c15ecf80f5..e2c0b7b878 100644 --- a/xen/arch/arm/platforms/exynos5.c +++ b/xen/arch/arm/platforms/exynos5.c @@ -26,6 +26,7 @@ #include #include #include +#include static bool secure_firmware; @@ -249,7 +250,7 @@ static int exynos5_cpu_up(int cpu) iounmap(power); if ( secure_firmware ) - call_smc(SMC_CMD_CPU1BOOT, cpu, 0, 0); + arm_smccc_smc(SMC_CMD_CPU1BOOT, cpu, NULL); return cpu_up_send_sgi(cpu); } diff --git a/xen/arch/arm/platforms/seattle.c b/xen/arch/arm/platforms/seattle.c index 893cc17972..64cc1868c2 100644 --- a/xen/arch/arm/platforms/seattle.c +++ b/xen/arch/arm/platforms/seattle.c @@ -33,12 +33,12 @@ static const char * const seattle_dt_compat[] __initconst = */ static void seattle_system_reset(void) { - call_smc(PSCI_0_2_FN32_SYSTEM_RESET, 0, 0, 0); + arm_smccc_smc(PSCI_0_2_FN32_SYSTEM_RESET, NULL); } static void seattle_system_off(void) { - call_smc(PSCI_0_2_FN32_SYSTEM_OFF, 0, 0, 0); + arm_smccc_smc(PSCI_0_2_FN32_SYSTEM_OFF, NULL); } PLATFORM_START(seattle, "SEATTLE") diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c index 941eec921b..4ae6504f3e 100644 --- a/xen/arch/arm/psci.c +++ b/xen/arch/arm/psci.c @@ -42,42 +42,53 @@ uint32_t smccc_ver; static uint32_t psci_cpu_on_nr; +#define PSCI_RET(res) ((int32_t)(res).a0) + int call_psci_cpu_on(int cpu) { - return call_smc(psci_cpu_on_nr, cpu_logical_map(cpu), __pa(init_secondary), 0); + struct arm_smccc_res res; + + arm_smccc_smc(psci_cpu_on_nr, cpu_logical_map(cpu), __pa(init_secondary), + &res); + + return PSCI_RET(res.a0); } void call_psci_cpu_off(void) { if ( psci_ver > PSCI_VERSION(0, 1) ) { - int errno; + struct arm_smccc_res res; /* If successfull the PSCI cpu_off call doesn't return */ - errno = call_smc(PSCI_0_2_FN32_CPU_OFF, 0, 0, 0); + arm_smccc_smc(PSCI_0_2_FN32_CPU_OFF, &res); panic("PSCI cpu off failed for CPU%d err=%d\n", smp_processor_id(), - errno); + PSCI_RET(res)); } } void call_psci_system_off(void) { if ( psci_ver > PSCI_VERSION(0, 1) ) - call_smc(PSCI_0_2_FN32_SYSTEM_OFF, 0, 0, 0); + arm_smccc_smc(PSCI_0_2_FN32_SYSTEM_OFF, NULL); } void call_psci_system_reset(void) { if ( psci_ver > PSCI_VERSION(0, 1) ) - call_smc(PSCI_0_2_FN32_SYSTEM_RESET, 0, 0, 0); + arm_smccc_smc(PSCI_0_2_FN32_SYSTEM_RESET, NULL); } static int __init psci_features(uint32_t psci_func_id) { + struct arm_smccc_res res; + 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); + arm_smccc_smc(PSCI_1_0_FN32_PSCI_FEATURES, psci_func_id, NULL); + + return PSCI_RET(res); } static int __init psci_is_smc_method(const struct dt_device_node *psci) @@ -112,11 +123,11 @@ static void __init psci_init_smccc(void) if ( psci_features(ARM_SMCCC_VERSION_FID) != PSCI_NOT_SUPPORTED ) { - uint32_t ret; + struct arm_smccc_res res; - ret = call_smc(ARM_SMCCC_VERSION_FID, 0, 0, 0); - if ( ret != ARM_SMCCC_NOT_SUPPORTED ) - smccc_ver = ret; + arm_smccc_smc(ARM_SMCCC_VERSION_FID, &res); + if ( PSCI_RET(res) != ARM_SMCCC_NOT_SUPPORTED ) + smccc_ver = PSCI_RET(res); } if ( smccc_ver >= SMCCC_VERSION(1, 1) ) @@ -165,6 +176,7 @@ static int __init psci_init_0_2(void) { /* sentinel */ }, }; int ret; + struct arm_smccc_res res; if ( acpi_disabled ) { @@ -186,7 +198,8 @@ static int __init psci_init_0_2(void) } } - psci_ver = call_smc(PSCI_0_2_FN32_PSCI_VERSION, 0, 0, 0); + arm_smccc_smc(PSCI_0_2_FN32_PSCI_VERSION, &res); + psci_ver = PSCI_RET(res); /* For the moment, we only support PSCI 0.2 and PSCI 1.x */ if ( psci_ver != PSCI_VERSION(0, 2) && PSCI_VERSION_MAJOR(psci_ver) != 1 ) diff --git a/xen/arch/arm/smc.S b/xen/arch/arm/smc.S deleted file mode 100644 index b8f182272a..0000000000 --- a/xen/arch/arm/smc.S +++ /dev/null @@ -1,21 +0,0 @@ -/* - * xen/arch/arm/smc.S - * - * Wrapper for Secure Monitors Calls - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include - -ENTRY(call_smc) - smc #0 - ret diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h index 222a02dd99..8016cf306f 100644 --- a/xen/include/asm-arm/processor.h +++ b/xen/include/asm-arm/processor.h @@ -812,9 +812,6 @@ void vcpu_regs_hyp_to_user(const struct vcpu *vcpu, void vcpu_regs_user_to_hyp(struct vcpu *vcpu, const struct vcpu_guest_core_regs *regs); -int call_smc(register_t function_id, register_t arg0, register_t arg1, - register_t arg2); - void do_trap_hyp_serror(struct cpu_user_regs *regs); void do_trap_guest_serror(struct cpu_user_regs *regs);