blob: fa2fd253974f899641a2de14d079b6d833460ab9 [file] [log] [blame]
Christoffer Dall749cf76c2013-01-20 18:28:06 -05001/*
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 Zyngier1a61ae72016-01-02 13:57:18 +000022#include <asm/virt.h>
23
Christoffer Dall749cf76c2013-01-20 18:28:06 -050024/* 0 is reserved as an invalid value. */
25#define c0_MPIDR 1 /* MultiProcessor ID Register */
26#define c0_CSSELR 2 /* Cache Size Selection Register */
27#define c1_SCTLR 3 /* System Control Register */
Geert Uytterhoeven47b2d142015-03-03 11:58:06 +010028#define c1_ACTLR 4 /* Auxiliary Control Register */
Christoffer Dall749cf76c2013-01-20 18:28:06 -050029#define c1_CPACR 5 /* Coprocessor Access Control */
30#define c2_TTBR0 6 /* Translation Table Base Register 0 */
31#define c2_TTBR0_high 7 /* TTBR0 top 32 bits */
32#define c2_TTBR1 8 /* Translation Table Base Register 1 */
33#define c2_TTBR1_high 9 /* TTBR1 top 32 bits */
34#define c2_TTBCR 10 /* Translation Table Base Control R. */
35#define c3_DACR 11 /* Domain Access Control Register */
36#define c5_DFSR 12 /* Data Fault Status Register */
37#define c5_IFSR 13 /* Instruction Fault Status Register */
38#define c5_ADFSR 14 /* Auxilary Data Fault Status R */
39#define c5_AIFSR 15 /* Auxilary Instrunction Fault Status R */
40#define c6_DFAR 16 /* Data Fault Address Register */
41#define c6_IFAR 17 /* Instruction Fault Address Register */
Marc Zyngier6a077e42013-06-21 13:08:46 +010042#define c7_PAR 18 /* Physical Address Register */
43#define c7_PAR_high 19 /* PAR top 32 bits */
Jonathan Austine8c2d992013-09-26 16:49:28 +010044#define c9_L2CTLR 20 /* Cortex A15/A7 L2 Control Register */
Marc Zyngier6a077e42013-06-21 13:08:46 +010045#define c10_PRRR 21 /* Primary Region Remap Register */
46#define c10_NMRR 22 /* Normal Memory Remap Register */
47#define c12_VBAR 23 /* Vector Base Address Register */
48#define c13_CID 24 /* Context ID Register */
49#define c13_TID_URW 25 /* Thread ID, User R/W */
50#define c13_TID_URO 26 /* Thread ID, User R/O */
51#define c13_TID_PRIV 27 /* Thread ID, Privileged */
52#define c14_CNTKCTL 28 /* Timer Control Register (PL1) */
Marc Zyngieraf208142014-01-22 10:20:09 +000053#define c10_AMAIR0 29 /* Auxilary Memory Attribute Indirection Reg0 */
54#define c10_AMAIR1 30 /* Auxilary Memory Attribute Indirection Reg1 */
55#define NR_CP15_REGS 31 /* Number of regs (incl. invalid) */
Christoffer Dall749cf76c2013-01-20 18:28:06 -050056
57#define ARM_EXCEPTION_RESET 0
58#define ARM_EXCEPTION_UNDEFINED 1
59#define ARM_EXCEPTION_SOFTWARE 2
60#define ARM_EXCEPTION_PREF_ABORT 3
61#define ARM_EXCEPTION_DATA_ABORT 4
62#define ARM_EXCEPTION_IRQ 5
63#define ARM_EXCEPTION_FIQ 6
Christoffer Dall342cd0a2013-01-20 18:28:06 -050064#define ARM_EXCEPTION_HVC 7
65
Victor Kamensky19b0e602014-06-12 09:30:02 -070066/*
67 * The rr_lo_hi macro swaps a pair of registers depending on
68 * current endianness. It is used in conjunction with ldrd and strd
69 * instructions that load/store a 64-bit value from/to memory to/from
70 * a pair of registers which are used with the mrrc and mcrr instructions.
71 * If used with the ldrd/strd instructions, the a1 parameter is the first
72 * source/destination register and the a2 parameter is the second
73 * source/destination register. Note that the ldrd/strd instructions
74 * already swap the bytes within the words correctly according to the
75 * endianness setting, but the order of the registers need to be effectively
76 * swapped when used with the mrrc/mcrr instructions.
77 */
78#ifdef CONFIG_CPU_ENDIAN_BE8
79#define rr_lo_hi(a1, a2) a2, a1
80#else
81#define rr_lo_hi(a1, a2) a1, a2
82#endif
83
Christoffer Dall342cd0a2013-01-20 18:28:06 -050084#ifndef __ASSEMBLY__
Christoffer Dalld5d81842013-01-20 18:28:07 -050085struct kvm;
Christoffer Dall342cd0a2013-01-20 18:28:06 -050086struct kvm_vcpu;
87
88extern char __kvm_hyp_init[];
89extern char __kvm_hyp_init_end[];
90
91extern char __kvm_hyp_exit[];
92extern char __kvm_hyp_exit_end[];
93
94extern char __kvm_hyp_vector[];
95
Marc Zyngier1a61ae72016-01-02 13:57:18 +000096#define __kvm_hyp_code_start __hyp_text_start
97#define __kvm_hyp_code_end __hyp_text_end
Christoffer Dall342cd0a2013-01-20 18:28:06 -050098
99extern void __kvm_flush_vm_context(void);
Marc Zyngier48762762013-01-28 15:27:00 +0000100extern void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa);
Mario Smarduch72fc36b2015-01-15 15:58:55 -0800101extern void __kvm_tlb_flush_vmid(struct kvm *kvm);
Christoffer Dall342cd0a2013-01-20 18:28:06 -0500102
103extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu);
104#endif
Christoffer Dall749cf76c2013-01-20 18:28:06 -0500105
106#endif /* __ARM_KVM_ASM_H__ */