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); 2668f9f708SSuraj 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); 63*38afd772SCédric Le Goater bool kvmppc_has_cap_xive(void); 648acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_cache(void); 658acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_bounds_check(void); 668acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_indirect_branch(void); 678ff43ee4SSuraj Jitindar Singh int kvmppc_get_cap_count_cache_flush_assist(void); 68b9a477b7SSuraj Jitindar Singh bool kvmppc_has_cap_nested_kvm_hv(void); 69b9a477b7SSuraj Jitindar Singh int kvmppc_set_cap_nested_kvm_hv(int enable); 707d050527SSuraj Jitindar Singh int kvmppc_get_cap_large_decr(void); 717d050527SSuraj Jitindar Singh int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable); 724d9392beSThomas Huth int kvmppc_enable_hwrng(void); 73e5c0d3ceSDavid Gibson int kvmppc_put_books_sregs(PowerPCCPU *cpu); 7452b2519cSThomas Huth PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void); 7530f4b05bSDavid Gibson void kvmppc_check_papr_resize_hpt(Error **errp); 76b55d295eSDavid Gibson int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, target_ulong flags, int shift); 77b55d295eSDavid Gibson int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulong flags, int shift); 78c363a37aSDaniel Henrique Barboza bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu); 79c1385933SAneesh Kumar K.V 8024c6863cSDavid Gibson bool kvmppc_hpt_needs_host_contiguous_pages(void); 81e5ca28ecSDavid Gibson void kvm_check_mmu(PowerPCCPU *cpu, Error **errp); 82a84f7179SNikunj A Dadhania void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online); 83df587133SThomas Huth 84921e28dbSAlexander Graf #else 85921e28dbSAlexander Graf 86921e28dbSAlexander Graf static inline uint32_t kvmppc_get_tbfreq(void) 87921e28dbSAlexander Graf { 88921e28dbSAlexander Graf return 0; 89921e28dbSAlexander Graf } 90921e28dbSAlexander Graf 91ef951443SNikunj A Dadhania static inline bool kvmppc_get_host_model(char **buf) 92ef951443SNikunj A Dadhania { 93ef951443SNikunj A Dadhania return false; 94ef951443SNikunj A Dadhania } 95ef951443SNikunj A Dadhania 96ef951443SNikunj A Dadhania static inline bool kvmppc_get_host_serial(char **buf) 97ef951443SNikunj A Dadhania { 98ef951443SNikunj A Dadhania return false; 99ef951443SNikunj A Dadhania } 100ef951443SNikunj A Dadhania 101921e28dbSAlexander Graf static inline uint64_t kvmppc_get_clockfreq(void) 102921e28dbSAlexander Graf { 103921e28dbSAlexander Graf return 0; 104921e28dbSAlexander Graf } 105921e28dbSAlexander Graf 1066659394fSDavid Gibson static inline uint32_t kvmppc_get_vmx(void) 1076659394fSDavid Gibson { 1086659394fSDavid Gibson return 0; 1096659394fSDavid Gibson } 1106659394fSDavid Gibson 1116659394fSDavid Gibson static inline uint32_t kvmppc_get_dfp(void) 1126659394fSDavid Gibson { 1136659394fSDavid Gibson return 0; 1146659394fSDavid Gibson } 1156659394fSDavid Gibson 1161a61a9aeSStuart Yoder static inline int kvmppc_get_hasidle(CPUPPCState *env) 1171a61a9aeSStuart Yoder { 1181a61a9aeSStuart Yoder return 0; 1191a61a9aeSStuart Yoder } 1201a61a9aeSStuart Yoder 121c995e942SDavid Gibson static inline int kvmppc_get_hypercall(CPUPPCState *env, 122c995e942SDavid Gibson uint8_t *buf, int buf_len) 123921e28dbSAlexander Graf { 124921e28dbSAlexander Graf return -1; 125921e28dbSAlexander Graf } 126921e28dbSAlexander Graf 1271bc22652SAndreas Färber static inline int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level) 128921e28dbSAlexander Graf { 129921e28dbSAlexander Graf return -1; 130921e28dbSAlexander Graf } 131921e28dbSAlexander Graf 132026bfd89SDavid Gibson static inline void kvmppc_enable_logical_ci_hcalls(void) 133026bfd89SDavid Gibson { 134026bfd89SDavid Gibson } 135026bfd89SDavid Gibson 136ef9971ddSAlexey Kardashevskiy static inline void kvmppc_enable_set_mode_hcall(void) 137ef9971ddSAlexey Kardashevskiy { 138ef9971ddSAlexey Kardashevskiy } 139ef9971ddSAlexey Kardashevskiy 1405145ad4fSNathan Whitehorn static inline void kvmppc_enable_clear_ref_mod_hcalls(void) 1415145ad4fSNathan Whitehorn { 1425145ad4fSNathan Whitehorn } 1435145ad4fSNathan Whitehorn 14468f9f708SSuraj Jitindar Singh static inline void kvmppc_enable_h_page_init(void) 14568f9f708SSuraj Jitindar Singh { 14668f9f708SSuraj Jitindar Singh } 14768f9f708SSuraj Jitindar Singh 1481bc22652SAndreas Färber static inline void kvmppc_set_papr(PowerPCCPU *cpu) 149f61b4bedSAlexander Graf { 150f61b4bedSAlexander Graf } 151f61b4bedSAlexander Graf 152d6e166c0SDavid Gibson static inline int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr) 1536db5bb0fSAlexey Kardashevskiy { 1546db5bb0fSAlexey Kardashevskiy return 0; 1556db5bb0fSAlexey Kardashevskiy } 1566db5bb0fSAlexey Kardashevskiy 1575b95b8b9SAlexander Graf static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy) 1585b95b8b9SAlexander Graf { 1595b95b8b9SAlexander Graf } 1605b95b8b9SAlexander Graf 161e97c3636SDavid Gibson static inline int kvmppc_smt_threads(void) 162e97c3636SDavid Gibson { 163e97c3636SDavid Gibson return 1; 164e97c3636SDavid Gibson } 165e97c3636SDavid Gibson 166fa98fbfcSSam Bobroff static inline void kvmppc_hint_smt_possible(Error **errp) 167fa98fbfcSSam Bobroff { 168fa98fbfcSSam Bobroff return; 169fa98fbfcSSam Bobroff } 170fa98fbfcSSam Bobroff 171fa98fbfcSSam Bobroff static inline int kvmppc_set_smt_threads(int smt) 172fa98fbfcSSam Bobroff { 173fa98fbfcSSam Bobroff return 0; 174fa98fbfcSSam Bobroff } 175fa98fbfcSSam Bobroff 17631f2cb8fSBharat Bhushan static inline int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) 17731f2cb8fSBharat Bhushan { 17831f2cb8fSBharat Bhushan return 0; 17931f2cb8fSBharat Bhushan } 18031f2cb8fSBharat Bhushan 18131f2cb8fSBharat Bhushan static inline int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) 18231f2cb8fSBharat Bhushan { 18331f2cb8fSBharat Bhushan return 0; 18431f2cb8fSBharat Bhushan } 18531f2cb8fSBharat Bhushan 18631f2cb8fSBharat Bhushan static inline int kvmppc_set_tcr(PowerPCCPU *cpu) 18731f2cb8fSBharat Bhushan { 18831f2cb8fSBharat Bhushan return 0; 18931f2cb8fSBharat Bhushan } 19031f2cb8fSBharat Bhushan 19131f2cb8fSBharat Bhushan static inline int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu) 19231f2cb8fSBharat Bhushan { 19331f2cb8fSBharat Bhushan return -1; 19431f2cb8fSBharat Bhushan } 19531f2cb8fSBharat Bhushan 196b4db5413SSuraj Jitindar Singh static inline target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, 197b4db5413SSuraj Jitindar Singh bool radix, bool gtse, 198b4db5413SSuraj Jitindar Singh uint64_t proc_tbl) 199b4db5413SSuraj Jitindar Singh { 200b4db5413SSuraj Jitindar Singh return 0; 201b4db5413SSuraj Jitindar Singh } 202b4db5413SSuraj Jitindar Singh 203a84f7179SNikunj A Dadhania static inline void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, 204a84f7179SNikunj A Dadhania unsigned int online) 205a84f7179SNikunj A Dadhania { 206a84f7179SNikunj A Dadhania return; 207a84f7179SNikunj A Dadhania } 208a84f7179SNikunj A Dadhania 20998efaf75SDavid Gibson #ifndef CONFIG_USER_ONLY 210da95324eSAlexey Kardashevskiy static inline bool kvmppc_spapr_use_multitce(void) 211da95324eSAlexey Kardashevskiy { 212da95324eSAlexey Kardashevskiy return false; 213da95324eSAlexey Kardashevskiy } 214da95324eSAlexey Kardashevskiy 2153dc410aeSAlexey Kardashevskiy static inline int kvmppc_spapr_enable_inkernel_multitce(void) 2163dc410aeSAlexey Kardashevskiy { 2173dc410aeSAlexey Kardashevskiy return -1; 2183dc410aeSAlexey Kardashevskiy } 2193dc410aeSAlexey Kardashevskiy 220d6ee2a7cSAlexey Kardashevskiy static inline void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, 221d6ee2a7cSAlexey Kardashevskiy uint64_t bus_offset, 222d6ee2a7cSAlexey Kardashevskiy uint32_t nb_table, 223d6ee2a7cSAlexey Kardashevskiy int *pfd, bool need_vfio) 2240f5cb298SDavid Gibson { 2250f5cb298SDavid Gibson return NULL; 2260f5cb298SDavid Gibson } 2270f5cb298SDavid Gibson 2280f5cb298SDavid Gibson static inline int kvmppc_remove_spapr_tce(void *table, int pfd, 229523e7b8aSAlexey Kardashevskiy uint32_t nb_table) 2300f5cb298SDavid Gibson { 2310f5cb298SDavid Gibson return -1; 2320f5cb298SDavid Gibson } 2337f763a5dSDavid Gibson 2347f763a5dSDavid Gibson static inline int kvmppc_reset_htab(int shift_hint) 2357f763a5dSDavid Gibson { 236a3166f8fSBharata B Rao return 0; 2377f763a5dSDavid Gibson } 2387f763a5dSDavid Gibson 2397f763a5dSDavid Gibson static inline uint64_t kvmppc_rma_size(uint64_t current_size, 2407f763a5dSDavid Gibson unsigned int hash_shift) 2417f763a5dSDavid Gibson { 2427f763a5dSDavid Gibson return ram_size; 2437f763a5dSDavid Gibson } 2447f763a5dSDavid Gibson 24524c6863cSDavid Gibson static inline bool kvmppc_hpt_needs_host_contiguous_pages(void) 24624c6863cSDavid Gibson { 24724c6863cSDavid Gibson return false; 24824c6863cSDavid Gibson } 24924c6863cSDavid Gibson 250e5ca28ecSDavid Gibson static inline void kvm_check_mmu(PowerPCCPU *cpu, Error **errp) 251e5ca28ecSDavid Gibson { 252e5ca28ecSDavid Gibson } 253e5ca28ecSDavid Gibson 2549ded780cSAlexey Kardashevskiy static inline bool kvmppc_has_cap_spapr_vfio(void) 2559ded780cSAlexey Kardashevskiy { 2569ded780cSAlexey Kardashevskiy return false; 2579ded780cSAlexey Kardashevskiy } 2589ded780cSAlexey Kardashevskiy 25998efaf75SDavid Gibson #endif /* !CONFIG_USER_ONLY */ 2600f5cb298SDavid Gibson 2613b961124SStuart Yoder static inline bool kvmppc_has_cap_epr(void) 2623b961124SStuart Yoder { 2633b961124SStuart Yoder return false; 2643b961124SStuart Yoder } 265e68cb8b4SAlexey Kardashevskiy 266feaa64c4SDavid Gibson static inline int kvmppc_define_rtas_kernel_token(uint32_t token, 267feaa64c4SDavid Gibson const char *function) 268feaa64c4SDavid Gibson { 269feaa64c4SDavid Gibson return -1; 270feaa64c4SDavid Gibson } 271feaa64c4SDavid Gibson 27214b0d748SGreg Kurz static inline int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp) 273e68cb8b4SAlexey Kardashevskiy { 274e68cb8b4SAlexey Kardashevskiy return -1; 275e68cb8b4SAlexey Kardashevskiy } 276e68cb8b4SAlexey Kardashevskiy 277e68cb8b4SAlexey Kardashevskiy static inline int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, 278e68cb8b4SAlexey Kardashevskiy int64_t max_ns) 279e68cb8b4SAlexey Kardashevskiy { 280e68cb8b4SAlexey Kardashevskiy abort(); 281e68cb8b4SAlexey Kardashevskiy } 282e68cb8b4SAlexey Kardashevskiy 283e68cb8b4SAlexey Kardashevskiy static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, 284e68cb8b4SAlexey Kardashevskiy uint16_t n_valid, uint16_t n_invalid) 285e68cb8b4SAlexey Kardashevskiy { 286e68cb8b4SAlexey Kardashevskiy abort(); 287e68cb8b4SAlexey Kardashevskiy } 288e68cb8b4SAlexey Kardashevskiy 2891ad9f0a4SDavid Gibson static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, 2901ad9f0a4SDavid Gibson hwaddr ptex, int n) 2917c43bca0SAneesh Kumar K.V { 2927c43bca0SAneesh Kumar K.V abort(); 2937c43bca0SAneesh Kumar K.V } 2947c43bca0SAneesh Kumar K.V 2951ad9f0a4SDavid Gibson static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1) 296c1385933SAneesh Kumar K.V { 297c1385933SAneesh Kumar K.V abort(); 298c1385933SAneesh Kumar K.V } 299c1385933SAneesh Kumar K.V 30087a91de6SAlexander Graf static inline bool kvmppc_has_cap_fixup_hcalls(void) 30187a91de6SAlexander Graf { 30287a91de6SAlexander Graf abort(); 30387a91de6SAlexander Graf } 30487a91de6SAlexander Graf 305bac3bf28SThomas Huth static inline bool kvmppc_has_cap_htm(void) 306bac3bf28SThomas Huth { 307bac3bf28SThomas Huth return false; 308bac3bf28SThomas Huth } 309bac3bf28SThomas Huth 310cf1c4cceSSam Bobroff static inline bool kvmppc_has_cap_mmu_radix(void) 311cf1c4cceSSam Bobroff { 312cf1c4cceSSam Bobroff return false; 313cf1c4cceSSam Bobroff } 314cf1c4cceSSam Bobroff 315cf1c4cceSSam Bobroff static inline bool kvmppc_has_cap_mmu_hash_v3(void) 316cf1c4cceSSam Bobroff { 317cf1c4cceSSam Bobroff return false; 318cf1c4cceSSam Bobroff } 319cf1c4cceSSam Bobroff 320*38afd772SCédric Le Goater static inline bool kvmppc_has_cap_xive(void) 321*38afd772SCédric Le Goater { 322*38afd772SCédric Le Goater return false; 323*38afd772SCédric Le Goater } 324*38afd772SCédric Le Goater 3258acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_cache(void) 3268acc2ae5SSuraj Jitindar Singh { 3278acc2ae5SSuraj Jitindar Singh return 0; 3288acc2ae5SSuraj Jitindar Singh } 3298acc2ae5SSuraj Jitindar Singh 3308acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_bounds_check(void) 3318acc2ae5SSuraj Jitindar Singh { 3328acc2ae5SSuraj Jitindar Singh return 0; 3338acc2ae5SSuraj Jitindar Singh } 3348acc2ae5SSuraj Jitindar Singh 3358acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_indirect_branch(void) 3368acc2ae5SSuraj Jitindar Singh { 3378acc2ae5SSuraj Jitindar Singh return 0; 3388acc2ae5SSuraj Jitindar Singh } 3398acc2ae5SSuraj Jitindar Singh 3408ff43ee4SSuraj Jitindar Singh static inline int kvmppc_get_cap_count_cache_flush_assist(void) 3418ff43ee4SSuraj Jitindar Singh { 3428ff43ee4SSuraj Jitindar Singh return 0; 3438ff43ee4SSuraj Jitindar Singh } 3448ff43ee4SSuraj Jitindar Singh 345b9a477b7SSuraj Jitindar Singh static inline bool kvmppc_has_cap_nested_kvm_hv(void) 346b9a477b7SSuraj Jitindar Singh { 347b9a477b7SSuraj Jitindar Singh return false; 348b9a477b7SSuraj Jitindar Singh } 349b9a477b7SSuraj Jitindar Singh 350b9a477b7SSuraj Jitindar Singh static inline int kvmppc_set_cap_nested_kvm_hv(int enable) 351b9a477b7SSuraj Jitindar Singh { 352b9a477b7SSuraj Jitindar Singh return -1; 353b9a477b7SSuraj Jitindar Singh } 354b9a477b7SSuraj Jitindar Singh 3557d050527SSuraj Jitindar Singh static inline int kvmppc_get_cap_large_decr(void) 3567d050527SSuraj Jitindar Singh { 3577d050527SSuraj Jitindar Singh return 0; 3587d050527SSuraj Jitindar Singh } 3597d050527SSuraj Jitindar Singh 3607d050527SSuraj Jitindar Singh static inline int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable) 3617d050527SSuraj Jitindar Singh { 3627d050527SSuraj Jitindar Singh return -1; 3637d050527SSuraj Jitindar Singh } 3647d050527SSuraj Jitindar Singh 3654d9392beSThomas Huth static inline int kvmppc_enable_hwrng(void) 3664d9392beSThomas Huth { 3674d9392beSThomas Huth return -1; 3684d9392beSThomas Huth } 369e5c0d3ceSDavid Gibson 370e5c0d3ceSDavid Gibson static inline int kvmppc_put_books_sregs(PowerPCCPU *cpu) 371e5c0d3ceSDavid Gibson { 372e5c0d3ceSDavid Gibson abort(); 373e5c0d3ceSDavid Gibson } 37452b2519cSThomas Huth 37552b2519cSThomas Huth static inline PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) 37652b2519cSThomas Huth { 37752b2519cSThomas Huth return NULL; 37852b2519cSThomas Huth } 37952b2519cSThomas Huth 38030f4b05bSDavid Gibson static inline void kvmppc_check_papr_resize_hpt(Error **errp) 38130f4b05bSDavid Gibson { 38230f4b05bSDavid Gibson return; 38330f4b05bSDavid Gibson } 384b55d295eSDavid Gibson 385b55d295eSDavid Gibson static inline int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, 386b55d295eSDavid Gibson target_ulong flags, int shift) 387b55d295eSDavid Gibson { 388b55d295eSDavid Gibson return -ENOSYS; 389b55d295eSDavid Gibson } 390b55d295eSDavid Gibson 391b55d295eSDavid Gibson static inline int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, 392b55d295eSDavid Gibson target_ulong flags, int shift) 393b55d295eSDavid Gibson { 394b55d295eSDavid Gibson return -ENOSYS; 395b55d295eSDavid Gibson } 396b55d295eSDavid Gibson 397921e28dbSAlexander Graf #endif 398921e28dbSAlexander Graf 399b45d63b6SBen Herrenschmidt #ifndef CONFIG_KVM 4003240dd9aSThomas Huth 401b45d63b6SBen Herrenschmidt #define kvmppc_eieio() do { } while (0) 4023240dd9aSThomas Huth 4033240dd9aSThomas Huth static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4043240dd9aSThomas Huth { 4053240dd9aSThomas Huth } 4063240dd9aSThomas Huth 4073240dd9aSThomas Huth static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4083240dd9aSThomas Huth { 4093240dd9aSThomas Huth } 4103240dd9aSThomas Huth 4113240dd9aSThomas Huth #else /* CONFIG_KVM */ 4123240dd9aSThomas Huth 413b45d63b6SBen Herrenschmidt #define kvmppc_eieio() \ 414b45d63b6SBen Herrenschmidt do { \ 415b45d63b6SBen Herrenschmidt if (kvm_enabled()) { \ 416b45d63b6SBen Herrenschmidt asm volatile("eieio" : : : "memory"); \ 417b45d63b6SBen Herrenschmidt } \ 418b45d63b6SBen Herrenschmidt } while (0) 4193240dd9aSThomas Huth 4203240dd9aSThomas Huth /* Store data cache blocks back to memory */ 4213240dd9aSThomas Huth static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4223240dd9aSThomas Huth { 4233240dd9aSThomas Huth uint8_t *p; 4243240dd9aSThomas Huth 4253240dd9aSThomas Huth for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) { 4263240dd9aSThomas Huth asm volatile("dcbst 0,%0" : : "r"(p) : "memory"); 4273240dd9aSThomas Huth } 4283240dd9aSThomas Huth } 4293240dd9aSThomas Huth 4303240dd9aSThomas Huth /* Invalidate instruction cache blocks */ 4313240dd9aSThomas Huth static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4323240dd9aSThomas Huth { 4333240dd9aSThomas Huth uint8_t *p; 4343240dd9aSThomas Huth 4353240dd9aSThomas Huth for (p = addr; p < addr + len; p += cpu->env.icache_line_size) { 4363240dd9aSThomas Huth asm volatile("icbi 0,%0" : : "r"(p)); 4373240dd9aSThomas Huth } 4383240dd9aSThomas Huth } 4393240dd9aSThomas Huth 4403240dd9aSThomas Huth #endif /* CONFIG_KVM */ 441b45d63b6SBen Herrenschmidt 4422a6a4076SMarkus Armbruster #endif /* KVM_PPC_H */ 443