aurel32 | d76d165 | 2008-12-16 10:43:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 IBM Corporation. |
| 3 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> |
| 4 | * |
| 5 | * This work is licensed under the GNU GPL license version 2 or later. |
| 6 | * |
| 7 | */ |
| 8 | |
Markus Armbruster | 2a6a407 | 2016-06-29 13:47:03 +0200 | [diff] [blame] | 9 | #ifndef KVM_PPC_H |
| 10 | #define KVM_PPC_H |
aurel32 | d76d165 | 2008-12-16 10:43:58 +0000 | [diff] [blame] | 11 | |
Igor Mammedov | c913706 | 2017-08-30 15:24:29 +0200 | [diff] [blame] | 12 | #define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host") |
Andreas Färber | 2985b86 | 2013-01-06 08:31:30 +0000 | [diff] [blame] | 13 | |
Alexander Graf | 921e28d | 2011-07-21 02:54:51 +0200 | [diff] [blame] | 14 | #ifdef CONFIG_KVM |
| 15 | |
Alexander Graf | dc333cd | 2010-02-09 17:37:05 +0100 | [diff] [blame] | 16 | uint32_t kvmppc_get_tbfreq(void); |
Alexander Graf | eadaada | 2011-07-21 02:29:15 +0200 | [diff] [blame] | 17 | uint64_t kvmppc_get_clockfreq(void); |
Nikunj A Dadhania | ef95144 | 2014-07-09 16:08:37 +0530 | [diff] [blame] | 18 | bool kvmppc_get_host_model(char **buf); |
| 19 | bool kvmppc_get_host_serial(char **buf); |
Stuart Yoder | 1a61a9a | 2013-01-03 12:37:02 +0000 | [diff] [blame] | 20 | int kvmppc_get_hasidle(CPUPPCState *env); |
Andreas Färber | 1328c2b | 2012-03-14 01:38:22 +0100 | [diff] [blame] | 21 | int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len); |
Andreas Färber | 1bc2265 | 2012-10-31 06:06:49 +0100 | [diff] [blame] | 22 | int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level); |
David Gibson | 026bfd8 | 2015-05-07 15:33:59 +1000 | [diff] [blame] | 23 | void kvmppc_enable_logical_ci_hcalls(void); |
Alexey Kardashevskiy | ef9971d | 2015-09-08 11:25:13 +1000 | [diff] [blame] | 24 | void kvmppc_enable_set_mode_hcall(void); |
Nathan Whitehorn | 5145ad4 | 2016-08-30 01:02:47 +0000 | [diff] [blame] | 25 | void kvmppc_enable_clear_ref_mod_hcalls(void); |
Andreas Färber | 1bc2265 | 2012-10-31 06:06:49 +0100 | [diff] [blame] | 26 | void kvmppc_set_papr(PowerPCCPU *cpu); |
David Gibson | d6e166c | 2016-10-28 22:09:37 +1100 | [diff] [blame] | 27 | int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr); |
Alexander Graf | 5b95b8b | 2013-01-17 11:54:38 +0100 | [diff] [blame] | 28 | void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy); |
David Gibson | e97c363 | 2011-09-29 21:39:10 +0000 | [diff] [blame] | 29 | int kvmppc_smt_threads(void); |
Sam Bobroff | fa98fbf | 2017-08-18 15:50:22 +1000 | [diff] [blame] | 30 | void kvmppc_hint_smt_possible(Error **errp); |
| 31 | int kvmppc_set_smt_threads(int smt); |
Bharat Bhushan | 31f2cb8 | 2013-02-24 18:16:21 +0000 | [diff] [blame] | 32 | int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits); |
| 33 | int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits); |
| 34 | int kvmppc_set_tcr(PowerPCCPU *cpu); |
| 35 | int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu); |
Suraj Jitindar Singh | b4db541 | 2017-03-20 10:46:46 +1100 | [diff] [blame] | 36 | target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, |
| 37 | bool radix, bool gtse, |
| 38 | uint64_t proc_tbl); |
David Gibson | 98efaf7 | 2011-10-23 17:25:04 +0000 | [diff] [blame] | 39 | #ifndef CONFIG_USER_ONLY |
Alexey Kardashevskiy | 658fa66 | 2014-07-11 01:03:41 +1000 | [diff] [blame] | 40 | off_t kvmppc_alloc_rma(void **rma); |
Alexey Kardashevskiy | da95324 | 2014-05-27 15:36:30 +1000 | [diff] [blame] | 41 | bool kvmppc_spapr_use_multitce(void); |
Alexey Kardashevskiy | 3dc410a | 2017-03-27 16:22:19 +1100 | [diff] [blame] | 42 | int kvmppc_spapr_enable_inkernel_multitce(void); |
Alexey Kardashevskiy | d6ee2a7 | 2017-03-10 12:41:13 +1100 | [diff] [blame] | 43 | void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, |
| 44 | uint64_t bus_offset, uint32_t nb_table, |
| 45 | int *pfd, bool need_vfio); |
David Gibson | 0f5cb29 | 2011-09-29 21:39:12 +0000 | [diff] [blame] | 46 | int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size); |
David Gibson | 7f763a5 | 2012-09-12 16:57:12 +0000 | [diff] [blame] | 47 | int kvmppc_reset_htab(int shift_hint); |
| 48 | uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift); |
Alexey Kardashevskiy | 9ded780 | 2018-02-06 11:08:24 -0700 | [diff] [blame] | 49 | bool kvmppc_has_cap_spapr_vfio(void); |
David Gibson | 98efaf7 | 2011-10-23 17:25:04 +0000 | [diff] [blame] | 50 | #endif /* !CONFIG_USER_ONLY */ |
Stuart Yoder | 3b96112 | 2013-03-30 06:40:49 +0000 | [diff] [blame] | 51 | bool kvmppc_has_cap_epr(void); |
David Gibson | feaa64c | 2013-09-26 16:18:35 +1000 | [diff] [blame] | 52 | int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function); |
Greg Kurz | 14b0d74 | 2017-09-15 15:16:20 +0200 | [diff] [blame] | 53 | int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp); |
Alexey Kardashevskiy | e68cb8b | 2013-07-18 14:33:03 -0500 | [diff] [blame] | 54 | int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns); |
| 55 | int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, |
| 56 | uint16_t n_valid, uint16_t n_invalid); |
David Gibson | 1ad9f0a | 2017-02-27 15:34:19 +1100 | [diff] [blame] | 57 | void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, hwaddr ptex, int n); |
| 58 | void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1); |
Alexander Graf | 87a91de | 2014-06-04 12:14:08 +0200 | [diff] [blame] | 59 | bool kvmppc_has_cap_fixup_hcalls(void); |
Thomas Huth | bac3bf2 | 2016-09-28 13:16:30 +0200 | [diff] [blame] | 60 | bool kvmppc_has_cap_htm(void); |
Sam Bobroff | cf1c4cc | 2017-03-20 10:46:44 +1100 | [diff] [blame] | 61 | bool kvmppc_has_cap_mmu_radix(void); |
| 62 | bool kvmppc_has_cap_mmu_hash_v3(void); |
Suraj Jitindar Singh | 8acc2ae | 2018-01-19 15:59:59 +1100 | [diff] [blame] | 63 | int kvmppc_get_cap_safe_cache(void); |
| 64 | int kvmppc_get_cap_safe_bounds_check(void); |
| 65 | int kvmppc_get_cap_safe_indirect_branch(void); |
Thomas Huth | 4d9392b | 2015-09-17 10:49:41 +0200 | [diff] [blame] | 66 | int kvmppc_enable_hwrng(void); |
David Gibson | e5c0d3c | 2016-03-08 11:33:46 +1100 | [diff] [blame] | 67 | int kvmppc_put_books_sregs(PowerPCCPU *cpu); |
Thomas Huth | 52b2519 | 2016-06-07 17:39:38 +0200 | [diff] [blame] | 68 | PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void); |
David Gibson | 30f4b05 | 2017-05-12 15:46:11 +1000 | [diff] [blame] | 69 | void kvmppc_check_papr_resize_hpt(Error **errp); |
David Gibson | b55d295 | 2017-07-12 17:56:55 +1000 | [diff] [blame] | 70 | int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, target_ulong flags, int shift); |
| 71 | int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulong flags, int shift); |
Daniel Henrique Barboza | c363a37 | 2017-08-09 17:43:46 -0300 | [diff] [blame] | 72 | bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu); |
Aneesh Kumar K.V | c138593 | 2014-02-20 18:52:38 +0100 | [diff] [blame] | 73 | |
Greg Kurz | ec69355 | 2017-06-06 18:12:24 +0200 | [diff] [blame] | 74 | bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path); |
Thomas Huth | df58713 | 2017-02-15 10:21:44 +0100 | [diff] [blame] | 75 | |
Alexander Graf | 921e28d | 2011-07-21 02:54:51 +0200 | [diff] [blame] | 76 | #else |
| 77 | |
| 78 | static inline uint32_t kvmppc_get_tbfreq(void) |
| 79 | { |
| 80 | return 0; |
| 81 | } |
| 82 | |
Nikunj A Dadhania | ef95144 | 2014-07-09 16:08:37 +0530 | [diff] [blame] | 83 | static inline bool kvmppc_get_host_model(char **buf) |
| 84 | { |
| 85 | return false; |
| 86 | } |
| 87 | |
| 88 | static inline bool kvmppc_get_host_serial(char **buf) |
| 89 | { |
| 90 | return false; |
| 91 | } |
| 92 | |
Alexander Graf | 921e28d | 2011-07-21 02:54:51 +0200 | [diff] [blame] | 93 | static inline uint64_t kvmppc_get_clockfreq(void) |
| 94 | { |
| 95 | return 0; |
| 96 | } |
| 97 | |
David Gibson | 6659394 | 2011-10-10 18:31:01 +0000 | [diff] [blame] | 98 | static inline uint32_t kvmppc_get_vmx(void) |
| 99 | { |
| 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | static inline uint32_t kvmppc_get_dfp(void) |
| 104 | { |
| 105 | return 0; |
| 106 | } |
| 107 | |
Stuart Yoder | 1a61a9a | 2013-01-03 12:37:02 +0000 | [diff] [blame] | 108 | static inline int kvmppc_get_hasidle(CPUPPCState *env) |
| 109 | { |
| 110 | return 0; |
| 111 | } |
| 112 | |
Andreas Färber | 1328c2b | 2012-03-14 01:38:22 +0100 | [diff] [blame] | 113 | static inline int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len) |
Alexander Graf | 921e28d | 2011-07-21 02:54:51 +0200 | [diff] [blame] | 114 | { |
| 115 | return -1; |
| 116 | } |
| 117 | |
Andreas Färber | 1bc2265 | 2012-10-31 06:06:49 +0100 | [diff] [blame] | 118 | static inline int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level) |
Alexander Graf | 921e28d | 2011-07-21 02:54:51 +0200 | [diff] [blame] | 119 | { |
| 120 | return -1; |
| 121 | } |
| 122 | |
David Gibson | 026bfd8 | 2015-05-07 15:33:59 +1000 | [diff] [blame] | 123 | static inline void kvmppc_enable_logical_ci_hcalls(void) |
| 124 | { |
| 125 | } |
| 126 | |
Alexey Kardashevskiy | ef9971d | 2015-09-08 11:25:13 +1000 | [diff] [blame] | 127 | static inline void kvmppc_enable_set_mode_hcall(void) |
| 128 | { |
| 129 | } |
| 130 | |
Nathan Whitehorn | 5145ad4 | 2016-08-30 01:02:47 +0000 | [diff] [blame] | 131 | static inline void kvmppc_enable_clear_ref_mod_hcalls(void) |
| 132 | { |
| 133 | } |
| 134 | |
Andreas Färber | 1bc2265 | 2012-10-31 06:06:49 +0100 | [diff] [blame] | 135 | static inline void kvmppc_set_papr(PowerPCCPU *cpu) |
Alexander Graf | f61b4be | 2011-08-09 17:57:37 +0200 | [diff] [blame] | 136 | { |
| 137 | } |
| 138 | |
David Gibson | d6e166c | 2016-10-28 22:09:37 +1100 | [diff] [blame] | 139 | static inline int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr) |
Alexey Kardashevskiy | 6db5bb0 | 2014-05-23 12:26:58 +1000 | [diff] [blame] | 140 | { |
| 141 | return 0; |
| 142 | } |
| 143 | |
Alexander Graf | 5b95b8b | 2013-01-17 11:54:38 +0100 | [diff] [blame] | 144 | static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy) |
| 145 | { |
| 146 | } |
| 147 | |
David Gibson | e97c363 | 2011-09-29 21:39:10 +0000 | [diff] [blame] | 148 | static inline int kvmppc_smt_threads(void) |
| 149 | { |
| 150 | return 1; |
| 151 | } |
| 152 | |
Sam Bobroff | fa98fbf | 2017-08-18 15:50:22 +1000 | [diff] [blame] | 153 | static inline void kvmppc_hint_smt_possible(Error **errp) |
| 154 | { |
| 155 | return; |
| 156 | } |
| 157 | |
| 158 | static inline int kvmppc_set_smt_threads(int smt) |
| 159 | { |
| 160 | return 0; |
| 161 | } |
| 162 | |
Bharat Bhushan | 31f2cb8 | 2013-02-24 18:16:21 +0000 | [diff] [blame] | 163 | static inline int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) |
| 164 | { |
| 165 | return 0; |
| 166 | } |
| 167 | |
| 168 | static inline int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) |
| 169 | { |
| 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | static inline int kvmppc_set_tcr(PowerPCCPU *cpu) |
| 174 | { |
| 175 | return 0; |
| 176 | } |
| 177 | |
| 178 | static inline int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu) |
| 179 | { |
| 180 | return -1; |
| 181 | } |
| 182 | |
Suraj Jitindar Singh | b4db541 | 2017-03-20 10:46:46 +1100 | [diff] [blame] | 183 | static inline target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, |
| 184 | bool radix, bool gtse, |
| 185 | uint64_t proc_tbl) |
| 186 | { |
| 187 | return 0; |
| 188 | } |
| 189 | |
David Gibson | 98efaf7 | 2011-10-23 17:25:04 +0000 | [diff] [blame] | 190 | #ifndef CONFIG_USER_ONLY |
Alexey Kardashevskiy | 658fa66 | 2014-07-11 01:03:41 +1000 | [diff] [blame] | 191 | static inline off_t kvmppc_alloc_rma(void **rma) |
David Gibson | 354ac20 | 2011-09-29 21:39:11 +0000 | [diff] [blame] | 192 | { |
| 193 | return 0; |
| 194 | } |
| 195 | |
Alexey Kardashevskiy | da95324 | 2014-05-27 15:36:30 +1000 | [diff] [blame] | 196 | static inline bool kvmppc_spapr_use_multitce(void) |
| 197 | { |
| 198 | return false; |
| 199 | } |
| 200 | |
Alexey Kardashevskiy | 3dc410a | 2017-03-27 16:22:19 +1100 | [diff] [blame] | 201 | static inline int kvmppc_spapr_enable_inkernel_multitce(void) |
| 202 | { |
| 203 | return -1; |
| 204 | } |
| 205 | |
Alexey Kardashevskiy | d6ee2a7 | 2017-03-10 12:41:13 +1100 | [diff] [blame] | 206 | static inline void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, |
| 207 | uint64_t bus_offset, |
| 208 | uint32_t nb_table, |
| 209 | int *pfd, bool need_vfio) |
David Gibson | 0f5cb29 | 2011-09-29 21:39:12 +0000 | [diff] [blame] | 210 | { |
| 211 | return NULL; |
| 212 | } |
| 213 | |
| 214 | static inline int kvmppc_remove_spapr_tce(void *table, int pfd, |
Alexey Kardashevskiy | 523e7b8 | 2014-05-27 15:36:35 +1000 | [diff] [blame] | 215 | uint32_t nb_table) |
David Gibson | 0f5cb29 | 2011-09-29 21:39:12 +0000 | [diff] [blame] | 216 | { |
| 217 | return -1; |
| 218 | } |
David Gibson | 7f763a5 | 2012-09-12 16:57:12 +0000 | [diff] [blame] | 219 | |
| 220 | static inline int kvmppc_reset_htab(int shift_hint) |
| 221 | { |
Bharata B Rao | a3166f8 | 2015-11-10 10:54:53 +0530 | [diff] [blame] | 222 | return 0; |
David Gibson | 7f763a5 | 2012-09-12 16:57:12 +0000 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | static inline uint64_t kvmppc_rma_size(uint64_t current_size, |
| 226 | unsigned int hash_shift) |
| 227 | { |
| 228 | return ram_size; |
| 229 | } |
| 230 | |
Greg Kurz | ec69355 | 2017-06-06 18:12:24 +0200 | [diff] [blame] | 231 | static inline bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path) |
Thomas Huth | df58713 | 2017-02-15 10:21:44 +0100 | [diff] [blame] | 232 | { |
| 233 | return true; |
| 234 | } |
| 235 | |
Alexey Kardashevskiy | 9ded780 | 2018-02-06 11:08:24 -0700 | [diff] [blame] | 236 | static inline bool kvmppc_has_cap_spapr_vfio(void) |
| 237 | { |
| 238 | return false; |
| 239 | } |
| 240 | |
David Gibson | 98efaf7 | 2011-10-23 17:25:04 +0000 | [diff] [blame] | 241 | #endif /* !CONFIG_USER_ONLY */ |
David Gibson | 0f5cb29 | 2011-09-29 21:39:12 +0000 | [diff] [blame] | 242 | |
Stuart Yoder | 3b96112 | 2013-03-30 06:40:49 +0000 | [diff] [blame] | 243 | static inline bool kvmppc_has_cap_epr(void) |
| 244 | { |
| 245 | return false; |
| 246 | } |
Alexey Kardashevskiy | e68cb8b | 2013-07-18 14:33:03 -0500 | [diff] [blame] | 247 | |
David Gibson | feaa64c | 2013-09-26 16:18:35 +1000 | [diff] [blame] | 248 | static inline int kvmppc_define_rtas_kernel_token(uint32_t token, |
| 249 | const char *function) |
| 250 | { |
| 251 | return -1; |
| 252 | } |
| 253 | |
Greg Kurz | 14b0d74 | 2017-09-15 15:16:20 +0200 | [diff] [blame] | 254 | static inline int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp) |
Alexey Kardashevskiy | e68cb8b | 2013-07-18 14:33:03 -0500 | [diff] [blame] | 255 | { |
| 256 | return -1; |
| 257 | } |
| 258 | |
| 259 | static inline int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, |
| 260 | int64_t max_ns) |
| 261 | { |
| 262 | abort(); |
| 263 | } |
| 264 | |
| 265 | static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, |
| 266 | uint16_t n_valid, uint16_t n_invalid) |
| 267 | { |
| 268 | abort(); |
| 269 | } |
| 270 | |
David Gibson | 1ad9f0a | 2017-02-27 15:34:19 +1100 | [diff] [blame] | 271 | static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, |
| 272 | hwaddr ptex, int n) |
Aneesh Kumar K.V | 7c43bca | 2014-02-20 18:52:24 +0100 | [diff] [blame] | 273 | { |
| 274 | abort(); |
| 275 | } |
| 276 | |
David Gibson | 1ad9f0a | 2017-02-27 15:34:19 +1100 | [diff] [blame] | 277 | static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1) |
Aneesh Kumar K.V | c138593 | 2014-02-20 18:52:38 +0100 | [diff] [blame] | 278 | { |
| 279 | abort(); |
| 280 | } |
| 281 | |
Alexander Graf | 87a91de | 2014-06-04 12:14:08 +0200 | [diff] [blame] | 282 | static inline bool kvmppc_has_cap_fixup_hcalls(void) |
| 283 | { |
| 284 | abort(); |
| 285 | } |
| 286 | |
Thomas Huth | bac3bf2 | 2016-09-28 13:16:30 +0200 | [diff] [blame] | 287 | static inline bool kvmppc_has_cap_htm(void) |
| 288 | { |
| 289 | return false; |
| 290 | } |
| 291 | |
Sam Bobroff | cf1c4cc | 2017-03-20 10:46:44 +1100 | [diff] [blame] | 292 | static inline bool kvmppc_has_cap_mmu_radix(void) |
| 293 | { |
| 294 | return false; |
| 295 | } |
| 296 | |
| 297 | static inline bool kvmppc_has_cap_mmu_hash_v3(void) |
| 298 | { |
| 299 | return false; |
| 300 | } |
| 301 | |
Suraj Jitindar Singh | 8acc2ae | 2018-01-19 15:59:59 +1100 | [diff] [blame] | 302 | static inline int kvmppc_get_cap_safe_cache(void) |
| 303 | { |
| 304 | return 0; |
| 305 | } |
| 306 | |
| 307 | static inline int kvmppc_get_cap_safe_bounds_check(void) |
| 308 | { |
| 309 | return 0; |
| 310 | } |
| 311 | |
| 312 | static inline int kvmppc_get_cap_safe_indirect_branch(void) |
| 313 | { |
| 314 | return 0; |
| 315 | } |
| 316 | |
Thomas Huth | 4d9392b | 2015-09-17 10:49:41 +0200 | [diff] [blame] | 317 | static inline int kvmppc_enable_hwrng(void) |
| 318 | { |
| 319 | return -1; |
| 320 | } |
David Gibson | e5c0d3c | 2016-03-08 11:33:46 +1100 | [diff] [blame] | 321 | |
| 322 | static inline int kvmppc_put_books_sregs(PowerPCCPU *cpu) |
| 323 | { |
| 324 | abort(); |
| 325 | } |
Thomas Huth | 52b2519 | 2016-06-07 17:39:38 +0200 | [diff] [blame] | 326 | |
| 327 | static inline PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) |
| 328 | { |
| 329 | return NULL; |
| 330 | } |
| 331 | |
David Gibson | 30f4b05 | 2017-05-12 15:46:11 +1000 | [diff] [blame] | 332 | static inline void kvmppc_check_papr_resize_hpt(Error **errp) |
| 333 | { |
| 334 | return; |
| 335 | } |
David Gibson | b55d295 | 2017-07-12 17:56:55 +1000 | [diff] [blame] | 336 | |
| 337 | static inline int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, |
| 338 | target_ulong flags, int shift) |
| 339 | { |
| 340 | return -ENOSYS; |
| 341 | } |
| 342 | |
| 343 | static inline int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, |
| 344 | target_ulong flags, int shift) |
| 345 | { |
| 346 | return -ENOSYS; |
| 347 | } |
| 348 | |
Alexander Graf | 921e28d | 2011-07-21 02:54:51 +0200 | [diff] [blame] | 349 | #endif |
| 350 | |
Ben Herrenschmidt | b45d63b | 2011-04-01 15:15:30 +1100 | [diff] [blame] | 351 | #ifndef CONFIG_KVM |
Thomas Huth | 3240dd9 | 2016-02-18 10:15:54 +0100 | [diff] [blame] | 352 | |
Ben Herrenschmidt | b45d63b | 2011-04-01 15:15:30 +1100 | [diff] [blame] | 353 | #define kvmppc_eieio() do { } while (0) |
Thomas Huth | 3240dd9 | 2016-02-18 10:15:54 +0100 | [diff] [blame] | 354 | |
| 355 | static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len) |
| 356 | { |
| 357 | } |
| 358 | |
| 359 | static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len) |
| 360 | { |
| 361 | } |
| 362 | |
| 363 | #else /* CONFIG_KVM */ |
| 364 | |
Ben Herrenschmidt | b45d63b | 2011-04-01 15:15:30 +1100 | [diff] [blame] | 365 | #define kvmppc_eieio() \ |
| 366 | do { \ |
| 367 | if (kvm_enabled()) { \ |
| 368 | asm volatile("eieio" : : : "memory"); \ |
| 369 | } \ |
| 370 | } while (0) |
Thomas Huth | 3240dd9 | 2016-02-18 10:15:54 +0100 | [diff] [blame] | 371 | |
| 372 | /* Store data cache blocks back to memory */ |
| 373 | static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len) |
| 374 | { |
| 375 | uint8_t *p; |
| 376 | |
| 377 | for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) { |
| 378 | asm volatile("dcbst 0,%0" : : "r"(p) : "memory"); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | /* Invalidate instruction cache blocks */ |
| 383 | static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len) |
| 384 | { |
| 385 | uint8_t *p; |
| 386 | |
| 387 | for (p = addr; p < addr + len; p += cpu->env.icache_line_size) { |
| 388 | asm volatile("icbi 0,%0" : : "r"(p)); |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | #endif /* CONFIG_KVM */ |
Ben Herrenschmidt | b45d63b | 2011-04-01 15:15:30 +1100 | [diff] [blame] | 393 | |
Markus Armbruster | 2a6a407 | 2016-06-29 13:47:03 +0200 | [diff] [blame] | 394 | #endif /* KVM_PPC_H */ |