1d76d1650Saurel32 /* 2d76d1650Saurel32 * Copyright 2008 IBM Corporation. 3d76d1650Saurel32 * Authors: Hollis Blanchard <hollisb@us.ibm.com> 4d76d1650Saurel32 * 5d76d1650Saurel32 * This work is licensed under the GNU GPL license version 2 or later. 6d76d1650Saurel32 * 7d76d1650Saurel32 */ 8d76d1650Saurel32 92a6a4076SMarkus Armbruster #ifndef KVM_PPC_H 102a6a4076SMarkus Armbruster #define KVM_PPC_H 11d76d1650Saurel32 12c9137065SIgor Mammedov #define TYPE_HOST_POWERPC_CPU POWERPC_CPU_TYPE_NAME("host") 132985b86bSAndreas Färber 14921e28dbSAlexander Graf #ifdef CONFIG_KVM 15921e28dbSAlexander Graf 16dc333cd6SAlexander Graf uint32_t kvmppc_get_tbfreq(void); 17eadaada1SAlexander Graf uint64_t kvmppc_get_clockfreq(void); 18ef951443SNikunj A Dadhania bool kvmppc_get_host_model(char **buf); 19ef951443SNikunj A Dadhania bool kvmppc_get_host_serial(char **buf); 201a61a9aeSStuart Yoder int kvmppc_get_hasidle(CPUPPCState *env); 211328c2bfSAndreas Färber int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len); 221bc22652SAndreas Färber int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level); 23026bfd89SDavid Gibson void kvmppc_enable_logical_ci_hcalls(void); 24ef9971ddSAlexey Kardashevskiy void kvmppc_enable_set_mode_hcall(void); 255145ad4fSNathan Whitehorn void kvmppc_enable_clear_ref_mod_hcalls(void); 261bc22652SAndreas Färber void kvmppc_set_papr(PowerPCCPU *cpu); 27d6e166c0SDavid Gibson int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr); 285b95b8b9SAlexander Graf void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy); 29e97c3636SDavid Gibson int kvmppc_smt_threads(void); 30fa98fbfcSSam Bobroff void kvmppc_hint_smt_possible(Error **errp); 31fa98fbfcSSam Bobroff int kvmppc_set_smt_threads(int smt); 3231f2cb8fSBharat Bhushan int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits); 3331f2cb8fSBharat Bhushan int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits); 3431f2cb8fSBharat Bhushan int kvmppc_set_tcr(PowerPCCPU *cpu); 3531f2cb8fSBharat Bhushan int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu); 36b4db5413SSuraj Jitindar Singh target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, 37b4db5413SSuraj Jitindar Singh bool radix, bool gtse, 38b4db5413SSuraj Jitindar Singh uint64_t proc_tbl); 3998efaf75SDavid Gibson #ifndef CONFIG_USER_ONLY 40da95324eSAlexey Kardashevskiy bool kvmppc_spapr_use_multitce(void); 413dc410aeSAlexey Kardashevskiy int kvmppc_spapr_enable_inkernel_multitce(void); 42d6ee2a7cSAlexey Kardashevskiy void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, 43d6ee2a7cSAlexey Kardashevskiy uint64_t bus_offset, uint32_t nb_table, 44d6ee2a7cSAlexey Kardashevskiy int *pfd, bool need_vfio); 450f5cb298SDavid Gibson int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size); 467f763a5dSDavid Gibson int kvmppc_reset_htab(int shift_hint); 477f763a5dSDavid Gibson uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift); 489ded780cSAlexey Kardashevskiy bool kvmppc_has_cap_spapr_vfio(void); 4998efaf75SDavid Gibson #endif /* !CONFIG_USER_ONLY */ 503b961124SStuart Yoder bool kvmppc_has_cap_epr(void); 51feaa64c4SDavid Gibson int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function); 5214b0d748SGreg Kurz int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp); 53e68cb8b4SAlexey Kardashevskiy int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns); 54e68cb8b4SAlexey Kardashevskiy int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, 55e68cb8b4SAlexey Kardashevskiy uint16_t n_valid, uint16_t n_invalid); 561ad9f0a4SDavid Gibson void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, hwaddr ptex, int n); 571ad9f0a4SDavid Gibson void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1); 5887a91de6SAlexander Graf bool kvmppc_has_cap_fixup_hcalls(void); 59bac3bf28SThomas Huth bool kvmppc_has_cap_htm(void); 60cf1c4cceSSam Bobroff bool kvmppc_has_cap_mmu_radix(void); 61cf1c4cceSSam Bobroff bool kvmppc_has_cap_mmu_hash_v3(void); 628acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_cache(void); 638acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_bounds_check(void); 648acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_indirect_branch(void); 65*b9a477b7SSuraj Jitindar Singh bool kvmppc_has_cap_nested_kvm_hv(void); 66*b9a477b7SSuraj Jitindar Singh int kvmppc_set_cap_nested_kvm_hv(int enable); 674d9392beSThomas Huth int kvmppc_enable_hwrng(void); 68e5c0d3ceSDavid Gibson int kvmppc_put_books_sregs(PowerPCCPU *cpu); 6952b2519cSThomas Huth PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void); 7030f4b05bSDavid Gibson void kvmppc_check_papr_resize_hpt(Error **errp); 71b55d295eSDavid Gibson int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, target_ulong flags, int shift); 72b55d295eSDavid Gibson int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulong flags, int shift); 73c363a37aSDaniel Henrique Barboza bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu); 74c1385933SAneesh Kumar K.V 7524c6863cSDavid Gibson bool kvmppc_hpt_needs_host_contiguous_pages(void); 76e5ca28ecSDavid Gibson void kvm_check_mmu(PowerPCCPU *cpu, Error **errp); 77a84f7179SNikunj A Dadhania void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online); 78df587133SThomas Huth 79921e28dbSAlexander Graf #else 80921e28dbSAlexander Graf 81921e28dbSAlexander Graf static inline uint32_t kvmppc_get_tbfreq(void) 82921e28dbSAlexander Graf { 83921e28dbSAlexander Graf return 0; 84921e28dbSAlexander Graf } 85921e28dbSAlexander Graf 86ef951443SNikunj A Dadhania static inline bool kvmppc_get_host_model(char **buf) 87ef951443SNikunj A Dadhania { 88ef951443SNikunj A Dadhania return false; 89ef951443SNikunj A Dadhania } 90ef951443SNikunj A Dadhania 91ef951443SNikunj A Dadhania static inline bool kvmppc_get_host_serial(char **buf) 92ef951443SNikunj A Dadhania { 93ef951443SNikunj A Dadhania return false; 94ef951443SNikunj A Dadhania } 95ef951443SNikunj A Dadhania 96921e28dbSAlexander Graf static inline uint64_t kvmppc_get_clockfreq(void) 97921e28dbSAlexander Graf { 98921e28dbSAlexander Graf return 0; 99921e28dbSAlexander Graf } 100921e28dbSAlexander Graf 1016659394fSDavid Gibson static inline uint32_t kvmppc_get_vmx(void) 1026659394fSDavid Gibson { 1036659394fSDavid Gibson return 0; 1046659394fSDavid Gibson } 1056659394fSDavid Gibson 1066659394fSDavid Gibson static inline uint32_t kvmppc_get_dfp(void) 1076659394fSDavid Gibson { 1086659394fSDavid Gibson return 0; 1096659394fSDavid Gibson } 1106659394fSDavid Gibson 1111a61a9aeSStuart Yoder static inline int kvmppc_get_hasidle(CPUPPCState *env) 1121a61a9aeSStuart Yoder { 1131a61a9aeSStuart Yoder return 0; 1141a61a9aeSStuart Yoder } 1151a61a9aeSStuart Yoder 1161328c2bfSAndreas Färber static inline int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len) 117921e28dbSAlexander Graf { 118921e28dbSAlexander Graf return -1; 119921e28dbSAlexander Graf } 120921e28dbSAlexander Graf 1211bc22652SAndreas Färber static inline int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level) 122921e28dbSAlexander Graf { 123921e28dbSAlexander Graf return -1; 124921e28dbSAlexander Graf } 125921e28dbSAlexander Graf 126026bfd89SDavid Gibson static inline void kvmppc_enable_logical_ci_hcalls(void) 127026bfd89SDavid Gibson { 128026bfd89SDavid Gibson } 129026bfd89SDavid Gibson 130ef9971ddSAlexey Kardashevskiy static inline void kvmppc_enable_set_mode_hcall(void) 131ef9971ddSAlexey Kardashevskiy { 132ef9971ddSAlexey Kardashevskiy } 133ef9971ddSAlexey Kardashevskiy 1345145ad4fSNathan Whitehorn static inline void kvmppc_enable_clear_ref_mod_hcalls(void) 1355145ad4fSNathan Whitehorn { 1365145ad4fSNathan Whitehorn } 1375145ad4fSNathan Whitehorn 1381bc22652SAndreas Färber static inline void kvmppc_set_papr(PowerPCCPU *cpu) 139f61b4bedSAlexander Graf { 140f61b4bedSAlexander Graf } 141f61b4bedSAlexander Graf 142d6e166c0SDavid Gibson static inline int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr) 1436db5bb0fSAlexey Kardashevskiy { 1446db5bb0fSAlexey Kardashevskiy return 0; 1456db5bb0fSAlexey Kardashevskiy } 1466db5bb0fSAlexey Kardashevskiy 1475b95b8b9SAlexander Graf static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy) 1485b95b8b9SAlexander Graf { 1495b95b8b9SAlexander Graf } 1505b95b8b9SAlexander Graf 151e97c3636SDavid Gibson static inline int kvmppc_smt_threads(void) 152e97c3636SDavid Gibson { 153e97c3636SDavid Gibson return 1; 154e97c3636SDavid Gibson } 155e97c3636SDavid Gibson 156fa98fbfcSSam Bobroff static inline void kvmppc_hint_smt_possible(Error **errp) 157fa98fbfcSSam Bobroff { 158fa98fbfcSSam Bobroff return; 159fa98fbfcSSam Bobroff } 160fa98fbfcSSam Bobroff 161fa98fbfcSSam Bobroff static inline int kvmppc_set_smt_threads(int smt) 162fa98fbfcSSam Bobroff { 163fa98fbfcSSam Bobroff return 0; 164fa98fbfcSSam Bobroff } 165fa98fbfcSSam Bobroff 16631f2cb8fSBharat Bhushan static inline int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) 16731f2cb8fSBharat Bhushan { 16831f2cb8fSBharat Bhushan return 0; 16931f2cb8fSBharat Bhushan } 17031f2cb8fSBharat Bhushan 17131f2cb8fSBharat Bhushan static inline int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) 17231f2cb8fSBharat Bhushan { 17331f2cb8fSBharat Bhushan return 0; 17431f2cb8fSBharat Bhushan } 17531f2cb8fSBharat Bhushan 17631f2cb8fSBharat Bhushan static inline int kvmppc_set_tcr(PowerPCCPU *cpu) 17731f2cb8fSBharat Bhushan { 17831f2cb8fSBharat Bhushan return 0; 17931f2cb8fSBharat Bhushan } 18031f2cb8fSBharat Bhushan 18131f2cb8fSBharat Bhushan static inline int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu) 18231f2cb8fSBharat Bhushan { 18331f2cb8fSBharat Bhushan return -1; 18431f2cb8fSBharat Bhushan } 18531f2cb8fSBharat Bhushan 186b4db5413SSuraj Jitindar Singh static inline target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, 187b4db5413SSuraj Jitindar Singh bool radix, bool gtse, 188b4db5413SSuraj Jitindar Singh uint64_t proc_tbl) 189b4db5413SSuraj Jitindar Singh { 190b4db5413SSuraj Jitindar Singh return 0; 191b4db5413SSuraj Jitindar Singh } 192b4db5413SSuraj Jitindar Singh 193a84f7179SNikunj A Dadhania static inline void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, 194a84f7179SNikunj A Dadhania unsigned int online) 195a84f7179SNikunj A Dadhania { 196a84f7179SNikunj A Dadhania return; 197a84f7179SNikunj A Dadhania } 198a84f7179SNikunj A Dadhania 19998efaf75SDavid Gibson #ifndef CONFIG_USER_ONLY 200da95324eSAlexey Kardashevskiy static inline bool kvmppc_spapr_use_multitce(void) 201da95324eSAlexey Kardashevskiy { 202da95324eSAlexey Kardashevskiy return false; 203da95324eSAlexey Kardashevskiy } 204da95324eSAlexey Kardashevskiy 2053dc410aeSAlexey Kardashevskiy static inline int kvmppc_spapr_enable_inkernel_multitce(void) 2063dc410aeSAlexey Kardashevskiy { 2073dc410aeSAlexey Kardashevskiy return -1; 2083dc410aeSAlexey Kardashevskiy } 2093dc410aeSAlexey Kardashevskiy 210d6ee2a7cSAlexey Kardashevskiy static inline void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, 211d6ee2a7cSAlexey Kardashevskiy uint64_t bus_offset, 212d6ee2a7cSAlexey Kardashevskiy uint32_t nb_table, 213d6ee2a7cSAlexey Kardashevskiy int *pfd, bool need_vfio) 2140f5cb298SDavid Gibson { 2150f5cb298SDavid Gibson return NULL; 2160f5cb298SDavid Gibson } 2170f5cb298SDavid Gibson 2180f5cb298SDavid Gibson static inline int kvmppc_remove_spapr_tce(void *table, int pfd, 219523e7b8aSAlexey Kardashevskiy uint32_t nb_table) 2200f5cb298SDavid Gibson { 2210f5cb298SDavid Gibson return -1; 2220f5cb298SDavid Gibson } 2237f763a5dSDavid Gibson 2247f763a5dSDavid Gibson static inline int kvmppc_reset_htab(int shift_hint) 2257f763a5dSDavid Gibson { 226a3166f8fSBharata B Rao return 0; 2277f763a5dSDavid Gibson } 2287f763a5dSDavid Gibson 2297f763a5dSDavid Gibson static inline uint64_t kvmppc_rma_size(uint64_t current_size, 2307f763a5dSDavid Gibson unsigned int hash_shift) 2317f763a5dSDavid Gibson { 2327f763a5dSDavid Gibson return ram_size; 2337f763a5dSDavid Gibson } 2347f763a5dSDavid Gibson 23524c6863cSDavid Gibson static inline bool kvmppc_hpt_needs_host_contiguous_pages(void) 23624c6863cSDavid Gibson { 23724c6863cSDavid Gibson return false; 23824c6863cSDavid Gibson } 23924c6863cSDavid Gibson 240e5ca28ecSDavid Gibson static inline void kvm_check_mmu(PowerPCCPU *cpu, Error **errp) 241e5ca28ecSDavid Gibson { 242e5ca28ecSDavid Gibson } 243e5ca28ecSDavid Gibson 2449ded780cSAlexey Kardashevskiy static inline bool kvmppc_has_cap_spapr_vfio(void) 2459ded780cSAlexey Kardashevskiy { 2469ded780cSAlexey Kardashevskiy return false; 2479ded780cSAlexey Kardashevskiy } 2489ded780cSAlexey Kardashevskiy 24998efaf75SDavid Gibson #endif /* !CONFIG_USER_ONLY */ 2500f5cb298SDavid Gibson 2513b961124SStuart Yoder static inline bool kvmppc_has_cap_epr(void) 2523b961124SStuart Yoder { 2533b961124SStuart Yoder return false; 2543b961124SStuart Yoder } 255e68cb8b4SAlexey Kardashevskiy 256feaa64c4SDavid Gibson static inline int kvmppc_define_rtas_kernel_token(uint32_t token, 257feaa64c4SDavid Gibson const char *function) 258feaa64c4SDavid Gibson { 259feaa64c4SDavid Gibson return -1; 260feaa64c4SDavid Gibson } 261feaa64c4SDavid Gibson 26214b0d748SGreg Kurz static inline int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp) 263e68cb8b4SAlexey Kardashevskiy { 264e68cb8b4SAlexey Kardashevskiy return -1; 265e68cb8b4SAlexey Kardashevskiy } 266e68cb8b4SAlexey Kardashevskiy 267e68cb8b4SAlexey Kardashevskiy static inline int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, 268e68cb8b4SAlexey Kardashevskiy int64_t max_ns) 269e68cb8b4SAlexey Kardashevskiy { 270e68cb8b4SAlexey Kardashevskiy abort(); 271e68cb8b4SAlexey Kardashevskiy } 272e68cb8b4SAlexey Kardashevskiy 273e68cb8b4SAlexey Kardashevskiy static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, 274e68cb8b4SAlexey Kardashevskiy uint16_t n_valid, uint16_t n_invalid) 275e68cb8b4SAlexey Kardashevskiy { 276e68cb8b4SAlexey Kardashevskiy abort(); 277e68cb8b4SAlexey Kardashevskiy } 278e68cb8b4SAlexey Kardashevskiy 2791ad9f0a4SDavid Gibson static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, 2801ad9f0a4SDavid Gibson hwaddr ptex, int n) 2817c43bca0SAneesh Kumar K.V { 2827c43bca0SAneesh Kumar K.V abort(); 2837c43bca0SAneesh Kumar K.V } 2847c43bca0SAneesh Kumar K.V 2851ad9f0a4SDavid Gibson static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1) 286c1385933SAneesh Kumar K.V { 287c1385933SAneesh Kumar K.V abort(); 288c1385933SAneesh Kumar K.V } 289c1385933SAneesh Kumar K.V 29087a91de6SAlexander Graf static inline bool kvmppc_has_cap_fixup_hcalls(void) 29187a91de6SAlexander Graf { 29287a91de6SAlexander Graf abort(); 29387a91de6SAlexander Graf } 29487a91de6SAlexander Graf 295bac3bf28SThomas Huth static inline bool kvmppc_has_cap_htm(void) 296bac3bf28SThomas Huth { 297bac3bf28SThomas Huth return false; 298bac3bf28SThomas Huth } 299bac3bf28SThomas Huth 300cf1c4cceSSam Bobroff static inline bool kvmppc_has_cap_mmu_radix(void) 301cf1c4cceSSam Bobroff { 302cf1c4cceSSam Bobroff return false; 303cf1c4cceSSam Bobroff } 304cf1c4cceSSam Bobroff 305cf1c4cceSSam Bobroff static inline bool kvmppc_has_cap_mmu_hash_v3(void) 306cf1c4cceSSam Bobroff { 307cf1c4cceSSam Bobroff return false; 308cf1c4cceSSam Bobroff } 309cf1c4cceSSam Bobroff 3108acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_cache(void) 3118acc2ae5SSuraj Jitindar Singh { 3128acc2ae5SSuraj Jitindar Singh return 0; 3138acc2ae5SSuraj Jitindar Singh } 3148acc2ae5SSuraj Jitindar Singh 3158acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_bounds_check(void) 3168acc2ae5SSuraj Jitindar Singh { 3178acc2ae5SSuraj Jitindar Singh return 0; 3188acc2ae5SSuraj Jitindar Singh } 3198acc2ae5SSuraj Jitindar Singh 3208acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_indirect_branch(void) 3218acc2ae5SSuraj Jitindar Singh { 3228acc2ae5SSuraj Jitindar Singh return 0; 3238acc2ae5SSuraj Jitindar Singh } 3248acc2ae5SSuraj Jitindar Singh 325*b9a477b7SSuraj Jitindar Singh static inline bool kvmppc_has_cap_nested_kvm_hv(void) 326*b9a477b7SSuraj Jitindar Singh { 327*b9a477b7SSuraj Jitindar Singh return false; 328*b9a477b7SSuraj Jitindar Singh } 329*b9a477b7SSuraj Jitindar Singh 330*b9a477b7SSuraj Jitindar Singh static inline int kvmppc_set_cap_nested_kvm_hv(int enable) 331*b9a477b7SSuraj Jitindar Singh { 332*b9a477b7SSuraj Jitindar Singh return -1; 333*b9a477b7SSuraj Jitindar Singh } 334*b9a477b7SSuraj Jitindar Singh 3354d9392beSThomas Huth static inline int kvmppc_enable_hwrng(void) 3364d9392beSThomas Huth { 3374d9392beSThomas Huth return -1; 3384d9392beSThomas Huth } 339e5c0d3ceSDavid Gibson 340e5c0d3ceSDavid Gibson static inline int kvmppc_put_books_sregs(PowerPCCPU *cpu) 341e5c0d3ceSDavid Gibson { 342e5c0d3ceSDavid Gibson abort(); 343e5c0d3ceSDavid Gibson } 34452b2519cSThomas Huth 34552b2519cSThomas Huth static inline PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) 34652b2519cSThomas Huth { 34752b2519cSThomas Huth return NULL; 34852b2519cSThomas Huth } 34952b2519cSThomas Huth 35030f4b05bSDavid Gibson static inline void kvmppc_check_papr_resize_hpt(Error **errp) 35130f4b05bSDavid Gibson { 35230f4b05bSDavid Gibson return; 35330f4b05bSDavid Gibson } 354b55d295eSDavid Gibson 355b55d295eSDavid Gibson static inline int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, 356b55d295eSDavid Gibson target_ulong flags, int shift) 357b55d295eSDavid Gibson { 358b55d295eSDavid Gibson return -ENOSYS; 359b55d295eSDavid Gibson } 360b55d295eSDavid Gibson 361b55d295eSDavid Gibson static inline int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, 362b55d295eSDavid Gibson target_ulong flags, int shift) 363b55d295eSDavid Gibson { 364b55d295eSDavid Gibson return -ENOSYS; 365b55d295eSDavid Gibson } 366b55d295eSDavid Gibson 367921e28dbSAlexander Graf #endif 368921e28dbSAlexander Graf 369b45d63b6SBen Herrenschmidt #ifndef CONFIG_KVM 3703240dd9aSThomas Huth 371b45d63b6SBen Herrenschmidt #define kvmppc_eieio() do { } while (0) 3723240dd9aSThomas Huth 3733240dd9aSThomas Huth static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len) 3743240dd9aSThomas Huth { 3753240dd9aSThomas Huth } 3763240dd9aSThomas Huth 3773240dd9aSThomas Huth static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len) 3783240dd9aSThomas Huth { 3793240dd9aSThomas Huth } 3803240dd9aSThomas Huth 3813240dd9aSThomas Huth #else /* CONFIG_KVM */ 3823240dd9aSThomas Huth 383b45d63b6SBen Herrenschmidt #define kvmppc_eieio() \ 384b45d63b6SBen Herrenschmidt do { \ 385b45d63b6SBen Herrenschmidt if (kvm_enabled()) { \ 386b45d63b6SBen Herrenschmidt asm volatile("eieio" : : : "memory"); \ 387b45d63b6SBen Herrenschmidt } \ 388b45d63b6SBen Herrenschmidt } while (0) 3893240dd9aSThomas Huth 3903240dd9aSThomas Huth /* Store data cache blocks back to memory */ 3913240dd9aSThomas Huth static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len) 3923240dd9aSThomas Huth { 3933240dd9aSThomas Huth uint8_t *p; 3943240dd9aSThomas Huth 3953240dd9aSThomas Huth for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) { 3963240dd9aSThomas Huth asm volatile("dcbst 0,%0" : : "r"(p) : "memory"); 3973240dd9aSThomas Huth } 3983240dd9aSThomas Huth } 3993240dd9aSThomas Huth 4003240dd9aSThomas Huth /* Invalidate instruction cache blocks */ 4013240dd9aSThomas Huth static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4023240dd9aSThomas Huth { 4033240dd9aSThomas Huth uint8_t *p; 4043240dd9aSThomas Huth 4053240dd9aSThomas Huth for (p = addr; p < addr + len; p += cpu->env.icache_line_size) { 4063240dd9aSThomas Huth asm volatile("icbi 0,%0" : : "r"(p)); 4073240dd9aSThomas Huth } 4083240dd9aSThomas Huth } 4093240dd9aSThomas Huth 4103240dd9aSThomas Huth #endif /* CONFIG_KVM */ 411b45d63b6SBen Herrenschmidt 4122a6a4076SMarkus Armbruster #endif /* KVM_PPC_H */ 413