Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 - Virtual Open Systems and Columbia University |
| 3 | * Author: Christoffer Dall <c.dall@virtualopensystems.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, write to the Free Software |
| 16 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | */ |
| 18 | |
| 19 | #ifndef __ARM_KVM_ASM_H__ |
| 20 | #define __ARM_KVM_ASM_H__ |
| 21 | |
Marc Zyngier | 1a61ae7 | 2016-01-02 13:57:18 +0000 | [diff] [blame] | 22 | #include <asm/virt.h> |
| 23 | |
Marc Zyngier | 435bca5 | 2016-09-06 14:02:11 +0100 | [diff] [blame] | 24 | #define ARM_EXIT_WITH_ABORT_BIT 31 |
| 25 | #define ARM_EXCEPTION_CODE(x) ((x) & ~(1U << ARM_EXIT_WITH_ABORT_BIT)) |
| 26 | #define ARM_ABORT_PENDING(x) !!((x) & (1U << ARM_EXIT_WITH_ABORT_BIT)) |
| 27 | |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 28 | #define ARM_EXCEPTION_RESET 0 |
| 29 | #define ARM_EXCEPTION_UNDEFINED 1 |
| 30 | #define ARM_EXCEPTION_SOFTWARE 2 |
| 31 | #define ARM_EXCEPTION_PREF_ABORT 3 |
| 32 | #define ARM_EXCEPTION_DATA_ABORT 4 |
| 33 | #define ARM_EXCEPTION_IRQ 5 |
| 34 | #define ARM_EXCEPTION_FIQ 6 |
Christoffer Dall | 342cd0a | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 35 | #define ARM_EXCEPTION_HVC 7 |
| 36 | |
Victor Kamensky | 19b0e60 | 2014-06-12 09:30:02 -0700 | [diff] [blame] | 37 | /* |
| 38 | * The rr_lo_hi macro swaps a pair of registers depending on |
| 39 | * current endianness. It is used in conjunction with ldrd and strd |
| 40 | * instructions that load/store a 64-bit value from/to memory to/from |
| 41 | * a pair of registers which are used with the mrrc and mcrr instructions. |
| 42 | * If used with the ldrd/strd instructions, the a1 parameter is the first |
| 43 | * source/destination register and the a2 parameter is the second |
| 44 | * source/destination register. Note that the ldrd/strd instructions |
| 45 | * already swap the bytes within the words correctly according to the |
| 46 | * endianness setting, but the order of the registers need to be effectively |
| 47 | * swapped when used with the mrrc/mcrr instructions. |
| 48 | */ |
| 49 | #ifdef CONFIG_CPU_ENDIAN_BE8 |
| 50 | #define rr_lo_hi(a1, a2) a2, a1 |
| 51 | #else |
| 52 | #define rr_lo_hi(a1, a2) a1, a2 |
| 53 | #endif |
| 54 | |
Ard Biesheuvel | a0bf977 | 2016-02-16 13:52:39 +0100 | [diff] [blame] | 55 | #define kvm_ksym_ref(kva) (kva) |
| 56 | |
Christoffer Dall | 342cd0a | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 57 | #ifndef __ASSEMBLY__ |
Christoffer Dall | d5d8184 | 2013-01-20 18:28:07 -0500 | [diff] [blame] | 58 | struct kvm; |
Christoffer Dall | 342cd0a | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 59 | struct kvm_vcpu; |
| 60 | |
| 61 | extern char __kvm_hyp_init[]; |
| 62 | extern char __kvm_hyp_init_end[]; |
| 63 | |
Christoffer Dall | 342cd0a | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 64 | extern char __kvm_hyp_vector[]; |
| 65 | |
Christoffer Dall | 342cd0a | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 66 | extern void __kvm_flush_vm_context(void); |
Marc Zyngier | 4876276 | 2013-01-28 15:27:00 +0000 | [diff] [blame] | 67 | extern void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa); |
Mario Smarduch | 72fc36b | 2015-01-15 15:58:55 -0800 | [diff] [blame] | 68 | extern void __kvm_tlb_flush_vmid(struct kvm *kvm); |
Marc Zyngier | 94d0e59 | 2016-10-18 18:37:49 +0100 | [diff] [blame] | 69 | extern void __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu); |
Christoffer Dall | 342cd0a | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 70 | |
| 71 | extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu); |
Marc Zyngier | d4c7688 | 2016-02-01 19:56:31 +0000 | [diff] [blame] | 72 | |
| 73 | extern void __init_stage2_translation(void); |
Marc Zyngier | e537ecd | 2016-06-30 18:40:48 +0100 | [diff] [blame] | 74 | |
| 75 | extern void __kvm_hyp_reset(unsigned long); |
Vladimir Murzin | acda543 | 2016-09-12 15:49:24 +0100 | [diff] [blame] | 76 | |
| 77 | extern u64 __vgic_v3_get_ich_vtr_el2(void); |
| 78 | extern void __vgic_v3_init_lrs(void); |
Christoffer Dall | 342cd0a | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 79 | #endif |
Christoffer Dall | 749cf76c | 2013-01-20 18:28:06 -0500 | [diff] [blame] | 80 | |
| 81 | #endif /* __ARM_KVM_ASM_H__ */ |