diff options
author | Olof Johansson <olof@lixom.net> | 2013-02-11 12:02:53 -0500 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2013-02-11 12:02:53 -0500 |
commit | 655e194cfee8ba89634228f97f1310df41b45cbb (patch) | |
tree | 85989f9f14ad53a3797ab5c70093a8181399e669 /arch/arm/include/asm | |
parent | 1e044f0490c9d9f26ebcdd3dc63e02790b798821 (diff) | |
parent | da141b67d29a05267a9a0d56bd7856b7f3f58d44 (diff) |
Merge branch 'for-rmk/virt/kvm/core' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux into next/virt
* 'for-rmk/virt/kvm/core' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux:
KVM: ARM: Add maintainer entry for KVM/ARM
KVM: ARM: Power State Coordination Interface implementation
KVM: ARM: Handle I/O aborts
KVM: ARM: Handle guest faults in KVM
KVM: ARM: VFP userspace interface
KVM: ARM: Demux CCSIDR in the userspace API
KVM: ARM: User space API for getting/setting co-proc registers
KVM: ARM: Emulation framework and CP15 emulation
KVM: ARM: World-switch implementation
KVM: ARM: Inject IRQs and FIQs from userspace
KVM: ARM: Memory virtualization setup
KVM: ARM: Hypervisor initialization
KVM: ARM: Initial skeleton to compile KVM support
ARM: Section based HYP idmap
ARM: Add page table and page defines needed by KVM
Diffstat (limited to 'arch/arm/include/asm')
-rw-r--r-- | arch/arm/include/asm/idmap.h | 1 | ||||
-rw-r--r-- | arch/arm/include/asm/kvm_arm.h | 214 | ||||
-rw-r--r-- | arch/arm/include/asm/kvm_asm.h | 82 | ||||
-rw-r--r-- | arch/arm/include/asm/kvm_coproc.h | 47 | ||||
-rw-r--r-- | arch/arm/include/asm/kvm_emulate.h | 72 | ||||
-rw-r--r-- | arch/arm/include/asm/kvm_host.h | 161 | ||||
-rw-r--r-- | arch/arm/include/asm/kvm_mmio.h | 56 | ||||
-rw-r--r-- | arch/arm/include/asm/kvm_mmu.h | 50 | ||||
-rw-r--r-- | arch/arm/include/asm/kvm_psci.h | 23 | ||||
-rw-r--r-- | arch/arm/include/asm/pgtable-3level-hwdef.h | 5 | ||||
-rw-r--r-- | arch/arm/include/asm/pgtable-3level.h | 18 | ||||
-rw-r--r-- | arch/arm/include/asm/pgtable.h | 7 |
12 files changed, 736 insertions, 0 deletions
diff --git a/arch/arm/include/asm/idmap.h b/arch/arm/include/asm/idmap.h index bf863edb517d..1a66f907e5cc 100644 --- a/arch/arm/include/asm/idmap.h +++ b/arch/arm/include/asm/idmap.h | |||
@@ -8,6 +8,7 @@ | |||
8 | #define __idmap __section(.idmap.text) noinline notrace | 8 | #define __idmap __section(.idmap.text) noinline notrace |
9 | 9 | ||
10 | extern pgd_t *idmap_pgd; | 10 | extern pgd_t *idmap_pgd; |
11 | extern pgd_t *hyp_pgd; | ||
11 | 12 | ||
12 | void setup_mm_for_reboot(void); | 13 | void setup_mm_for_reboot(void); |
13 | 14 | ||
diff --git a/arch/arm/include/asm/kvm_arm.h b/arch/arm/include/asm/kvm_arm.h new file mode 100644 index 000000000000..7c3d813e15df --- /dev/null +++ b/arch/arm/include/asm/kvm_arm.h | |||
@@ -0,0 +1,214 @@ | |||
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_ARM_H__ | ||
20 | #define __ARM_KVM_ARM_H__ | ||
21 | |||
22 | #include <linux/types.h> | ||
23 | |||
24 | /* Hyp Configuration Register (HCR) bits */ | ||
25 | #define HCR_TGE (1 << 27) | ||
26 | #define HCR_TVM (1 << 26) | ||
27 | #define HCR_TTLB (1 << 25) | ||
28 | #define HCR_TPU (1 << 24) | ||
29 | #define HCR_TPC (1 << 23) | ||
30 | #define HCR_TSW (1 << 22) | ||
31 | #define HCR_TAC (1 << 21) | ||
32 | #define HCR_TIDCP (1 << 20) | ||
33 | #define HCR_TSC (1 << 19) | ||
34 | #define HCR_TID3 (1 << 18) | ||
35 | #define HCR_TID2 (1 << 17) | ||
36 | #define HCR_TID1 (1 << 16) | ||
37 | #define HCR_TID0 (1 << 15) | ||
38 | #define HCR_TWE (1 << 14) | ||
39 | #define HCR_TWI (1 << 13) | ||
40 | #define HCR_DC (1 << 12) | ||
41 | #define HCR_BSU (3 << 10) | ||
42 | #define HCR_BSU_IS (1 << 10) | ||
43 | #define HCR_FB (1 << 9) | ||
44 | #define HCR_VA (1 << 8) | ||
45 | #define HCR_VI (1 << 7) | ||
46 | #define HCR_VF (1 << 6) | ||
47 | #define HCR_AMO (1 << 5) | ||
48 | #define HCR_IMO (1 << 4) | ||
49 | #define HCR_FMO (1 << 3) | ||
50 | #define HCR_PTW (1 << 2) | ||
51 | #define HCR_SWIO (1 << 1) | ||
52 | #define HCR_VM 1 | ||
53 | |||
54 | /* | ||
55 | * The bits we set in HCR: | ||
56 | * TAC: Trap ACTLR | ||
57 | * TSC: Trap SMC | ||
58 | * TSW: Trap cache operations by set/way | ||
59 | * TWI: Trap WFI | ||
60 | * TIDCP: Trap L2CTLR/L2ECTLR | ||
61 | * BSU_IS: Upgrade barriers to the inner shareable domain | ||
62 | * FB: Force broadcast of all maintainance operations | ||
63 | * AMO: Override CPSR.A and enable signaling with VA | ||
64 | * IMO: Override CPSR.I and enable signaling with VI | ||
65 | * FMO: Override CPSR.F and enable signaling with VF | ||
66 | * SWIO: Turn set/way invalidates into set/way clean+invalidate | ||
67 | */ | ||
68 | #define HCR_GUEST_MASK (HCR_TSC | HCR_TSW | HCR_TWI | HCR_VM | HCR_BSU_IS | \ | ||
69 | HCR_FB | HCR_TAC | HCR_AMO | HCR_IMO | HCR_FMO | \ | ||
70 | HCR_SWIO | HCR_TIDCP) | ||
71 | #define HCR_VIRT_EXCP_MASK (HCR_VA | HCR_VI | HCR_VF) | ||
72 | |||
73 | /* System Control Register (SCTLR) bits */ | ||
74 | #define SCTLR_TE (1 << 30) | ||
75 | #define SCTLR_EE (1 << 25) | ||
76 | #define SCTLR_V (1 << 13) | ||
77 | |||
78 | /* Hyp System Control Register (HSCTLR) bits */ | ||
79 | #define HSCTLR_TE (1 << 30) | ||
80 | #define HSCTLR_EE (1 << 25) | ||
81 | #define HSCTLR_FI (1 << 21) | ||
82 | #define HSCTLR_WXN (1 << 19) | ||
83 | #define HSCTLR_I (1 << 12) | ||
84 | #define HSCTLR_C (1 << 2) | ||
85 | #define HSCTLR_A (1 << 1) | ||
86 | #define HSCTLR_M 1 | ||
87 | #define HSCTLR_MASK (HSCTLR_M | HSCTLR_A | HSCTLR_C | HSCTLR_I | \ | ||
88 | HSCTLR_WXN | HSCTLR_FI | HSCTLR_EE | HSCTLR_TE) | ||
89 | |||
90 | /* TTBCR and HTCR Registers bits */ | ||
91 | #define TTBCR_EAE (1 << 31) | ||
92 | #define TTBCR_IMP (1 << 30) | ||
93 | #define TTBCR_SH1 (3 << 28) | ||
94 | #define TTBCR_ORGN1 (3 << 26) | ||
95 | #define TTBCR_IRGN1 (3 << 24) | ||
96 | #define TTBCR_EPD1 (1 << 23) | ||
97 | #define TTBCR_A1 (1 << 22) | ||
98 | #define TTBCR_T1SZ (3 << 16) | ||
99 | #define TTBCR_SH0 (3 << 12) | ||
100 | #define TTBCR_ORGN0 (3 << 10) | ||
101 | #define TTBCR_IRGN0 (3 << 8) | ||
102 | #define TTBCR_EPD0 (1 << 7) | ||
103 | #define TTBCR_T0SZ 3 | ||
104 | #define HTCR_MASK (TTBCR_T0SZ | TTBCR_IRGN0 | TTBCR_ORGN0 | TTBCR_SH0) | ||
105 | |||
106 | /* Hyp System Trap Register */ | ||
107 | #define HSTR_T(x) (1 << x) | ||
108 | #define HSTR_TTEE (1 << 16) | ||
109 | #define HSTR_TJDBX (1 << 17) | ||
110 | |||
111 | /* Hyp Coprocessor Trap Register */ | ||
112 | #define HCPTR_TCP(x) (1 << x) | ||
113 | #define HCPTR_TCP_MASK (0x3fff) | ||
114 | #define HCPTR_TASE (1 << 15) | ||
115 | #define HCPTR_TTA (1 << 20) | ||
116 | #define HCPTR_TCPAC (1 << 31) | ||
117 | |||
118 | /* Hyp Debug Configuration Register bits */ | ||
119 | #define HDCR_TDRA (1 << 11) | ||
120 | #define HDCR_TDOSA (1 << 10) | ||
121 | #define HDCR_TDA (1 << 9) | ||
122 | #define HDCR_TDE (1 << 8) | ||
123 | #define HDCR_HPME (1 << 7) | ||
124 | #define HDCR_TPM (1 << 6) | ||
125 | #define HDCR_TPMCR (1 << 5) | ||
126 | #define HDCR_HPMN_MASK (0x1F) | ||
127 | |||
128 | /* | ||
129 | * The architecture supports 40-bit IPA as input to the 2nd stage translations | ||
130 | * and PTRS_PER_S2_PGD becomes 1024, because each entry covers 1GB of address | ||
131 | * space. | ||
132 | */ | ||
133 | #define KVM_PHYS_SHIFT (40) | ||
134 | #define KVM_PHYS_SIZE (1ULL << KVM_PHYS_SHIFT) | ||
135 | #define KVM_PHYS_MASK (KVM_PHYS_SIZE - 1ULL) | ||
136 | #define PTRS_PER_S2_PGD (1ULL << (KVM_PHYS_SHIFT - 30)) | ||
137 | #define S2_PGD_ORDER get_order(PTRS_PER_S2_PGD * sizeof(pgd_t)) | ||
138 | #define S2_PGD_SIZE (1 << S2_PGD_ORDER) | ||
139 | |||
140 | /* Virtualization Translation Control Register (VTCR) bits */ | ||
141 | #define VTCR_SH0 (3 << 12) | ||
142 | #define VTCR_ORGN0 (3 << 10) | ||
143 | #define VTCR_IRGN0 (3 << 8) | ||
144 | #define VTCR_SL0 (3 << 6) | ||
145 | #define VTCR_S (1 << 4) | ||
146 | #define VTCR_T0SZ (0xf) | ||
147 | #define VTCR_MASK (VTCR_SH0 | VTCR_ORGN0 | VTCR_IRGN0 | VTCR_SL0 | \ | ||
148 | VTCR_S | VTCR_T0SZ) | ||
149 | #define VTCR_HTCR_SH (VTCR_SH0 | VTCR_ORGN0 | VTCR_IRGN0) | ||
150 | #define VTCR_SL_L2 (0 << 6) /* Starting-level: 2 */ | ||
151 | #define VTCR_SL_L1 (1 << 6) /* Starting-level: 1 */ | ||
152 | #define KVM_VTCR_SL0 VTCR_SL_L1 | ||
153 | /* stage-2 input address range defined as 2^(32-T0SZ) */ | ||
154 | #define KVM_T0SZ (32 - KVM_PHYS_SHIFT) | ||
155 | #define KVM_VTCR_T0SZ (KVM_T0SZ & VTCR_T0SZ) | ||
156 | #define KVM_VTCR_S ((KVM_VTCR_T0SZ << 1) & VTCR_S) | ||
157 | |||
158 | /* Virtualization Translation Table Base Register (VTTBR) bits */ | ||
159 | #if KVM_VTCR_SL0 == VTCR_SL_L2 /* see ARM DDI 0406C: B4-1720 */ | ||
160 | #define VTTBR_X (14 - KVM_T0SZ) | ||
161 | #else | ||
162 | #define VTTBR_X (5 - KVM_T0SZ) | ||
163 | #endif | ||
164 | #define VTTBR_BADDR_SHIFT (VTTBR_X - 1) | ||
165 | #define VTTBR_BADDR_MASK (((1LLU << (40 - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT) | ||
166 | #define VTTBR_VMID_SHIFT (48LLU) | ||
167 | #define VTTBR_VMID_MASK (0xffLLU << VTTBR_VMID_SHIFT) | ||
168 | |||
169 | /* Hyp Syndrome Register (HSR) bits */ | ||
170 | #define HSR_EC_SHIFT (26) | ||
171 | #define HSR_EC (0x3fU << HSR_EC_SHIFT) | ||
172 | #define HSR_IL (1U << 25) | ||
173 | #define HSR_ISS (HSR_IL - 1) | ||
174 | #define HSR_ISV_SHIFT (24) | ||
175 | #define HSR_ISV (1U << HSR_ISV_SHIFT) | ||
176 | #define HSR_SRT_SHIFT (16) | ||
177 | #define HSR_SRT_MASK (0xf << HSR_SRT_SHIFT) | ||
178 | #define HSR_FSC (0x3f) | ||
179 | #define HSR_FSC_TYPE (0x3c) | ||
180 | #define HSR_SSE (1 << 21) | ||
181 | #define HSR_WNR (1 << 6) | ||
182 | #define HSR_CV_SHIFT (24) | ||
183 | #define HSR_CV (1U << HSR_CV_SHIFT) | ||
184 | #define HSR_COND_SHIFT (20) | ||
185 | #define HSR_COND (0xfU << HSR_COND_SHIFT) | ||
186 | |||
187 | #define FSC_FAULT (0x04) | ||
188 | #define FSC_PERM (0x0c) | ||
189 | |||
190 | /* Hyp Prefetch Fault Address Register (HPFAR/HDFAR) */ | ||
191 | #define HPFAR_MASK (~0xf) | ||
192 | |||
193 | #define HSR_EC_UNKNOWN (0x00) | ||
194 | #define HSR_EC_WFI (0x01) | ||
195 | #define HSR_EC_CP15_32 (0x03) | ||
196 | #define HSR_EC_CP15_64 (0x04) | ||
197 | #define HSR_EC_CP14_MR (0x05) | ||
198 | #define HSR_EC_CP14_LS (0x06) | ||
199 | #define HSR_EC_CP_0_13 (0x07) | ||
200 | #define HSR_EC_CP10_ID (0x08) | ||
201 | #define HSR_EC_JAZELLE (0x09) | ||
202 | #define HSR_EC_BXJ (0x0A) | ||
203 | #define HSR_EC_CP14_64 (0x0C) | ||
204 | #define HSR_EC_SVC_HYP (0x11) | ||
205 | #define HSR_EC_HVC (0x12) | ||
206 | #define HSR_EC_SMC (0x13) | ||
207 | #define HSR_EC_IABT (0x20) | ||
208 | #define HSR_EC_IABT_HYP (0x21) | ||
209 | #define HSR_EC_DABT (0x24) | ||
210 | #define HSR_EC_DABT_HYP (0x25) | ||
211 | |||
212 | #define HSR_HVC_IMM_MASK ((1UL << 16) - 1) | ||
213 | |||
214 | #endif /* __ARM_KVM_ARM_H__ */ | ||
diff --git a/arch/arm/include/asm/kvm_asm.h b/arch/arm/include/asm/kvm_asm.h new file mode 100644 index 000000000000..5e06e8177784 --- /dev/null +++ b/arch/arm/include/asm/kvm_asm.h | |||
@@ -0,0 +1,82 @@ | |||
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 | |||
22 | /* 0 is reserved as an invalid value. */ | ||
23 | #define c0_MPIDR 1 /* MultiProcessor ID Register */ | ||
24 | #define c0_CSSELR 2 /* Cache Size Selection Register */ | ||
25 | #define c1_SCTLR 3 /* System Control Register */ | ||
26 | #define c1_ACTLR 4 /* Auxilliary Control Register */ | ||
27 | #define c1_CPACR 5 /* Coprocessor Access Control */ | ||
28 | #define c2_TTBR0 6 /* Translation Table Base Register 0 */ | ||
29 | #define c2_TTBR0_high 7 /* TTBR0 top 32 bits */ | ||
30 | #define c2_TTBR1 8 /* Translation Table Base Register 1 */ | ||
31 | #define c2_TTBR1_high 9 /* TTBR1 top 32 bits */ | ||
32 | #define c2_TTBCR 10 /* Translation Table Base Control R. */ | ||
33 | #define c3_DACR 11 /* Domain Access Control Register */ | ||
34 | #define c5_DFSR 12 /* Data Fault Status Register */ | ||
35 | #define c5_IFSR 13 /* Instruction Fault Status Register */ | ||
36 | #define c5_ADFSR 14 /* Auxilary Data Fault Status R */ | ||
37 | #define c5_AIFSR 15 /* Auxilary Instrunction Fault Status R */ | ||
38 | #define c6_DFAR 16 /* Data Fault Address Register */ | ||
39 | #define c6_IFAR 17 /* Instruction Fault Address Register */ | ||
40 | #define c9_L2CTLR 18 /* Cortex A15 L2 Control Register */ | ||
41 | #define c10_PRRR 19 /* Primary Region Remap Register */ | ||
42 | #define c10_NMRR 20 /* Normal Memory Remap Register */ | ||
43 | #define c12_VBAR 21 /* Vector Base Address Register */ | ||
44 | #define c13_CID 22 /* Context ID Register */ | ||
45 | #define c13_TID_URW 23 /* Thread ID, User R/W */ | ||
46 | #define c13_TID_URO 24 /* Thread ID, User R/O */ | ||
47 | #define c13_TID_PRIV 25 /* Thread ID, Privileged */ | ||
48 | #define NR_CP15_REGS 26 /* Number of regs (incl. invalid) */ | ||
49 | |||
50 | #define ARM_EXCEPTION_RESET 0 | ||
51 | #define ARM_EXCEPTION_UNDEFINED 1 | ||
52 | #define ARM_EXCEPTION_SOFTWARE 2 | ||
53 | #define ARM_EXCEPTION_PREF_ABORT 3 | ||
54 | #define ARM_EXCEPTION_DATA_ABORT 4 | ||
55 | #define ARM_EXCEPTION_IRQ 5 | ||
56 | #define ARM_EXCEPTION_FIQ 6 | ||
57 | #define ARM_EXCEPTION_HVC 7 | ||
58 | |||
59 | #ifndef __ASSEMBLY__ | ||
60 | struct kvm; | ||
61 | struct kvm_vcpu; | ||
62 | |||
63 | extern char __kvm_hyp_init[]; | ||
64 | extern char __kvm_hyp_init_end[]; | ||
65 | |||
66 | extern char __kvm_hyp_exit[]; | ||
67 | extern char __kvm_hyp_exit_end[]; | ||
68 | |||
69 | extern char __kvm_hyp_vector[]; | ||
70 | |||
71 | extern char __kvm_hyp_code_start[]; | ||
72 | extern char __kvm_hyp_code_end[]; | ||
73 | |||
74 | extern void __kvm_tlb_flush_vmid(struct kvm *kvm); | ||
75 | |||
76 | extern void __kvm_flush_vm_context(void); | ||
77 | extern void __kvm_tlb_flush_vmid(struct kvm *kvm); | ||
78 | |||
79 | extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu); | ||
80 | #endif | ||
81 | |||
82 | #endif /* __ARM_KVM_ASM_H__ */ | ||
diff --git a/arch/arm/include/asm/kvm_coproc.h b/arch/arm/include/asm/kvm_coproc.h new file mode 100644 index 000000000000..4917c2f7e459 --- /dev/null +++ b/arch/arm/include/asm/kvm_coproc.h | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Rusty Russell IBM Corporation | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License, version 2, as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program; if not, write to the Free Software | ||
15 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
16 | */ | ||
17 | |||
18 | #ifndef __ARM_KVM_COPROC_H__ | ||
19 | #define __ARM_KVM_COPROC_H__ | ||
20 | #include <linux/kvm_host.h> | ||
21 | |||
22 | void kvm_reset_coprocs(struct kvm_vcpu *vcpu); | ||
23 | |||
24 | struct kvm_coproc_target_table { | ||
25 | unsigned target; | ||
26 | const struct coproc_reg *table; | ||
27 | size_t num; | ||
28 | }; | ||
29 | void kvm_register_target_coproc_table(struct kvm_coproc_target_table *table); | ||
30 | |||
31 | int kvm_handle_cp10_id(struct kvm_vcpu *vcpu, struct kvm_run *run); | ||
32 | int kvm_handle_cp_0_13_access(struct kvm_vcpu *vcpu, struct kvm_run *run); | ||
33 | int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu, struct kvm_run *run); | ||
34 | int kvm_handle_cp14_access(struct kvm_vcpu *vcpu, struct kvm_run *run); | ||
35 | int kvm_handle_cp15_32(struct kvm_vcpu *vcpu, struct kvm_run *run); | ||
36 | int kvm_handle_cp15_64(struct kvm_vcpu *vcpu, struct kvm_run *run); | ||
37 | |||
38 | unsigned long kvm_arm_num_guest_msrs(struct kvm_vcpu *vcpu); | ||
39 | int kvm_arm_copy_msrindices(struct kvm_vcpu *vcpu, u64 __user *uindices); | ||
40 | void kvm_coproc_table_init(void); | ||
41 | |||
42 | struct kvm_one_reg; | ||
43 | int kvm_arm_copy_coproc_indices(struct kvm_vcpu *vcpu, u64 __user *uindices); | ||
44 | int kvm_arm_coproc_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *); | ||
45 | int kvm_arm_coproc_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *); | ||
46 | unsigned long kvm_arm_num_coproc_regs(struct kvm_vcpu *vcpu); | ||
47 | #endif /* __ARM_KVM_COPROC_H__ */ | ||
diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h new file mode 100644 index 000000000000..fd611996bfb5 --- /dev/null +++ b/arch/arm/include/asm/kvm_emulate.h | |||
@@ -0,0 +1,72 @@ | |||
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_EMULATE_H__ | ||
20 | #define __ARM_KVM_EMULATE_H__ | ||
21 | |||
22 | #include <linux/kvm_host.h> | ||
23 | #include <asm/kvm_asm.h> | ||
24 | #include <asm/kvm_mmio.h> | ||
25 | |||
26 | u32 *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num); | ||
27 | u32 *vcpu_spsr(struct kvm_vcpu *vcpu); | ||
28 | |||
29 | int kvm_handle_wfi(struct kvm_vcpu *vcpu, struct kvm_run *run); | ||
30 | void kvm_skip_instr(struct kvm_vcpu *vcpu, bool is_wide_instr); | ||
31 | void kvm_inject_undefined(struct kvm_vcpu *vcpu); | ||
32 | void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr); | ||
33 | void kvm_inject_pabt(struct kvm_vcpu *vcpu, unsigned long addr); | ||
34 | |||
35 | static inline bool vcpu_mode_is_32bit(struct kvm_vcpu *vcpu) | ||
36 | { | ||
37 | return 1; | ||
38 | } | ||
39 | |||
40 | static inline u32 *vcpu_pc(struct kvm_vcpu *vcpu) | ||
41 | { | ||
42 | return (u32 *)&vcpu->arch.regs.usr_regs.ARM_pc; | ||
43 | } | ||
44 | |||
45 | static inline u32 *vcpu_cpsr(struct kvm_vcpu *vcpu) | ||
46 | { | ||
47 | return (u32 *)&vcpu->arch.regs.usr_regs.ARM_cpsr; | ||
48 | } | ||
49 | |||
50 | static inline void vcpu_set_thumb(struct kvm_vcpu *vcpu) | ||
51 | { | ||
52 | *vcpu_cpsr(vcpu) |= PSR_T_BIT; | ||
53 | } | ||
54 | |||
55 | static inline bool mode_has_spsr(struct kvm_vcpu *vcpu) | ||
56 | { | ||
57 | unsigned long cpsr_mode = vcpu->arch.regs.usr_regs.ARM_cpsr & MODE_MASK; | ||
58 | return (cpsr_mode > USR_MODE && cpsr_mode < SYSTEM_MODE); | ||
59 | } | ||
60 | |||
61 | static inline bool vcpu_mode_priv(struct kvm_vcpu *vcpu) | ||
62 | { | ||
63 | unsigned long cpsr_mode = vcpu->arch.regs.usr_regs.ARM_cpsr & MODE_MASK; | ||
64 | return cpsr_mode > USR_MODE;; | ||
65 | } | ||
66 | |||
67 | static inline bool kvm_vcpu_reg_is_pc(struct kvm_vcpu *vcpu, int reg) | ||
68 | { | ||
69 | return reg == 15; | ||
70 | } | ||
71 | |||
72 | #endif /* __ARM_KVM_EMULATE_H__ */ | ||
diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h new file mode 100644 index 000000000000..98b4d1a72923 --- /dev/null +++ b/arch/arm/include/asm/kvm_host.h | |||
@@ -0,0 +1,161 @@ | |||
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_HOST_H__ | ||
20 | #define __ARM_KVM_HOST_H__ | ||
21 | |||
22 | #include <asm/kvm.h> | ||
23 | #include <asm/kvm_asm.h> | ||
24 | #include <asm/kvm_mmio.h> | ||
25 | #include <asm/fpstate.h> | ||
26 | |||
27 | #define KVM_MAX_VCPUS CONFIG_KVM_ARM_MAX_VCPUS | ||
28 | #define KVM_MEMORY_SLOTS 32 | ||
29 | #define KVM_PRIVATE_MEM_SLOTS 4 | ||
30 | #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 | ||
31 | #define KVM_HAVE_ONE_REG | ||
32 | |||
33 | #define KVM_VCPU_MAX_FEATURES 1 | ||
34 | |||
35 | /* We don't currently support large pages. */ | ||
36 | #define KVM_HPAGE_GFN_SHIFT(x) 0 | ||
37 | #define KVM_NR_PAGE_SIZES 1 | ||
38 | #define KVM_PAGES_PER_HPAGE(x) (1UL<<31) | ||
39 | |||
40 | struct kvm_vcpu; | ||
41 | u32 *kvm_vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num, u32 mode); | ||
42 | int kvm_target_cpu(void); | ||
43 | int kvm_reset_vcpu(struct kvm_vcpu *vcpu); | ||
44 | void kvm_reset_coprocs(struct kvm_vcpu *vcpu); | ||
45 | |||
46 | struct kvm_arch { | ||
47 | /* VTTBR value associated with below pgd and vmid */ | ||
48 | u64 vttbr; | ||
49 | |||
50 | /* | ||
51 | * Anything that is not used directly from assembly code goes | ||
52 | * here. | ||
53 | */ | ||
54 | |||
55 | /* The VMID generation used for the virt. memory system */ | ||
56 | u64 vmid_gen; | ||
57 | u32 vmid; | ||
58 | |||
59 | /* Stage-2 page table */ | ||
60 | pgd_t *pgd; | ||
61 | }; | ||
62 | |||
63 | #define KVM_NR_MEM_OBJS 40 | ||
64 | |||
65 | /* | ||
66 | * We don't want allocation failures within the mmu code, so we preallocate | ||
67 | * enough memory for a single page fault in a cache. | ||
68 | */ | ||
69 | struct kvm_mmu_memory_cache { | ||
70 | int nobjs; | ||
71 | void *objects[KVM_NR_MEM_OBJS]; | ||
72 | }; | ||
73 | |||
74 | struct kvm_vcpu_arch { | ||
75 | struct kvm_regs regs; | ||
76 | |||
77 | int target; /* Processor target */ | ||
78 | DECLARE_BITMAP(features, KVM_VCPU_MAX_FEATURES); | ||
79 | |||
80 | /* System control coprocessor (cp15) */ | ||
81 | u32 cp15[NR_CP15_REGS]; | ||
82 | |||
83 | /* The CPU type we expose to the VM */ | ||
84 | u32 midr; | ||
85 | |||
86 | /* Exception Information */ | ||
87 | u32 hsr; /* Hyp Syndrome Register */ | ||
88 | u32 hxfar; /* Hyp Data/Inst Fault Address Register */ | ||
89 | u32 hpfar; /* Hyp IPA Fault Address Register */ | ||
90 | |||
91 | /* Floating point registers (VFP and Advanced SIMD/NEON) */ | ||
92 | struct vfp_hard_struct vfp_guest; | ||
93 | struct vfp_hard_struct *vfp_host; | ||
94 | |||
95 | /* | ||
96 | * Anything that is not used directly from assembly code goes | ||
97 | * here. | ||
98 | */ | ||
99 | /* dcache set/way operation pending */ | ||
100 | int last_pcpu; | ||
101 | cpumask_t require_dcache_flush; | ||
102 | |||
103 | /* Don't run the guest on this vcpu */ | ||
104 | bool pause; | ||
105 | |||
106 | /* IO related fields */ | ||
107 | struct kvm_decode mmio_decode; | ||
108 | |||
109 | /* Interrupt related fields */ | ||
110 | u32 irq_lines; /* IRQ and FIQ levels */ | ||
111 | |||
112 | /* Hyp exception information */ | ||
113 | u32 hyp_pc; /* PC when exception was taken from Hyp mode */ | ||
114 | |||
115 | /* Cache some mmu pages needed inside spinlock regions */ | ||
116 | struct kvm_mmu_memory_cache mmu_page_cache; | ||
117 | |||
118 | /* Detect first run of a vcpu */ | ||
119 | bool has_run_once; | ||
120 | }; | ||
121 | |||
122 | struct kvm_vm_stat { | ||
123 | u32 remote_tlb_flush; | ||
124 | }; | ||
125 | |||
126 | struct kvm_vcpu_stat { | ||
127 | u32 halt_wakeup; | ||
128 | }; | ||
129 | |||
130 | struct kvm_vcpu_init; | ||
131 | int kvm_vcpu_set_target(struct kvm_vcpu *vcpu, | ||
132 | const struct kvm_vcpu_init *init); | ||
133 | unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu); | ||
134 | int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices); | ||
135 | struct kvm_one_reg; | ||
136 | int kvm_arm_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg); | ||
137 | int kvm_arm_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg); | ||
138 | u64 kvm_call_hyp(void *hypfn, ...); | ||
139 | void force_vm_exit(const cpumask_t *mask); | ||
140 | |||
141 | #define KVM_ARCH_WANT_MMU_NOTIFIER | ||
142 | struct kvm; | ||
143 | int kvm_unmap_hva(struct kvm *kvm, unsigned long hva); | ||
144 | int kvm_unmap_hva_range(struct kvm *kvm, | ||
145 | unsigned long start, unsigned long end); | ||
146 | void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte); | ||
147 | |||
148 | unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu); | ||
149 | int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices); | ||
150 | |||
151 | /* We do not have shadow page tables, hence the empty hooks */ | ||
152 | static inline int kvm_age_hva(struct kvm *kvm, unsigned long hva) | ||
153 | { | ||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | static inline int kvm_test_age_hva(struct kvm *kvm, unsigned long hva) | ||
158 | { | ||
159 | return 0; | ||
160 | } | ||
161 | #endif /* __ARM_KVM_HOST_H__ */ | ||
diff --git a/arch/arm/include/asm/kvm_mmio.h b/arch/arm/include/asm/kvm_mmio.h new file mode 100644 index 000000000000..adcc0d7d3175 --- /dev/null +++ b/arch/arm/include/asm/kvm_mmio.h | |||
@@ -0,0 +1,56 @@ | |||
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_MMIO_H__ | ||
20 | #define __ARM_KVM_MMIO_H__ | ||
21 | |||
22 | #include <linux/kvm_host.h> | ||
23 | #include <asm/kvm_asm.h> | ||
24 | #include <asm/kvm_arm.h> | ||
25 | |||
26 | struct kvm_decode { | ||
27 | unsigned long rt; | ||
28 | bool sign_extend; | ||
29 | }; | ||
30 | |||
31 | /* | ||
32 | * The in-kernel MMIO emulation code wants to use a copy of run->mmio, | ||
33 | * which is an anonymous type. Use our own type instead. | ||
34 | */ | ||
35 | struct kvm_exit_mmio { | ||
36 | phys_addr_t phys_addr; | ||
37 | u8 data[8]; | ||
38 | u32 len; | ||
39 | bool is_write; | ||
40 | }; | ||
41 | |||
42 | static inline void kvm_prepare_mmio(struct kvm_run *run, | ||
43 | struct kvm_exit_mmio *mmio) | ||
44 | { | ||
45 | run->mmio.phys_addr = mmio->phys_addr; | ||
46 | run->mmio.len = mmio->len; | ||
47 | run->mmio.is_write = mmio->is_write; | ||
48 | memcpy(run->mmio.data, mmio->data, mmio->len); | ||
49 | run->exit_reason = KVM_EXIT_MMIO; | ||
50 | } | ||
51 | |||
52 | int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run); | ||
53 | int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run, | ||
54 | phys_addr_t fault_ipa); | ||
55 | |||
56 | #endif /* __ARM_KVM_MMIO_H__ */ | ||
diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h new file mode 100644 index 000000000000..421a20b34874 --- /dev/null +++ b/arch/arm/include/asm/kvm_mmu.h | |||
@@ -0,0 +1,50 @@ | |||
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_MMU_H__ | ||
20 | #define __ARM_KVM_MMU_H__ | ||
21 | |||
22 | int create_hyp_mappings(void *from, void *to); | ||
23 | int create_hyp_io_mappings(void *from, void *to, phys_addr_t); | ||
24 | void free_hyp_pmds(void); | ||
25 | |||
26 | int kvm_alloc_stage2_pgd(struct kvm *kvm); | ||
27 | void kvm_free_stage2_pgd(struct kvm *kvm); | ||
28 | int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa, | ||
29 | phys_addr_t pa, unsigned long size); | ||
30 | |||
31 | int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run); | ||
32 | |||
33 | void kvm_mmu_free_memory_caches(struct kvm_vcpu *vcpu); | ||
34 | |||
35 | phys_addr_t kvm_mmu_get_httbr(void); | ||
36 | int kvm_mmu_init(void); | ||
37 | void kvm_clear_hyp_idmap(void); | ||
38 | |||
39 | static inline bool kvm_is_write_fault(unsigned long hsr) | ||
40 | { | ||
41 | unsigned long hsr_ec = hsr >> HSR_EC_SHIFT; | ||
42 | if (hsr_ec == HSR_EC_IABT) | ||
43 | return false; | ||
44 | else if ((hsr & HSR_ISV) && !(hsr & HSR_WNR)) | ||
45 | return false; | ||
46 | else | ||
47 | return true; | ||
48 | } | ||
49 | |||
50 | #endif /* __ARM_KVM_MMU_H__ */ | ||
diff --git a/arch/arm/include/asm/kvm_psci.h b/arch/arm/include/asm/kvm_psci.h new file mode 100644 index 000000000000..9a83d98bf170 --- /dev/null +++ b/arch/arm/include/asm/kvm_psci.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 - 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 | #ifndef __ARM_KVM_PSCI_H__ | ||
19 | #define __ARM_KVM_PSCI_H__ | ||
20 | |||
21 | bool kvm_psci_call(struct kvm_vcpu *vcpu); | ||
22 | |||
23 | #endif /* __ARM_KVM_PSCI_H__ */ | ||
diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h index d7952824c5c4..18f5cef82ad5 100644 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h | |||
@@ -32,6 +32,9 @@ | |||
32 | #define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0) | 32 | #define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0) |
33 | #define PMD_BIT4 (_AT(pmdval_t, 0)) | 33 | #define PMD_BIT4 (_AT(pmdval_t, 0)) |
34 | #define PMD_DOMAIN(x) (_AT(pmdval_t, 0)) | 34 | #define PMD_DOMAIN(x) (_AT(pmdval_t, 0)) |
35 | #define PMD_APTABLE_SHIFT (61) | ||
36 | #define PMD_APTABLE (_AT(pgdval_t, 3) << PGD_APTABLE_SHIFT) | ||
37 | #define PMD_PXNTABLE (_AT(pgdval_t, 1) << 59) | ||
35 | 38 | ||
36 | /* | 39 | /* |
37 | * - section | 40 | * - section |
@@ -41,9 +44,11 @@ | |||
41 | #define PMD_SECT_S (_AT(pmdval_t, 3) << 8) | 44 | #define PMD_SECT_S (_AT(pmdval_t, 3) << 8) |
42 | #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10) | 45 | #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10) |
43 | #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11) | 46 | #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11) |
47 | #define PMD_SECT_PXN (_AT(pmdval_t, 1) << 53) | ||
44 | #define PMD_SECT_XN (_AT(pmdval_t, 1) << 54) | 48 | #define PMD_SECT_XN (_AT(pmdval_t, 1) << 54) |
45 | #define PMD_SECT_AP_WRITE (_AT(pmdval_t, 0)) | 49 | #define PMD_SECT_AP_WRITE (_AT(pmdval_t, 0)) |
46 | #define PMD_SECT_AP_READ (_AT(pmdval_t, 0)) | 50 | #define PMD_SECT_AP_READ (_AT(pmdval_t, 0)) |
51 | #define PMD_SECT_AP1 (_AT(pmdval_t, 1) << 6) | ||
47 | #define PMD_SECT_TEX(x) (_AT(pmdval_t, 0)) | 52 | #define PMD_SECT_TEX(x) (_AT(pmdval_t, 0)) |
48 | 53 | ||
49 | /* | 54 | /* |
diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index a3f37929940a..6ef8afd1b64c 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h | |||
@@ -104,11 +104,29 @@ | |||
104 | */ | 104 | */ |
105 | #define L_PGD_SWAPPER (_AT(pgdval_t, 1) << 55) /* swapper_pg_dir entry */ | 105 | #define L_PGD_SWAPPER (_AT(pgdval_t, 1) << 55) /* swapper_pg_dir entry */ |
106 | 106 | ||
107 | /* | ||
108 | * 2nd stage PTE definitions for LPAE. | ||
109 | */ | ||
110 | #define L_PTE_S2_MT_UNCACHED (_AT(pteval_t, 0x5) << 2) /* MemAttr[3:0] */ | ||
111 | #define L_PTE_S2_MT_WRITETHROUGH (_AT(pteval_t, 0xa) << 2) /* MemAttr[3:0] */ | ||
112 | #define L_PTE_S2_MT_WRITEBACK (_AT(pteval_t, 0xf) << 2) /* MemAttr[3:0] */ | ||
113 | #define L_PTE_S2_RDONLY (_AT(pteval_t, 1) << 6) /* HAP[1] */ | ||
114 | #define L_PTE_S2_RDWR (_AT(pteval_t, 2) << 6) /* HAP[2:1] */ | ||
115 | |||
116 | /* | ||
117 | * Hyp-mode PL2 PTE definitions for LPAE. | ||
118 | */ | ||
119 | #define L_PTE_HYP L_PTE_USER | ||
120 | |||
107 | #ifndef __ASSEMBLY__ | 121 | #ifndef __ASSEMBLY__ |
108 | 122 | ||
109 | #define pud_none(pud) (!pud_val(pud)) | 123 | #define pud_none(pud) (!pud_val(pud)) |
110 | #define pud_bad(pud) (!(pud_val(pud) & 2)) | 124 | #define pud_bad(pud) (!(pud_val(pud) & 2)) |
111 | #define pud_present(pud) (pud_val(pud)) | 125 | #define pud_present(pud) (pud_val(pud)) |
126 | #define pmd_table(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ | ||
127 | PMD_TYPE_TABLE) | ||
128 | #define pmd_sect(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ | ||
129 | PMD_TYPE_SECT) | ||
112 | 130 | ||
113 | #define pud_clear(pudp) \ | 131 | #define pud_clear(pudp) \ |
114 | do { \ | 132 | do { \ |
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index 9c82f988c0e3..f30ac3b55ba9 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h | |||
@@ -70,6 +70,9 @@ extern void __pgd_error(const char *file, int line, pgd_t); | |||
70 | 70 | ||
71 | extern pgprot_t pgprot_user; | 71 | extern pgprot_t pgprot_user; |
72 | extern pgprot_t pgprot_kernel; | 72 | extern pgprot_t pgprot_kernel; |
73 | extern pgprot_t pgprot_hyp_device; | ||
74 | extern pgprot_t pgprot_s2; | ||
75 | extern pgprot_t pgprot_s2_device; | ||
73 | 76 | ||
74 | #define _MOD_PROT(p, b) __pgprot(pgprot_val(p) | (b)) | 77 | #define _MOD_PROT(p, b) __pgprot(pgprot_val(p) | (b)) |
75 | 78 | ||
@@ -82,6 +85,10 @@ extern pgprot_t pgprot_kernel; | |||
82 | #define PAGE_READONLY_EXEC _MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_RDONLY) | 85 | #define PAGE_READONLY_EXEC _MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_RDONLY) |
83 | #define PAGE_KERNEL _MOD_PROT(pgprot_kernel, L_PTE_XN) | 86 | #define PAGE_KERNEL _MOD_PROT(pgprot_kernel, L_PTE_XN) |
84 | #define PAGE_KERNEL_EXEC pgprot_kernel | 87 | #define PAGE_KERNEL_EXEC pgprot_kernel |
88 | #define PAGE_HYP _MOD_PROT(pgprot_kernel, L_PTE_HYP) | ||
89 | #define PAGE_HYP_DEVICE _MOD_PROT(pgprot_hyp_device, L_PTE_HYP) | ||
90 | #define PAGE_S2 _MOD_PROT(pgprot_s2, L_PTE_S2_RDONLY) | ||
91 | #define PAGE_S2_DEVICE _MOD_PROT(pgprot_s2_device, L_PTE_USER | L_PTE_S2_RDONLY) | ||
85 | 92 | ||
86 | #define __PAGE_NONE __pgprot(_L_PTE_DEFAULT | L_PTE_RDONLY | L_PTE_XN | L_PTE_NONE) | 93 | #define __PAGE_NONE __pgprot(_L_PTE_DEFAULT | L_PTE_RDONLY | L_PTE_XN | L_PTE_NONE) |
87 | #define __PAGE_SHARED __pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_XN) | 94 | #define __PAGE_SHARED __pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_XN) |