From: Andre Przywara Subject: [PATCH v2 4/6] arm: add a function to invoke the PSCI handler Date: Mon, 2 Dec 2013 12:08:56 +0100 Message-ID: <1385982538-17855-5-git-send-email-andre.przywara@linaro.org> References: <1385982538-17855-1-git-send-email-andre.przywara@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VnRNg-0006Hn-Bq for xen-devel@lists.xenproject.org; Mon, 02 Dec 2013 11:09:36 +0000 Received: by mail-bk0-f54.google.com with SMTP id v16so5420011bkz.27 for ; Mon, 02 Dec 2013 03:09:34 -0800 (PST) In-Reply-To: <1385982538-17855-1-git-send-email-andre.przywara@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com Cc: xen-devel@lists.xenproject.org, julien.grall@linaro.org, Andre Przywara , patches@linaro.org List-Id: xen-devel@lists.xenproject.org The PSCI handler is invoked via a secure monitor call with the arguments defined in registers. Copy the function from the Linux code and adjust it to work on both ARM32 and ARM64. Signed-off-by: Andre Przywara --- xen/arch/arm/psci.c | 28 ++++++++++++++++++++++++++++ xen/include/asm-arm/psci.h | 1 + 2 files changed, 29 insertions(+) diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c index 9ff06cd..cc382be 100644 --- a/xen/arch/arm/psci.c +++ b/xen/arch/arm/psci.c @@ -25,8 +25,36 @@ int psci_available; +#ifdef CONFIG_ARM_32 +#define REG_PREFIX "r" +#else +#define REG_PREFIX "x" +#endif + +static noinline int __invoke_psci_fn_smc(u32 function_id, u32 arg0, u32 arg1, + u32 arg2) +{ + asm volatile( + __asmeq("%0", REG_PREFIX"0") + __asmeq("%1", REG_PREFIX"1") + __asmeq("%2", REG_PREFIX"2") + __asmeq("%3", REG_PREFIX"3") + "smc #0" + : "+r" (function_id) + : "r" (arg0), "r" (arg1), "r" (arg2)); + + return function_id; +} + +#undef REG_PREFIX + static uint32_t psci_cpu_on_nr; +int call_psci_cpu_on(int cpu, void *smp_pen) +{ + return __invoke_psci_fn_smc(psci_cpu_on_nr, cpu, __pa(smp_pen), 0); +} + int __init psci_init(void) { struct dt_device_node *psci; diff --git a/xen/include/asm-arm/psci.h b/xen/include/asm-arm/psci.h index 2f37612..50513bf 100644 --- a/xen/include/asm-arm/psci.h +++ b/xen/include/asm-arm/psci.h @@ -10,6 +10,7 @@ extern int psci_available; int psci_init(void); +int call_psci_cpu_on(int cpu, void *smp_pen); /* functions to handle guest PSCI requests */ int do_psci_cpu_on(uint32_t vcpuid, register_t entry_point); -- 1.7.12.1