hyp.S 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #include <linux/linkage.h>
  18. #include <asm/alternative.h>
  19. #include <asm/assembler.h>
  20. #include <asm/cpufeature.h>
  21. /*
  22. * u64 __kvm_call_hyp(void *hypfn, ...);
  23. *
  24. * This is not really a variadic function in the classic C-way and care must
  25. * be taken when calling this to ensure parameters are passed in registers
  26. * only, since the stack will change between the caller and the callee.
  27. *
  28. * Call the function with the first argument containing a pointer to the
  29. * function you wish to call in Hyp mode, and subsequent arguments will be
  30. * passed as x0, x1, and x2 (a maximum of 3 arguments in addition to the
  31. * function pointer can be passed). The function being called must be mapped
  32. * in Hyp mode (see init_hyp_mode in arch/arm/kvm/arm.c). Return values are
  33. * passed in x0.
  34. *
  35. * A function pointer with a value less than 0xfff has a special meaning,
  36. * and is used to implement __hyp_get_vectors in the same way as in
  37. * arch/arm64/kernel/hyp_stub.S.
  38. * HVC behaves as a 'bl' call and will clobber lr.
  39. */
  40. ENTRY(__kvm_call_hyp)
  41. alternative_if_not ARM64_HAS_VIRT_HOST_EXTN
  42. str lr, [sp, #-16]!
  43. hvc #0
  44. ldr lr, [sp], #16
  45. ret
  46. alternative_else_nop_endif
  47. b __vhe_hyp_call
  48. ENDPROC(__kvm_call_hyp)