diff options
Diffstat (limited to 'arch/arm/include/asm')
-rw-r--r-- | arch/arm/include/asm/kvm_arm.h | 9 | ||||
-rw-r--r-- | arch/arm/include/asm/kvm_asm.h | 2 | ||||
-rw-r--r-- | arch/arm/include/asm/kvm_emulate.h | 51 | ||||
-rw-r--r-- | arch/arm/include/asm/kvm_host.h | 6 | ||||
-rw-r--r-- | arch/arm/include/asm/kvm_mmu.h | 17 | ||||
-rw-r--r-- | arch/arm/include/asm/pgtable-3level.h | 2 |
6 files changed, 75 insertions, 12 deletions
diff --git a/arch/arm/include/asm/kvm_arm.h b/arch/arm/include/asm/kvm_arm.h index 64e96960de29..1d3153c7eb41 100644 --- a/arch/arm/include/asm/kvm_arm.h +++ b/arch/arm/include/asm/kvm_arm.h | |||
@@ -57,6 +57,7 @@ | |||
57 | * TSC: Trap SMC | 57 | * TSC: Trap SMC |
58 | * TSW: Trap cache operations by set/way | 58 | * TSW: Trap cache operations by set/way |
59 | * TWI: Trap WFI | 59 | * TWI: Trap WFI |
60 | * TWE: Trap WFE | ||
60 | * TIDCP: Trap L2CTLR/L2ECTLR | 61 | * TIDCP: Trap L2CTLR/L2ECTLR |
61 | * BSU_IS: Upgrade barriers to the inner shareable domain | 62 | * BSU_IS: Upgrade barriers to the inner shareable domain |
62 | * FB: Force broadcast of all maintainance operations | 63 | * FB: Force broadcast of all maintainance operations |
@@ -67,7 +68,7 @@ | |||
67 | */ | 68 | */ |
68 | #define HCR_GUEST_MASK (HCR_TSC | HCR_TSW | HCR_TWI | HCR_VM | HCR_BSU_IS | \ | 69 | #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_FB | HCR_TAC | HCR_AMO | HCR_IMO | HCR_FMO | \ |
70 | HCR_SWIO | HCR_TIDCP) | 71 | HCR_TWE | HCR_SWIO | HCR_TIDCP) |
71 | #define HCR_VIRT_EXCP_MASK (HCR_VA | HCR_VI | HCR_VF) | 72 | #define HCR_VIRT_EXCP_MASK (HCR_VA | HCR_VI | HCR_VF) |
72 | 73 | ||
73 | /* System Control Register (SCTLR) bits */ | 74 | /* System Control Register (SCTLR) bits */ |
@@ -95,12 +96,12 @@ | |||
95 | #define TTBCR_IRGN1 (3 << 24) | 96 | #define TTBCR_IRGN1 (3 << 24) |
96 | #define TTBCR_EPD1 (1 << 23) | 97 | #define TTBCR_EPD1 (1 << 23) |
97 | #define TTBCR_A1 (1 << 22) | 98 | #define TTBCR_A1 (1 << 22) |
98 | #define TTBCR_T1SZ (3 << 16) | 99 | #define TTBCR_T1SZ (7 << 16) |
99 | #define TTBCR_SH0 (3 << 12) | 100 | #define TTBCR_SH0 (3 << 12) |
100 | #define TTBCR_ORGN0 (3 << 10) | 101 | #define TTBCR_ORGN0 (3 << 10) |
101 | #define TTBCR_IRGN0 (3 << 8) | 102 | #define TTBCR_IRGN0 (3 << 8) |
102 | #define TTBCR_EPD0 (1 << 7) | 103 | #define TTBCR_EPD0 (1 << 7) |
103 | #define TTBCR_T0SZ 3 | 104 | #define TTBCR_T0SZ (7 << 0) |
104 | #define HTCR_MASK (TTBCR_T0SZ | TTBCR_IRGN0 | TTBCR_ORGN0 | TTBCR_SH0) | 105 | #define HTCR_MASK (TTBCR_T0SZ | TTBCR_IRGN0 | TTBCR_ORGN0 | TTBCR_SH0) |
105 | 106 | ||
106 | /* Hyp System Trap Register */ | 107 | /* Hyp System Trap Register */ |
@@ -208,6 +209,8 @@ | |||
208 | #define HSR_EC_DABT (0x24) | 209 | #define HSR_EC_DABT (0x24) |
209 | #define HSR_EC_DABT_HYP (0x25) | 210 | #define HSR_EC_DABT_HYP (0x25) |
210 | 211 | ||
212 | #define HSR_WFI_IS_WFE (1U << 0) | ||
213 | |||
211 | #define HSR_HVC_IMM_MASK ((1UL << 16) - 1) | 214 | #define HSR_HVC_IMM_MASK ((1UL << 16) - 1) |
212 | 215 | ||
213 | #define HSR_DABT_S1PTW (1U << 7) | 216 | #define HSR_DABT_S1PTW (1U << 7) |
diff --git a/arch/arm/include/asm/kvm_asm.h b/arch/arm/include/asm/kvm_asm.h index a2f43ddcc300..661da11f76f4 100644 --- a/arch/arm/include/asm/kvm_asm.h +++ b/arch/arm/include/asm/kvm_asm.h | |||
@@ -39,7 +39,7 @@ | |||
39 | #define c6_IFAR 17 /* Instruction Fault Address Register */ | 39 | #define c6_IFAR 17 /* Instruction Fault Address Register */ |
40 | #define c7_PAR 18 /* Physical Address Register */ | 40 | #define c7_PAR 18 /* Physical Address Register */ |
41 | #define c7_PAR_high 19 /* PAR top 32 bits */ | 41 | #define c7_PAR_high 19 /* PAR top 32 bits */ |
42 | #define c9_L2CTLR 20 /* Cortex A15 L2 Control Register */ | 42 | #define c9_L2CTLR 20 /* Cortex A15/A7 L2 Control Register */ |
43 | #define c10_PRRR 21 /* Primary Region Remap Register */ | 43 | #define c10_PRRR 21 /* Primary Region Remap Register */ |
44 | #define c10_NMRR 22 /* Normal Memory Remap Register */ | 44 | #define c10_NMRR 22 /* Normal Memory Remap Register */ |
45 | #define c12_VBAR 23 /* Vector Base Address Register */ | 45 | #define c12_VBAR 23 /* Vector Base Address Register */ |
diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h index a464e8d7b6c5..0fa90c962ac8 100644 --- a/arch/arm/include/asm/kvm_emulate.h +++ b/arch/arm/include/asm/kvm_emulate.h | |||
@@ -157,4 +157,55 @@ static inline u32 kvm_vcpu_hvc_get_imm(struct kvm_vcpu *vcpu) | |||
157 | return kvm_vcpu_get_hsr(vcpu) & HSR_HVC_IMM_MASK; | 157 | return kvm_vcpu_get_hsr(vcpu) & HSR_HVC_IMM_MASK; |
158 | } | 158 | } |
159 | 159 | ||
160 | static inline unsigned long kvm_vcpu_get_mpidr(struct kvm_vcpu *vcpu) | ||
161 | { | ||
162 | return vcpu->arch.cp15[c0_MPIDR]; | ||
163 | } | ||
164 | |||
165 | static inline void kvm_vcpu_set_be(struct kvm_vcpu *vcpu) | ||
166 | { | ||
167 | *vcpu_cpsr(vcpu) |= PSR_E_BIT; | ||
168 | } | ||
169 | |||
170 | static inline bool kvm_vcpu_is_be(struct kvm_vcpu *vcpu) | ||
171 | { | ||
172 | return !!(*vcpu_cpsr(vcpu) & PSR_E_BIT); | ||
173 | } | ||
174 | |||
175 | static inline unsigned long vcpu_data_guest_to_host(struct kvm_vcpu *vcpu, | ||
176 | unsigned long data, | ||
177 | unsigned int len) | ||
178 | { | ||
179 | if (kvm_vcpu_is_be(vcpu)) { | ||
180 | switch (len) { | ||
181 | case 1: | ||
182 | return data & 0xff; | ||
183 | case 2: | ||
184 | return be16_to_cpu(data & 0xffff); | ||
185 | default: | ||
186 | return be32_to_cpu(data); | ||
187 | } | ||
188 | } | ||
189 | |||
190 | return data; /* Leave LE untouched */ | ||
191 | } | ||
192 | |||
193 | static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu, | ||
194 | unsigned long data, | ||
195 | unsigned int len) | ||
196 | { | ||
197 | if (kvm_vcpu_is_be(vcpu)) { | ||
198 | switch (len) { | ||
199 | case 1: | ||
200 | return data & 0xff; | ||
201 | case 2: | ||
202 | return cpu_to_be16(data & 0xffff); | ||
203 | default: | ||
204 | return cpu_to_be32(data); | ||
205 | } | ||
206 | } | ||
207 | |||
208 | return data; /* Leave LE untouched */ | ||
209 | } | ||
210 | |||
160 | #endif /* __ARM_KVM_EMULATE_H__ */ | 211 | #endif /* __ARM_KVM_EMULATE_H__ */ |
diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index 7d22517d8071..8a6f6db14ee4 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h | |||
@@ -38,11 +38,6 @@ | |||
38 | 38 | ||
39 | #define KVM_VCPU_MAX_FEATURES 1 | 39 | #define KVM_VCPU_MAX_FEATURES 1 |
40 | 40 | ||
41 | /* We don't currently support large pages. */ | ||
42 | #define KVM_HPAGE_GFN_SHIFT(x) 0 | ||
43 | #define KVM_NR_PAGE_SIZES 1 | ||
44 | #define KVM_PAGES_PER_HPAGE(x) (1UL<<31) | ||
45 | |||
46 | #include <kvm/arm_vgic.h> | 41 | #include <kvm/arm_vgic.h> |
47 | 42 | ||
48 | struct kvm_vcpu; | 43 | struct kvm_vcpu; |
@@ -154,6 +149,7 @@ struct kvm_vcpu_stat { | |||
154 | struct kvm_vcpu_init; | 149 | struct kvm_vcpu_init; |
155 | int kvm_vcpu_set_target(struct kvm_vcpu *vcpu, | 150 | int kvm_vcpu_set_target(struct kvm_vcpu *vcpu, |
156 | const struct kvm_vcpu_init *init); | 151 | const struct kvm_vcpu_init *init); |
152 | int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init); | ||
157 | unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu); | 153 | unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu); |
158 | int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices); | 154 | int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices); |
159 | struct kvm_one_reg; | 155 | struct kvm_one_reg; |
diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h index 9b28c41f4ba9..77de4a41cc50 100644 --- a/arch/arm/include/asm/kvm_mmu.h +++ b/arch/arm/include/asm/kvm_mmu.h | |||
@@ -62,6 +62,12 @@ phys_addr_t kvm_get_idmap_vector(void); | |||
62 | int kvm_mmu_init(void); | 62 | int kvm_mmu_init(void); |
63 | void kvm_clear_hyp_idmap(void); | 63 | void kvm_clear_hyp_idmap(void); |
64 | 64 | ||
65 | static inline void kvm_set_pmd(pmd_t *pmd, pmd_t new_pmd) | ||
66 | { | ||
67 | *pmd = new_pmd; | ||
68 | flush_pmd_entry(pmd); | ||
69 | } | ||
70 | |||
65 | static inline void kvm_set_pte(pte_t *pte, pte_t new_pte) | 71 | static inline void kvm_set_pte(pte_t *pte, pte_t new_pte) |
66 | { | 72 | { |
67 | *pte = new_pte; | 73 | *pte = new_pte; |
@@ -103,9 +109,15 @@ static inline void kvm_set_s2pte_writable(pte_t *pte) | |||
103 | pte_val(*pte) |= L_PTE_S2_RDWR; | 109 | pte_val(*pte) |= L_PTE_S2_RDWR; |
104 | } | 110 | } |
105 | 111 | ||
112 | static inline void kvm_set_s2pmd_writable(pmd_t *pmd) | ||
113 | { | ||
114 | pmd_val(*pmd) |= L_PMD_S2_RDWR; | ||
115 | } | ||
116 | |||
106 | struct kvm; | 117 | struct kvm; |
107 | 118 | ||
108 | static inline void coherent_icache_guest_page(struct kvm *kvm, gfn_t gfn) | 119 | static inline void coherent_icache_guest_page(struct kvm *kvm, hva_t hva, |
120 | unsigned long size) | ||
109 | { | 121 | { |
110 | /* | 122 | /* |
111 | * If we are going to insert an instruction page and the icache is | 123 | * If we are going to insert an instruction page and the icache is |
@@ -120,8 +132,7 @@ static inline void coherent_icache_guest_page(struct kvm *kvm, gfn_t gfn) | |||
120 | * need any kind of flushing (DDI 0406C.b - Page B3-1392). | 132 | * need any kind of flushing (DDI 0406C.b - Page B3-1392). |
121 | */ | 133 | */ |
122 | if (icache_is_pipt()) { | 134 | if (icache_is_pipt()) { |
123 | unsigned long hva = gfn_to_hva(kvm, gfn); | 135 | __cpuc_coherent_user_range(hva, hva + size); |
124 | __cpuc_coherent_user_range(hva, hva + PAGE_SIZE); | ||
125 | } else if (!icache_is_vivt_asid_tagged()) { | 136 | } else if (!icache_is_vivt_asid_tagged()) { |
126 | /* any kind of VIPT cache */ | 137 | /* any kind of VIPT cache */ |
127 | __flush_icache_all(); | 138 | __flush_icache_all(); |
diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index 39c54cfa03e9..4f9503908dca 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h | |||
@@ -126,6 +126,8 @@ | |||
126 | #define L_PTE_S2_RDONLY (_AT(pteval_t, 1) << 6) /* HAP[1] */ | 126 | #define L_PTE_S2_RDONLY (_AT(pteval_t, 1) << 6) /* HAP[1] */ |
127 | #define L_PTE_S2_RDWR (_AT(pteval_t, 3) << 6) /* HAP[2:1] */ | 127 | #define L_PTE_S2_RDWR (_AT(pteval_t, 3) << 6) /* HAP[2:1] */ |
128 | 128 | ||
129 | #define L_PMD_S2_RDWR (_AT(pmdval_t, 3) << 6) /* HAP[2:1] */ | ||
130 | |||
129 | /* | 131 | /* |
130 | * Hyp-mode PL2 PTE definitions for LPAE. | 132 | * Hyp-mode PL2 PTE definitions for LPAE. |
131 | */ | 133 | */ |