Thomas Gleixner | d94d71c | 2019-05-29 07:12:40 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 2 | /* |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 3 | * |
| 4 | * Copyright IBM Corp. 2008 |
| 5 | * |
| 6 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> |
| 7 | */ |
| 8 | |
| 9 | #ifndef __POWERPC_KVM_PPC_H__ |
| 10 | #define __POWERPC_KVM_PPC_H__ |
| 11 | |
| 12 | /* This file exists just so we can dereference kvm_vcpu, avoiding nested header |
| 13 | * dependencies. */ |
| 14 | |
| 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> |
Paul Mackerras | a136a8b | 2012-09-25 20:31:56 +0000 | [diff] [blame] | 20 | #include <linux/bug.h> |
Alexander Graf | 1c0006d | 2010-01-15 14:49:12 +0100 | [diff] [blame] | 21 | #ifdef CONFIG_PPC_BOOK3S |
| 22 | #include <asm/kvm_book3s.h> |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 23 | #else |
| 24 | #include <asm/kvm_booke.h> |
Alexander Graf | 1c0006d | 2010-01-15 14:49:12 +0100 | [diff] [blame] | 25 | #endif |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 26 | #ifdef CONFIG_KVM_BOOK3S_64_HANDLER |
| 27 | #include <asm/paca.h> |
Paul Mackerras | 03f9533 | 2019-02-04 22:07:20 +1100 | [diff] [blame] | 28 | #include <asm/xive.h> |
| 29 | #include <asm/cpu_has_feature.h> |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 30 | #endif |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 31 | |
Madhavan Srinivasan | a59c1d9 | 2014-09-09 22:37:35 +0530 | [diff] [blame] | 32 | /* |
| 33 | * KVMPPC_INST_SW_BREAKPOINT is debug Instruction |
| 34 | * for supporting software breakpoint. |
| 35 | */ |
| 36 | #define KVMPPC_INST_SW_BREAKPOINT 0x00dddd00 |
| 37 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 38 | enum emulation_result { |
| 39 | EMULATE_DONE, /* no further processing */ |
| 40 | EMULATE_DO_MMIO, /* kvm_run filled with MMIO request */ |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 41 | EMULATE_FAIL, /* can't emulate this instruction */ |
Alexander Graf | 37f5bca | 2010-02-19 11:00:31 +0100 | [diff] [blame] | 42 | EMULATE_AGAIN, /* something went wrong. go again */ |
Bharat Bhushan | c402a3f | 2013-04-08 00:32:13 +0000 | [diff] [blame] | 43 | EMULATE_EXIT_USER, /* emulation requires exit to user-space */ |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 44 | }; |
| 45 | |
Simon Guo | 7092360 | 2018-05-21 13:24:21 +0800 | [diff] [blame] | 46 | enum instruction_fetch_type { |
Mihai Caraman | 51f0472 | 2014-07-23 19:06:21 +0300 | [diff] [blame] | 47 | INST_GENERIC, |
| 48 | INST_SC, /* system call */ |
| 49 | }; |
| 50 | |
Alexander Graf | 7d15c06f | 2014-06-20 13:52:36 +0200 | [diff] [blame] | 51 | enum xlate_instdata { |
| 52 | XLATE_INST, /* translate instruction address */ |
| 53 | XLATE_DATA /* translate data address */ |
| 54 | }; |
| 55 | |
| 56 | enum xlate_readwrite { |
| 57 | XLATE_READ, /* check for read permissions */ |
| 58 | XLATE_WRITE /* check for write permissions */ |
| 59 | }; |
| 60 | |
Tianjia Zhang | 8c99d34 | 2020-04-27 12:35:11 +0800 | [diff] [blame] | 61 | extern int kvmppc_vcpu_run(struct kvm_vcpu *vcpu); |
Tianjia Zhang | 7ec21d9 | 2020-06-23 21:14:16 +0800 | [diff] [blame] | 62 | extern int __kvmppc_vcpu_run(struct kvm_vcpu *vcpu); |
Alexander Graf | 29eb61b | 2009-10-30 05:47:07 +0000 | [diff] [blame] | 63 | extern void kvmppc_handler_highmem(void); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 64 | |
| 65 | extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu); |
Tianjia Zhang | 8c99d34 | 2020-04-27 12:35:11 +0800 | [diff] [blame] | 66 | extern int kvmppc_handle_load(struct kvm_vcpu *vcpu, |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 67 | unsigned int rt, unsigned int bytes, |
Cédric Le Goater | 7360177 | 2014-01-09 11:51:16 +0100 | [diff] [blame] | 68 | int is_default_endian); |
Tianjia Zhang | 8c99d34 | 2020-04-27 12:35:11 +0800 | [diff] [blame] | 69 | extern int kvmppc_handle_loads(struct kvm_vcpu *vcpu, |
Alexander Graf | 3587d53 | 2010-02-19 11:00:30 +0100 | [diff] [blame] | 70 | unsigned int rt, unsigned int bytes, |
Cédric Le Goater | 7360177 | 2014-01-09 11:51:16 +0100 | [diff] [blame] | 71 | int is_default_endian); |
Tianjia Zhang | 8c99d34 | 2020-04-27 12:35:11 +0800 | [diff] [blame] | 72 | extern int kvmppc_handle_vsx_load(struct kvm_vcpu *vcpu, |
Bin Lu | 6f63e81 | 2017-02-21 21:12:36 +0800 | [diff] [blame] | 73 | unsigned int rt, unsigned int bytes, |
| 74 | int is_default_endian, int mmio_sign_extend); |
Tianjia Zhang | 8c99d34 | 2020-04-27 12:35:11 +0800 | [diff] [blame] | 75 | extern int kvmppc_handle_vmx_load(struct kvm_vcpu *vcpu, |
Simon Guo | acc9eb9 | 2018-05-21 13:24:26 +0800 | [diff] [blame] | 76 | unsigned int rt, unsigned int bytes, int is_default_endian); |
Tianjia Zhang | 8c99d34 | 2020-04-27 12:35:11 +0800 | [diff] [blame] | 77 | extern int kvmppc_handle_vmx_store(struct kvm_vcpu *vcpu, |
Simon Guo | acc9eb9 | 2018-05-21 13:24:26 +0800 | [diff] [blame] | 78 | unsigned int rs, unsigned int bytes, int is_default_endian); |
Tianjia Zhang | 8c99d34 | 2020-04-27 12:35:11 +0800 | [diff] [blame] | 79 | extern int kvmppc_handle_store(struct kvm_vcpu *vcpu, |
Cédric Le Goater | 7360177 | 2014-01-09 11:51:16 +0100 | [diff] [blame] | 80 | u64 val, unsigned int bytes, |
| 81 | int is_default_endian); |
Tianjia Zhang | 8c99d34 | 2020-04-27 12:35:11 +0800 | [diff] [blame] | 82 | extern int kvmppc_handle_vsx_store(struct kvm_vcpu *vcpu, |
Bin Lu | 6f63e81 | 2017-02-21 21:12:36 +0800 | [diff] [blame] | 83 | int rs, unsigned int bytes, |
| 84 | int is_default_endian); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 85 | |
Mihai Caraman | 51f0472 | 2014-07-23 19:06:21 +0300 | [diff] [blame] | 86 | extern int kvmppc_load_last_inst(struct kvm_vcpu *vcpu, |
Simon Guo | 7092360 | 2018-05-21 13:24:21 +0800 | [diff] [blame] | 87 | enum instruction_fetch_type type, u32 *inst); |
Mihai Caraman | 51f0472 | 2014-07-23 19:06:21 +0300 | [diff] [blame] | 88 | |
Alexander Graf | 35c4a73 | 2014-06-20 13:58:16 +0200 | [diff] [blame] | 89 | extern int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, |
| 90 | bool data); |
| 91 | extern int kvmppc_st(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, |
| 92 | bool data); |
Tianjia Zhang | 8c99d34 | 2020-04-27 12:35:11 +0800 | [diff] [blame] | 93 | extern int kvmppc_emulate_instruction(struct kvm_vcpu *vcpu); |
Alexander Graf | d69614a | 2014-06-18 14:53:49 +0200 | [diff] [blame] | 94 | extern int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu); |
Tianjia Zhang | 8c99d34 | 2020-04-27 12:35:11 +0800 | [diff] [blame] | 95 | extern int kvmppc_emulate_mmio(struct kvm_vcpu *vcpu); |
Hollis Blanchard | 75f74f0 | 2008-11-05 09:36:16 -0600 | [diff] [blame] | 96 | extern void kvmppc_emulate_dec(struct kvm_vcpu *vcpu); |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 97 | extern u32 kvmppc_get_dec(struct kvm_vcpu *vcpu, u64 tb); |
Mihai Caraman | d02d4d1 | 2014-09-01 17:19:56 +0300 | [diff] [blame] | 98 | extern void kvmppc_decrementer_func(struct kvm_vcpu *vcpu); |
Alexander Graf | af8f38b | 2011-08-10 13:57:08 +0200 | [diff] [blame] | 99 | extern int kvmppc_sanity_check(struct kvm_vcpu *vcpu); |
Bharat Bhushan | f61c94b | 2012-08-08 20:38:19 +0000 | [diff] [blame] | 100 | extern int kvmppc_subarch_vcpu_init(struct kvm_vcpu *vcpu); |
| 101 | extern void kvmppc_subarch_vcpu_uninit(struct kvm_vcpu *vcpu); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 102 | |
Hollis Blanchard | ecc0981 | 2009-01-03 16:22:59 -0600 | [diff] [blame] | 103 | /* Core-specific hooks */ |
| 104 | |
Hollis Blanchard | 8916861 | 2008-12-02 15:51:53 -0600 | [diff] [blame] | 105 | extern void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gpa_t gpaddr, |
Hollis Blanchard | 7924bd4 | 2008-12-02 15:51:55 -0600 | [diff] [blame] | 106 | unsigned int gtlb_idx); |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 107 | extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode); |
Hollis Blanchard | 49dd2c4 | 2008-07-25 13:54:53 -0500 | [diff] [blame] | 108 | extern void kvmppc_mmu_switch_pid(struct kvm_vcpu *vcpu, u32 pid); |
Hollis Blanchard | fa86b8d | 2009-01-03 16:23:03 -0600 | [diff] [blame] | 109 | extern int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr); |
| 110 | extern int kvmppc_mmu_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr); |
Hollis Blanchard | be8d1ca | 2009-01-03 16:23:02 -0600 | [diff] [blame] | 111 | extern gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, unsigned int gtlb_index, |
| 112 | gva_t eaddr); |
Hollis Blanchard | b52a638 | 2009-01-03 16:23:11 -0600 | [diff] [blame] | 113 | extern void kvmppc_mmu_dtlb_miss(struct kvm_vcpu *vcpu); |
| 114 | extern void kvmppc_mmu_itlb_miss(struct kvm_vcpu *vcpu); |
Alexander Graf | 7d15c06f | 2014-06-20 13:52:36 +0200 | [diff] [blame] | 115 | extern int kvmppc_xlate(struct kvm_vcpu *vcpu, ulong eaddr, |
| 116 | enum xlate_instdata xlid, enum xlate_readwrite xlrw, |
| 117 | struct kvmppc_pte *pte); |
Hollis Blanchard | 9dd921c | 2008-11-05 09:36:14 -0600 | [diff] [blame] | 118 | |
Sean Christopherson | ff030fd | 2019-12-18 13:55:00 -0800 | [diff] [blame] | 119 | extern int kvmppc_core_vcpu_create(struct kvm_vcpu *vcpu); |
Hollis Blanchard | db93f57 | 2008-11-05 09:36:18 -0600 | [diff] [blame] | 120 | extern void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu); |
Hollis Blanchard | 5cbb510 | 2008-11-05 09:36:17 -0600 | [diff] [blame] | 121 | extern int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu); |
Hollis Blanchard | 9dd921c | 2008-11-05 09:36:14 -0600 | [diff] [blame] | 122 | extern int kvmppc_core_check_processor_compat(void); |
Hollis Blanchard | 5cbb510 | 2008-11-05 09:36:17 -0600 | [diff] [blame] | 123 | extern int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu, |
| 124 | struct kvm_translation *tr); |
Hollis Blanchard | 9dd921c | 2008-11-05 09:36:14 -0600 | [diff] [blame] | 125 | |
| 126 | extern void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu); |
| 127 | extern void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu); |
| 128 | |
Alexander Graf | a8e4ef8 | 2012-02-16 14:07:37 +0000 | [diff] [blame] | 129 | extern int kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu); |
Hollis Blanchard | 9dd921c | 2008-11-05 09:36:14 -0600 | [diff] [blame] | 130 | extern int kvmppc_core_pending_dec(struct kvm_vcpu *vcpu); |
Paul Mackerras | 884dfb7 | 2019-02-21 13:38:49 +1100 | [diff] [blame] | 131 | extern void kvmppc_core_queue_machine_check(struct kvm_vcpu *vcpu, ulong flags); |
Nicholas Piggin | 9dc2bab | 2021-05-28 19:07:33 +1000 | [diff] [blame] | 132 | extern void kvmppc_core_queue_syscall(struct kvm_vcpu *vcpu); |
Alexander Graf | 25a8a02 | 2010-01-08 02:58:07 +0100 | [diff] [blame] | 133 | extern void kvmppc_core_queue_program(struct kvm_vcpu *vcpu, ulong flags); |
Paul Mackerras | 307d927 | 2017-03-22 21:02:08 +1100 | [diff] [blame] | 134 | extern void kvmppc_core_queue_fpunavail(struct kvm_vcpu *vcpu); |
| 135 | extern void kvmppc_core_queue_vec_unavail(struct kvm_vcpu *vcpu); |
| 136 | extern void kvmppc_core_queue_vsx_unavail(struct kvm_vcpu *vcpu); |
Hollis Blanchard | 9dd921c | 2008-11-05 09:36:14 -0600 | [diff] [blame] | 137 | extern void kvmppc_core_queue_dec(struct kvm_vcpu *vcpu); |
Alexander Graf | 7706664d | 2009-12-21 20:21:24 +0100 | [diff] [blame] | 138 | extern void kvmppc_core_dequeue_dec(struct kvm_vcpu *vcpu); |
Hollis Blanchard | 9dd921c | 2008-11-05 09:36:14 -0600 | [diff] [blame] | 139 | extern void kvmppc_core_queue_external(struct kvm_vcpu *vcpu, |
| 140 | struct kvm_interrupt *irq); |
Paul Mackerras | 4fe27d2 | 2013-02-14 14:00:25 +0000 | [diff] [blame] | 141 | extern void kvmppc_core_dequeue_external(struct kvm_vcpu *vcpu); |
Alexander Graf | 8de1201 | 2014-06-18 21:56:55 +0200 | [diff] [blame] | 142 | extern void kvmppc_core_queue_dtlb_miss(struct kvm_vcpu *vcpu, ulong dear_flags, |
| 143 | ulong esr_flags); |
| 144 | extern void kvmppc_core_queue_data_storage(struct kvm_vcpu *vcpu, |
| 145 | ulong dear_flags, |
| 146 | ulong esr_flags); |
| 147 | extern void kvmppc_core_queue_itlb_miss(struct kvm_vcpu *vcpu); |
| 148 | extern void kvmppc_core_queue_inst_storage(struct kvm_vcpu *vcpu, |
| 149 | ulong esr_flags); |
Alexander Graf | 862d31f | 2012-07-31 00:19:50 +0200 | [diff] [blame] | 150 | extern void kvmppc_core_flush_tlb(struct kvm_vcpu *vcpu); |
Alexander Graf | 7c973a2 | 2012-08-13 12:50:35 +0200 | [diff] [blame] | 151 | extern int kvmppc_core_check_requests(struct kvm_vcpu *vcpu); |
Hollis Blanchard | 75f74f0 | 2008-11-05 09:36:16 -0600 | [diff] [blame] | 152 | |
Hollis Blanchard | db93f57 | 2008-11-05 09:36:18 -0600 | [diff] [blame] | 153 | extern int kvmppc_booke_init(void); |
| 154 | extern void kvmppc_booke_exit(void); |
| 155 | |
Hollis Blanchard | c30f8a6 | 2008-11-24 11:37:38 -0600 | [diff] [blame] | 156 | extern void kvmppc_core_destroy_mmu(struct kvm_vcpu *vcpu); |
Alexander Graf | 2a342ed | 2010-07-29 14:47:48 +0200 | [diff] [blame] | 157 | extern int kvmppc_kvm_pv(struct kvm_vcpu *vcpu); |
Scott Wood | a4cd8b2 | 2011-06-14 18:34:41 -0500 | [diff] [blame] | 158 | extern void kvmppc_map_magic(struct kvm_vcpu *vcpu); |
Hollis Blanchard | c30f8a6 | 2008-11-24 11:37:38 -0600 | [diff] [blame] | 159 | |
David Gibson | aae0777 | 2016-12-20 16:49:02 +1100 | [diff] [blame] | 160 | extern int kvmppc_allocate_hpt(struct kvm_hpt_info *info, u32 order); |
| 161 | extern void kvmppc_set_hpt(struct kvm *kvm, struct kvm_hpt_info *info); |
David Gibson | f98a8bf | 2016-12-20 16:49:03 +1100 | [diff] [blame] | 162 | extern long kvmppc_alloc_reset_hpt(struct kvm *kvm, int order); |
David Gibson | aae0777 | 2016-12-20 16:49:02 +1100 | [diff] [blame] | 163 | extern void kvmppc_free_hpt(struct kvm_hpt_info *info); |
Paul Mackerras | 18c3640 | 2017-09-13 16:00:10 +1000 | [diff] [blame] | 164 | extern void kvmppc_rmap_reset(struct kvm *kvm); |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame] | 165 | extern long kvmppc_prepare_vrma(struct kvm *kvm, |
| 166 | struct kvm_userspace_memory_region *mem); |
Paul Mackerras | c77162d | 2011-12-12 12:31:00 +0000 | [diff] [blame] | 167 | extern void kvmppc_map_vrma(struct kvm_vcpu *vcpu, |
Paul Mackerras | da9d1d7 | 2011-12-12 12:31:41 +0000 | [diff] [blame] | 168 | struct kvm_memory_slot *memslot, unsigned long porder); |
Paul Mackerras | a8606e2 | 2011-06-29 00:22:05 +0000 | [diff] [blame] | 169 | extern int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu); |
Alexey Kardashevskiy | 121f80b | 2017-03-22 15:21:56 +1100 | [diff] [blame] | 170 | extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd, |
| 171 | struct iommu_group *grp); |
| 172 | extern void kvm_spapr_tce_release_iommu_group(struct kvm *kvm, |
| 173 | struct iommu_group *grp); |
Paul Mackerras | 18c3640 | 2017-09-13 16:00:10 +1000 | [diff] [blame] | 174 | extern int kvmppc_switch_mmu_to_hpt(struct kvm *kvm); |
| 175 | extern int kvmppc_switch_mmu_to_radix(struct kvm *kvm); |
Paul Mackerras | ded13fc | 2017-11-22 14:38:53 +1100 | [diff] [blame] | 176 | extern void kvmppc_setup_partition_table(struct kvm *kvm); |
Benjamin Herrenschmidt | bc5ad3f | 2013-04-17 20:30:26 +0000 | [diff] [blame] | 177 | |
David Gibson | 54738c0 | 2011-06-29 00:22:41 +0000 | [diff] [blame] | 178 | extern long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, |
Alexey Kardashevskiy | 58ded42 | 2016-03-01 17:54:40 +1100 | [diff] [blame] | 179 | struct kvm_create_spapr_tce_64 *args); |
Alexey Kardashevskiy | d3695aa | 2016-02-15 12:55:09 +1100 | [diff] [blame] | 180 | extern struct kvmppc_spapr_tce_table *kvmppc_find_table( |
Alexey Kardashevskiy | 503bfcb | 2017-03-22 15:21:53 +1100 | [diff] [blame] | 181 | struct kvm *kvm, unsigned long liobn); |
Alexey Kardashevskiy | b1af23d | 2017-03-22 15:21:55 +1100 | [diff] [blame] | 182 | #define kvmppc_ioba_validate(stt, ioba, npages) \ |
| 183 | (iommu_tce_check_ioba((stt)->page_shift, (stt)->offset, \ |
| 184 | (stt)->size, (ioba), (npages)) ? \ |
| 185 | H_PARAMETER : H_SUCCESS) |
Benjamin Herrenschmidt | f31e65e | 2012-03-15 21:58:34 +0000 | [diff] [blame] | 186 | extern long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn, |
| 187 | unsigned long ioba, unsigned long tce); |
Alexey Kardashevskiy | d3695aa | 2016-02-15 12:55:09 +1100 | [diff] [blame] | 188 | extern long kvmppc_h_put_tce_indirect(struct kvm_vcpu *vcpu, |
| 189 | unsigned long liobn, unsigned long ioba, |
| 190 | unsigned long tce_list, unsigned long npages); |
| 191 | extern long kvmppc_h_stuff_tce(struct kvm_vcpu *vcpu, |
| 192 | unsigned long liobn, unsigned long ioba, |
| 193 | unsigned long tce_value, unsigned long npages); |
Laurent Dufour | 69e9fbb2 | 2014-02-21 16:31:10 +0100 | [diff] [blame] | 194 | extern long kvmppc_h_get_tce(struct kvm_vcpu *vcpu, unsigned long liobn, |
| 195 | unsigned long ioba); |
David Gibson | db9a290 | 2016-12-20 16:48:59 +1100 | [diff] [blame] | 196 | extern struct page *kvm_alloc_hpt_cma(unsigned long nr_pages); |
| 197 | extern void kvm_free_hpt_cma(struct page *page, unsigned long nr_pages); |
Paul Mackerras | f9e0554 | 2011-06-29 00:19:22 +0000 | [diff] [blame] | 198 | extern int kvmppc_core_init_vm(struct kvm *kvm); |
| 199 | extern void kvmppc_core_destroy_vm(struct kvm *kvm); |
Aneesh Kumar K.V | 5587027 | 2013-10-07 22:18:00 +0530 | [diff] [blame] | 200 | extern void kvmppc_core_free_memslot(struct kvm *kvm, |
Sean Christopherson | e96c81e | 2020-02-18 13:07:27 -0800 | [diff] [blame] | 201 | struct kvm_memory_slot *slot); |
Paul Mackerras | f9e0554 | 2011-06-29 00:19:22 +0000 | [diff] [blame] | 202 | extern int kvmppc_core_prepare_memory_region(struct kvm *kvm, |
Paul Mackerras | a66b48c | 2012-09-11 13:27:46 +0000 | [diff] [blame] | 203 | struct kvm_memory_slot *memslot, |
Sean Christopherson | 82307e6 | 2020-02-18 13:07:18 -0800 | [diff] [blame] | 204 | const struct kvm_userspace_memory_region *mem, |
| 205 | enum kvm_mr_change change); |
Paul Mackerras | f9e0554 | 2011-06-29 00:19:22 +0000 | [diff] [blame] | 206 | extern void kvmppc_core_commit_memory_region(struct kvm *kvm, |
Paolo Bonzini | 09170a4 | 2015-05-18 13:59:39 +0200 | [diff] [blame] | 207 | const struct kvm_userspace_memory_region *mem, |
Paolo Bonzini | f36f3f2 | 2015-05-18 13:20:23 +0200 | [diff] [blame] | 208 | const struct kvm_memory_slot *old, |
Bharata B Rao | f032b73 | 2018-12-12 15:15:30 +1100 | [diff] [blame] | 209 | const struct kvm_memory_slot *new, |
| 210 | enum kvm_mr_change change); |
Benjamin Herrenschmidt | 5b74716 | 2012-04-26 19:43:42 +0000 | [diff] [blame] | 211 | extern int kvm_vm_ioctl_get_smmu_info(struct kvm *kvm, |
| 212 | struct kvm_ppc_smmu_info *info); |
Paul Mackerras | dfe49db | 2012-09-11 13:28:18 +0000 | [diff] [blame] | 213 | extern void kvmppc_core_flush_memslot(struct kvm *kvm, |
| 214 | struct kvm_memory_slot *memslot); |
Paul Mackerras | f9e0554 | 2011-06-29 00:19:22 +0000 | [diff] [blame] | 215 | |
Scott Wood | d30f6e4 | 2011-12-20 15:34:43 +0000 | [diff] [blame] | 216 | extern int kvmppc_bookehv_init(void); |
| 217 | extern void kvmppc_bookehv_exit(void); |
| 218 | |
Alexander Graf | 03d25c5 | 2012-08-10 12:28:50 +0200 | [diff] [blame] | 219 | extern int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu); |
| 220 | |
Paul Mackerras | a293292 | 2012-11-19 22:57:20 +0000 | [diff] [blame] | 221 | extern int kvm_vm_ioctl_get_htab_fd(struct kvm *kvm, struct kvm_get_htab_fd *); |
David Gibson | 5e98596 | 2016-12-20 16:49:05 +1100 | [diff] [blame] | 222 | extern long kvm_vm_ioctl_resize_hpt_prepare(struct kvm *kvm, |
| 223 | struct kvm_ppc_resize_hpt *rhpt); |
| 224 | extern long kvm_vm_ioctl_resize_hpt_commit(struct kvm *kvm, |
| 225 | struct kvm_ppc_resize_hpt *rhpt); |
Paul Mackerras | a293292 | 2012-11-19 22:57:20 +0000 | [diff] [blame] | 226 | |
Scott Wood | 5df554ad | 2013-04-12 14:08:46 +0000 | [diff] [blame] | 227 | int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq); |
| 228 | |
Michael Ellerman | 8e591cb | 2013-04-17 20:30:00 +0000 | [diff] [blame] | 229 | extern int kvm_vm_ioctl_rtas_define_token(struct kvm *kvm, void __user *argp); |
| 230 | extern int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu); |
| 231 | extern void kvmppc_rtas_tokens_free(struct kvm *kvm); |
Benjamin Herrenschmidt | 5af5099 | 2017-04-05 17:54:56 +1000 | [diff] [blame] | 232 | |
Benjamin Herrenschmidt | bc5ad3f | 2013-04-17 20:30:26 +0000 | [diff] [blame] | 233 | extern int kvmppc_xics_set_xive(struct kvm *kvm, u32 irq, u32 server, |
| 234 | u32 priority); |
| 235 | extern int kvmppc_xics_get_xive(struct kvm *kvm, u32 irq, u32 *server, |
| 236 | u32 *priority); |
Paul Mackerras | d19bd862 | 2013-04-17 20:32:04 +0000 | [diff] [blame] | 237 | extern int kvmppc_xics_int_on(struct kvm *kvm, u32 irq); |
| 238 | extern int kvmppc_xics_int_off(struct kvm *kvm, u32 irq); |
Michael Ellerman | 8e591cb | 2013-04-17 20:30:00 +0000 | [diff] [blame] | 239 | |
Bharat Bhushan | 2f699a5 | 2014-08-13 14:39:44 +0530 | [diff] [blame] | 240 | void kvmppc_core_dequeue_debug(struct kvm_vcpu *vcpu); |
| 241 | void kvmppc_core_queue_debug(struct kvm_vcpu *vcpu); |
| 242 | |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 243 | union kvmppc_one_reg { |
| 244 | u32 wval; |
| 245 | u64 dval; |
| 246 | vector128 vval; |
| 247 | u64 vsxval[2]; |
Bin Lu | 6f63e81 | 2017-02-21 21:12:36 +0800 | [diff] [blame] | 248 | u32 vsx32val[4]; |
Simon Guo | acc9eb9 | 2018-05-21 13:24:26 +0800 | [diff] [blame] | 249 | u16 vsx16val[8]; |
| 250 | u8 vsx8val[16]; |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 251 | struct { |
| 252 | u64 addr; |
| 253 | u64 length; |
| 254 | } vpaval; |
Cédric Le Goater | e4945b9 | 2019-04-18 12:39:35 +0200 | [diff] [blame] | 255 | u64 xive_timaval[2]; |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 256 | }; |
| 257 | |
| 258 | struct kvmppc_ops { |
Aneesh Kumar K.V | cbbc58d | 2013-10-07 22:18:01 +0530 | [diff] [blame] | 259 | struct module *owner; |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 260 | int (*get_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); |
| 261 | int (*set_sregs)(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); |
| 262 | int (*get_one_reg)(struct kvm_vcpu *vcpu, u64 id, |
| 263 | union kvmppc_one_reg *val); |
| 264 | int (*set_one_reg)(struct kvm_vcpu *vcpu, u64 id, |
| 265 | union kvmppc_one_reg *val); |
| 266 | void (*vcpu_load)(struct kvm_vcpu *vcpu, int cpu); |
| 267 | void (*vcpu_put)(struct kvm_vcpu *vcpu); |
Nicholas Piggin | 87a45e0 | 2019-10-02 16:00:22 +1000 | [diff] [blame] | 268 | void (*inject_interrupt)(struct kvm_vcpu *vcpu, int vec, u64 srr1_flags); |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 269 | void (*set_msr)(struct kvm_vcpu *vcpu, u64 msr); |
Tianjia Zhang | 8c99d34 | 2020-04-27 12:35:11 +0800 | [diff] [blame] | 270 | int (*vcpu_run)(struct kvm_vcpu *vcpu); |
Sean Christopherson | ff030fd | 2019-12-18 13:55:00 -0800 | [diff] [blame] | 271 | int (*vcpu_create)(struct kvm_vcpu *vcpu); |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 272 | void (*vcpu_free)(struct kvm_vcpu *vcpu); |
| 273 | int (*check_requests)(struct kvm_vcpu *vcpu); |
| 274 | int (*get_dirty_log)(struct kvm *kvm, struct kvm_dirty_log *log); |
| 275 | void (*flush_memslot)(struct kvm *kvm, struct kvm_memory_slot *memslot); |
| 276 | int (*prepare_memory_region)(struct kvm *kvm, |
| 277 | struct kvm_memory_slot *memslot, |
Sean Christopherson | 82307e6 | 2020-02-18 13:07:18 -0800 | [diff] [blame] | 278 | const struct kvm_userspace_memory_region *mem, |
| 279 | enum kvm_mr_change change); |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 280 | void (*commit_memory_region)(struct kvm *kvm, |
Paolo Bonzini | 09170a4 | 2015-05-18 13:59:39 +0200 | [diff] [blame] | 281 | const struct kvm_userspace_memory_region *mem, |
Paolo Bonzini | f36f3f2 | 2015-05-18 13:20:23 +0200 | [diff] [blame] | 282 | const struct kvm_memory_slot *old, |
Bharata B Rao | f032b73 | 2018-12-12 15:15:30 +1100 | [diff] [blame] | 283 | const struct kvm_memory_slot *new, |
| 284 | enum kvm_mr_change change); |
Sean Christopherson | b1c5356 | 2021-04-01 17:56:53 -0700 | [diff] [blame] | 285 | bool (*unmap_gfn_range)(struct kvm *kvm, struct kvm_gfn_range *range); |
| 286 | bool (*age_gfn)(struct kvm *kvm, struct kvm_gfn_range *range); |
| 287 | bool (*test_age_gfn)(struct kvm *kvm, struct kvm_gfn_range *range); |
| 288 | bool (*set_spte_gfn)(struct kvm *kvm, struct kvm_gfn_range *range); |
Sean Christopherson | e96c81e | 2020-02-18 13:07:27 -0800 | [diff] [blame] | 289 | void (*free_memslot)(struct kvm_memory_slot *slot); |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 290 | int (*init_vm)(struct kvm *kvm); |
| 291 | void (*destroy_vm)(struct kvm *kvm); |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 292 | int (*get_smmu_info)(struct kvm *kvm, struct kvm_ppc_smmu_info *info); |
Tianjia Zhang | 8c99d34 | 2020-04-27 12:35:11 +0800 | [diff] [blame] | 293 | int (*emulate_op)(struct kvm_vcpu *vcpu, |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 294 | unsigned int inst, int *advance); |
| 295 | int (*emulate_mtspr)(struct kvm_vcpu *vcpu, int sprn, ulong spr_val); |
| 296 | int (*emulate_mfspr)(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val); |
| 297 | void (*fast_vcpu_kick)(struct kvm_vcpu *vcpu); |
| 298 | long (*arch_vm_ioctl)(struct file *filp, unsigned int ioctl, |
| 299 | unsigned long arg); |
Paul Mackerras | ae2113a | 2014-06-02 11:03:00 +1000 | [diff] [blame] | 300 | int (*hcall_implemented)(unsigned long hcall); |
Suresh Warrier | 9576730 | 2016-08-19 15:35:47 +1000 | [diff] [blame] | 301 | int (*irq_bypass_add_producer)(struct irq_bypass_consumer *, |
| 302 | struct irq_bypass_producer *); |
| 303 | void (*irq_bypass_del_producer)(struct irq_bypass_consumer *, |
| 304 | struct irq_bypass_producer *); |
Paul Mackerras | c927013 | 2017-01-30 21:21:41 +1100 | [diff] [blame] | 305 | int (*configure_mmu)(struct kvm *kvm, struct kvm_ppc_mmuv3_cfg *cfg); |
| 306 | int (*get_rmmu_info)(struct kvm *kvm, struct kvm_ppc_rmmu_info *info); |
Paul Mackerras | 3c31352 | 2017-02-06 13:24:41 +1100 | [diff] [blame] | 307 | int (*set_smt_mode)(struct kvm *kvm, unsigned long mode, |
| 308 | unsigned long flags); |
Simon Guo | 2e6baa4 | 2018-05-21 13:24:22 +0800 | [diff] [blame] | 309 | void (*giveup_ext)(struct kvm_vcpu *vcpu, ulong msr); |
Paul Mackerras | aa069a9 | 2018-09-21 20:02:01 +1000 | [diff] [blame] | 310 | int (*enable_nested)(struct kvm *kvm); |
Suraj Jitindar Singh | dceadcf | 2018-12-14 16:29:06 +1100 | [diff] [blame] | 311 | int (*load_from_eaddr)(struct kvm_vcpu *vcpu, ulong *eaddr, void *ptr, |
| 312 | int size); |
| 313 | int (*store_to_eaddr)(struct kvm_vcpu *vcpu, ulong *eaddr, void *ptr, |
| 314 | int size); |
Paul Mackerras | 9a5788c | 2020-03-19 15:29:55 +1100 | [diff] [blame] | 315 | int (*enable_svm)(struct kvm *kvm); |
Bharata B Rao | 2294568 | 2019-11-25 08:36:30 +0530 | [diff] [blame] | 316 | int (*svm_off)(struct kvm *kvm); |
Ravi Bangoria | d9a47ed | 2020-12-16 16:12:19 +0530 | [diff] [blame] | 317 | int (*enable_dawr1)(struct kvm *kvm); |
Fabiano Rosas | a722076 | 2021-02-05 13:41:54 -0300 | [diff] [blame] | 318 | bool (*hash_v3_possible)(void); |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 319 | }; |
| 320 | |
Aneesh Kumar K.V | cbbc58d | 2013-10-07 22:18:01 +0530 | [diff] [blame] | 321 | extern struct kvmppc_ops *kvmppc_hv_ops; |
| 322 | extern struct kvmppc_ops *kvmppc_pr_ops; |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 323 | |
Mihai Caraman | 51f0472 | 2014-07-23 19:06:21 +0300 | [diff] [blame] | 324 | static inline int kvmppc_get_last_inst(struct kvm_vcpu *vcpu, |
Simon Guo | 7092360 | 2018-05-21 13:24:21 +0800 | [diff] [blame] | 325 | enum instruction_fetch_type type, u32 *inst) |
Mihai Caraman | 51f0472 | 2014-07-23 19:06:21 +0300 | [diff] [blame] | 326 | { |
| 327 | int ret = EMULATE_DONE; |
| 328 | u32 fetched_inst; |
| 329 | |
| 330 | /* Load the instruction manually if it failed to do so in the |
| 331 | * exit path */ |
| 332 | if (vcpu->arch.last_inst == KVM_INST_FETCH_FAILED) |
| 333 | ret = kvmppc_load_last_inst(vcpu, type, &vcpu->arch.last_inst); |
| 334 | |
| 335 | /* Write fetch_failed unswapped if the fetch failed */ |
| 336 | if (ret == EMULATE_DONE) |
| 337 | fetched_inst = kvmppc_need_byteswap(vcpu) ? |
| 338 | swab32(vcpu->arch.last_inst) : |
| 339 | vcpu->arch.last_inst; |
| 340 | else |
| 341 | fetched_inst = vcpu->arch.last_inst; |
| 342 | |
| 343 | *inst = fetched_inst; |
| 344 | return ret; |
| 345 | } |
| 346 | |
Aneesh Kumar K.V | a78b55d | 2013-10-07 22:18:02 +0530 | [diff] [blame] | 347 | static inline bool is_kvmppc_hv_enabled(struct kvm *kvm) |
| 348 | { |
| 349 | return kvm->arch.kvm_ops == kvmppc_hv_ops; |
| 350 | } |
| 351 | |
Michael Ellerman | e928e9c | 2015-03-20 20:39:41 +1100 | [diff] [blame] | 352 | extern int kvmppc_hwrng_present(void); |
| 353 | |
Alexander Graf | 0564ee8 | 2010-02-19 11:00:42 +0100 | [diff] [blame] | 354 | /* |
| 355 | * Cuts out inst bits with ordering according to spec. |
| 356 | * That means the leftmost bit is zero. All given bits are included. |
| 357 | */ |
| 358 | static inline u32 kvmppc_get_field(u64 inst, int msb, int lsb) |
| 359 | { |
| 360 | u32 r; |
| 361 | u32 mask; |
| 362 | |
| 363 | BUG_ON(msb > lsb); |
| 364 | |
| 365 | mask = (1 << (lsb - msb + 1)) - 1; |
| 366 | r = (inst >> (63 - lsb)) & mask; |
| 367 | |
| 368 | return r; |
| 369 | } |
| 370 | |
| 371 | /* |
| 372 | * Replaces inst bits with ordering according to spec. |
| 373 | */ |
| 374 | static inline u32 kvmppc_set_field(u64 inst, int msb, int lsb, int value) |
| 375 | { |
| 376 | u32 r; |
| 377 | u32 mask; |
| 378 | |
| 379 | BUG_ON(msb > lsb); |
| 380 | |
| 381 | mask = ((1 << (lsb - msb + 1)) - 1) << (63 - lsb); |
| 382 | r = (inst & ~mask) | ((value << (63 - lsb)) & mask); |
| 383 | |
| 384 | return r; |
| 385 | } |
| 386 | |
Paul Mackerras | a136a8b | 2012-09-25 20:31:56 +0000 | [diff] [blame] | 387 | #define one_reg_size(id) \ |
| 388 | (1ul << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT)) |
| 389 | |
| 390 | #define get_reg_val(id, reg) ({ \ |
| 391 | union kvmppc_one_reg __u; \ |
| 392 | switch (one_reg_size(id)) { \ |
| 393 | case 4: __u.wval = (reg); break; \ |
| 394 | case 8: __u.dval = (reg); break; \ |
| 395 | default: BUG(); \ |
| 396 | } \ |
| 397 | __u; \ |
| 398 | }) |
| 399 | |
| 400 | |
| 401 | #define set_reg_val(id, val) ({ \ |
| 402 | u64 __v; \ |
| 403 | switch (one_reg_size(id)) { \ |
| 404 | case 4: __v = (val).wval; break; \ |
| 405 | case 8: __v = (val).dval; break; \ |
| 406 | default: BUG(); \ |
| 407 | } \ |
| 408 | __v; \ |
| 409 | }) |
| 410 | |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 411 | int kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 412 | int kvmppc_core_set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); |
| 413 | |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 414 | int kvmppc_get_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 415 | int kvmppc_set_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); |
| 416 | |
Paul Mackerras | 31f3438 | 2011-12-12 12:26:50 +0000 | [diff] [blame] | 417 | int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg); |
| 418 | int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg); |
Paul Mackerras | a136a8b | 2012-09-25 20:31:56 +0000 | [diff] [blame] | 419 | int kvmppc_get_one_reg(struct kvm_vcpu *vcpu, u64 id, union kvmppc_one_reg *); |
| 420 | int kvmppc_set_one_reg(struct kvm_vcpu *vcpu, u64 id, union kvmppc_one_reg *); |
Paul Mackerras | 31f3438 | 2011-12-12 12:26:50 +0000 | [diff] [blame] | 421 | |
Scott Wood | 5ce941e | 2011-04-27 17:24:21 -0500 | [diff] [blame] | 422 | void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid); |
| 423 | |
Scott Wood | 5df554ad | 2013-04-12 14:08:46 +0000 | [diff] [blame] | 424 | struct openpic; |
Scott Wood | 5df554ad | 2013-04-12 14:08:46 +0000 | [diff] [blame] | 425 | |
Aneesh Kumar K.V | 9975f5e | 2013-10-07 22:17:52 +0530 | [diff] [blame] | 426 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE |
Aneesh Kumar K.V | fa61a4e3 | 2013-07-02 11:15:16 +0530 | [diff] [blame] | 427 | extern void kvm_cma_reserve(void) __init; |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 428 | static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) |
| 429 | { |
Nicholas Piggin | d2e6007 | 2018-02-14 01:08:12 +1000 | [diff] [blame] | 430 | paca_ptrs[cpu]->kvm_hstate.xics_phys = (void __iomem *)addr; |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 431 | } |
Paul Mackerras | aa04b4c | 2011-06-29 00:25:44 +0000 | [diff] [blame] | 432 | |
Benjamin Herrenschmidt | 5af5099 | 2017-04-05 17:54:56 +1000 | [diff] [blame] | 433 | static inline void kvmppc_set_xive_tima(int cpu, |
| 434 | unsigned long phys_addr, |
| 435 | void __iomem *virt_addr) |
| 436 | { |
Nicholas Piggin | d2e6007 | 2018-02-14 01:08:12 +1000 | [diff] [blame] | 437 | paca_ptrs[cpu]->kvm_hstate.xive_tima_phys = (void __iomem *)phys_addr; |
| 438 | paca_ptrs[cpu]->kvm_hstate.xive_tima_virt = virt_addr; |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 439 | } |
Paul Mackerras | aa04b4c | 2011-06-29 00:25:44 +0000 | [diff] [blame] | 440 | |
Benjamin Herrenschmidt | 54695c3 | 2013-04-17 20:30:50 +0000 | [diff] [blame] | 441 | static inline u32 kvmppc_get_xics_latch(void) |
| 442 | { |
Aneesh Kumar K.V | 699cc87 | 2013-10-07 22:17:56 +0530 | [diff] [blame] | 443 | u32 xirr; |
Benjamin Herrenschmidt | 54695c3 | 2013-04-17 20:30:50 +0000 | [diff] [blame] | 444 | |
Aneesh Kumar K.V | 699cc87 | 2013-10-07 22:17:56 +0530 | [diff] [blame] | 445 | xirr = get_paca()->kvm_hstate.saved_xirr; |
Benjamin Herrenschmidt | 54695c3 | 2013-04-17 20:30:50 +0000 | [diff] [blame] | 446 | get_paca()->kvm_hstate.saved_xirr = 0; |
Benjamin Herrenschmidt | 54695c3 | 2013-04-17 20:30:50 +0000 | [diff] [blame] | 447 | return xirr; |
| 448 | } |
| 449 | |
Michael Roth | 3a83f67 | 2019-09-11 17:31:55 -0500 | [diff] [blame] | 450 | /* |
| 451 | * To avoid the need to unnecessarily exit fully to the host kernel, an IPI to |
| 452 | * a CPU thread that's running/napping inside of a guest is by default regarded |
| 453 | * as a request to wake the CPU (if needed) and continue execution within the |
| 454 | * guest, potentially to process new state like externally-generated |
| 455 | * interrupts or IPIs sent from within the guest itself (e.g. H_PROD/H_IPI). |
| 456 | * |
| 457 | * To force an exit to the host kernel, kvmppc_set_host_ipi() must be called |
| 458 | * prior to issuing the IPI to set the corresponding 'host_ipi' flag in the |
| 459 | * target CPU's PACA. To avoid unnecessary exits to the host, this flag should |
| 460 | * be immediately cleared via kvmppc_clear_host_ipi() by the IPI handler on |
| 461 | * the receiving side prior to processing the IPI work. |
| 462 | * |
| 463 | * NOTE: |
| 464 | * |
| 465 | * We currently issue an smp_mb() at the beginning of kvmppc_set_host_ipi(). |
| 466 | * This is to guard against sequences such as the following: |
| 467 | * |
| 468 | * CPU |
| 469 | * X: smp_muxed_ipi_set_message(): |
| 470 | * X: smp_mb() |
| 471 | * X: message[RESCHEDULE] = 1 |
| 472 | * X: doorbell_global_ipi(42): |
| 473 | * X: kvmppc_set_host_ipi(42) |
| 474 | * X: ppc_msgsnd_sync()/smp_mb() |
| 475 | * X: ppc_msgsnd() -> 42 |
| 476 | * 42: doorbell_exception(): // from CPU X |
| 477 | * 42: ppc_msgsync() |
| 478 | * 105: smp_muxed_ipi_set_message(): |
| 479 | * 105: smb_mb() |
| 480 | * // STORE DEFERRED DUE TO RE-ORDERING |
| 481 | * --105: message[CALL_FUNCTION] = 1 |
| 482 | * | 105: doorbell_global_ipi(42): |
| 483 | * | 105: kvmppc_set_host_ipi(42) |
| 484 | * | 42: kvmppc_clear_host_ipi(42) |
| 485 | * | 42: smp_ipi_demux_relaxed() |
| 486 | * | 42: // returns to executing guest |
| 487 | * | // RE-ORDERED STORE COMPLETES |
| 488 | * ->105: message[CALL_FUNCTION] = 1 |
| 489 | * 105: ppc_msgsnd_sync()/smp_mb() |
| 490 | * 105: ppc_msgsnd() -> 42 |
| 491 | * 42: local_paca->kvm_hstate.host_ipi == 0 // IPI ignored |
| 492 | * 105: // hangs waiting on 42 to process messages/call_single_queue |
| 493 | * |
| 494 | * We also issue an smp_mb() at the end of kvmppc_clear_host_ipi(). This is |
| 495 | * to guard against sequences such as the following (as well as to create |
| 496 | * a read-side pairing with the barrier in kvmppc_set_host_ipi()): |
| 497 | * |
| 498 | * CPU |
| 499 | * X: smp_muxed_ipi_set_message(): |
| 500 | * X: smp_mb() |
| 501 | * X: message[RESCHEDULE] = 1 |
| 502 | * X: doorbell_global_ipi(42): |
| 503 | * X: kvmppc_set_host_ipi(42) |
| 504 | * X: ppc_msgsnd_sync()/smp_mb() |
| 505 | * X: ppc_msgsnd() -> 42 |
| 506 | * 42: doorbell_exception(): // from CPU X |
| 507 | * 42: ppc_msgsync() |
| 508 | * // STORE DEFERRED DUE TO RE-ORDERING |
| 509 | * -- 42: kvmppc_clear_host_ipi(42) |
| 510 | * | 42: smp_ipi_demux_relaxed() |
| 511 | * | 105: smp_muxed_ipi_set_message(): |
| 512 | * | 105: smb_mb() |
| 513 | * | 105: message[CALL_FUNCTION] = 1 |
| 514 | * | 105: doorbell_global_ipi(42): |
| 515 | * | 105: kvmppc_set_host_ipi(42) |
| 516 | * | // RE-ORDERED STORE COMPLETES |
| 517 | * -> 42: kvmppc_clear_host_ipi(42) |
| 518 | * 42: // returns to executing guest |
| 519 | * 105: ppc_msgsnd_sync()/smp_mb() |
| 520 | * 105: ppc_msgsnd() -> 42 |
| 521 | * 42: local_paca->kvm_hstate.host_ipi == 0 // IPI ignored |
| 522 | * 105: // hangs waiting on 42 to process messages/call_single_queue |
| 523 | */ |
| 524 | static inline void kvmppc_set_host_ipi(int cpu) |
Benjamin Herrenschmidt | 54695c3 | 2013-04-17 20:30:50 +0000 | [diff] [blame] | 525 | { |
Michael Roth | 3a83f67 | 2019-09-11 17:31:55 -0500 | [diff] [blame] | 526 | /* |
| 527 | * order stores of IPI messages vs. setting of host_ipi flag |
| 528 | * |
| 529 | * pairs with the barrier in kvmppc_clear_host_ipi() |
| 530 | */ |
| 531 | smp_mb(); |
| 532 | paca_ptrs[cpu]->kvm_hstate.host_ipi = 1; |
| 533 | } |
| 534 | |
| 535 | static inline void kvmppc_clear_host_ipi(int cpu) |
| 536 | { |
| 537 | paca_ptrs[cpu]->kvm_hstate.host_ipi = 0; |
| 538 | /* |
| 539 | * order clearing of host_ipi flag vs. processing of IPI messages |
| 540 | * |
| 541 | * pairs with the barrier in kvmppc_set_host_ipi() |
| 542 | */ |
| 543 | smp_mb(); |
Benjamin Herrenschmidt | 54695c3 | 2013-04-17 20:30:50 +0000 | [diff] [blame] | 544 | } |
| 545 | |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 546 | static inline void kvmppc_fast_vcpu_kick(struct kvm_vcpu *vcpu) |
| 547 | { |
Aneesh Kumar K.V | cbbc58d | 2013-10-07 22:18:01 +0530 | [diff] [blame] | 548 | vcpu->kvm->arch.kvm_ops->fast_vcpu_kick(vcpu); |
Aneesh Kumar K.V | 3a167bea | 2013-10-07 22:17:53 +0530 | [diff] [blame] | 549 | } |
Paul Mackerras | aa04b4c | 2011-06-29 00:25:44 +0000 | [diff] [blame] | 550 | |
Michael Ellerman | 441c19c | 2014-05-23 18:15:25 +1000 | [diff] [blame] | 551 | extern void kvm_hv_vm_activated(void); |
| 552 | extern void kvm_hv_vm_deactivated(void); |
| 553 | extern bool kvm_hv_mode_active(void); |
| 554 | |
Paul Mackerras | 70ea13f | 2019-04-29 19:02:58 +1000 | [diff] [blame] | 555 | extern void kvmppc_check_need_tlb_flush(struct kvm *kvm, int pcpu, |
| 556 | struct kvm_nested_guest *nested); |
Paul Mackerras | 2940ba0 | 2019-04-29 19:00:40 +1000 | [diff] [blame] | 557 | |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 558 | #else |
Aneesh Kumar K.V | fa61a4e3 | 2013-07-02 11:15:16 +0530 | [diff] [blame] | 559 | static inline void __init kvm_cma_reserve(void) |
| 560 | {} |
| 561 | |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 562 | static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) |
| 563 | {} |
Paul Mackerras | aa04b4c | 2011-06-29 00:25:44 +0000 | [diff] [blame] | 564 | |
Benjamin Herrenschmidt | 5af5099 | 2017-04-05 17:54:56 +1000 | [diff] [blame] | 565 | static inline void kvmppc_set_xive_tima(int cpu, |
| 566 | unsigned long phys_addr, |
| 567 | void __iomem *virt_addr) |
| 568 | {} |
| 569 | |
Benjamin Herrenschmidt | 54695c3 | 2013-04-17 20:30:50 +0000 | [diff] [blame] | 570 | static inline u32 kvmppc_get_xics_latch(void) |
| 571 | { |
| 572 | return 0; |
| 573 | } |
| 574 | |
Michael Roth | 3a83f67 | 2019-09-11 17:31:55 -0500 | [diff] [blame] | 575 | static inline void kvmppc_set_host_ipi(int cpu) |
| 576 | {} |
| 577 | |
| 578 | static inline void kvmppc_clear_host_ipi(int cpu) |
Benjamin Herrenschmidt | 54695c3 | 2013-04-17 20:30:50 +0000 | [diff] [blame] | 579 | {} |
| 580 | |
| 581 | static inline void kvmppc_fast_vcpu_kick(struct kvm_vcpu *vcpu) |
| 582 | { |
| 583 | kvm_vcpu_kick(vcpu); |
| 584 | } |
Michael Ellerman | 441c19c | 2014-05-23 18:15:25 +1000 | [diff] [blame] | 585 | |
| 586 | static inline bool kvm_hv_mode_active(void) { return false; } |
| 587 | |
Benjamin Herrenschmidt | bc5ad3f | 2013-04-17 20:30:26 +0000 | [diff] [blame] | 588 | #endif |
| 589 | |
| 590 | #ifdef CONFIG_KVM_XICS |
| 591 | static inline int kvmppc_xics_enabled(struct kvm_vcpu *vcpu) |
| 592 | { |
| 593 | return vcpu->arch.irq_type == KVMPPC_IRQ_XICS; |
| 594 | } |
Suresh Warrier | 8daaafc | 2016-08-19 15:35:48 +1000 | [diff] [blame] | 595 | |
| 596 | static inline struct kvmppc_passthru_irqmap *kvmppc_get_passthru_irqmap( |
| 597 | struct kvm *kvm) |
| 598 | { |
Suresh Warrier | 644abbb | 2016-08-19 15:35:54 +1000 | [diff] [blame] | 599 | if (kvm && kvm_irq_bypass) |
Suresh Warrier | 8daaafc | 2016-08-19 15:35:48 +1000 | [diff] [blame] | 600 | return kvm->arch.pimap; |
| 601 | return NULL; |
| 602 | } |
| 603 | |
Suresh Warrier | 79b6c24 | 2015-12-17 14:59:06 -0600 | [diff] [blame] | 604 | extern void kvmppc_alloc_host_rm_ops(void); |
| 605 | extern void kvmppc_free_host_rm_ops(void); |
Suresh Warrier | 8daaafc | 2016-08-19 15:35:48 +1000 | [diff] [blame] | 606 | extern void kvmppc_free_pimap(struct kvm *kvm); |
Suresh Warrier | f7af520 | 2016-08-19 15:35:52 +1000 | [diff] [blame] | 607 | extern int kvmppc_xics_rm_complete(struct kvm_vcpu *vcpu, u32 hcall); |
Benjamin Herrenschmidt | bc5ad3f | 2013-04-17 20:30:26 +0000 | [diff] [blame] | 608 | extern void kvmppc_xics_free_icp(struct kvm_vcpu *vcpu); |
Benjamin Herrenschmidt | bc5ad3f | 2013-04-17 20:30:26 +0000 | [diff] [blame] | 609 | extern int kvmppc_xics_hcall(struct kvm_vcpu *vcpu, u32 cmd); |
Nicholas Piggin | 9dc2bab | 2021-05-28 19:07:33 +1000 | [diff] [blame] | 610 | extern int kvmppc_xive_xics_hcall(struct kvm_vcpu *vcpu, u32 req); |
Paul Mackerras | 8b78645 | 2013-04-17 20:32:26 +0000 | [diff] [blame] | 611 | extern u64 kvmppc_xics_get_icp(struct kvm_vcpu *vcpu); |
| 612 | extern int kvmppc_xics_set_icp(struct kvm_vcpu *vcpu, u64 icpval); |
Paul Mackerras | 5975a2e | 2013-04-27 00:28:37 +0000 | [diff] [blame] | 613 | extern int kvmppc_xics_connect_vcpu(struct kvm_device *dev, |
| 614 | struct kvm_vcpu *vcpu, u32 cpu); |
Suresh Warrier | 0c2a660 | 2015-12-17 14:59:09 -0600 | [diff] [blame] | 615 | extern void kvmppc_xics_ipi_action(void); |
Paul Mackerras | 5d37519 | 2016-08-19 15:35:56 +1000 | [diff] [blame] | 616 | extern void kvmppc_xics_set_mapped(struct kvm *kvm, unsigned long guest_irq, |
| 617 | unsigned long host_irq); |
| 618 | extern void kvmppc_xics_clr_mapped(struct kvm *kvm, unsigned long guest_irq, |
| 619 | unsigned long host_irq); |
Paul Mackerras | f725758 | 2016-11-18 09:02:08 +1100 | [diff] [blame] | 620 | extern long kvmppc_deliver_irq_passthru(struct kvm_vcpu *vcpu, __be32 xirr, |
| 621 | struct kvmppc_irq_map *irq_map, |
| 622 | struct kvmppc_passthru_irqmap *pimap, |
| 623 | bool *again); |
Benjamin Herrenschmidt | 5af5099 | 2017-04-05 17:54:56 +1000 | [diff] [blame] | 624 | |
| 625 | extern int kvmppc_xics_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, |
| 626 | int level, bool line_status); |
| 627 | |
Suresh E. Warrier | 520fe9c | 2015-12-21 16:33:57 -0600 | [diff] [blame] | 628 | extern int h_ipi_redirect; |
Benjamin Herrenschmidt | bc5ad3f | 2013-04-17 20:30:26 +0000 | [diff] [blame] | 629 | #else |
Suresh Warrier | 8daaafc | 2016-08-19 15:35:48 +1000 | [diff] [blame] | 630 | static inline struct kvmppc_passthru_irqmap *kvmppc_get_passthru_irqmap( |
| 631 | struct kvm *kvm) |
| 632 | { return NULL; } |
Chengyang Fan | 6c6fdbb | 2021-01-25 17:53:38 +0800 | [diff] [blame] | 633 | static inline void kvmppc_alloc_host_rm_ops(void) {} |
| 634 | static inline void kvmppc_free_host_rm_ops(void) {} |
| 635 | static inline void kvmppc_free_pimap(struct kvm *kvm) {} |
Suresh Warrier | f7af520 | 2016-08-19 15:35:52 +1000 | [diff] [blame] | 636 | static inline int kvmppc_xics_rm_complete(struct kvm_vcpu *vcpu, u32 hcall) |
| 637 | { return 0; } |
Benjamin Herrenschmidt | bc5ad3f | 2013-04-17 20:30:26 +0000 | [diff] [blame] | 638 | static inline int kvmppc_xics_enabled(struct kvm_vcpu *vcpu) |
| 639 | { return 0; } |
| 640 | static inline void kvmppc_xics_free_icp(struct kvm_vcpu *vcpu) { } |
Benjamin Herrenschmidt | bc5ad3f | 2013-04-17 20:30:26 +0000 | [diff] [blame] | 641 | static inline int kvmppc_xics_hcall(struct kvm_vcpu *vcpu, u32 cmd) |
| 642 | { return 0; } |
Nicholas Piggin | 9dc2bab | 2021-05-28 19:07:33 +1000 | [diff] [blame] | 643 | static inline int kvmppc_xive_xics_hcall(struct kvm_vcpu *vcpu, u32 req) |
| 644 | { return 0; } |
Paul Mackerras | 371fefd | 2011-06-29 00:23:08 +0000 | [diff] [blame] | 645 | #endif |
| 646 | |
Benjamin Herrenschmidt | 5af5099 | 2017-04-05 17:54:56 +1000 | [diff] [blame] | 647 | #ifdef CONFIG_KVM_XIVE |
| 648 | /* |
| 649 | * Below the first "xive" is the "eXternal Interrupt Virtualization Engine" |
| 650 | * ie. P9 new interrupt controller, while the second "xive" is the legacy |
| 651 | * "eXternal Interrupt Vector Entry" which is the configuration of an |
| 652 | * interrupt on the "xics" interrupt controller on P8 and earlier. Those |
| 653 | * two function consume or produce a legacy "XIVE" state from the |
| 654 | * new "XIVE" interrupt controller. |
| 655 | */ |
| 656 | extern int kvmppc_xive_set_xive(struct kvm *kvm, u32 irq, u32 server, |
| 657 | u32 priority); |
| 658 | extern int kvmppc_xive_get_xive(struct kvm *kvm, u32 irq, u32 *server, |
| 659 | u32 *priority); |
| 660 | extern int kvmppc_xive_int_on(struct kvm *kvm, u32 irq); |
| 661 | extern int kvmppc_xive_int_off(struct kvm *kvm, u32 irq); |
Benjamin Herrenschmidt | 5af5099 | 2017-04-05 17:54:56 +1000 | [diff] [blame] | 662 | |
| 663 | extern int kvmppc_xive_connect_vcpu(struct kvm_device *dev, |
| 664 | struct kvm_vcpu *vcpu, u32 cpu); |
| 665 | extern void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu); |
| 666 | extern int kvmppc_xive_set_mapped(struct kvm *kvm, unsigned long guest_irq, |
Cédric Le Goater | e5e78b1 | 2021-07-01 15:27:32 +0200 | [diff] [blame] | 667 | unsigned long host_irq); |
Benjamin Herrenschmidt | 5af5099 | 2017-04-05 17:54:56 +1000 | [diff] [blame] | 668 | extern int kvmppc_xive_clr_mapped(struct kvm *kvm, unsigned long guest_irq, |
Cédric Le Goater | e5e78b1 | 2021-07-01 15:27:32 +0200 | [diff] [blame] | 669 | unsigned long host_irq); |
Benjamin Herrenschmidt | 5af5099 | 2017-04-05 17:54:56 +1000 | [diff] [blame] | 670 | extern u64 kvmppc_xive_get_icp(struct kvm_vcpu *vcpu); |
| 671 | extern int kvmppc_xive_set_icp(struct kvm_vcpu *vcpu, u64 icpval); |
| 672 | |
| 673 | extern int kvmppc_xive_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, |
| 674 | int level, bool line_status); |
Paul Mackerras | 95a6432 | 2018-10-08 16:30:55 +1100 | [diff] [blame] | 675 | extern void kvmppc_xive_push_vcpu(struct kvm_vcpu *vcpu); |
Nicholas Piggin | 023c3c9 | 2021-05-28 19:07:28 +1000 | [diff] [blame] | 676 | extern void kvmppc_xive_pull_vcpu(struct kvm_vcpu *vcpu); |
Nicholas Piggin | 9dc2bab | 2021-05-28 19:07:33 +1000 | [diff] [blame] | 677 | extern void kvmppc_xive_rearm_escalation(struct kvm_vcpu *vcpu); |
Cédric Le Goater | 90c7379 | 2019-04-18 12:39:27 +0200 | [diff] [blame] | 678 | |
Cédric Le Goater | eacc56b | 2019-04-18 12:39:28 +0200 | [diff] [blame] | 679 | static inline int kvmppc_xive_enabled(struct kvm_vcpu *vcpu) |
| 680 | { |
| 681 | return vcpu->arch.irq_type == KVMPPC_IRQ_XIVE; |
| 682 | } |
| 683 | |
| 684 | extern int kvmppc_xive_native_connect_vcpu(struct kvm_device *dev, |
| 685 | struct kvm_vcpu *vcpu, u32 cpu); |
| 686 | extern void kvmppc_xive_native_cleanup_vcpu(struct kvm_vcpu *vcpu); |
Cédric Le Goater | e4945b9 | 2019-04-18 12:39:35 +0200 | [diff] [blame] | 687 | extern int kvmppc_xive_native_get_vp(struct kvm_vcpu *vcpu, |
| 688 | union kvmppc_one_reg *val); |
| 689 | extern int kvmppc_xive_native_set_vp(struct kvm_vcpu *vcpu, |
| 690 | union kvmppc_one_reg *val); |
Paul Mackerras | 2ad7a27 | 2019-08-26 16:21:21 +1000 | [diff] [blame] | 691 | extern bool kvmppc_xive_native_supported(void); |
Cédric Le Goater | 90c7379 | 2019-04-18 12:39:27 +0200 | [diff] [blame] | 692 | |
Benjamin Herrenschmidt | 5af5099 | 2017-04-05 17:54:56 +1000 | [diff] [blame] | 693 | #else |
| 694 | static inline int kvmppc_xive_set_xive(struct kvm *kvm, u32 irq, u32 server, |
| 695 | u32 priority) { return -1; } |
| 696 | static inline int kvmppc_xive_get_xive(struct kvm *kvm, u32 irq, u32 *server, |
| 697 | u32 *priority) { return -1; } |
| 698 | static inline int kvmppc_xive_int_on(struct kvm *kvm, u32 irq) { return -1; } |
| 699 | static inline int kvmppc_xive_int_off(struct kvm *kvm, u32 irq) { return -1; } |
Benjamin Herrenschmidt | 5af5099 | 2017-04-05 17:54:56 +1000 | [diff] [blame] | 700 | |
| 701 | static inline int kvmppc_xive_connect_vcpu(struct kvm_device *dev, |
| 702 | struct kvm_vcpu *vcpu, u32 cpu) { return -EBUSY; } |
| 703 | static inline void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu) { } |
| 704 | static inline int kvmppc_xive_set_mapped(struct kvm *kvm, unsigned long guest_irq, |
| 705 | struct irq_desc *host_desc) { return -ENODEV; } |
| 706 | static inline int kvmppc_xive_clr_mapped(struct kvm *kvm, unsigned long guest_irq, |
| 707 | struct irq_desc *host_desc) { return -ENODEV; } |
| 708 | static inline u64 kvmppc_xive_get_icp(struct kvm_vcpu *vcpu) { return 0; } |
| 709 | static inline int kvmppc_xive_set_icp(struct kvm_vcpu *vcpu, u64 icpval) { return -ENOENT; } |
| 710 | |
| 711 | static inline int kvmppc_xive_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, |
| 712 | int level, bool line_status) { return -ENODEV; } |
Paul Mackerras | 95a6432 | 2018-10-08 16:30:55 +1100 | [diff] [blame] | 713 | static inline void kvmppc_xive_push_vcpu(struct kvm_vcpu *vcpu) { } |
Nicholas Piggin | 023c3c9 | 2021-05-28 19:07:28 +1000 | [diff] [blame] | 714 | static inline void kvmppc_xive_pull_vcpu(struct kvm_vcpu *vcpu) { } |
Nicholas Piggin | 9dc2bab | 2021-05-28 19:07:33 +1000 | [diff] [blame] | 715 | static inline void kvmppc_xive_rearm_escalation(struct kvm_vcpu *vcpu) { } |
Cédric Le Goater | 90c7379 | 2019-04-18 12:39:27 +0200 | [diff] [blame] | 716 | |
Cédric Le Goater | eacc56b | 2019-04-18 12:39:28 +0200 | [diff] [blame] | 717 | static inline int kvmppc_xive_enabled(struct kvm_vcpu *vcpu) |
| 718 | { return 0; } |
| 719 | static inline int kvmppc_xive_native_connect_vcpu(struct kvm_device *dev, |
| 720 | struct kvm_vcpu *vcpu, u32 cpu) { return -EBUSY; } |
| 721 | static inline void kvmppc_xive_native_cleanup_vcpu(struct kvm_vcpu *vcpu) { } |
Cédric Le Goater | e4945b9 | 2019-04-18 12:39:35 +0200 | [diff] [blame] | 722 | static inline int kvmppc_xive_native_get_vp(struct kvm_vcpu *vcpu, |
| 723 | union kvmppc_one_reg *val) |
| 724 | { return 0; } |
| 725 | static inline int kvmppc_xive_native_set_vp(struct kvm_vcpu *vcpu, |
| 726 | union kvmppc_one_reg *val) |
| 727 | { return -ENOENT; } |
Cédric Le Goater | 90c7379 | 2019-04-18 12:39:27 +0200 | [diff] [blame] | 728 | |
Benjamin Herrenschmidt | 5af5099 | 2017-04-05 17:54:56 +1000 | [diff] [blame] | 729 | #endif /* CONFIG_KVM_XIVE */ |
| 730 | |
Paul Mackerras | e74d53e | 2019-02-25 14:35:06 +1100 | [diff] [blame] | 731 | #if defined(CONFIG_PPC_POWERNV) && defined(CONFIG_KVM_BOOK3S_64_HANDLER) |
Paul Mackerras | 03f9533 | 2019-02-04 22:07:20 +1100 | [diff] [blame] | 732 | static inline bool xics_on_xive(void) |
| 733 | { |
| 734 | return xive_enabled() && cpu_has_feature(CPU_FTR_HVMODE); |
| 735 | } |
| 736 | #else |
| 737 | static inline bool xics_on_xive(void) |
| 738 | { |
| 739 | return false; |
| 740 | } |
| 741 | #endif |
| 742 | |
Suresh Warrier | 79b6c24 | 2015-12-17 14:59:06 -0600 | [diff] [blame] | 743 | /* |
Paul Mackerras | e34af78 | 2016-12-01 14:03:46 +1100 | [diff] [blame] | 744 | * Prototypes for functions called only from assembler code. |
| 745 | * Having prototypes reduces sparse errors. |
| 746 | */ |
| 747 | long kvmppc_rm_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn, |
| 748 | unsigned long ioba, unsigned long tce); |
| 749 | long kvmppc_rm_h_put_tce_indirect(struct kvm_vcpu *vcpu, |
| 750 | unsigned long liobn, unsigned long ioba, |
| 751 | unsigned long tce_list, unsigned long npages); |
| 752 | long kvmppc_rm_h_stuff_tce(struct kvm_vcpu *vcpu, |
| 753 | unsigned long liobn, unsigned long ioba, |
| 754 | unsigned long tce_value, unsigned long npages); |
| 755 | long int kvmppc_rm_h_confer(struct kvm_vcpu *vcpu, int target, |
| 756 | unsigned int yield_count); |
Nicholas Piggin | dcbac73 | 2021-05-28 19:07:44 +1000 | [diff] [blame] | 757 | long kvmppc_rm_h_random(struct kvm_vcpu *vcpu); |
Paul Mackerras | e34af78 | 2016-12-01 14:03:46 +1100 | [diff] [blame] | 758 | void kvmhv_commence_exit(int trap); |
Paul Mackerras | 884dfb7 | 2019-02-21 13:38:49 +1100 | [diff] [blame] | 759 | void kvmppc_realmode_machine_check(struct kvm_vcpu *vcpu); |
Paul Mackerras | e34af78 | 2016-12-01 14:03:46 +1100 | [diff] [blame] | 760 | void kvmppc_subcore_enter_guest(void); |
| 761 | void kvmppc_subcore_exit_guest(void); |
| 762 | long kvmppc_realmode_hmi_handler(void); |
| 763 | long kvmppc_h_enter(struct kvm_vcpu *vcpu, unsigned long flags, |
| 764 | long pte_index, unsigned long pteh, unsigned long ptel); |
| 765 | long kvmppc_h_remove(struct kvm_vcpu *vcpu, unsigned long flags, |
| 766 | unsigned long pte_index, unsigned long avpn); |
| 767 | long kvmppc_h_bulk_remove(struct kvm_vcpu *vcpu); |
| 768 | long kvmppc_h_protect(struct kvm_vcpu *vcpu, unsigned long flags, |
Nicholas Piggin | 6c12c43 | 2021-04-12 11:48:40 +1000 | [diff] [blame] | 769 | unsigned long pte_index, unsigned long avpn); |
Paul Mackerras | e34af78 | 2016-12-01 14:03:46 +1100 | [diff] [blame] | 770 | long kvmppc_h_read(struct kvm_vcpu *vcpu, unsigned long flags, |
| 771 | unsigned long pte_index); |
| 772 | long kvmppc_h_clear_ref(struct kvm_vcpu *vcpu, unsigned long flags, |
| 773 | unsigned long pte_index); |
| 774 | long kvmppc_h_clear_mod(struct kvm_vcpu *vcpu, unsigned long flags, |
| 775 | unsigned long pte_index); |
Suraj Jitindar Singh | eadfb1c | 2019-03-22 17:05:45 +1100 | [diff] [blame] | 776 | long kvmppc_rm_h_page_init(struct kvm_vcpu *vcpu, unsigned long flags, |
| 777 | unsigned long dest, unsigned long src); |
Paul Mackerras | e34af78 | 2016-12-01 14:03:46 +1100 | [diff] [blame] | 778 | long kvmppc_hpte_hv_fault(struct kvm_vcpu *vcpu, unsigned long addr, |
| 779 | unsigned long slb_v, unsigned int status, bool data); |
| 780 | unsigned long kvmppc_rm_h_xirr(struct kvm_vcpu *vcpu); |
Benjamin Herrenschmidt | 5af5099 | 2017-04-05 17:54:56 +1000 | [diff] [blame] | 781 | unsigned long kvmppc_rm_h_xirr_x(struct kvm_vcpu *vcpu); |
| 782 | unsigned long kvmppc_rm_h_ipoll(struct kvm_vcpu *vcpu, unsigned long server); |
Paul Mackerras | e34af78 | 2016-12-01 14:03:46 +1100 | [diff] [blame] | 783 | int kvmppc_rm_h_ipi(struct kvm_vcpu *vcpu, unsigned long server, |
| 784 | unsigned long mfrr); |
| 785 | int kvmppc_rm_h_cppr(struct kvm_vcpu *vcpu, unsigned long cppr); |
| 786 | int kvmppc_rm_h_eoi(struct kvm_vcpu *vcpu, unsigned long xirr); |
Paul Mackerras | f7035ce | 2018-10-08 16:30:50 +1100 | [diff] [blame] | 787 | void kvmppc_guest_entry_inject_int(struct kvm_vcpu *vcpu); |
Paul Mackerras | e34af78 | 2016-12-01 14:03:46 +1100 | [diff] [blame] | 788 | |
| 789 | /* |
Suresh Warrier | 79b6c24 | 2015-12-17 14:59:06 -0600 | [diff] [blame] | 790 | * Host-side operations we want to set up while running in real |
| 791 | * mode in the guest operating on the xics. |
| 792 | * Currently only VCPU wakeup is supported. |
| 793 | */ |
| 794 | |
| 795 | union kvmppc_rm_state { |
| 796 | unsigned long raw; |
| 797 | struct { |
| 798 | u32 in_host; |
| 799 | u32 rm_action; |
| 800 | }; |
| 801 | }; |
| 802 | |
| 803 | struct kvmppc_host_rm_core { |
| 804 | union kvmppc_rm_state rm_state; |
| 805 | void *rm_data; |
| 806 | char pad[112]; |
| 807 | }; |
| 808 | |
| 809 | struct kvmppc_host_rm_ops { |
| 810 | struct kvmppc_host_rm_core *rm_core; |
| 811 | void (*vcpu_kick)(struct kvm_vcpu *vcpu); |
| 812 | }; |
| 813 | |
| 814 | extern struct kvmppc_host_rm_ops *kvmppc_host_rm_ops_hv; |
| 815 | |
Bharat Bhushan | 34f754b | 2014-07-17 17:01:40 +0530 | [diff] [blame] | 816 | static inline unsigned long kvmppc_get_epr(struct kvm_vcpu *vcpu) |
| 817 | { |
| 818 | #ifdef CONFIG_KVM_BOOKE_HV |
| 819 | return mfspr(SPRN_GEPR); |
| 820 | #elif defined(CONFIG_BOOKE) |
| 821 | return vcpu->arch.epr; |
| 822 | #else |
| 823 | return 0; |
| 824 | #endif |
| 825 | } |
| 826 | |
Alexander Graf | 1c81063 | 2013-01-04 18:12:48 +0100 | [diff] [blame] | 827 | static inline void kvmppc_set_epr(struct kvm_vcpu *vcpu, u32 epr) |
| 828 | { |
| 829 | #ifdef CONFIG_KVM_BOOKE_HV |
| 830 | mtspr(SPRN_GEPR, epr); |
| 831 | #elif defined(CONFIG_BOOKE) |
| 832 | vcpu->arch.epr = epr; |
| 833 | #endif |
| 834 | } |
| 835 | |
Scott Wood | 5df554ad | 2013-04-12 14:08:46 +0000 | [diff] [blame] | 836 | #ifdef CONFIG_KVM_MPIC |
| 837 | |
| 838 | void kvmppc_mpic_set_epr(struct kvm_vcpu *vcpu); |
Scott Wood | eb1e4f4 | 2013-04-12 14:08:47 +0000 | [diff] [blame] | 839 | int kvmppc_mpic_connect_vcpu(struct kvm_device *dev, struct kvm_vcpu *vcpu, |
| 840 | u32 cpu); |
| 841 | void kvmppc_mpic_disconnect_vcpu(struct openpic *opp, struct kvm_vcpu *vcpu); |
Scott Wood | 5df554ad | 2013-04-12 14:08:46 +0000 | [diff] [blame] | 842 | |
| 843 | #else |
| 844 | |
| 845 | static inline void kvmppc_mpic_set_epr(struct kvm_vcpu *vcpu) |
| 846 | { |
| 847 | } |
| 848 | |
Scott Wood | eb1e4f4 | 2013-04-12 14:08:47 +0000 | [diff] [blame] | 849 | static inline int kvmppc_mpic_connect_vcpu(struct kvm_device *dev, |
| 850 | struct kvm_vcpu *vcpu, u32 cpu) |
| 851 | { |
| 852 | return -EINVAL; |
| 853 | } |
| 854 | |
| 855 | static inline void kvmppc_mpic_disconnect_vcpu(struct openpic *opp, |
| 856 | struct kvm_vcpu *vcpu) |
| 857 | { |
| 858 | } |
| 859 | |
Scott Wood | 5df554ad | 2013-04-12 14:08:46 +0000 | [diff] [blame] | 860 | #endif /* CONFIG_KVM_MPIC */ |
| 861 | |
Scott Wood | dc83b8b | 2011-08-18 15:25:21 -0500 | [diff] [blame] | 862 | int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu, |
| 863 | struct kvm_config_tlb *cfg); |
| 864 | int kvm_vcpu_ioctl_dirty_tlb(struct kvm_vcpu *vcpu, |
| 865 | struct kvm_dirty_tlb *cfg); |
| 866 | |
Scott Wood | 043cc4d | 2011-12-20 15:34:20 +0000 | [diff] [blame] | 867 | long kvmppc_alloc_lpid(void); |
| 868 | void kvmppc_claim_lpid(long lpid); |
| 869 | void kvmppc_free_lpid(long lpid); |
| 870 | void kvmppc_init_lpid(unsigned long nr_lpids); |
| 871 | |
Dan Williams | ba049e9 | 2016-01-15 16:56:11 -0800 | [diff] [blame] | 872 | static inline void kvmppc_mmu_flush_icache(kvm_pfn_t pfn) |
Alexander Graf | 249ba1e | 2012-08-03 13:56:33 +0200 | [diff] [blame] | 873 | { |
Alexander Graf | 249ba1e | 2012-08-03 13:56:33 +0200 | [diff] [blame] | 874 | struct page *page; |
Bharat Bhushan | adccf65 | 2013-04-25 06:33:57 +0000 | [diff] [blame] | 875 | /* |
| 876 | * We can only access pages that the kernel maps |
| 877 | * as memory. Bail out for unmapped ones. |
| 878 | */ |
| 879 | if (!pfn_valid(pfn)) |
| 880 | return; |
| 881 | |
| 882 | /* Clear i-cache for new pages */ |
Alexander Graf | 249ba1e | 2012-08-03 13:56:33 +0200 | [diff] [blame] | 883 | page = pfn_to_page(pfn); |
Aneesh Kumar K.V | ec94b9b | 2021-02-03 10:28:11 +0530 | [diff] [blame] | 884 | if (!test_bit(PG_dcache_clean, &page->flags)) { |
Alexander Graf | 249ba1e | 2012-08-03 13:56:33 +0200 | [diff] [blame] | 885 | flush_dcache_icache_page(page); |
Aneesh Kumar K.V | ec94b9b | 2021-02-03 10:28:11 +0530 | [diff] [blame] | 886 | set_bit(PG_dcache_clean, &page->flags); |
Alexander Graf | 249ba1e | 2012-08-03 13:56:33 +0200 | [diff] [blame] | 887 | } |
| 888 | } |
| 889 | |
Scott Wood | 5f1c248 | 2013-07-10 17:47:39 -0500 | [diff] [blame] | 890 | /* |
Alexander Graf | 5deb8e7 | 2014-04-24 13:46:24 +0200 | [diff] [blame] | 891 | * Shared struct helpers. The shared struct can be little or big endian, |
| 892 | * depending on the guest endianness. So expose helpers to all of them. |
| 893 | */ |
| 894 | static inline bool kvmppc_shared_big_endian(struct kvm_vcpu *vcpu) |
| 895 | { |
| 896 | #if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_KVM_BOOK3S_PR_POSSIBLE) |
| 897 | /* Only Book3S_64 PR supports bi-endian for now */ |
| 898 | return vcpu->arch.shared_big_endian; |
| 899 | #elif defined(CONFIG_PPC_BOOK3S_64) && defined(__LITTLE_ENDIAN__) |
| 900 | /* Book3s_64 HV on little endian is always little endian */ |
| 901 | return false; |
| 902 | #else |
| 903 | return true; |
| 904 | #endif |
| 905 | } |
| 906 | |
Bharat Bhushan | 5a484c7 | 2014-07-30 15:03:56 +0530 | [diff] [blame] | 907 | #define SPRNG_WRAPPER_GET(reg, bookehv_spr) \ |
Bharat Bhushan | 1dc0c5b | 2014-07-17 17:01:35 +0530 | [diff] [blame] | 908 | static inline ulong kvmppc_get_##reg(struct kvm_vcpu *vcpu) \ |
| 909 | { \ |
Bharat Bhushan | 5a484c7 | 2014-07-30 15:03:56 +0530 | [diff] [blame] | 910 | return mfspr(bookehv_spr); \ |
Bharat Bhushan | 1dc0c5b | 2014-07-17 17:01:35 +0530 | [diff] [blame] | 911 | } \ |
| 912 | |
Bharat Bhushan | 5a484c7 | 2014-07-30 15:03:56 +0530 | [diff] [blame] | 913 | #define SPRNG_WRAPPER_SET(reg, bookehv_spr) \ |
Bharat Bhushan | 1dc0c5b | 2014-07-17 17:01:35 +0530 | [diff] [blame] | 914 | static inline void kvmppc_set_##reg(struct kvm_vcpu *vcpu, ulong val) \ |
| 915 | { \ |
Bharat Bhushan | 5a484c7 | 2014-07-30 15:03:56 +0530 | [diff] [blame] | 916 | mtspr(bookehv_spr, val); \ |
Bharat Bhushan | 1dc0c5b | 2014-07-17 17:01:35 +0530 | [diff] [blame] | 917 | } \ |
| 918 | |
Alexander Graf | 5deb8e7 | 2014-04-24 13:46:24 +0200 | [diff] [blame] | 919 | #define SHARED_WRAPPER_GET(reg, size) \ |
Bharat Bhushan | 1dc0c5b | 2014-07-17 17:01:35 +0530 | [diff] [blame] | 920 | static inline u##size kvmppc_get_##reg(struct kvm_vcpu *vcpu) \ |
Alexander Graf | 5deb8e7 | 2014-04-24 13:46:24 +0200 | [diff] [blame] | 921 | { \ |
| 922 | if (kvmppc_shared_big_endian(vcpu)) \ |
| 923 | return be##size##_to_cpu(vcpu->arch.shared->reg); \ |
| 924 | else \ |
| 925 | return le##size##_to_cpu(vcpu->arch.shared->reg); \ |
| 926 | } \ |
| 927 | |
| 928 | #define SHARED_WRAPPER_SET(reg, size) \ |
| 929 | static inline void kvmppc_set_##reg(struct kvm_vcpu *vcpu, u##size val) \ |
| 930 | { \ |
| 931 | if (kvmppc_shared_big_endian(vcpu)) \ |
| 932 | vcpu->arch.shared->reg = cpu_to_be##size(val); \ |
| 933 | else \ |
| 934 | vcpu->arch.shared->reg = cpu_to_le##size(val); \ |
| 935 | } \ |
| 936 | |
| 937 | #define SHARED_WRAPPER(reg, size) \ |
| 938 | SHARED_WRAPPER_GET(reg, size) \ |
| 939 | SHARED_WRAPPER_SET(reg, size) \ |
| 940 | |
Bharat Bhushan | 5a484c7 | 2014-07-30 15:03:56 +0530 | [diff] [blame] | 941 | #define SPRNG_WRAPPER(reg, bookehv_spr) \ |
| 942 | SPRNG_WRAPPER_GET(reg, bookehv_spr) \ |
| 943 | SPRNG_WRAPPER_SET(reg, bookehv_spr) \ |
Bharat Bhushan | 1dc0c5b | 2014-07-17 17:01:35 +0530 | [diff] [blame] | 944 | |
| 945 | #ifdef CONFIG_KVM_BOOKE_HV |
| 946 | |
Bharat Bhushan | 5a484c7 | 2014-07-30 15:03:56 +0530 | [diff] [blame] | 947 | #define SHARED_SPRNG_WRAPPER(reg, size, bookehv_spr) \ |
| 948 | SPRNG_WRAPPER(reg, bookehv_spr) \ |
Bharat Bhushan | 1dc0c5b | 2014-07-17 17:01:35 +0530 | [diff] [blame] | 949 | |
| 950 | #else |
| 951 | |
Bharat Bhushan | 5a484c7 | 2014-07-30 15:03:56 +0530 | [diff] [blame] | 952 | #define SHARED_SPRNG_WRAPPER(reg, size, bookehv_spr) \ |
Bharat Bhushan | 1dc0c5b | 2014-07-17 17:01:35 +0530 | [diff] [blame] | 953 | SHARED_WRAPPER(reg, size) \ |
| 954 | |
| 955 | #endif |
| 956 | |
Alexander Graf | 5deb8e7 | 2014-04-24 13:46:24 +0200 | [diff] [blame] | 957 | SHARED_WRAPPER(critical, 64) |
Bharat Bhushan | 1dc0c5b | 2014-07-17 17:01:35 +0530 | [diff] [blame] | 958 | SHARED_SPRNG_WRAPPER(sprg0, 64, SPRN_GSPRG0) |
| 959 | SHARED_SPRNG_WRAPPER(sprg1, 64, SPRN_GSPRG1) |
| 960 | SHARED_SPRNG_WRAPPER(sprg2, 64, SPRN_GSPRG2) |
| 961 | SHARED_SPRNG_WRAPPER(sprg3, 64, SPRN_GSPRG3) |
| 962 | SHARED_SPRNG_WRAPPER(srr0, 64, SPRN_GSRR0) |
| 963 | SHARED_SPRNG_WRAPPER(srr1, 64, SPRN_GSRR1) |
| 964 | SHARED_SPRNG_WRAPPER(dar, 64, SPRN_GDEAR) |
Bharat Bhushan | dc16854 | 2014-07-17 17:01:38 +0530 | [diff] [blame] | 965 | SHARED_SPRNG_WRAPPER(esr, 64, SPRN_GESR) |
Alexander Graf | 5deb8e7 | 2014-04-24 13:46:24 +0200 | [diff] [blame] | 966 | SHARED_WRAPPER_GET(msr, 64) |
| 967 | static inline void kvmppc_set_msr_fast(struct kvm_vcpu *vcpu, u64 val) |
| 968 | { |
| 969 | if (kvmppc_shared_big_endian(vcpu)) |
| 970 | vcpu->arch.shared->msr = cpu_to_be64(val); |
| 971 | else |
| 972 | vcpu->arch.shared->msr = cpu_to_le64(val); |
| 973 | } |
| 974 | SHARED_WRAPPER(dsisr, 32) |
| 975 | SHARED_WRAPPER(int_pending, 32) |
| 976 | SHARED_WRAPPER(sprg4, 64) |
| 977 | SHARED_WRAPPER(sprg5, 64) |
| 978 | SHARED_WRAPPER(sprg6, 64) |
| 979 | SHARED_WRAPPER(sprg7, 64) |
| 980 | |
| 981 | static inline u32 kvmppc_get_sr(struct kvm_vcpu *vcpu, int nr) |
| 982 | { |
| 983 | if (kvmppc_shared_big_endian(vcpu)) |
| 984 | return be32_to_cpu(vcpu->arch.shared->sr[nr]); |
| 985 | else |
| 986 | return le32_to_cpu(vcpu->arch.shared->sr[nr]); |
| 987 | } |
| 988 | |
| 989 | static inline void kvmppc_set_sr(struct kvm_vcpu *vcpu, int nr, u32 val) |
| 990 | { |
| 991 | if (kvmppc_shared_big_endian(vcpu)) |
| 992 | vcpu->arch.shared->sr[nr] = cpu_to_be32(val); |
| 993 | else |
| 994 | vcpu->arch.shared->sr[nr] = cpu_to_le32(val); |
| 995 | } |
| 996 | |
| 997 | /* |
Scott Wood | 5f1c248 | 2013-07-10 17:47:39 -0500 | [diff] [blame] | 998 | * Please call after prepare_to_enter. This function puts the lazy ee and irq |
| 999 | * disabled tracking state back to normal mode, without actually enabling |
| 1000 | * interrupts. |
| 1001 | */ |
| 1002 | static inline void kvmppc_fix_ee_before_entry(void) |
Alexander Graf | bd2be68 | 2012-08-13 01:04:19 +0200 | [diff] [blame] | 1003 | { |
Scott Wood | 5f1c248 | 2013-07-10 17:47:39 -0500 | [diff] [blame] | 1004 | trace_hardirqs_on(); |
| 1005 | |
Alexander Graf | bd2be68 | 2012-08-13 01:04:19 +0200 | [diff] [blame] | 1006 | #ifdef CONFIG_PPC64 |
Scott Wood | 6c85f52 | 2014-01-09 19:18:40 -0600 | [diff] [blame] | 1007 | /* |
| 1008 | * To avoid races, the caller must have gone directly from having |
| 1009 | * interrupts fully-enabled to hard-disabled. |
| 1010 | */ |
| 1011 | WARN_ON(local_paca->irq_happened != PACA_IRQ_HARD_DIS); |
| 1012 | |
Alexander Graf | bd2be68 | 2012-08-13 01:04:19 +0200 | [diff] [blame] | 1013 | /* Only need to enable IRQs by hard enabling them after this */ |
| 1014 | local_paca->irq_happened = 0; |
Madhavan Srinivasan | 4e26bc4 | 2017-12-20 09:25:50 +0530 | [diff] [blame] | 1015 | irq_soft_mask_set(IRQS_ENABLED); |
Alexander Graf | bd2be68 | 2012-08-13 01:04:19 +0200 | [diff] [blame] | 1016 | #endif |
| 1017 | } |
Alexander Graf | 249ba1e | 2012-08-03 13:56:33 +0200 | [diff] [blame] | 1018 | |
Mihai Caraman | 7cdd7a9 | 2012-10-11 06:13:22 +0000 | [diff] [blame] | 1019 | static inline ulong kvmppc_get_ea_indexed(struct kvm_vcpu *vcpu, int ra, int rb) |
| 1020 | { |
| 1021 | ulong ea; |
Mihai Caraman | 8823a8f | 2012-10-11 06:13:23 +0000 | [diff] [blame] | 1022 | ulong msr_64bit = 0; |
Mihai Caraman | 7cdd7a9 | 2012-10-11 06:13:22 +0000 | [diff] [blame] | 1023 | |
| 1024 | ea = kvmppc_get_gpr(vcpu, rb); |
| 1025 | if (ra) |
| 1026 | ea += kvmppc_get_gpr(vcpu, ra); |
| 1027 | |
Mihai Caraman | 8823a8f | 2012-10-11 06:13:23 +0000 | [diff] [blame] | 1028 | #if defined(CONFIG_PPC_BOOK3E_64) |
| 1029 | msr_64bit = MSR_CM; |
| 1030 | #elif defined(CONFIG_PPC_BOOK3S_64) |
| 1031 | msr_64bit = MSR_SF; |
| 1032 | #endif |
| 1033 | |
Alexander Graf | 5deb8e7 | 2014-04-24 13:46:24 +0200 | [diff] [blame] | 1034 | if (!(kvmppc_get_msr(vcpu) & msr_64bit)) |
Mihai Caraman | 8823a8f | 2012-10-11 06:13:23 +0000 | [diff] [blame] | 1035 | ea = (uint32_t)ea; |
| 1036 | |
Mihai Caraman | 7cdd7a9 | 2012-10-11 06:13:22 +0000 | [diff] [blame] | 1037 | return ea; |
| 1038 | } |
| 1039 | |
Benjamin Herrenschmidt | 54695c3 | 2013-04-17 20:30:50 +0000 | [diff] [blame] | 1040 | extern void xics_wake_cpu(int cpu); |
| 1041 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 1042 | #endif /* __POWERPC_KVM_PPC_H__ */ |