hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/powerpc/include/asm/kvm_book3s.h
....@@ -1,16 +1,5 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
2
- * This program is free software; you can redistribute it and/or modify
3
- * it under the terms of the GNU General Public License, version 2, as
4
- * published by the Free Software Foundation.
5
- *
6
- * This program is distributed in the hope that it will be useful,
7
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
8
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
- * GNU General Public License for more details.
10
- *
11
- * You should have received a copy of the GNU General Public License
12
- * along with this program; if not, write to the Free Software
13
- * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
143 *
154 * Copyright SUSE Linux Products GmbH 2009
165 *
....@@ -89,7 +78,7 @@
8978 struct kvm_vcpu *runnable_threads[MAX_SMT_THREADS];
9079 struct list_head preempt_list;
9180 spinlock_t lock;
92
- struct swait_queue_head wq;
81
+ struct rcuwait wait;
9382 spinlock_t stoltb_lock; /* protects stolen_tb and preempt_tb */
9483 u64 stolen_tb;
9584 u64 preempt_tb;
....@@ -166,12 +155,11 @@
166155 extern int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr);
167156 extern void kvmppc_mmu_flush_segment(struct kvm_vcpu *vcpu, ulong eaddr, ulong seg_size);
168157 extern void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu);
169
-extern int kvmppc_book3s_hv_page_fault(struct kvm_run *run,
170
- struct kvm_vcpu *vcpu, unsigned long addr,
171
- unsigned long status);
158
+extern int kvmppc_book3s_hv_page_fault(struct kvm_vcpu *vcpu,
159
+ unsigned long addr, unsigned long status);
172160 extern long kvmppc_hv_find_lock_hpte(struct kvm *kvm, gva_t eaddr,
173161 unsigned long slb_v, unsigned long valid);
174
-extern int kvmppc_hv_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu,
162
+extern int kvmppc_hv_emulate_mmio(struct kvm_vcpu *vcpu,
175163 unsigned long gpa, gva_t ea, int is_store);
176164
177165 extern void kvmppc_mmu_hpte_cache_map(struct kvm_vcpu *vcpu, struct hpte_cache *pte);
....@@ -185,13 +173,41 @@
185173 extern int kvmppc_mmu_hv_init(void);
186174 extern int kvmppc_book3s_hcall_implemented(struct kvm *kvm, unsigned long hc);
187175
188
-extern int kvmppc_book3s_radix_page_fault(struct kvm_run *run,
189
- struct kvm_vcpu *vcpu,
176
+extern int kvmppc_book3s_radix_page_fault(struct kvm_vcpu *vcpu,
190177 unsigned long ea, unsigned long dsisr);
178
+extern unsigned long __kvmhv_copy_tofrom_guest_radix(int lpid, int pid,
179
+ gva_t eaddr, void *to, void *from,
180
+ unsigned long n);
181
+extern long kvmhv_copy_from_guest_radix(struct kvm_vcpu *vcpu, gva_t eaddr,
182
+ void *to, unsigned long n);
183
+extern long kvmhv_copy_to_guest_radix(struct kvm_vcpu *vcpu, gva_t eaddr,
184
+ void *from, unsigned long n);
185
+extern int kvmppc_mmu_walk_radix_tree(struct kvm_vcpu *vcpu, gva_t eaddr,
186
+ struct kvmppc_pte *gpte, u64 root,
187
+ u64 *pte_ret_p);
188
+extern int kvmppc_mmu_radix_translate_table(struct kvm_vcpu *vcpu, gva_t eaddr,
189
+ struct kvmppc_pte *gpte, u64 table,
190
+ int table_index, u64 *pte_ret_p);
191191 extern int kvmppc_mmu_radix_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
192192 struct kvmppc_pte *gpte, bool data, bool iswrite);
193
+extern void kvmppc_radix_tlbie_page(struct kvm *kvm, unsigned long addr,
194
+ unsigned int pshift, unsigned int lpid);
195
+extern void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte, unsigned long gpa,
196
+ unsigned int shift,
197
+ const struct kvm_memory_slot *memslot,
198
+ unsigned int lpid);
199
+extern bool kvmppc_hv_handle_set_rc(struct kvm *kvm, bool nested,
200
+ bool writing, unsigned long gpa,
201
+ unsigned int lpid);
202
+extern int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu,
203
+ unsigned long gpa,
204
+ struct kvm_memory_slot *memslot,
205
+ bool writing, bool kvm_ro,
206
+ pte_t *inserted_pte, unsigned int *levelp);
193207 extern int kvmppc_init_vm_radix(struct kvm *kvm);
194208 extern void kvmppc_free_radix(struct kvm *kvm);
209
+extern void kvmppc_free_pgtable_radix(struct kvm *kvm, pgd_t *pgd,
210
+ unsigned int lpid);
195211 extern int kvmppc_radix_init(void);
196212 extern void kvmppc_radix_exit(void);
197213 extern int kvm_unmap_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
....@@ -202,6 +218,8 @@
202218 unsigned long gfn);
203219 extern long kvmppc_hv_get_dirty_log_radix(struct kvm *kvm,
204220 struct kvm_memory_slot *memslot, unsigned long *map);
221
+extern void kvmppc_radix_flush_memslot(struct kvm *kvm,
222
+ const struct kvm_memory_slot *memslot);
205223 extern int kvmhv_get_rmmu_info(struct kvm *kvm, struct kvm_ppc_rmmu_info *info);
206224
207225 /* XXX remove this export when load_last_inst() is generic */
....@@ -214,12 +232,12 @@
214232 extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat,
215233 bool upper, u32 val);
216234 extern void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr);
217
-extern int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu);
235
+extern int kvmppc_emulate_paired_single(struct kvm_vcpu *vcpu);
218236 extern kvm_pfn_t kvmppc_gpa_to_pfn(struct kvm_vcpu *vcpu, gpa_t gpa,
219237 bool writing, bool *writable);
220238 extern void kvmppc_add_revmap_chain(struct kvm *kvm, struct revmap_entry *rev,
221239 unsigned long *rmap, long pte_index, int realmode);
222
-extern void kvmppc_update_dirty_map(struct kvm_memory_slot *memslot,
240
+extern void kvmppc_update_dirty_map(const struct kvm_memory_slot *memslot,
223241 unsigned long gfn, unsigned long psize);
224242 extern void kvmppc_invalidate_hpte(struct kvm *kvm, __be64 *hptep,
225243 unsigned long pte_index);
....@@ -270,6 +288,22 @@
270288 static inline void kvmppc_save_tm_sprs(struct kvm_vcpu *vcpu) {}
271289 static inline void kvmppc_restore_tm_sprs(struct kvm_vcpu *vcpu) {}
272290 #endif
291
+
292
+long kvmhv_nested_init(void);
293
+void kvmhv_nested_exit(void);
294
+void kvmhv_vm_nested_init(struct kvm *kvm);
295
+long kvmhv_set_partition_table(struct kvm_vcpu *vcpu);
296
+long kvmhv_copy_tofrom_guest_nested(struct kvm_vcpu *vcpu);
297
+void kvmhv_set_ptbl_entry(unsigned int lpid, u64 dw0, u64 dw1);
298
+void kvmhv_release_all_nested(struct kvm *kvm);
299
+long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu);
300
+long kvmhv_do_nested_tlbie(struct kvm_vcpu *vcpu);
301
+int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu,
302
+ u64 time_limit, unsigned long lpcr);
303
+void kvmhv_save_hv_regs(struct kvm_vcpu *vcpu, struct hv_guest_state *hr);
304
+void kvmhv_restore_hv_return_state(struct kvm_vcpu *vcpu,
305
+ struct hv_guest_state *hr);
306
+long int kvmhv_nested_page_fault(struct kvm_vcpu *vcpu);
273307
274308 void kvmppc_giveup_fac(struct kvm_vcpu *vcpu, ulong fac);
275309
....@@ -383,9 +417,6 @@
383417 #define INS_DCBZ 0x7c0007ec
384418 /* TO = 31 for unconditional trap */
385419 #define INS_TW 0x7fe00008
386
-
387
-/* LPIDs we support with this build -- runtime limit may be lower */
388
-#define KVMPPC_NR_LPIDS (LPID_RSVD + 1)
389420
390421 #define SPLIT_HACK_MASK 0xff000000
391422 #define SPLIT_HACK_OFFS 0xfb000000