/******************************************************************************1* hypercall.S2*3* Xen hypercall wrappers4*5* Stefano Stabellini <[email protected]>, Citrix, 20126*7* This program is free software; you can redistribute it and/or8* modify it under the terms of the GNU General Public License version 29* as published by the Free Software Foundation; or, when distributed10* separately from the Linux kernel or incorporated into other11* software packages, subject to the following license:12*13* Permission is hereby granted, free of charge, to any person obtaining a copy14* of this source file (the "Software"), to deal in the Software without15* restriction, including without limitation the rights to use, copy, modify,16* merge, publish, distribute, sublicense, and/or sell copies of the Software,17* and to permit persons to whom the Software is furnished to do so, subject to18* the following conditions:19*20* The above copyright notice and this permission notice shall be included in21* all copies or substantial portions of the Software.22*23* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR24* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,25* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE26* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER27* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING28* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS29* IN THE SOFTWARE.30*/3132/*33* The Xen hypercall calling convention is very similar to the procedure34* call standard for the ARM 64-bit architecture: the first parameter is35* passed in x0, the second in x1, the third in x2, the fourth in x3 and36* the fifth in x4.37*38* The hypercall number is passed in x16.39*40* The return value is in x0.41*42* The hvc ISS is required to be 0xEA1, that is the Xen specific ARM43* hypercall tag.44*45* Parameter structs passed to hypercalls are laid out according to46* the ARM 64-bit EABI standard.47*/4849#include <linux/linkage.h>50#include <asm/assembler.h>51#include <asm/asm-uaccess.h>52#include <xen/interface/xen.h>535455#define XEN_IMM 0xEA15657#define HYPERCALL_SIMPLE(hypercall) \58SYM_FUNC_START(HYPERVISOR_##hypercall) \59mov x16, #__HYPERVISOR_##hypercall; \60hvc XEN_IMM; \61ret; \62SYM_FUNC_END(HYPERVISOR_##hypercall)6364#define HYPERCALL0 HYPERCALL_SIMPLE65#define HYPERCALL1 HYPERCALL_SIMPLE66#define HYPERCALL2 HYPERCALL_SIMPLE67#define HYPERCALL3 HYPERCALL_SIMPLE68#define HYPERCALL4 HYPERCALL_SIMPLE69#define HYPERCALL5 HYPERCALL_SIMPLE7071.text7273HYPERCALL2(xen_version);74HYPERCALL3(console_io);75HYPERCALL3(grant_table_op);76HYPERCALL2(sched_op);77HYPERCALL2(event_channel_op);78HYPERCALL2(hvm_op);79HYPERCALL2(memory_op);80HYPERCALL2(physdev_op);81HYPERCALL3(vcpu_op);82HYPERCALL1(platform_op_raw);83HYPERCALL2(multicall);84HYPERCALL2(vm_assist);8586SYM_FUNC_START(HYPERVISOR_dm_op)87mov x16, #__HYPERVISOR_dm_op; \88/*89* dm_op hypercalls are issued by the userspace. The kernel needs to90* enable access to TTBR0_EL1 as the hypervisor would issue stage 191* translations to user memory via AT instructions. Since AT92* instructions are not affected by the PAN bit (ARMv8.1), we only93* need the explicit uaccess_enable/disable if the TTBR0 PAN emulation94* is enabled (it implies that hardware UAO and PAN disabled).95*/96uaccess_ttbr0_enable x6, x7, x897hvc XEN_IMM9899/*100* Disable userspace access from kernel once the hyp call completed.101*/102uaccess_ttbr0_disable x6, x7103ret104SYM_FUNC_END(HYPERVISOR_dm_op);105106SYM_FUNC_START(privcmd_call)107mov x16, x0108mov x0, x1109mov x1, x2110mov x2, x3111mov x3, x4112mov x4, x5113/*114* Privcmd calls are issued by the userspace. The kernel needs to115* enable access to TTBR0_EL1 as the hypervisor would issue stage 1116* translations to user memory via AT instructions. Since AT117* instructions are not affected by the PAN bit (ARMv8.1), we only118* need the explicit uaccess_enable/disable if the TTBR0 PAN emulation119* is enabled (it implies that hardware UAO and PAN disabled).120*/121uaccess_ttbr0_enable x6, x7, x8122hvc XEN_IMM123124/*125* Disable userspace access from kernel once the hyp call completed.126*/127uaccess_ttbr0_disable x6, x7128ret129SYM_FUNC_END(privcmd_call);130131132