Marc Zyngier | 55c7401 | 2012-12-10 16:40:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012,2013 - ARM Ltd |
| 3 | * Author: Marc Zyngier <marc.zyngier@arm.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #include <linux/linkage.h> |
Marc Zyngier | 55c7401 | 2012-12-10 16:40:18 +0000 | [diff] [blame] | 19 | |
Marc Zyngier | b81125c | 2015-01-29 13:52:12 +0000 | [diff] [blame] | 20 | #include <asm/alternative.h> |
Mark Rutland | c6d01a9 | 2014-11-24 13:59:30 +0000 | [diff] [blame] | 21 | #include <asm/assembler.h> |
Marc Zyngier | b81125c | 2015-01-29 13:52:12 +0000 | [diff] [blame] | 22 | #include <asm/cpufeature.h> |
Marc Zyngier | 55c7401 | 2012-12-10 16:40:18 +0000 | [diff] [blame] | 23 | |
Marc Zyngier | b20c9f2 | 2014-02-26 18:47:36 +0000 | [diff] [blame] | 24 | /* |
Ard Biesheuvel | a0bf977 | 2016-02-16 13:52:39 +0100 | [diff] [blame] | 25 | * u64 __kvm_call_hyp(void *hypfn, ...); |
Marc Zyngier | b20c9f2 | 2014-02-26 18:47:36 +0000 | [diff] [blame] | 26 | * |
| 27 | * This is not really a variadic function in the classic C-way and care must |
| 28 | * be taken when calling this to ensure parameters are passed in registers |
| 29 | * only, since the stack will change between the caller and the callee. |
| 30 | * |
| 31 | * Call the function with the first argument containing a pointer to the |
| 32 | * function you wish to call in Hyp mode, and subsequent arguments will be |
| 33 | * passed as x0, x1, and x2 (a maximum of 3 arguments in addition to the |
| 34 | * function pointer can be passed). The function being called must be mapped |
| 35 | * in Hyp mode (see init_hyp_mode in arch/arm/kvm/arm.c). Return values are |
Marc Zyngier | 1ea66d2 | 2015-10-25 15:51:41 +0000 | [diff] [blame] | 36 | * passed in x0. |
Marc Zyngier | b20c9f2 | 2014-02-26 18:47:36 +0000 | [diff] [blame] | 37 | * |
Geoff Levand | ad72e59 | 2016-04-27 17:47:03 +0100 | [diff] [blame] | 38 | * A function pointer with a value less than 0xfff has a special meaning, |
Marc Zyngier | 0b51c54 | 2017-04-03 19:38:04 +0100 | [diff] [blame] | 39 | * and is used to implement hyp stubs in the same way as in |
Marc Zyngier | b20c9f2 | 2014-02-26 18:47:36 +0000 | [diff] [blame] | 40 | * arch/arm64/kernel/hyp_stub.S. |
| 41 | */ |
Ard Biesheuvel | a0bf977 | 2016-02-16 13:52:39 +0100 | [diff] [blame] | 42 | ENTRY(__kvm_call_hyp) |
James Morse | 00a44cd | 2016-04-27 17:47:02 +0100 | [diff] [blame] | 43 | alternative_if_not ARM64_HAS_VIRT_HOST_EXTN |
Marc Zyngier | 55c7401 | 2012-12-10 16:40:18 +0000 | [diff] [blame] | 44 | hvc #0 |
| 45 | ret |
Mark Rutland | e506236 | 2016-09-07 11:07:10 +0100 | [diff] [blame] | 46 | alternative_else_nop_endif |
Marc Zyngier | b81125c | 2015-01-29 13:52:12 +0000 | [diff] [blame] | 47 | b __vhe_hyp_call |
Ard Biesheuvel | a0bf977 | 2016-02-16 13:52:39 +0100 | [diff] [blame] | 48 | ENDPROC(__kvm_call_hyp) |