From patchwork Mon Dec 2 11:08:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 21927 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f69.google.com (mail-qe0-f69.google.com [209.85.128.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6EAEF23FCF for ; Mon, 2 Dec 2013 11:09:37 +0000 (UTC) Received: by mail-qe0-f69.google.com with SMTP id 1sf24383484qec.4 for ; Mon, 02 Dec 2013 03:09:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=TsFYEsmMZSs2Tg76ivx06YLmTcXWW60+qTBo3zdkOFc=; b=fhmA/jTEtjzJ+800fZT+6p+wXOHP1nbMM2q9DslYRkd3AX4UT7W5ZLBY6VbBVhsxqn Dcnzss7oGeA6cWD0ogO5vA9WSq4/iHEPvMpE5FbErs8Nvfgl2ReRqGaDJZyqnplWEo6E iQ2iwueCKjwwgkx+5QvnGGR6FyU6ZzquxKukkZN9gRgXTElFHTU8SptBjCdQpqLYFnxy ovTdYOlQtILg09zDvfNEG7xThcprvOszmuICvI2XZxCln16vhGixi6VWKdbc+BhuwK7h Oywu9e13v4WAiYsI3hmKGIYbht3zQCTmJRPp0WlfyfBidA9Wgw8mriLYdCywl03weWlL lUOw== X-Gm-Message-State: ALoCoQkPiBoaDTJzqdZ7KACy6vaF2ycycvsymrNsDmbsvr8WAAFIHxbzbhGGtLKJuyhjprdm9oKg X-Received: by 10.236.142.75 with SMTP id h51mr7508615yhj.21.1385982576291; Mon, 02 Dec 2013 03:09:36 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.61.229 with SMTP id t5ls1746211qer.53.gmail; Mon, 02 Dec 2013 03:09:36 -0800 (PST) X-Received: by 10.220.122.129 with SMTP id l1mr112977vcr.48.1385982576215; Mon, 02 Dec 2013 03:09:36 -0800 (PST) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id z15si29439483vce.72.2013.12.02.03.09.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Dec 2013 03:09:36 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id oy12so8734504veb.15 for ; Mon, 02 Dec 2013 03:09:36 -0800 (PST) X-Received: by 10.53.2.36 with SMTP id bl4mr852086vdd.32.1385982576145; Mon, 02 Dec 2013 03:09:36 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp110798vcz; Mon, 2 Dec 2013 03:09:35 -0800 (PST) X-Received: by 10.205.65.81 with SMTP id xl17mr303531bkb.66.1385982574934; Mon, 02 Dec 2013 03:09:34 -0800 (PST) Received: from mail-bk0-f50.google.com (mail-bk0-f50.google.com [209.85.214.50]) by mx.google.com with ESMTPS id tw3si1830204bkb.109.2013.12.02.03.09.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Dec 2013 03:09:34 -0800 (PST) Received-SPF: neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of andre.przywara@linaro.org) client-ip=209.85.214.50; Received: by mail-bk0-f50.google.com with SMTP id e11so5322663bkh.37 for ; Mon, 02 Dec 2013 03:09:34 -0800 (PST) X-Received: by 10.205.102.73 with SMTP id dd9mr299529bkc.62.1385982574329; Mon, 02 Dec 2013 03:09:34 -0800 (PST) Received: from slackpad.drs.calxeda.com (f053082149.adsl.alicedsl.de. [78.53.82.149]) by mx.google.com with ESMTPSA id z6sm74390807bkn.8.2013.12.02.03.09.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Dec 2013 03:09:33 -0800 (PST) From: Andre Przywara To: Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com Cc: julien.grall@linaro.org, xen-devel@lists.xenproject.org, patches@linaro.org, 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> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1385982538-17855-1-git-send-email-andre.przywara@linaro.org> References: <1385982538-17855-1-git-send-email-andre.przywara@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: andre.przywara@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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);