From patchwork Tue Aug 8 20:08:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volodymyr Babchuk X-Patchwork-Id: 9889033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9526B60352 for ; Tue, 8 Aug 2017 20:12:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 871AF287D5 for ; Tue, 8 Aug 2017 20:12:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B3EF2892B; Tue, 8 Aug 2017 20:12:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9E97B287D5 for ; Tue, 8 Aug 2017 20:12:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfAon-0000hd-Vy; Tue, 08 Aug 2017 20:09:33 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfAom-0000gw-FQ for xen-devel@lists.xen.org; Tue, 08 Aug 2017 20:09:32 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id 5E/8B-01729-B7A1A895; Tue, 08 Aug 2017 20:09:31 +0000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msg-Ref: server-7.tower-206.messagelabs.com!1502222970!103528068!1 X-Originating-IP: [104.47.2.75] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7842 invoked from network); 8 Aug 2017 20:09:30 -0000 Received: from mail-db5eur01on0075.outbound.protection.outlook.com (HELO EUR01-DB5-obe.outbound.protection.outlook.com) (104.47.2.75) by server-7.tower-206.messagelabs.com with AES256-SHA256 encrypted SMTP; 8 Aug 2017 20:09:30 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=EPAM.onmicrosoft.com; s=selector1-epam-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=iBeS/x1AKQbfsnhxzZJzq1bypFlpzIFs/EBzjO+WVuE=; b=CQX7DdwdZKj4odmkn+m2MBxcBRvFPEKVX+SqtavyFf/mJA4iQZjFS4hbomSiO/bdpWNp8uSNZERswu0xLqMqMAfG43oGVOrIAtAfZ/u4swRLwIMbO4iYpaFojbRtRH8IG7qF3LDeFrE2VkOQKA63mLx4FH19/OkRwOmeLyy35bs= Received: from EPUAKYIW2556.kyiv.epam.com (85.223.209.58) by AM4PR0301MB2129.eurprd03.prod.outlook.com (2603:10a6:200:4d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1320.16; Tue, 8 Aug 2017 20:09:27 +0000 Received: by EPUAKYIW2556.kyiv.epam.com (sSMTP sendmail emulation); Tue, 08 Aug 2017 23:09:22 +0300 From: Volodymyr Babchuk To: xen-devel@lists.xen.org Date: Tue, 8 Aug 2017 23:08:40 +0300 Message-Id: <1502222922-25821-6-git-send-email-volodymyr_babchuk@epam.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502222922-25821-1-git-send-email-volodymyr_babchuk@epam.com> References: <1502222922-25821-1-git-send-email-volodymyr_babchuk@epam.com> MIME-Version: 1.0 X-Originating-IP: [85.223.209.58] X-ClientProxiedBy: HE1PR0202CA0023.eurprd02.prod.outlook.com (2603:10a6:3:8c::33) To AM4PR0301MB2129.eurprd03.prod.outlook.com (2603:10a6:200:4d::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c7d08c68-1587-4ce3-c389-08d4de995f73 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:AM4PR0301MB2129; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0301MB2129; 3:H2obOmstVtphtZLgaMR4nb8tQnQCp86ZqH4N43edXi3gah1MOy0Y+Og5HQWywqA9We6WzfCiBeoL0pFCCXgm1shxXiXAWOVfZfHctwjLy9QIb4zDdjI3C+A4AgdRX5sBaCzAb+kgfIDpaaPv4gvqsiM+FkuJq5DYGitrXwEAn1E9lD0q5jNaP0epjRvSu/ZdoER/FDPKpXtLibVf3xo76qMLRrHQVnpkpEj/rKNekJRu2Seo3g1VyAJnKzodUlg+; 25:pas0AJgu/XNH7rUNnni7jAiXbzQQLcESAduKQAxtsiPX0qQXdAidGs9SQsTxAUOYaQvRMfTM3iQlngJUfHaPp001r5oJWbHiTHyFLW7hIosnC+NCgDXXwzb+nGg8K0rPncfGojtgf92fr8vf119BVYHRSRkv0aicWMqA+D8y435sbrXlKqoYBRsakat5N3vzeskPUSF1I99zZylotpSu30+D11IV/iT/RmrcD9+tNbeKySwSrztijLXsaWD94Jue6tPmNL14T3bndZ2SFWPWVhnufMIjal0ASBcuamoFEOmcuzYgD8ZvoWZKmR5VjNRdOR/y/vO+2yjvmVksDqEmhg==; 31:zSQwOO63xWfsL6HLIUliVDRZgc6pAozF/YHOr2IiLdBOkLuK/qIgq2rkt3PiIynft100tV0/Chjx/yqz+6r19lFbUQ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-Antispam-Report-Test: UriScan:(4114951738403)(17755550239193); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM4PR0301MB2129; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM4PR0301MB2129; X-Forefront-PRVS: 03932714EB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39450400003)(39840400002)(39410400002)(39400400002)(39850400002)(189002)(199003)(86362001)(101416001)(2351001)(5660300001)(105586002)(2950100002)(6916009)(2906002)(478600001)(6666003)(53936002)(8676002)(50226002)(7736002)(106356001)(76176999)(50986999)(81166006)(305945005)(7350300001)(107886003)(8656003)(2361001)(80792005)(33646002)(38730400002)(81156014)(110136004)(48376002)(47776003)(5003940100001)(97736004)(8666007)(68736007)(66066001)(189998001)(4326008)(42186005)(72206003)(54906002)(36756003)(50466002)(6116002)(122856001)(3846002)(81973001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0301MB2129; H:EPUAKYIW2556.kyiv.epam.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: epam.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR0301MB2129; 23:1jx9cd13J0O1dje1zh3zQHExbb5/9COJ1zSkI+G?= =?us-ascii?Q?f7jQrNxC6Px3QAT/XPQXMAZqaIPj8ZiOUgw0EQXs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lyCBa4IoxVlU8FhhduROKw==; 24:HjgcXS/xMImqLFQQOrojjf3dRBE/w5kyNYkO0KxVBCy2Cn4co7BkF0F26L7pAgqBGK3Z0WiWlUtKytN6jyTiXqYMYaR7Np1sFU1l9xcvBTM=; 7:j8u1QJJNYspgiSjF2OveS6bnlnkHd4GfNeonVEQvtuKkYMW/32NpXGNh7UOthyWAwSK17C3T/IgRr2DURVUX5pS9ub1Ylr0/M/JZt09y6attz9Lm4GstnvPl3/2HSM0WCG3hIHhetd4ntQV0urjIGMjgH6jZ7aOsGVZq9iw/iK3vdPh3bIIsSKEGMw4yz3lged9mh8R6NF57c/LBAIVxg/VfwSwO+f/U6MoDaaJkPZY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2017 20:09:27.1523 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0301MB2129 Cc: "Edgar E . Iglesias" , Julien Grall , Stefano Stabellini , Volodymyr Babchuk Subject: [Xen-devel] [PATCH 5/7] arm: traps: handle PSCI calls inside `smccc.c` X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP PSCI is part of HVC/SMC interface, so it should be handled in appropriate place: `vsmc.c`. This patch just moves PSCI handler calls from `traps.c` to `vsmc.c`. PSCI is considered as two different "services" in terms of SMCCC. Older PSCI 1.0 is treated as "architecture service", while never PSCI 2.0 is defined as "standard secure service". Signed-off-by: Volodymyr Babchuk Reviewed-by: Oleksandr Andrushchenko Reviewed-by: Oleksandr Tyshchenko --- - Added do_trap_hvc() handler in vsmc.c --- xen/arch/arm/traps.c | 124 ++------------------------------ xen/arch/arm/vsmc.c | 144 ++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/vsmc.h | 1 + xen/include/public/arch-arm/smc.h | 10 ++- 4 files changed, 160 insertions(+), 119 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index b119dc0..7b296da 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -1446,119 +1445,6 @@ static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code) } #endif -#define PSCI_SET_RESULT(reg, val) set_user_reg(reg, 0, val) -#define PSCI_ARG(reg,n) get_user_reg(reg, n) - -#ifdef CONFIG_ARM_64 -#define PSCI_ARG32(reg,n) (uint32_t)(get_user_reg(reg, n) & 0x00000000FFFFFFFF) -#else -#define PSCI_ARG32(reg,n) PSCI_ARG(reg,n) -#endif - -/* helper function for checking arm mode 32/64 bit */ -static inline int psci_mode_check(struct domain *d, register_t fid) -{ - return !( is_64bit_domain(d)^( (fid & PSCI_0_2_64BIT) >> 30 ) ); -} - -static void do_trap_psci(struct cpu_user_regs *regs) -{ - register_t fid = PSCI_ARG(regs,0); - - /* preloading in case psci_mode_check fails */ - PSCI_SET_RESULT(regs, PSCI_INVALID_PARAMETERS); - switch( fid ) - { - case PSCI_cpu_off: - { - uint32_t pstate = PSCI_ARG32(regs,1); - perfc_incr(vpsci_cpu_off); - PSCI_SET_RESULT(regs, do_psci_cpu_off(pstate)); - } - break; - case PSCI_cpu_on: - { - uint32_t vcpuid = PSCI_ARG32(regs,1); - register_t epoint = PSCI_ARG(regs,2); - perfc_incr(vpsci_cpu_on); - PSCI_SET_RESULT(regs, do_psci_cpu_on(vcpuid, epoint)); - } - break; - case PSCI_0_2_FN_PSCI_VERSION: - perfc_incr(vpsci_version); - PSCI_SET_RESULT(regs, do_psci_0_2_version()); - break; - case PSCI_0_2_FN_CPU_OFF: - perfc_incr(vpsci_cpu_off); - PSCI_SET_RESULT(regs, do_psci_0_2_cpu_off()); - break; - case PSCI_0_2_FN_MIGRATE_INFO_TYPE: - perfc_incr(vpsci_migrate_info_type); - PSCI_SET_RESULT(regs, do_psci_0_2_migrate_info_type()); - break; - case PSCI_0_2_FN_MIGRATE_INFO_UP_CPU: - case PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU: - perfc_incr(vpsci_migrate_info_up_cpu); - if ( psci_mode_check(current->domain, fid) ) - PSCI_SET_RESULT(regs, do_psci_0_2_migrate_info_up_cpu()); - break; - case PSCI_0_2_FN_SYSTEM_OFF: - perfc_incr(vpsci_system_off); - do_psci_0_2_system_off(); - PSCI_SET_RESULT(regs, PSCI_INTERNAL_FAILURE); - break; - case PSCI_0_2_FN_SYSTEM_RESET: - perfc_incr(vpsci_system_reset); - do_psci_0_2_system_reset(); - PSCI_SET_RESULT(regs, PSCI_INTERNAL_FAILURE); - break; - case PSCI_0_2_FN_CPU_ON: - case PSCI_0_2_FN64_CPU_ON: - perfc_incr(vpsci_cpu_on); - if ( psci_mode_check(current->domain, fid) ) - { - register_t vcpuid = PSCI_ARG(regs,1); - register_t epoint = PSCI_ARG(regs,2); - register_t cid = PSCI_ARG(regs,3); - PSCI_SET_RESULT(regs, do_psci_0_2_cpu_on(vcpuid, epoint, cid)); - } - break; - case PSCI_0_2_FN_CPU_SUSPEND: - case PSCI_0_2_FN64_CPU_SUSPEND: - perfc_incr(vpsci_cpu_suspend); - if ( psci_mode_check(current->domain, fid) ) - { - uint32_t pstate = PSCI_ARG32(regs,1); - register_t epoint = PSCI_ARG(regs,2); - register_t cid = PSCI_ARG(regs,3); - PSCI_SET_RESULT(regs, do_psci_0_2_cpu_suspend(pstate, epoint, cid)); - } - break; - case PSCI_0_2_FN_AFFINITY_INFO: - case PSCI_0_2_FN64_AFFINITY_INFO: - perfc_incr(vpsci_cpu_affinity_info); - if ( psci_mode_check(current->domain, fid) ) - { - register_t taff = PSCI_ARG(regs,1); - uint32_t laff = PSCI_ARG32(regs,2); - PSCI_SET_RESULT(regs, do_psci_0_2_affinity_info(taff, laff)); - } - break; - case PSCI_0_2_FN_MIGRATE: - case PSCI_0_2_FN64_MIGRATE: - perfc_incr(vpsci_cpu_migrate); - if ( psci_mode_check(current->domain, fid) ) - { - uint32_t tcpu = PSCI_ARG32(regs,1); - PSCI_SET_RESULT(regs, do_psci_0_2_migrate(tcpu)); - } - break; - default: - domain_crash_synchronous(); - return; - } -} - #ifdef CONFIG_ARM_64 #define HYPERCALL_RESULT_REG(r) (r)->x0 #define HYPERCALL_ARG1(r) (r)->x0 @@ -2865,8 +2751,9 @@ asmlinkage void do_trap_guest_sync(struct cpu_user_regs *regs) return do_debug_trap(regs, hsr.iss & 0x00ff); #endif if ( hsr.iss == 0 ) - return do_trap_psci(regs); - do_trap_hypercall(regs, (register_t *)®s->r12, hsr.iss); + do_trap_hvc_smccc(regs); + else + do_trap_hypercall(regs, (register_t *)®s->r12, hsr.iss); break; #ifdef CONFIG_ARM_64 case HSR_EC_HVC64: @@ -2877,8 +2764,9 @@ asmlinkage void do_trap_guest_sync(struct cpu_user_regs *regs) return do_debug_trap(regs, hsr.iss & 0x00ff); #endif if ( hsr.iss == 0 ) - return do_trap_psci(regs); - do_trap_hypercall(regs, ®s->x16, hsr.iss); + do_trap_hvc_smccc(regs); + else + do_trap_hypercall(regs, ®s->x16, hsr.iss); break; case HSR_EC_SMC64: /* diff --git a/xen/arch/arm/vsmc.c b/xen/arch/arm/vsmc.c index 5ef6167..718b30f 100644 --- a/xen/arch/arm/vsmc.c +++ b/xen/arch/arm/vsmc.c @@ -19,12 +19,16 @@ #include #include #include +#include #include #include /* Number of functions currently supported by Hypervisor Service. */ #define XEN_SMCCC_FUNCTION_COUNT 3 +/* Number of functions currently supported by Standard Service Service. */ +#define SSC_SMCCC_FUNCTION_COUNT 13 + /* SMCCC interface for hypervisor. Tell about itself. */ static bool handle_hypervisor(struct cpu_user_regs *regs) { @@ -47,6 +51,133 @@ static bool handle_hypervisor(struct cpu_user_regs *regs) return false; } +#define PSCI_SET_RESULT(reg, val) set_user_reg(reg, 0, val) +#define PSCI_ARG(reg,n) get_user_reg(reg, n) + +#ifdef CONFIG_ARM_64 +#define PSCI_ARG32(reg,n) (uint32_t)(get_user_reg(reg, n) & 0x00000000FFFFFFFF) +#else +#define PSCI_ARG32(reg,n) PSCI_ARG(reg,n) +#endif + +/* old (arvm7) PSCI interface */ +static bool handle_arch(struct cpu_user_regs *regs) +{ + switch ( get_user_reg(regs,0) & 0xFFFFFFFF ) + { + case PSCI_cpu_off: + { + uint32_t pstate = PSCI_ARG32(regs,1); + perfc_incr(vpsci_cpu_off); + PSCI_SET_RESULT(regs, do_psci_cpu_off(pstate)); + } + return true; + case PSCI_cpu_on: + { + uint32_t vcpuid = PSCI_ARG32(regs,1); + register_t epoint = PSCI_ARG(regs,2); + perfc_incr(vpsci_cpu_on); + PSCI_SET_RESULT(regs, do_psci_cpu_on(vcpuid, epoint)); + } + return true; + } + return false; +} + +/* helper function for checking arm mode 32/64 bit */ +static inline int psci_mode_check(struct domain *d, register_t fid) +{ + return !( is_64bit_domain(d)^( (fid & PSCI_0_2_64BIT) >> 30 ) ); +} + +/* PSCI 2.0 interface */ +static bool handle_ssc(struct cpu_user_regs *regs) +{ + register_t fid = PSCI_ARG(regs, 0); + + switch ( ARM_SMCCC_FUNC_NUM(fid) ) + { + case ARM_SMCCC_FUNC_NUM(PSCI_0_2_FN_PSCI_VERSION): + perfc_incr(vpsci_version); + PSCI_SET_RESULT(regs, do_psci_0_2_version()); + return true; + case ARM_SMCCC_FUNC_NUM(PSCI_0_2_FN_CPU_OFF): + perfc_incr(vpsci_cpu_off); + PSCI_SET_RESULT(regs, do_psci_0_2_cpu_off()); + return true; + case ARM_SMCCC_FUNC_NUM(PSCI_0_2_FN_MIGRATE_INFO_TYPE): + perfc_incr(vpsci_migrate_info_type); + PSCI_SET_RESULT(regs, do_psci_0_2_migrate_info_type()); + return true; + case ARM_SMCCC_FUNC_NUM(PSCI_0_2_FN_MIGRATE_INFO_UP_CPU): + perfc_incr(vpsci_migrate_info_up_cpu); + if ( psci_mode_check(current->domain, fid) ) + PSCI_SET_RESULT(regs, do_psci_0_2_migrate_info_up_cpu()); + return true; + case ARM_SMCCC_FUNC_NUM(PSCI_0_2_FN_SYSTEM_OFF): + perfc_incr(vpsci_system_off); + do_psci_0_2_system_off(); + PSCI_SET_RESULT(regs, PSCI_INTERNAL_FAILURE); + return true; + case ARM_SMCCC_FUNC_NUM(PSCI_0_2_FN_SYSTEM_RESET): + perfc_incr(vpsci_system_reset); + do_psci_0_2_system_reset(); + PSCI_SET_RESULT(regs, PSCI_INTERNAL_FAILURE); + return true; + case ARM_SMCCC_FUNC_NUM(PSCI_0_2_FN_CPU_ON): + perfc_incr(vpsci_cpu_on); + if ( psci_mode_check(current->domain, fid) ) + { + register_t vcpuid = PSCI_ARG(regs,1); + register_t epoint = PSCI_ARG(regs,2); + register_t cid = PSCI_ARG(regs,3); + PSCI_SET_RESULT(regs, do_psci_0_2_cpu_on(vcpuid, epoint, cid)); + } + return true; + case ARM_SMCCC_FUNC_NUM(PSCI_0_2_FN_CPU_SUSPEND): + perfc_incr(vpsci_cpu_suspend); + if ( psci_mode_check(current->domain, fid) ) + { + uint32_t pstate = PSCI_ARG32(regs,1); + register_t epoint = PSCI_ARG(regs,2); + register_t cid = PSCI_ARG(regs,3); + PSCI_SET_RESULT(regs, do_psci_0_2_cpu_suspend(pstate, epoint, cid)); + } + return true; + case ARM_SMCCC_FUNC_NUM(PSCI_0_2_FN_AFFINITY_INFO): + perfc_incr(vpsci_cpu_affinity_info); + if ( psci_mode_check(current->domain, fid) ) + { + register_t taff = PSCI_ARG(regs,1); + uint32_t laff = PSCI_ARG32(regs,2); + PSCI_SET_RESULT(regs, do_psci_0_2_affinity_info(taff, laff)); + } + return true; + case ARM_SMCCC_FUNC_NUM(PSCI_0_2_FN_MIGRATE): + perfc_incr(vpsci_cpu_migrate); + if ( psci_mode_check(current->domain, fid) ) + { + uint32_t tcpu = PSCI_ARG32(regs,1); + PSCI_SET_RESULT(regs, do_psci_0_2_migrate(tcpu)); + } + return true; + case ARM_SMCCC_FUNC_CALL_COUNT: + set_user_reg(regs, 0, SSC_SMCCC_FUNCTION_COUNT); + return true; + case ARM_SMCCC_FUNC_CALL_UID: + set_user_reg(regs, 0, SSC_SMCCC_UID.a[0]); + set_user_reg(regs, 1, SSC_SMCCC_UID.a[1]); + set_user_reg(regs, 2, SSC_SMCCC_UID.a[2]); + set_user_reg(regs, 3, SSC_SMCCC_UID.a[3]); + return true; + case ARM_SMCCC_FUNC_CALL_REVISION: + set_user_reg(regs, 0, SSC_SMCCC_MAJOR_REVISION); + set_user_reg(regs, 1, SSC_SMCCC_MINOR_REVISION); + return true; + } + return false; +} + /* * vsmc_handle_call() - handle SMC/HVC call according to ARM SMCCC. * returns true if that was valid SMCCC call (even if function number @@ -91,6 +222,12 @@ static bool vsmc_handle_call(struct cpu_user_regs *regs) case ARM_SMCCC_OWNER_HYPERVISOR: handled = handle_hypervisor(regs); break; + case ARM_SMCCC_OWNER_ARCH: + handled = handle_arch(regs); + break; + case ARM_SMCCC_OWNER_STANDARD: + handled = handle_ssc(regs); + break; } if ( !handled ) @@ -129,6 +266,13 @@ void do_trap_smc(struct cpu_user_regs *regs, const union hsr hsr) inject_undef_exception(regs, hsr); } +/* This function will be called from traps.c */ +void do_trap_hvc_smccc(struct cpu_user_regs *regs) +{ + if ( !vsmc_handle_call(regs) ) + domain_crash_synchronous(); +} + /* * Local variables: * mode: C diff --git a/xen/include/asm-arm/vsmc.h b/xen/include/asm-arm/vsmc.h index 7baabef..d1e7b01 100644 --- a/xen/include/asm-arm/vsmc.h +++ b/xen/include/asm-arm/vsmc.h @@ -81,6 +81,7 @@ #define ARM_SMCCC_ERR_UNKNOWN_FUNCTION (-1) void do_trap_smc(struct cpu_user_regs *regs, const union hsr hsr); +void do_trap_hvc_smccc(struct cpu_user_regs *regs); #endif /* __ASM_ARM_VSMC_H__ */ diff --git a/xen/include/public/arch-arm/smc.h b/xen/include/public/arch-arm/smc.h index 42f3165..11b5ef7 100644 --- a/xen/include/public/arch-arm/smc.h +++ b/xen/include/public/arch-arm/smc.h @@ -56,8 +56,16 @@ typedef struct { 0x9a, 0xcf, 0x79, 0xd1, \ 0x8d, 0xde, 0xe6, 0x67) -#endif /* __XEN_PUBLIC_ARCH_ARM_SMC_H__ */ +/* Standard Service version. Check comment for Hypervisor Service for rules. */ +#define SSC_SMCCC_MAJOR_REVISION 0 +#define SSC_SMCCC_MINOR_REVISION 1 + +/* Standard Service Call UID. Randomly generated with 3rd party tool. */ +#define SSC_SMCCC_UID XEN_ARM_SMCCC_UID(0xf863386f, 0x4b39, 0x4cbd, \ + 0x92, 0x20, 0xce, 0x16, \ + 0x41, 0xe5, 0x9f, 0x6f) +#endif /* __XEN_PUBLIC_ARCH_ARM_SMC_H__ */ /* * Local variables: * mode: C