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); 26*68f9f708SSuraj Jitindar Singh void kvmppc_enable_h_page_init(void); 271bc22652SAndreas Färber void kvmppc_set_papr(PowerPCCPU *cpu); 28d6e166c0SDavid Gibson int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr); 295b95b8b9SAlexander Graf void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy); 30e97c3636SDavid Gibson int kvmppc_smt_threads(void); 31fa98fbfcSSam Bobroff void kvmppc_hint_smt_possible(Error **errp); 32fa98fbfcSSam Bobroff int kvmppc_set_smt_threads(int smt); 3331f2cb8fSBharat Bhushan int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits); 3431f2cb8fSBharat Bhushan int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits); 3531f2cb8fSBharat Bhushan int kvmppc_set_tcr(PowerPCCPU *cpu); 3631f2cb8fSBharat Bhushan int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu); 37b4db5413SSuraj Jitindar Singh target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, 38b4db5413SSuraj Jitindar Singh bool radix, bool gtse, 39b4db5413SSuraj Jitindar Singh uint64_t proc_tbl); 4098efaf75SDavid Gibson #ifndef CONFIG_USER_ONLY 41da95324eSAlexey Kardashevskiy bool kvmppc_spapr_use_multitce(void); 423dc410aeSAlexey Kardashevskiy int kvmppc_spapr_enable_inkernel_multitce(void); 43d6ee2a7cSAlexey Kardashevskiy void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, 44d6ee2a7cSAlexey Kardashevskiy uint64_t bus_offset, uint32_t nb_table, 45d6ee2a7cSAlexey Kardashevskiy int *pfd, bool need_vfio); 460f5cb298SDavid Gibson int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size); 477f763a5dSDavid Gibson int kvmppc_reset_htab(int shift_hint); 487f763a5dSDavid Gibson uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift); 499ded780cSAlexey Kardashevskiy bool kvmppc_has_cap_spapr_vfio(void); 5098efaf75SDavid Gibson #endif /* !CONFIG_USER_ONLY */ 513b961124SStuart Yoder bool kvmppc_has_cap_epr(void); 52feaa64c4SDavid Gibson int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function); 5314b0d748SGreg Kurz int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp); 54e68cb8b4SAlexey Kardashevskiy int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns); 55e68cb8b4SAlexey Kardashevskiy int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, 56e68cb8b4SAlexey Kardashevskiy uint16_t n_valid, uint16_t n_invalid); 571ad9f0a4SDavid Gibson void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, hwaddr ptex, int n); 581ad9f0a4SDavid Gibson void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1); 5987a91de6SAlexander Graf bool kvmppc_has_cap_fixup_hcalls(void); 60bac3bf28SThomas Huth bool kvmppc_has_cap_htm(void); 61cf1c4cceSSam Bobroff bool kvmppc_has_cap_mmu_radix(void); 62cf1c4cceSSam Bobroff bool kvmppc_has_cap_mmu_hash_v3(void); 638acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_cache(void); 648acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_bounds_check(void); 658acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_indirect_branch(void); 668ff43ee4SSuraj Jitindar Singh int kvmppc_get_cap_count_cache_flush_assist(void); 67b9a477b7SSuraj Jitindar Singh bool kvmppc_has_cap_nested_kvm_hv(void); 68b9a477b7SSuraj Jitindar Singh int kvmppc_set_cap_nested_kvm_hv(int enable); 697d050527SSuraj Jitindar Singh int kvmppc_get_cap_large_decr(void); 707d050527SSuraj Jitindar Singh int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable); 714d9392beSThomas Huth int kvmppc_enable_hwrng(void); 72e5c0d3ceSDavid Gibson int kvmppc_put_books_sregs(PowerPCCPU *cpu); 7352b2519cSThomas Huth PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void); 7430f4b05bSDavid Gibson void kvmppc_check_papr_resize_hpt(Error **errp); 75b55d295eSDavid Gibson int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, target_ulong flags, int shift); 76b55d295eSDavid Gibson int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulong flags, int shift); 77c363a37aSDaniel Henrique Barboza bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu); 78c1385933SAneesh Kumar K.V 7924c6863cSDavid Gibson bool kvmppc_hpt_needs_host_contiguous_pages(void); 80e5ca28ecSDavid Gibson void kvm_check_mmu(PowerPCCPU *cpu, Error **errp); 81a84f7179SNikunj A Dadhania void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online); 82df587133SThomas Huth 83921e28dbSAlexander Graf #else 84921e28dbSAlexander Graf 85921e28dbSAlexander Graf static inline uint32_t kvmppc_get_tbfreq(void) 86921e28dbSAlexander Graf { 87921e28dbSAlexander Graf return 0; 88921e28dbSAlexander Graf } 89921e28dbSAlexander Graf 90ef951443SNikunj A Dadhania static inline bool kvmppc_get_host_model(char **buf) 91ef951443SNikunj A Dadhania { 92ef951443SNikunj A Dadhania return false; 93ef951443SNikunj A Dadhania } 94ef951443SNikunj A Dadhania 95ef951443SNikunj A Dadhania static inline bool kvmppc_get_host_serial(char **buf) 96ef951443SNikunj A Dadhania { 97ef951443SNikunj A Dadhania return false; 98ef951443SNikunj A Dadhania } 99ef951443SNikunj A Dadhania 100921e28dbSAlexander Graf static inline uint64_t kvmppc_get_clockfreq(void) 101921e28dbSAlexander Graf { 102921e28dbSAlexander Graf return 0; 103921e28dbSAlexander Graf } 104921e28dbSAlexander Graf 1056659394fSDavid Gibson static inline uint32_t kvmppc_get_vmx(void) 1066659394fSDavid Gibson { 1076659394fSDavid Gibson return 0; 1086659394fSDavid Gibson } 1096659394fSDavid Gibson 1106659394fSDavid Gibson static inline uint32_t kvmppc_get_dfp(void) 1116659394fSDavid Gibson { 1126659394fSDavid Gibson return 0; 1136659394fSDavid Gibson } 1146659394fSDavid Gibson 1151a61a9aeSStuart Yoder static inline int kvmppc_get_hasidle(CPUPPCState *env) 1161a61a9aeSStuart Yoder { 1171a61a9aeSStuart Yoder return 0; 1181a61a9aeSStuart Yoder } 1191a61a9aeSStuart Yoder 1201328c2bfSAndreas Färber static inline int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len) 121921e28dbSAlexander Graf { 122921e28dbSAlexander Graf return -1; 123921e28dbSAlexander Graf } 124921e28dbSAlexander Graf 1251bc22652SAndreas Färber static inline int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level) 126921e28dbSAlexander Graf { 127921e28dbSAlexander Graf return -1; 128921e28dbSAlexander Graf } 129921e28dbSAlexander Graf 130026bfd89SDavid Gibson static inline void kvmppc_enable_logical_ci_hcalls(void) 131026bfd89SDavid Gibson { 132026bfd89SDavid Gibson } 133026bfd89SDavid Gibson 134ef9971ddSAlexey Kardashevskiy static inline void kvmppc_enable_set_mode_hcall(void) 135ef9971ddSAlexey Kardashevskiy { 136ef9971ddSAlexey Kardashevskiy } 137ef9971ddSAlexey Kardashevskiy 1385145ad4fSNathan Whitehorn static inline void kvmppc_enable_clear_ref_mod_hcalls(void) 1395145ad4fSNathan Whitehorn { 1405145ad4fSNathan Whitehorn } 1415145ad4fSNathan Whitehorn 142*68f9f708SSuraj Jitindar Singh static inline void kvmppc_enable_h_page_init(void) 143*68f9f708SSuraj Jitindar Singh { 144*68f9f708SSuraj Jitindar Singh } 145*68f9f708SSuraj Jitindar Singh 1461bc22652SAndreas Färber static inline void kvmppc_set_papr(PowerPCCPU *cpu) 147f61b4bedSAlexander Graf { 148f61b4bedSAlexander Graf } 149f61b4bedSAlexander Graf 150d6e166c0SDavid Gibson static inline int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr) 1516db5bb0fSAlexey Kardashevskiy { 1526db5bb0fSAlexey Kardashevskiy return 0; 1536db5bb0fSAlexey Kardashevskiy } 1546db5bb0fSAlexey Kardashevskiy 1555b95b8b9SAlexander Graf static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy) 1565b95b8b9SAlexander Graf { 1575b95b8b9SAlexander Graf } 1585b95b8b9SAlexander Graf 159e97c3636SDavid Gibson static inline int kvmppc_smt_threads(void) 160e97c3636SDavid Gibson { 161e97c3636SDavid Gibson return 1; 162e97c3636SDavid Gibson } 163e97c3636SDavid Gibson 164fa98fbfcSSam Bobroff static inline void kvmppc_hint_smt_possible(Error **errp) 165fa98fbfcSSam Bobroff { 166fa98fbfcSSam Bobroff return; 167fa98fbfcSSam Bobroff } 168fa98fbfcSSam Bobroff 169fa98fbfcSSam Bobroff static inline int kvmppc_set_smt_threads(int smt) 170fa98fbfcSSam Bobroff { 171fa98fbfcSSam Bobroff return 0; 172fa98fbfcSSam Bobroff } 173fa98fbfcSSam Bobroff 17431f2cb8fSBharat Bhushan static inline int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) 17531f2cb8fSBharat Bhushan { 17631f2cb8fSBharat Bhushan return 0; 17731f2cb8fSBharat Bhushan } 17831f2cb8fSBharat Bhushan 17931f2cb8fSBharat Bhushan static inline int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) 18031f2cb8fSBharat Bhushan { 18131f2cb8fSBharat Bhushan return 0; 18231f2cb8fSBharat Bhushan } 18331f2cb8fSBharat Bhushan 18431f2cb8fSBharat Bhushan static inline int kvmppc_set_tcr(PowerPCCPU *cpu) 18531f2cb8fSBharat Bhushan { 18631f2cb8fSBharat Bhushan return 0; 18731f2cb8fSBharat Bhushan } 18831f2cb8fSBharat Bhushan 18931f2cb8fSBharat Bhushan static inline int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu) 19031f2cb8fSBharat Bhushan { 19131f2cb8fSBharat Bhushan return -1; 19231f2cb8fSBharat Bhushan } 19331f2cb8fSBharat Bhushan 194b4db5413SSuraj Jitindar Singh static inline target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, 195b4db5413SSuraj Jitindar Singh bool radix, bool gtse, 196b4db5413SSuraj Jitindar Singh uint64_t proc_tbl) 197b4db5413SSuraj Jitindar Singh { 198b4db5413SSuraj Jitindar Singh return 0; 199b4db5413SSuraj Jitindar Singh } 200b4db5413SSuraj Jitindar Singh 201a84f7179SNikunj A Dadhania static inline void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, 202a84f7179SNikunj A Dadhania unsigned int online) 203a84f7179SNikunj A Dadhania { 204a84f7179SNikunj A Dadhania return; 205a84f7179SNikunj A Dadhania } 206a84f7179SNikunj A Dadhania 20798efaf75SDavid Gibson #ifndef CONFIG_USER_ONLY 208da95324eSAlexey Kardashevskiy static inline bool kvmppc_spapr_use_multitce(void) 209da95324eSAlexey Kardashevskiy { 210da95324eSAlexey Kardashevskiy return false; 211da95324eSAlexey Kardashevskiy } 212da95324eSAlexey Kardashevskiy 2133dc410aeSAlexey Kardashevskiy static inline int kvmppc_spapr_enable_inkernel_multitce(void) 2143dc410aeSAlexey Kardashevskiy { 2153dc410aeSAlexey Kardashevskiy return -1; 2163dc410aeSAlexey Kardashevskiy } 2173dc410aeSAlexey Kardashevskiy 218d6ee2a7cSAlexey Kardashevskiy static inline void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, 219d6ee2a7cSAlexey Kardashevskiy uint64_t bus_offset, 220d6ee2a7cSAlexey Kardashevskiy uint32_t nb_table, 221d6ee2a7cSAlexey Kardashevskiy int *pfd, bool need_vfio) 2220f5cb298SDavid Gibson { 2230f5cb298SDavid Gibson return NULL; 2240f5cb298SDavid Gibson } 2250f5cb298SDavid Gibson 2260f5cb298SDavid Gibson static inline int kvmppc_remove_spapr_tce(void *table, int pfd, 227523e7b8aSAlexey Kardashevskiy uint32_t nb_table) 2280f5cb298SDavid Gibson { 2290f5cb298SDavid Gibson return -1; 2300f5cb298SDavid Gibson } 2317f763a5dSDavid Gibson 2327f763a5dSDavid Gibson static inline int kvmppc_reset_htab(int shift_hint) 2337f763a5dSDavid Gibson { 234a3166f8fSBharata B Rao return 0; 2357f763a5dSDavid Gibson } 2367f763a5dSDavid Gibson 2377f763a5dSDavid Gibson static inline uint64_t kvmppc_rma_size(uint64_t current_size, 2387f763a5dSDavid Gibson unsigned int hash_shift) 2397f763a5dSDavid Gibson { 2407f763a5dSDavid Gibson return ram_size; 2417f763a5dSDavid Gibson } 2427f763a5dSDavid Gibson 24324c6863cSDavid Gibson static inline bool kvmppc_hpt_needs_host_contiguous_pages(void) 24424c6863cSDavid Gibson { 24524c6863cSDavid Gibson return false; 24624c6863cSDavid Gibson } 24724c6863cSDavid Gibson 248e5ca28ecSDavid Gibson static inline void kvm_check_mmu(PowerPCCPU *cpu, Error **errp) 249e5ca28ecSDavid Gibson { 250e5ca28ecSDavid Gibson } 251e5ca28ecSDavid Gibson 2529ded780cSAlexey Kardashevskiy static inline bool kvmppc_has_cap_spapr_vfio(void) 2539ded780cSAlexey Kardashevskiy { 2549ded780cSAlexey Kardashevskiy return false; 2559ded780cSAlexey Kardashevskiy } 2569ded780cSAlexey Kardashevskiy 25798efaf75SDavid Gibson #endif /* !CONFIG_USER_ONLY */ 2580f5cb298SDavid Gibson 2593b961124SStuart Yoder static inline bool kvmppc_has_cap_epr(void) 2603b961124SStuart Yoder { 2613b961124SStuart Yoder return false; 2623b961124SStuart Yoder } 263e68cb8b4SAlexey Kardashevskiy 264feaa64c4SDavid Gibson static inline int kvmppc_define_rtas_kernel_token(uint32_t token, 265feaa64c4SDavid Gibson const char *function) 266feaa64c4SDavid Gibson { 267feaa64c4SDavid Gibson return -1; 268feaa64c4SDavid Gibson } 269feaa64c4SDavid Gibson 27014b0d748SGreg Kurz static inline int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp) 271e68cb8b4SAlexey Kardashevskiy { 272e68cb8b4SAlexey Kardashevskiy return -1; 273e68cb8b4SAlexey Kardashevskiy } 274e68cb8b4SAlexey Kardashevskiy 275e68cb8b4SAlexey Kardashevskiy static inline int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, 276e68cb8b4SAlexey Kardashevskiy int64_t max_ns) 277e68cb8b4SAlexey Kardashevskiy { 278e68cb8b4SAlexey Kardashevskiy abort(); 279e68cb8b4SAlexey Kardashevskiy } 280e68cb8b4SAlexey Kardashevskiy 281e68cb8b4SAlexey Kardashevskiy static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, 282e68cb8b4SAlexey Kardashevskiy uint16_t n_valid, uint16_t n_invalid) 283e68cb8b4SAlexey Kardashevskiy { 284e68cb8b4SAlexey Kardashevskiy abort(); 285e68cb8b4SAlexey Kardashevskiy } 286e68cb8b4SAlexey Kardashevskiy 2871ad9f0a4SDavid Gibson static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, 2881ad9f0a4SDavid Gibson hwaddr ptex, int n) 2897c43bca0SAneesh Kumar K.V { 2907c43bca0SAneesh Kumar K.V abort(); 2917c43bca0SAneesh Kumar K.V } 2927c43bca0SAneesh Kumar K.V 2931ad9f0a4SDavid Gibson static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1) 294c1385933SAneesh Kumar K.V { 295c1385933SAneesh Kumar K.V abort(); 296c1385933SAneesh Kumar K.V } 297c1385933SAneesh Kumar K.V 29887a91de6SAlexander Graf static inline bool kvmppc_has_cap_fixup_hcalls(void) 29987a91de6SAlexander Graf { 30087a91de6SAlexander Graf abort(); 30187a91de6SAlexander Graf } 30287a91de6SAlexander Graf 303bac3bf28SThomas Huth static inline bool kvmppc_has_cap_htm(void) 304bac3bf28SThomas Huth { 305bac3bf28SThomas Huth return false; 306bac3bf28SThomas Huth } 307bac3bf28SThomas Huth 308cf1c4cceSSam Bobroff static inline bool kvmppc_has_cap_mmu_radix(void) 309cf1c4cceSSam Bobroff { 310cf1c4cceSSam Bobroff return false; 311cf1c4cceSSam Bobroff } 312cf1c4cceSSam Bobroff 313cf1c4cceSSam Bobroff static inline bool kvmppc_has_cap_mmu_hash_v3(void) 314cf1c4cceSSam Bobroff { 315cf1c4cceSSam Bobroff return false; 316cf1c4cceSSam Bobroff } 317cf1c4cceSSam Bobroff 3188acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_cache(void) 3198acc2ae5SSuraj Jitindar Singh { 3208acc2ae5SSuraj Jitindar Singh return 0; 3218acc2ae5SSuraj Jitindar Singh } 3228acc2ae5SSuraj Jitindar Singh 3238acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_bounds_check(void) 3248acc2ae5SSuraj Jitindar Singh { 3258acc2ae5SSuraj Jitindar Singh return 0; 3268acc2ae5SSuraj Jitindar Singh } 3278acc2ae5SSuraj Jitindar Singh 3288acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_indirect_branch(void) 3298acc2ae5SSuraj Jitindar Singh { 3308acc2ae5SSuraj Jitindar Singh return 0; 3318acc2ae5SSuraj Jitindar Singh } 3328acc2ae5SSuraj Jitindar Singh 3338ff43ee4SSuraj Jitindar Singh static inline int kvmppc_get_cap_count_cache_flush_assist(void) 3348ff43ee4SSuraj Jitindar Singh { 3358ff43ee4SSuraj Jitindar Singh return 0; 3368ff43ee4SSuraj Jitindar Singh } 3378ff43ee4SSuraj Jitindar Singh 338b9a477b7SSuraj Jitindar Singh static inline bool kvmppc_has_cap_nested_kvm_hv(void) 339b9a477b7SSuraj Jitindar Singh { 340b9a477b7SSuraj Jitindar Singh return false; 341b9a477b7SSuraj Jitindar Singh } 342b9a477b7SSuraj Jitindar Singh 343b9a477b7SSuraj Jitindar Singh static inline int kvmppc_set_cap_nested_kvm_hv(int enable) 344b9a477b7SSuraj Jitindar Singh { 345b9a477b7SSuraj Jitindar Singh return -1; 346b9a477b7SSuraj Jitindar Singh } 347b9a477b7SSuraj Jitindar Singh 3487d050527SSuraj Jitindar Singh static inline int kvmppc_get_cap_large_decr(void) 3497d050527SSuraj Jitindar Singh { 3507d050527SSuraj Jitindar Singh return 0; 3517d050527SSuraj Jitindar Singh } 3527d050527SSuraj Jitindar Singh 3537d050527SSuraj Jitindar Singh static inline int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable) 3547d050527SSuraj Jitindar Singh { 3557d050527SSuraj Jitindar Singh return -1; 3567d050527SSuraj Jitindar Singh } 3577d050527SSuraj Jitindar Singh 3584d9392beSThomas Huth static inline int kvmppc_enable_hwrng(void) 3594d9392beSThomas Huth { 3604d9392beSThomas Huth return -1; 3614d9392beSThomas Huth } 362e5c0d3ceSDavid Gibson 363e5c0d3ceSDavid Gibson static inline int kvmppc_put_books_sregs(PowerPCCPU *cpu) 364e5c0d3ceSDavid Gibson { 365e5c0d3ceSDavid Gibson abort(); 366e5c0d3ceSDavid Gibson } 36752b2519cSThomas Huth 36852b2519cSThomas Huth static inline PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) 36952b2519cSThomas Huth { 37052b2519cSThomas Huth return NULL; 37152b2519cSThomas Huth } 37252b2519cSThomas Huth 37330f4b05bSDavid Gibson static inline void kvmppc_check_papr_resize_hpt(Error **errp) 37430f4b05bSDavid Gibson { 37530f4b05bSDavid Gibson return; 37630f4b05bSDavid Gibson } 377b55d295eSDavid Gibson 378b55d295eSDavid Gibson static inline int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, 379b55d295eSDavid Gibson target_ulong flags, int shift) 380b55d295eSDavid Gibson { 381b55d295eSDavid Gibson return -ENOSYS; 382b55d295eSDavid Gibson } 383b55d295eSDavid Gibson 384b55d295eSDavid Gibson static inline int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, 385b55d295eSDavid Gibson target_ulong flags, int shift) 386b55d295eSDavid Gibson { 387b55d295eSDavid Gibson return -ENOSYS; 388b55d295eSDavid Gibson } 389b55d295eSDavid Gibson 390921e28dbSAlexander Graf #endif 391921e28dbSAlexander Graf 392b45d63b6SBen Herrenschmidt #ifndef CONFIG_KVM 3933240dd9aSThomas Huth 394b45d63b6SBen Herrenschmidt #define kvmppc_eieio() do { } while (0) 3953240dd9aSThomas Huth 3963240dd9aSThomas Huth static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len) 3973240dd9aSThomas Huth { 3983240dd9aSThomas Huth } 3993240dd9aSThomas Huth 4003240dd9aSThomas Huth static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4013240dd9aSThomas Huth { 4023240dd9aSThomas Huth } 4033240dd9aSThomas Huth 4043240dd9aSThomas Huth #else /* CONFIG_KVM */ 4053240dd9aSThomas Huth 406b45d63b6SBen Herrenschmidt #define kvmppc_eieio() \ 407b45d63b6SBen Herrenschmidt do { \ 408b45d63b6SBen Herrenschmidt if (kvm_enabled()) { \ 409b45d63b6SBen Herrenschmidt asm volatile("eieio" : : : "memory"); \ 410b45d63b6SBen Herrenschmidt } \ 411b45d63b6SBen Herrenschmidt } while (0) 4123240dd9aSThomas Huth 4133240dd9aSThomas Huth /* Store data cache blocks back to memory */ 4143240dd9aSThomas Huth static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4153240dd9aSThomas Huth { 4163240dd9aSThomas Huth uint8_t *p; 4173240dd9aSThomas Huth 4183240dd9aSThomas Huth for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) { 4193240dd9aSThomas Huth asm volatile("dcbst 0,%0" : : "r"(p) : "memory"); 4203240dd9aSThomas Huth } 4213240dd9aSThomas Huth } 4223240dd9aSThomas Huth 4233240dd9aSThomas Huth /* Invalidate instruction cache blocks */ 4243240dd9aSThomas Huth static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4253240dd9aSThomas Huth { 4263240dd9aSThomas Huth uint8_t *p; 4273240dd9aSThomas Huth 4283240dd9aSThomas Huth for (p = addr; p < addr + len; p += cpu->env.icache_line_size) { 4293240dd9aSThomas Huth asm volatile("icbi 0,%0" : : "r"(p)); 4303240dd9aSThomas Huth } 4313240dd9aSThomas Huth } 4323240dd9aSThomas Huth 4333240dd9aSThomas Huth #endif /* CONFIG_KVM */ 434b45d63b6SBen Herrenschmidt 4352a6a4076SMarkus Armbruster #endif /* KVM_PPC_H */ 436