1 /* SPDX-License-Identifier: GPL-2.0-only */
4 * Copyright IBM Corp. 2008
6 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
9 #ifndef __POWERPC_KVM_PPC_H__
10 #define __POWERPC_KVM_PPC_H__
12 /* This file exists just so we can dereference kvm_vcpu, avoiding nested header
15 #include <linux/mutex.h>
16 #include <linux/timer.h>
17 #include <linux/types.h>
18 #include <linux/kvm_types.h>
19 #include <linux/kvm_host.h>
20 #include <linux/bug.h>
21 #ifdef CONFIG_PPC_BOOK3S
22 #include <asm/kvm_book3s.h>
24 #include <asm/kvm_booke.h>
26 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
29 #include <asm/cpu_has_feature.h>
34 * KVMPPC_INST_SW_BREAKPOINT is debug Instruction
35 * for supporting software breakpoint.
37 #define KVMPPC_INST_SW_BREAKPOINT 0x00dddd00
39 enum emulation_result {
40 EMULATE_DONE, /* no further processing */
41 EMULATE_DO_MMIO, /* kvm_run filled with MMIO request */
42 EMULATE_FAIL, /* can't emulate this instruction */
43 EMULATE_AGAIN, /* something went wrong. go again */
44 EMULATE_EXIT_USER, /* emulation requires exit to user-space */
47 enum instruction_fetch_type {
49 INST_SC, /* system call */
53 XLATE_INST, /* translate instruction address */
54 XLATE_DATA /* translate data address */
57 enum xlate_readwrite {
58 XLATE_READ, /* check for read permissions */
59 XLATE_WRITE /* check for write permissions */
62 extern int kvmppc_vcpu_run(struct kvm_vcpu *vcpu);
63 extern int __kvmppc_vcpu_run(struct kvm_vcpu *vcpu);
64 extern void kvmppc_handler_highmem(void);
66 extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu);
67 extern int kvmppc_handle_load(struct kvm_vcpu *vcpu,
68 unsigned int rt, unsigned int bytes,
69 int is_default_endian);
70 extern int kvmppc_handle_loads(struct kvm_vcpu *vcpu,
71 unsigned int rt, unsigned int bytes,
72 int is_default_endian);
73 extern int kvmppc_handle_vsx_load(struct kvm_vcpu *vcpu,
74 unsigned int rt, unsigned int bytes,
75 int is_default_endian, int mmio_sign_extend);
76 extern int kvmppc_handle_vmx_load(struct kvm_vcpu *vcpu,
77 unsigned int rt, unsigned int bytes, int is_default_endian);
78 extern int kvmppc_handle_vmx_store(struct kvm_vcpu *vcpu,
79 unsigned int rs, unsigned int bytes, int is_default_endian);
80 extern int kvmppc_handle_store(struct kvm_vcpu *vcpu,
81 u64 val, unsigned int bytes,
82 int is_default_endian);
83 extern int kvmppc_handle_vsx_store(struct kvm_vcpu *vcpu,
84 int rs, unsigned int bytes,
85 int is_default_endian);
87 extern int kvmppc_load_last_inst(struct kvm_vcpu *vcpu,
88 enum instruction_fetch_type type,
91 extern int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr,
93 extern int kvmppc_st(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr,
95 extern int kvmppc_emulate_instruction(struct kvm_vcpu *vcpu);
96 extern int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu);
97 extern int kvmppc_emulate_mmio(struct kvm_vcpu *vcpu);
98 extern void kvmppc_emulate_dec(struct kvm_vcpu *vcpu);
99 extern u32 kvmppc_get_dec(struct kvm_vcpu *vcpu, u64 tb);
100 extern void kvmppc_decrementer_func(struct kvm_vcpu *vcpu);
101 extern int kvmppc_sanity_check(struct kvm_vcpu *vcpu);
102 extern int kvmppc_subarch_vcpu_init(struct kvm_vcpu *vcpu);
103 extern void kvmppc_subarch_vcpu_uninit(struct kvm_vcpu *vcpu);
105 /* Core-specific hooks */
107 extern void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gpa_t gpaddr,
108 unsigned int gtlb_idx);
109 extern void kvmppc_mmu_switch_pid(struct kvm_vcpu *vcpu, u32 pid);
110 extern int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr);
111 extern int kvmppc_mmu_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr);
112 extern gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, unsigned int gtlb_index,
114 extern void kvmppc_mmu_dtlb_miss(struct kvm_vcpu *vcpu);
115 extern void kvmppc_mmu_itlb_miss(struct kvm_vcpu *vcpu);
116 extern int kvmppc_xlate(struct kvm_vcpu *vcpu, ulong eaddr,
117 enum xlate_instdata xlid, enum xlate_readwrite xlrw,
118 struct kvmppc_pte *pte);
120 extern int kvmppc_core_vcpu_create(struct kvm_vcpu *vcpu);
121 extern void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu);
122 extern int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu);
123 extern int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu,
124 struct kvm_translation *tr);
126 extern void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
127 extern void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu);
129 extern int kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu);
130 extern int kvmppc_core_pending_dec(struct kvm_vcpu *vcpu);
132 extern void kvmppc_core_queue_machine_check(struct kvm_vcpu *vcpu,
134 extern void kvmppc_core_queue_syscall(struct kvm_vcpu *vcpu);
135 extern void kvmppc_core_queue_program(struct kvm_vcpu *vcpu,
137 extern void kvmppc_core_queue_fpunavail(struct kvm_vcpu *vcpu,
139 extern void kvmppc_core_queue_vec_unavail(struct kvm_vcpu *vcpu,
141 extern void kvmppc_core_queue_vsx_unavail(struct kvm_vcpu *vcpu,
143 extern void kvmppc_core_queue_dec(struct kvm_vcpu *vcpu);
144 extern void kvmppc_core_dequeue_dec(struct kvm_vcpu *vcpu);
145 extern void kvmppc_core_queue_external(struct kvm_vcpu *vcpu,
146 struct kvm_interrupt *irq);
147 extern void kvmppc_core_dequeue_external(struct kvm_vcpu *vcpu);
148 extern void kvmppc_core_queue_dtlb_miss(struct kvm_vcpu *vcpu,
151 extern void kvmppc_core_queue_data_storage(struct kvm_vcpu *vcpu,
155 extern void kvmppc_core_queue_itlb_miss(struct kvm_vcpu *vcpu);
156 extern void kvmppc_core_queue_inst_storage(struct kvm_vcpu *vcpu,
159 extern void kvmppc_core_flush_tlb(struct kvm_vcpu *vcpu);
160 extern int kvmppc_core_check_requests(struct kvm_vcpu *vcpu);
162 extern int kvmppc_booke_init(void);
163 extern void kvmppc_booke_exit(void);
165 extern int kvmppc_kvm_pv(struct kvm_vcpu *vcpu);
166 extern void kvmppc_map_magic(struct kvm_vcpu *vcpu);
168 extern int kvmppc_allocate_hpt(struct kvm_hpt_info *info, u32 order);
169 extern void kvmppc_set_hpt(struct kvm *kvm, struct kvm_hpt_info *info);
170 extern int kvmppc_alloc_reset_hpt(struct kvm *kvm, int order);
171 extern void kvmppc_free_hpt(struct kvm_hpt_info *info);
172 extern void kvmppc_rmap_reset(struct kvm *kvm);
173 extern void kvmppc_map_vrma(struct kvm_vcpu *vcpu,
174 struct kvm_memory_slot *memslot, unsigned long porder);
175 extern int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu);
176 extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,
177 struct iommu_group *grp);
178 extern void kvm_spapr_tce_release_iommu_group(struct kvm *kvm,
179 struct iommu_group *grp);
180 extern int kvmppc_switch_mmu_to_hpt(struct kvm *kvm);
181 extern int kvmppc_switch_mmu_to_radix(struct kvm *kvm);
182 extern void kvmppc_setup_partition_table(struct kvm *kvm);
184 extern int kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
185 struct kvm_create_spapr_tce_64 *args);
186 #define kvmppc_ioba_validate(stt, ioba, npages) \
187 (iommu_tce_check_ioba((stt)->page_shift, (stt)->offset, \
188 (stt)->size, (ioba), (npages)) ? \
189 H_PARAMETER : H_SUCCESS)
190 extern long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
191 unsigned long ioba, unsigned long tce);
192 extern long kvmppc_h_put_tce_indirect(struct kvm_vcpu *vcpu,
193 unsigned long liobn, unsigned long ioba,
194 unsigned long tce_list, unsigned long npages);
195 extern long kvmppc_h_stuff_tce(struct kvm_vcpu *vcpu,
196 unsigned long liobn, unsigned long ioba,
197 unsigned long tce_value, unsigned long npages);
198 extern long kvmppc_h_get_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
200 extern struct page *kvm_alloc_hpt_cma(unsigned long nr_pages);
201 extern void kvm_free_hpt_cma(struct page *page, unsigned long nr_pages);
202 extern int kvmppc_core_init_vm(struct kvm *kvm);
203 extern void kvmppc_core_destroy_vm(struct kvm *kvm);
204 extern void kvmppc_core_free_memslot(struct kvm *kvm,
205 struct kvm_memory_slot *slot);
206 extern int kvmppc_core_prepare_memory_region(struct kvm *kvm,
207 const struct kvm_memory_slot *old,
208 struct kvm_memory_slot *new,
209 enum kvm_mr_change change);
210 extern void kvmppc_core_commit_memory_region(struct kvm *kvm,
211 struct kvm_memory_slot *old,
212 const struct kvm_memory_slot *new,
213 enum kvm_mr_change change);
214 extern int kvm_vm_ioctl_get_smmu_info(struct kvm *kvm,
215 struct kvm_ppc_smmu_info *info);
216 extern void kvmppc_core_flush_memslot(struct kvm *kvm,
217 struct kvm_memory_slot *memslot);
219 extern int kvmppc_bookehv_init(void);
220 extern void kvmppc_bookehv_exit(void);
222 extern int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu);
224 extern int kvm_vm_ioctl_get_htab_fd(struct kvm *kvm, struct kvm_get_htab_fd *);
225 extern int kvm_vm_ioctl_resize_hpt_prepare(struct kvm *kvm,
226 struct kvm_ppc_resize_hpt *rhpt);
227 extern int kvm_vm_ioctl_resize_hpt_commit(struct kvm *kvm,
228 struct kvm_ppc_resize_hpt *rhpt);
230 int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq);
232 extern int kvm_vm_ioctl_rtas_define_token(struct kvm *kvm, void __user *argp);
233 extern int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu);
234 extern void kvmppc_rtas_tokens_free(struct kvm *kvm);
236 extern int kvmppc_xics_set_xive(struct kvm *kvm, u32 irq, u32 server,
238 extern int kvmppc_xics_get_xive(struct kvm *kvm, u32 irq, u32 *server,
240 extern int kvmppc_xics_int_on(struct kvm *kvm, u32 irq);
241 extern int kvmppc_xics_int_off(struct kvm *kvm, u32 irq);
243 void kvmppc_core_dequeue_debug(struct kvm_vcpu *vcpu);
244 void kvmppc_core_queue_debug(struct kvm_vcpu *vcpu);
246 union kvmppc_one_reg {
262 struct module *owner;
263 int (*get_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
264 int (*set_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
265 int (*get_one_reg)(struct kvm_vcpu *vcpu, u64 id,
266 union kvmppc_one_reg *val);
267 int (*set_one_reg)(struct kvm_vcpu *vcpu, u64 id,
268 union kvmppc_one_reg *val);
269 void (*vcpu_load)(struct kvm_vcpu *vcpu, int cpu);
270 void (*vcpu_put)(struct kvm_vcpu *vcpu);
271 void (*inject_interrupt)(struct kvm_vcpu *vcpu, int vec, u64 srr1_flags);
272 void (*set_msr)(struct kvm_vcpu *vcpu, u64 msr);
273 int (*vcpu_run)(struct kvm_vcpu *vcpu);
274 int (*vcpu_create)(struct kvm_vcpu *vcpu);
275 void (*vcpu_free)(struct kvm_vcpu *vcpu);
276 int (*check_requests)(struct kvm_vcpu *vcpu);
277 int (*get_dirty_log)(struct kvm *kvm, struct kvm_dirty_log *log);
278 void (*flush_memslot)(struct kvm *kvm, struct kvm_memory_slot *memslot);
279 int (*prepare_memory_region)(struct kvm *kvm,
280 const struct kvm_memory_slot *old,
281 struct kvm_memory_slot *new,
282 enum kvm_mr_change change);
283 void (*commit_memory_region)(struct kvm *kvm,
284 struct kvm_memory_slot *old,
285 const struct kvm_memory_slot *new,
286 enum kvm_mr_change change);
287 bool (*unmap_gfn_range)(struct kvm *kvm, struct kvm_gfn_range *range);
288 bool (*age_gfn)(struct kvm *kvm, struct kvm_gfn_range *range);
289 bool (*test_age_gfn)(struct kvm *kvm, struct kvm_gfn_range *range);
290 bool (*set_spte_gfn)(struct kvm *kvm, struct kvm_gfn_range *range);
291 void (*free_memslot)(struct kvm_memory_slot *slot);
292 int (*init_vm)(struct kvm *kvm);
293 void (*destroy_vm)(struct kvm *kvm);
294 int (*get_smmu_info)(struct kvm *kvm, struct kvm_ppc_smmu_info *info);
295 int (*emulate_op)(struct kvm_vcpu *vcpu,
296 unsigned int inst, int *advance);
297 int (*emulate_mtspr)(struct kvm_vcpu *vcpu, int sprn, ulong spr_val);
298 int (*emulate_mfspr)(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val);
299 void (*fast_vcpu_kick)(struct kvm_vcpu *vcpu);
300 int (*arch_vm_ioctl)(struct file *filp, unsigned int ioctl,
302 int (*hcall_implemented)(unsigned long hcall);
303 int (*irq_bypass_add_producer)(struct irq_bypass_consumer *,
304 struct irq_bypass_producer *);
305 void (*irq_bypass_del_producer)(struct irq_bypass_consumer *,
306 struct irq_bypass_producer *);
307 int (*configure_mmu)(struct kvm *kvm, struct kvm_ppc_mmuv3_cfg *cfg);
308 int (*get_rmmu_info)(struct kvm *kvm, struct kvm_ppc_rmmu_info *info);
309 int (*set_smt_mode)(struct kvm *kvm, unsigned long mode,
310 unsigned long flags);
311 void (*giveup_ext)(struct kvm_vcpu *vcpu, ulong msr);
312 int (*enable_nested)(struct kvm *kvm);
313 int (*load_from_eaddr)(struct kvm_vcpu *vcpu, ulong *eaddr, void *ptr,
315 int (*store_to_eaddr)(struct kvm_vcpu *vcpu, ulong *eaddr, void *ptr,
317 int (*enable_svm)(struct kvm *kvm);
318 int (*svm_off)(struct kvm *kvm);
319 int (*enable_dawr1)(struct kvm *kvm);
320 bool (*hash_v3_possible)(void);
321 int (*create_vm_debugfs)(struct kvm *kvm);
322 int (*create_vcpu_debugfs)(struct kvm_vcpu *vcpu, struct dentry *debugfs_dentry);
325 extern struct kvmppc_ops *kvmppc_hv_ops;
326 extern struct kvmppc_ops *kvmppc_pr_ops;
328 static inline int kvmppc_get_last_inst(struct kvm_vcpu *vcpu,
329 enum instruction_fetch_type type, ppc_inst_t *inst)
331 int ret = EMULATE_DONE;
334 /* Load the instruction manually if it failed to do so in the
336 if (vcpu->arch.last_inst == KVM_INST_FETCH_FAILED)
337 ret = kvmppc_load_last_inst(vcpu, type, &vcpu->arch.last_inst);
339 /* Write fetch_failed unswapped if the fetch failed */
340 if (ret != EMULATE_DONE) {
341 *inst = ppc_inst(KVM_INST_FETCH_FAILED);
346 /* Is this a prefixed instruction? */
347 if ((vcpu->arch.last_inst >> 32) != 0) {
348 u32 prefix = vcpu->arch.last_inst >> 32;
349 u32 suffix = vcpu->arch.last_inst;
350 if (kvmppc_need_byteswap(vcpu)) {
351 prefix = swab32(prefix);
352 suffix = swab32(suffix);
354 *inst = ppc_inst_prefix(prefix, suffix);
359 fetched_inst = kvmppc_need_byteswap(vcpu) ?
360 swab32(vcpu->arch.last_inst) :
361 vcpu->arch.last_inst;
362 *inst = ppc_inst(fetched_inst);
366 static inline bool is_kvmppc_hv_enabled(struct kvm *kvm)
368 return kvm->arch.kvm_ops == kvmppc_hv_ops;
371 extern int kvmppc_hwrng_present(void);
374 * Cuts out inst bits with ordering according to spec.
375 * That means the leftmost bit is zero. All given bits are included.
377 static inline u32 kvmppc_get_field(u64 inst, int msb, int lsb)
384 mask = (1 << (lsb - msb + 1)) - 1;
385 r = (inst >> (63 - lsb)) & mask;
391 * Replaces inst bits with ordering according to spec.
393 static inline u32 kvmppc_set_field(u64 inst, int msb, int lsb, int value)
400 mask = ((1 << (lsb - msb + 1)) - 1) << (63 - lsb);
401 r = (inst & ~mask) | ((value << (63 - lsb)) & mask);
406 #define one_reg_size(id) \
407 (1ul << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT))
409 #define get_reg_val(id, reg) ({ \
410 union kvmppc_one_reg __u; \
411 switch (one_reg_size(id)) { \
412 case 4: __u.wval = (reg); break; \
413 case 8: __u.dval = (reg); break; \
420 #define set_reg_val(id, val) ({ \
422 switch (one_reg_size(id)) { \
423 case 4: __v = (val).wval; break; \
424 case 8: __v = (val).dval; break; \
430 int kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
431 int kvmppc_core_set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
433 int kvmppc_get_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
434 int kvmppc_set_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
436 int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg);
437 int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg);
438 int kvmppc_get_one_reg(struct kvm_vcpu *vcpu, u64 id, union kvmppc_one_reg *);
439 int kvmppc_set_one_reg(struct kvm_vcpu *vcpu, u64 id, union kvmppc_one_reg *);
441 void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid);
445 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
446 extern void kvm_cma_reserve(void) __init;
447 static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr)
449 paca_ptrs[cpu]->kvm_hstate.xics_phys = (void __iomem *)addr;
452 static inline void kvmppc_set_xive_tima(int cpu,
453 unsigned long phys_addr,
454 void __iomem *virt_addr)
456 paca_ptrs[cpu]->kvm_hstate.xive_tima_phys = (void __iomem *)phys_addr;
457 paca_ptrs[cpu]->kvm_hstate.xive_tima_virt = virt_addr;
460 static inline u32 kvmppc_get_xics_latch(void)
464 xirr = get_paca()->kvm_hstate.saved_xirr;
465 get_paca()->kvm_hstate.saved_xirr = 0;
470 * To avoid the need to unnecessarily exit fully to the host kernel, an IPI to
471 * a CPU thread that's running/napping inside of a guest is by default regarded
472 * as a request to wake the CPU (if needed) and continue execution within the
473 * guest, potentially to process new state like externally-generated
474 * interrupts or IPIs sent from within the guest itself (e.g. H_PROD/H_IPI).
476 * To force an exit to the host kernel, kvmppc_set_host_ipi() must be called
477 * prior to issuing the IPI to set the corresponding 'host_ipi' flag in the
478 * target CPU's PACA. To avoid unnecessary exits to the host, this flag should
479 * be immediately cleared via kvmppc_clear_host_ipi() by the IPI handler on
480 * the receiving side prior to processing the IPI work.
484 * We currently issue an smp_mb() at the beginning of kvmppc_set_host_ipi().
485 * This is to guard against sequences such as the following:
488 * X: smp_muxed_ipi_set_message():
490 * X: message[RESCHEDULE] = 1
491 * X: doorbell_global_ipi(42):
492 * X: kvmppc_set_host_ipi(42)
493 * X: ppc_msgsnd_sync()/smp_mb()
494 * X: ppc_msgsnd() -> 42
495 * 42: doorbell_exception(): // from CPU X
497 * 105: smp_muxed_ipi_set_message():
499 * // STORE DEFERRED DUE TO RE-ORDERING
500 * --105: message[CALL_FUNCTION] = 1
501 * | 105: doorbell_global_ipi(42):
502 * | 105: kvmppc_set_host_ipi(42)
503 * | 42: kvmppc_clear_host_ipi(42)
504 * | 42: smp_ipi_demux_relaxed()
505 * | 42: // returns to executing guest
506 * | // RE-ORDERED STORE COMPLETES
507 * ->105: message[CALL_FUNCTION] = 1
508 * 105: ppc_msgsnd_sync()/smp_mb()
509 * 105: ppc_msgsnd() -> 42
510 * 42: local_paca->kvm_hstate.host_ipi == 0 // IPI ignored
511 * 105: // hangs waiting on 42 to process messages/call_single_queue
513 * We also issue an smp_mb() at the end of kvmppc_clear_host_ipi(). This is
514 * to guard against sequences such as the following (as well as to create
515 * a read-side pairing with the barrier in kvmppc_set_host_ipi()):
518 * X: smp_muxed_ipi_set_message():
520 * X: message[RESCHEDULE] = 1
521 * X: doorbell_global_ipi(42):
522 * X: kvmppc_set_host_ipi(42)
523 * X: ppc_msgsnd_sync()/smp_mb()
524 * X: ppc_msgsnd() -> 42
525 * 42: doorbell_exception(): // from CPU X
527 * // STORE DEFERRED DUE TO RE-ORDERING
528 * -- 42: kvmppc_clear_host_ipi(42)
529 * | 42: smp_ipi_demux_relaxed()
530 * | 105: smp_muxed_ipi_set_message():
532 * | 105: message[CALL_FUNCTION] = 1
533 * | 105: doorbell_global_ipi(42):
534 * | 105: kvmppc_set_host_ipi(42)
535 * | // RE-ORDERED STORE COMPLETES
536 * -> 42: kvmppc_clear_host_ipi(42)
537 * 42: // returns to executing guest
538 * 105: ppc_msgsnd_sync()/smp_mb()
539 * 105: ppc_msgsnd() -> 42
540 * 42: local_paca->kvm_hstate.host_ipi == 0 // IPI ignored
541 * 105: // hangs waiting on 42 to process messages/call_single_queue
543 static inline void kvmppc_set_host_ipi(int cpu)
546 * order stores of IPI messages vs. setting of host_ipi flag
548 * pairs with the barrier in kvmppc_clear_host_ipi()
551 WRITE_ONCE(paca_ptrs[cpu]->kvm_hstate.host_ipi, 1);
554 static inline void kvmppc_clear_host_ipi(int cpu)
556 WRITE_ONCE(paca_ptrs[cpu]->kvm_hstate.host_ipi, 0);
558 * order clearing of host_ipi flag vs. processing of IPI messages
560 * pairs with the barrier in kvmppc_set_host_ipi()
565 static inline void kvmppc_fast_vcpu_kick(struct kvm_vcpu *vcpu)
567 vcpu->kvm->arch.kvm_ops->fast_vcpu_kick(vcpu);
570 extern void kvm_hv_vm_activated(void);
571 extern void kvm_hv_vm_deactivated(void);
572 extern bool kvm_hv_mode_active(void);
574 extern void kvmppc_check_need_tlb_flush(struct kvm *kvm, int pcpu);
577 static inline void __init kvm_cma_reserve(void)
580 static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr)
583 static inline void kvmppc_set_xive_tima(int cpu,
584 unsigned long phys_addr,
585 void __iomem *virt_addr)
588 static inline u32 kvmppc_get_xics_latch(void)
593 static inline void kvmppc_set_host_ipi(int cpu)
596 static inline void kvmppc_clear_host_ipi(int cpu)
599 static inline void kvmppc_fast_vcpu_kick(struct kvm_vcpu *vcpu)
604 static inline bool kvm_hv_mode_active(void) { return false; }
608 #ifdef CONFIG_PPC_PSERIES
609 static inline bool kvmhv_on_pseries(void)
611 return !cpu_has_feature(CPU_FTR_HVMODE);
614 static inline bool kvmhv_on_pseries(void)
621 #ifndef CONFIG_PPC_BOOK3S
623 static inline bool kvmhv_is_nestedv2(void)
628 static inline bool kvmhv_is_nestedv1(void)
633 static inline int kvmhv_nestedv2_reload_ptregs(struct kvm_vcpu *vcpu,
634 struct pt_regs *regs)
638 static inline int kvmhv_nestedv2_mark_dirty_ptregs(struct kvm_vcpu *vcpu,
639 struct pt_regs *regs)
644 static inline int kvmhv_nestedv2_mark_dirty(struct kvm_vcpu *vcpu, u16 iden)
649 static inline int kvmhv_nestedv2_cached_reload(struct kvm_vcpu *vcpu, u16 iden)
656 #ifdef CONFIG_KVM_XICS
657 static inline int kvmppc_xics_enabled(struct kvm_vcpu *vcpu)
659 return vcpu->arch.irq_type == KVMPPC_IRQ_XICS;
662 static inline struct kvmppc_passthru_irqmap *kvmppc_get_passthru_irqmap(
665 if (kvm && kvm_irq_bypass)
666 return kvm->arch.pimap;
670 extern void kvmppc_alloc_host_rm_ops(void);
671 extern void kvmppc_free_host_rm_ops(void);
672 extern void kvmppc_free_pimap(struct kvm *kvm);
673 extern int kvmppc_xics_rm_complete(struct kvm_vcpu *vcpu, u32 hcall);
674 extern void kvmppc_xics_free_icp(struct kvm_vcpu *vcpu);
675 extern int kvmppc_xics_hcall(struct kvm_vcpu *vcpu, u32 cmd);
676 extern int kvmppc_xive_xics_hcall(struct kvm_vcpu *vcpu, u32 req);
677 extern u64 kvmppc_xics_get_icp(struct kvm_vcpu *vcpu);
678 extern int kvmppc_xics_set_icp(struct kvm_vcpu *vcpu, u64 icpval);
679 extern int kvmppc_xics_connect_vcpu(struct kvm_device *dev,
680 struct kvm_vcpu *vcpu, u32 cpu);
681 extern void kvmppc_xics_ipi_action(void);
682 extern void kvmppc_xics_set_mapped(struct kvm *kvm, unsigned long guest_irq,
683 unsigned long host_irq);
684 extern void kvmppc_xics_clr_mapped(struct kvm *kvm, unsigned long guest_irq,
685 unsigned long host_irq);
686 extern long kvmppc_deliver_irq_passthru(struct kvm_vcpu *vcpu, __be32 xirr,
687 struct kvmppc_irq_map *irq_map,
688 struct kvmppc_passthru_irqmap *pimap,
691 extern int kvmppc_xics_set_irq(struct kvm *kvm, int irq_source_id, u32 irq,
692 int level, bool line_status);
694 extern int h_ipi_redirect;
696 static inline struct kvmppc_passthru_irqmap *kvmppc_get_passthru_irqmap(
699 static inline void kvmppc_alloc_host_rm_ops(void) {}
700 static inline void kvmppc_free_host_rm_ops(void) {}
701 static inline void kvmppc_free_pimap(struct kvm *kvm) {}
702 static inline int kvmppc_xics_rm_complete(struct kvm_vcpu *vcpu, u32 hcall)
704 static inline int kvmppc_xics_enabled(struct kvm_vcpu *vcpu)
706 static inline void kvmppc_xics_free_icp(struct kvm_vcpu *vcpu) { }
707 static inline int kvmppc_xics_hcall(struct kvm_vcpu *vcpu, u32 cmd)
709 static inline int kvmppc_xive_xics_hcall(struct kvm_vcpu *vcpu, u32 req)
713 #ifdef CONFIG_KVM_XIVE
715 * Below the first "xive" is the "eXternal Interrupt Virtualization Engine"
716 * ie. P9 new interrupt controller, while the second "xive" is the legacy
717 * "eXternal Interrupt Vector Entry" which is the configuration of an
718 * interrupt on the "xics" interrupt controller on P8 and earlier. Those
719 * two function consume or produce a legacy "XIVE" state from the
720 * new "XIVE" interrupt controller.
722 extern int kvmppc_xive_set_xive(struct kvm *kvm, u32 irq, u32 server,
724 extern int kvmppc_xive_get_xive(struct kvm *kvm, u32 irq, u32 *server,
726 extern int kvmppc_xive_int_on(struct kvm *kvm, u32 irq);
727 extern int kvmppc_xive_int_off(struct kvm *kvm, u32 irq);
729 extern int kvmppc_xive_connect_vcpu(struct kvm_device *dev,
730 struct kvm_vcpu *vcpu, u32 cpu);
731 extern void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu);
732 extern int kvmppc_xive_set_mapped(struct kvm *kvm, unsigned long guest_irq,
733 unsigned long host_irq);
734 extern int kvmppc_xive_clr_mapped(struct kvm *kvm, unsigned long guest_irq,
735 unsigned long host_irq);
736 extern u64 kvmppc_xive_get_icp(struct kvm_vcpu *vcpu);
737 extern int kvmppc_xive_set_icp(struct kvm_vcpu *vcpu, u64 icpval);
739 extern int kvmppc_xive_set_irq(struct kvm *kvm, int irq_source_id, u32 irq,
740 int level, bool line_status);
741 extern void kvmppc_xive_push_vcpu(struct kvm_vcpu *vcpu);
742 extern void kvmppc_xive_pull_vcpu(struct kvm_vcpu *vcpu);
743 extern bool kvmppc_xive_rearm_escalation(struct kvm_vcpu *vcpu);
745 static inline int kvmppc_xive_enabled(struct kvm_vcpu *vcpu)
747 return vcpu->arch.irq_type == KVMPPC_IRQ_XIVE;
750 extern int kvmppc_xive_native_connect_vcpu(struct kvm_device *dev,
751 struct kvm_vcpu *vcpu, u32 cpu);
752 extern void kvmppc_xive_native_cleanup_vcpu(struct kvm_vcpu *vcpu);
753 extern int kvmppc_xive_native_get_vp(struct kvm_vcpu *vcpu,
754 union kvmppc_one_reg *val);
755 extern int kvmppc_xive_native_set_vp(struct kvm_vcpu *vcpu,
756 union kvmppc_one_reg *val);
757 extern bool kvmppc_xive_native_supported(void);
760 static inline int kvmppc_xive_set_xive(struct kvm *kvm, u32 irq, u32 server,
761 u32 priority) { return -1; }
762 static inline int kvmppc_xive_get_xive(struct kvm *kvm, u32 irq, u32 *server,
763 u32 *priority) { return -1; }
764 static inline int kvmppc_xive_int_on(struct kvm *kvm, u32 irq) { return -1; }
765 static inline int kvmppc_xive_int_off(struct kvm *kvm, u32 irq) { return -1; }
767 static inline int kvmppc_xive_connect_vcpu(struct kvm_device *dev,
768 struct kvm_vcpu *vcpu, u32 cpu) { return -EBUSY; }
769 static inline void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu) { }
770 static inline int kvmppc_xive_set_mapped(struct kvm *kvm, unsigned long guest_irq,
771 struct irq_desc *host_desc) { return -ENODEV; }
772 static inline int kvmppc_xive_clr_mapped(struct kvm *kvm, unsigned long guest_irq,
773 struct irq_desc *host_desc) { return -ENODEV; }
774 static inline u64 kvmppc_xive_get_icp(struct kvm_vcpu *vcpu) { return 0; }
775 static inline int kvmppc_xive_set_icp(struct kvm_vcpu *vcpu, u64 icpval) { return -ENOENT; }
777 static inline int kvmppc_xive_set_irq(struct kvm *kvm, int irq_source_id, u32 irq,
778 int level, bool line_status) { return -ENODEV; }
779 static inline void kvmppc_xive_push_vcpu(struct kvm_vcpu *vcpu) { }
780 static inline void kvmppc_xive_pull_vcpu(struct kvm_vcpu *vcpu) { }
781 static inline bool kvmppc_xive_rearm_escalation(struct kvm_vcpu *vcpu) { return true; }
783 static inline int kvmppc_xive_enabled(struct kvm_vcpu *vcpu)
785 static inline int kvmppc_xive_native_connect_vcpu(struct kvm_device *dev,
786 struct kvm_vcpu *vcpu, u32 cpu) { return -EBUSY; }
787 static inline void kvmppc_xive_native_cleanup_vcpu(struct kvm_vcpu *vcpu) { }
788 static inline int kvmppc_xive_native_get_vp(struct kvm_vcpu *vcpu,
789 union kvmppc_one_reg *val)
791 static inline int kvmppc_xive_native_set_vp(struct kvm_vcpu *vcpu,
792 union kvmppc_one_reg *val)
795 #endif /* CONFIG_KVM_XIVE */
797 #if defined(CONFIG_PPC_POWERNV) && defined(CONFIG_KVM_BOOK3S_64_HANDLER)
798 static inline bool xics_on_xive(void)
800 return xive_enabled() && cpu_has_feature(CPU_FTR_HVMODE);
803 static inline bool xics_on_xive(void)
810 * Prototypes for functions called only from assembler code.
811 * Having prototypes reduces sparse errors.
813 long kvmppc_rm_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
814 unsigned long ioba, unsigned long tce);
815 long kvmppc_rm_h_put_tce_indirect(struct kvm_vcpu *vcpu,
816 unsigned long liobn, unsigned long ioba,
817 unsigned long tce_list, unsigned long npages);
818 long kvmppc_rm_h_stuff_tce(struct kvm_vcpu *vcpu,
819 unsigned long liobn, unsigned long ioba,
820 unsigned long tce_value, unsigned long npages);
821 long int kvmppc_rm_h_confer(struct kvm_vcpu *vcpu, int target,
822 unsigned int yield_count);
823 long kvmppc_rm_h_random(struct kvm_vcpu *vcpu);
824 void kvmhv_commence_exit(int trap);
825 void kvmppc_realmode_machine_check(struct kvm_vcpu *vcpu);
826 void kvmppc_subcore_enter_guest(void);
827 void kvmppc_subcore_exit_guest(void);
828 long kvmppc_realmode_hmi_handler(void);
829 long kvmppc_p9_realmode_hmi_handler(struct kvm_vcpu *vcpu);
830 long kvmppc_h_enter(struct kvm_vcpu *vcpu, unsigned long flags,
831 long pte_index, unsigned long pteh, unsigned long ptel);
832 long kvmppc_h_remove(struct kvm_vcpu *vcpu, unsigned long flags,
833 unsigned long pte_index, unsigned long avpn);
834 long kvmppc_h_bulk_remove(struct kvm_vcpu *vcpu);
835 long kvmppc_h_protect(struct kvm_vcpu *vcpu, unsigned long flags,
836 unsigned long pte_index, unsigned long avpn);
837 long kvmppc_h_read(struct kvm_vcpu *vcpu, unsigned long flags,
838 unsigned long pte_index);
839 long kvmppc_h_clear_ref(struct kvm_vcpu *vcpu, unsigned long flags,
840 unsigned long pte_index);
841 long kvmppc_h_clear_mod(struct kvm_vcpu *vcpu, unsigned long flags,
842 unsigned long pte_index);
843 long kvmppc_rm_h_page_init(struct kvm_vcpu *vcpu, unsigned long flags,
844 unsigned long dest, unsigned long src);
845 long kvmppc_hpte_hv_fault(struct kvm_vcpu *vcpu, unsigned long addr,
846 unsigned long slb_v, unsigned int status, bool data);
847 void kvmppc_guest_entry_inject_int(struct kvm_vcpu *vcpu);
850 * Host-side operations we want to set up while running in real
851 * mode in the guest operating on the xics.
852 * Currently only VCPU wakeup is supported.
855 union kvmppc_rm_state {
863 struct kvmppc_host_rm_core {
864 union kvmppc_rm_state rm_state;
869 struct kvmppc_host_rm_ops {
870 struct kvmppc_host_rm_core *rm_core;
871 void (*vcpu_kick)(struct kvm_vcpu *vcpu);
874 extern struct kvmppc_host_rm_ops *kvmppc_host_rm_ops_hv;
876 static inline unsigned long kvmppc_get_epr(struct kvm_vcpu *vcpu)
878 #ifdef CONFIG_KVM_BOOKE_HV
879 return mfspr(SPRN_GEPR);
880 #elif defined(CONFIG_BOOKE)
881 return vcpu->arch.epr;
887 static inline void kvmppc_set_epr(struct kvm_vcpu *vcpu, u32 epr)
889 #ifdef CONFIG_KVM_BOOKE_HV
890 mtspr(SPRN_GEPR, epr);
891 #elif defined(CONFIG_BOOKE)
892 vcpu->arch.epr = epr;
896 #ifdef CONFIG_KVM_MPIC
898 void kvmppc_mpic_set_epr(struct kvm_vcpu *vcpu);
899 int kvmppc_mpic_connect_vcpu(struct kvm_device *dev, struct kvm_vcpu *vcpu,
901 void kvmppc_mpic_disconnect_vcpu(struct openpic *opp, struct kvm_vcpu *vcpu);
905 static inline void kvmppc_mpic_set_epr(struct kvm_vcpu *vcpu)
909 static inline int kvmppc_mpic_connect_vcpu(struct kvm_device *dev,
910 struct kvm_vcpu *vcpu, u32 cpu)
915 static inline void kvmppc_mpic_disconnect_vcpu(struct openpic *opp,
916 struct kvm_vcpu *vcpu)
920 #endif /* CONFIG_KVM_MPIC */
922 int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
923 struct kvm_config_tlb *cfg);
924 int kvm_vcpu_ioctl_dirty_tlb(struct kvm_vcpu *vcpu,
925 struct kvm_dirty_tlb *cfg);
927 long kvmppc_alloc_lpid(void);
928 void kvmppc_free_lpid(long lpid);
929 void kvmppc_init_lpid(unsigned long nr_lpids);
931 static inline void kvmppc_mmu_flush_icache(kvm_pfn_t pfn)
935 * We can only access pages that the kernel maps
936 * as memory. Bail out for unmapped ones.
941 /* Clear i-cache for new pages */
942 folio = page_folio(pfn_to_page(pfn));
943 if (!test_bit(PG_dcache_clean, &folio->flags)) {
944 flush_dcache_icache_folio(folio);
945 set_bit(PG_dcache_clean, &folio->flags);
950 * Shared struct helpers. The shared struct can be little or big endian,
951 * depending on the guest endianness. So expose helpers to all of them.
953 static inline bool kvmppc_shared_big_endian(struct kvm_vcpu *vcpu)
955 #if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_KVM_BOOK3S_PR_POSSIBLE)
956 /* Only Book3S_64 PR supports bi-endian for now */
957 return vcpu->arch.shared_big_endian;
958 #elif defined(CONFIG_PPC_BOOK3S_64) && defined(__LITTLE_ENDIAN__)
959 /* Book3s_64 HV on little endian is always little endian */
966 #define KVMPPC_BOOKE_HV_SPRNG_ACCESSOR_GET(reg, bookehv_spr) \
967 static inline ulong kvmppc_get_##reg(struct kvm_vcpu *vcpu) \
969 return mfspr(bookehv_spr); \
972 #define KVMPPC_BOOKE_HV_SPRNG_ACCESSOR_SET(reg, bookehv_spr) \
973 static inline void kvmppc_set_##reg(struct kvm_vcpu *vcpu, ulong val) \
975 mtspr(bookehv_spr, val); \
978 #define KVMPPC_VCPU_SHARED_REGS_ACCESSOR_GET(reg, size, iden) \
979 static inline u##size kvmppc_get_##reg(struct kvm_vcpu *vcpu) \
982 WARN_ON(kvmhv_nestedv2_cached_reload(vcpu, iden) < 0); \
983 if (kvmppc_shared_big_endian(vcpu)) \
984 return be##size##_to_cpu((__be##size __force)vcpu->arch.shared->reg); \
986 return le##size##_to_cpu((__le##size __force)vcpu->arch.shared->reg); \
989 #define KVMPPC_VCPU_SHARED_REGS_ACCESSOR_SET(reg, size, iden) \
990 static inline void kvmppc_set_##reg(struct kvm_vcpu *vcpu, u##size val) \
992 if (kvmppc_shared_big_endian(vcpu)) \
993 vcpu->arch.shared->reg = (u##size __force)cpu_to_be##size(val); \
995 vcpu->arch.shared->reg = (u##size __force)cpu_to_le##size(val); \
998 kvmhv_nestedv2_mark_dirty(vcpu, iden); \
1001 #define KVMPPC_VCPU_SHARED_REGS_ACCESSOR(reg, size, iden) \
1002 KVMPPC_VCPU_SHARED_REGS_ACCESSOR_GET(reg, size, iden) \
1003 KVMPPC_VCPU_SHARED_REGS_ACCESSOR_SET(reg, size, iden) \
1005 #define KVMPPC_BOOKE_HV_SPRNG_ACCESSOR(reg, bookehv_spr) \
1006 KVMPPC_BOOKE_HV_SPRNG_ACCESSOR_GET(reg, bookehv_spr) \
1007 KVMPPC_BOOKE_HV_SPRNG_ACCESSOR_SET(reg, bookehv_spr) \
1009 #ifdef CONFIG_KVM_BOOKE_HV
1011 #define KVMPPC_BOOKE_HV_SPRNG_OR_VCPU_SHARED_REGS_ACCESSOR(reg, size, bookehv_spr, iden) \
1012 KVMPPC_BOOKE_HV_SPRNG_ACCESSOR(reg, bookehv_spr) \
1016 #define KVMPPC_BOOKE_HV_SPRNG_OR_VCPU_SHARED_REGS_ACCESSOR(reg, size, bookehv_spr, iden) \
1017 KVMPPC_VCPU_SHARED_REGS_ACCESSOR(reg, size, iden) \
1021 KVMPPC_VCPU_SHARED_REGS_ACCESSOR(critical, 64, 0)
1022 KVMPPC_BOOKE_HV_SPRNG_OR_VCPU_SHARED_REGS_ACCESSOR(sprg0, 64, SPRN_GSPRG0, KVMPPC_GSID_SPRG0)
1023 KVMPPC_BOOKE_HV_SPRNG_OR_VCPU_SHARED_REGS_ACCESSOR(sprg1, 64, SPRN_GSPRG1, KVMPPC_GSID_SPRG1)
1024 KVMPPC_BOOKE_HV_SPRNG_OR_VCPU_SHARED_REGS_ACCESSOR(sprg2, 64, SPRN_GSPRG2, KVMPPC_GSID_SPRG2)
1025 KVMPPC_BOOKE_HV_SPRNG_OR_VCPU_SHARED_REGS_ACCESSOR(sprg3, 64, SPRN_GSPRG3, KVMPPC_GSID_SPRG3)
1026 KVMPPC_BOOKE_HV_SPRNG_OR_VCPU_SHARED_REGS_ACCESSOR(srr0, 64, SPRN_GSRR0, KVMPPC_GSID_SRR0)
1027 KVMPPC_BOOKE_HV_SPRNG_OR_VCPU_SHARED_REGS_ACCESSOR(srr1, 64, SPRN_GSRR1, KVMPPC_GSID_SRR1)
1028 KVMPPC_BOOKE_HV_SPRNG_OR_VCPU_SHARED_REGS_ACCESSOR(dar, 64, SPRN_GDEAR, KVMPPC_GSID_DAR)
1029 KVMPPC_BOOKE_HV_SPRNG_OR_VCPU_SHARED_REGS_ACCESSOR(esr, 64, SPRN_GESR, 0)
1030 KVMPPC_VCPU_SHARED_REGS_ACCESSOR_GET(msr, 64, KVMPPC_GSID_MSR)
1031 static inline void kvmppc_set_msr_fast(struct kvm_vcpu *vcpu, u64 val)
1033 if (kvmppc_shared_big_endian(vcpu))
1034 vcpu->arch.shared->msr = cpu_to_be64(val);
1036 vcpu->arch.shared->msr = cpu_to_le64(val);
1037 kvmhv_nestedv2_mark_dirty(vcpu, KVMPPC_GSID_MSR);
1039 KVMPPC_VCPU_SHARED_REGS_ACCESSOR(dsisr, 32, KVMPPC_GSID_DSISR)
1040 KVMPPC_VCPU_SHARED_REGS_ACCESSOR(int_pending, 32, 0)
1041 KVMPPC_VCPU_SHARED_REGS_ACCESSOR(sprg4, 64, 0)
1042 KVMPPC_VCPU_SHARED_REGS_ACCESSOR(sprg5, 64, 0)
1043 KVMPPC_VCPU_SHARED_REGS_ACCESSOR(sprg6, 64, 0)
1044 KVMPPC_VCPU_SHARED_REGS_ACCESSOR(sprg7, 64, 0)
1046 static inline u32 kvmppc_get_sr(struct kvm_vcpu *vcpu, int nr)
1048 if (kvmppc_shared_big_endian(vcpu))
1049 return be32_to_cpu(vcpu->arch.shared->sr[nr]);
1051 return le32_to_cpu(vcpu->arch.shared->sr[nr]);
1054 static inline void kvmppc_set_sr(struct kvm_vcpu *vcpu, int nr, u32 val)
1056 if (kvmppc_shared_big_endian(vcpu))
1057 vcpu->arch.shared->sr[nr] = cpu_to_be32(val);
1059 vcpu->arch.shared->sr[nr] = cpu_to_le32(val);
1063 * Please call after prepare_to_enter. This function puts the lazy ee and irq
1064 * disabled tracking state back to normal mode, without actually enabling
1067 static inline void kvmppc_fix_ee_before_entry(void)
1069 trace_hardirqs_on();
1073 * To avoid races, the caller must have gone directly from having
1074 * interrupts fully-enabled to hard-disabled.
1076 WARN_ON(local_paca->irq_happened != PACA_IRQ_HARD_DIS);
1078 /* Only need to enable IRQs by hard enabling them after this */
1079 local_paca->irq_happened = 0;
1080 irq_soft_mask_set(IRQS_ENABLED);
1084 static inline void kvmppc_fix_ee_after_exit(void)
1087 /* Only need to enable IRQs by hard enabling them after this */
1088 local_paca->irq_happened = PACA_IRQ_HARD_DIS;
1089 irq_soft_mask_set(IRQS_ALL_DISABLED);
1092 trace_hardirqs_off();
1096 static inline ulong kvmppc_get_ea_indexed(struct kvm_vcpu *vcpu, int ra, int rb)
1099 ulong msr_64bit = 0;
1101 ea = kvmppc_get_gpr(vcpu, rb);
1103 ea += kvmppc_get_gpr(vcpu, ra);
1105 #if defined(CONFIG_PPC_BOOK3E_64)
1107 #elif defined(CONFIG_PPC_BOOK3S_64)
1111 if (!(kvmppc_get_msr(vcpu) & msr_64bit))
1117 extern void xics_wake_cpu(int cpu);
1119 #endif /* __POWERPC_KVM_PPC_H__ */