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); 30*9d953ce4SAravinda Prasad int kvmppc_set_fwnmi(void); 31e97c3636SDavid Gibson int kvmppc_smt_threads(void); 320c115681SVladimir Sementsov-Ogievskiy void kvmppc_error_append_smt_possible_hint(Error *const *errp); 33fa98fbfcSSam Bobroff int kvmppc_set_smt_threads(int smt); 3431f2cb8fSBharat Bhushan int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits); 3531f2cb8fSBharat Bhushan int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits); 3631f2cb8fSBharat Bhushan int kvmppc_set_tcr(PowerPCCPU *cpu); 3731f2cb8fSBharat Bhushan int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu); 38b4db5413SSuraj Jitindar Singh target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, 39b4db5413SSuraj Jitindar Singh bool radix, bool gtse, 40b4db5413SSuraj Jitindar Singh uint64_t proc_tbl); 41905db916SBharata B Rao void kvmppc_svm_off(Error **errp); 4298efaf75SDavid Gibson #ifndef CONFIG_USER_ONLY 43da95324eSAlexey Kardashevskiy bool kvmppc_spapr_use_multitce(void); 443dc410aeSAlexey Kardashevskiy int kvmppc_spapr_enable_inkernel_multitce(void); 45d6ee2a7cSAlexey Kardashevskiy void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, 46d6ee2a7cSAlexey Kardashevskiy uint64_t bus_offset, uint32_t nb_table, 47d6ee2a7cSAlexey Kardashevskiy int *pfd, bool need_vfio); 480f5cb298SDavid Gibson int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size); 497f763a5dSDavid Gibson int kvmppc_reset_htab(int shift_hint); 507f763a5dSDavid Gibson uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift); 519ded780cSAlexey Kardashevskiy bool kvmppc_has_cap_spapr_vfio(void); 5298efaf75SDavid Gibson #endif /* !CONFIG_USER_ONLY */ 533b961124SStuart Yoder bool kvmppc_has_cap_epr(void); 54feaa64c4SDavid Gibson int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function); 5514b0d748SGreg Kurz int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp); 56e68cb8b4SAlexey Kardashevskiy int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns); 57e68cb8b4SAlexey Kardashevskiy int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, 58e68cb8b4SAlexey Kardashevskiy uint16_t n_valid, uint16_t n_invalid); 591ad9f0a4SDavid Gibson void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, hwaddr ptex, int n); 601ad9f0a4SDavid Gibson void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1); 6187a91de6SAlexander Graf bool kvmppc_has_cap_fixup_hcalls(void); 62bac3bf28SThomas Huth bool kvmppc_has_cap_htm(void); 63cf1c4cceSSam Bobroff bool kvmppc_has_cap_mmu_radix(void); 64cf1c4cceSSam Bobroff bool kvmppc_has_cap_mmu_hash_v3(void); 6538afd772SCédric Le Goater bool kvmppc_has_cap_xive(void); 668acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_cache(void); 678acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_bounds_check(void); 688acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_indirect_branch(void); 698ff43ee4SSuraj Jitindar Singh int kvmppc_get_cap_count_cache_flush_assist(void); 70b9a477b7SSuraj Jitindar Singh bool kvmppc_has_cap_nested_kvm_hv(void); 71b9a477b7SSuraj Jitindar Singh int kvmppc_set_cap_nested_kvm_hv(int enable); 727d050527SSuraj Jitindar Singh int kvmppc_get_cap_large_decr(void); 737d050527SSuraj Jitindar Singh int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable); 744d9392beSThomas Huth int kvmppc_enable_hwrng(void); 75e5c0d3ceSDavid Gibson int kvmppc_put_books_sregs(PowerPCCPU *cpu); 7652b2519cSThomas Huth PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void); 7730f4b05bSDavid Gibson void kvmppc_check_papr_resize_hpt(Error **errp); 78b55d295eSDavid Gibson int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, target_ulong flags, int shift); 79b55d295eSDavid Gibson int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulong flags, int shift); 80c363a37aSDaniel Henrique Barboza bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu); 81c1385933SAneesh Kumar K.V 8224c6863cSDavid Gibson bool kvmppc_hpt_needs_host_contiguous_pages(void); 83e5ca28ecSDavid Gibson void kvm_check_mmu(PowerPCCPU *cpu, Error **errp); 84a84f7179SNikunj A Dadhania void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online); 859723295aSGreg Kurz void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset); 86df587133SThomas Huth 87921e28dbSAlexander Graf #else 88921e28dbSAlexander Graf 89921e28dbSAlexander Graf static inline uint32_t kvmppc_get_tbfreq(void) 90921e28dbSAlexander Graf { 91921e28dbSAlexander Graf return 0; 92921e28dbSAlexander Graf } 93921e28dbSAlexander Graf 94ef951443SNikunj A Dadhania static inline bool kvmppc_get_host_model(char **buf) 95ef951443SNikunj A Dadhania { 96ef951443SNikunj A Dadhania return false; 97ef951443SNikunj A Dadhania } 98ef951443SNikunj A Dadhania 99ef951443SNikunj A Dadhania static inline bool kvmppc_get_host_serial(char **buf) 100ef951443SNikunj A Dadhania { 101ef951443SNikunj A Dadhania return false; 102ef951443SNikunj A Dadhania } 103ef951443SNikunj A Dadhania 104921e28dbSAlexander Graf static inline uint64_t kvmppc_get_clockfreq(void) 105921e28dbSAlexander Graf { 106921e28dbSAlexander Graf return 0; 107921e28dbSAlexander Graf } 108921e28dbSAlexander Graf 1096659394fSDavid Gibson static inline uint32_t kvmppc_get_vmx(void) 1106659394fSDavid Gibson { 1116659394fSDavid Gibson return 0; 1126659394fSDavid Gibson } 1136659394fSDavid Gibson 1146659394fSDavid Gibson static inline uint32_t kvmppc_get_dfp(void) 1156659394fSDavid Gibson { 1166659394fSDavid Gibson return 0; 1176659394fSDavid Gibson } 1186659394fSDavid Gibson 1191a61a9aeSStuart Yoder static inline int kvmppc_get_hasidle(CPUPPCState *env) 1201a61a9aeSStuart Yoder { 1211a61a9aeSStuart Yoder return 0; 1221a61a9aeSStuart Yoder } 1231a61a9aeSStuart Yoder 124c995e942SDavid Gibson static inline int kvmppc_get_hypercall(CPUPPCState *env, 125c995e942SDavid Gibson uint8_t *buf, int buf_len) 126921e28dbSAlexander Graf { 127921e28dbSAlexander Graf return -1; 128921e28dbSAlexander Graf } 129921e28dbSAlexander Graf 1301bc22652SAndreas Färber static inline int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level) 131921e28dbSAlexander Graf { 132921e28dbSAlexander Graf return -1; 133921e28dbSAlexander Graf } 134921e28dbSAlexander Graf 135026bfd89SDavid Gibson static inline void kvmppc_enable_logical_ci_hcalls(void) 136026bfd89SDavid Gibson { 137026bfd89SDavid Gibson } 138026bfd89SDavid Gibson 139ef9971ddSAlexey Kardashevskiy static inline void kvmppc_enable_set_mode_hcall(void) 140ef9971ddSAlexey Kardashevskiy { 141ef9971ddSAlexey Kardashevskiy } 142ef9971ddSAlexey Kardashevskiy 1435145ad4fSNathan Whitehorn static inline void kvmppc_enable_clear_ref_mod_hcalls(void) 1445145ad4fSNathan Whitehorn { 1455145ad4fSNathan Whitehorn } 1465145ad4fSNathan Whitehorn 14768f9f708SSuraj Jitindar Singh static inline void kvmppc_enable_h_page_init(void) 14868f9f708SSuraj Jitindar Singh { 14968f9f708SSuraj Jitindar Singh } 15068f9f708SSuraj Jitindar Singh 1511bc22652SAndreas Färber static inline void kvmppc_set_papr(PowerPCCPU *cpu) 152f61b4bedSAlexander Graf { 153f61b4bedSAlexander Graf } 154f61b4bedSAlexander Graf 155d6e166c0SDavid Gibson static inline int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr) 1566db5bb0fSAlexey Kardashevskiy { 1576db5bb0fSAlexey Kardashevskiy return 0; 1586db5bb0fSAlexey Kardashevskiy } 1596db5bb0fSAlexey Kardashevskiy 1605b95b8b9SAlexander Graf static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy) 1615b95b8b9SAlexander Graf { 1625b95b8b9SAlexander Graf } 1635b95b8b9SAlexander Graf 164*9d953ce4SAravinda Prasad static inline int kvmppc_set_fwnmi(void) 165*9d953ce4SAravinda Prasad { 166*9d953ce4SAravinda Prasad return -1; 167*9d953ce4SAravinda Prasad } 168*9d953ce4SAravinda Prasad 169e97c3636SDavid Gibson static inline int kvmppc_smt_threads(void) 170e97c3636SDavid Gibson { 171e97c3636SDavid Gibson return 1; 172e97c3636SDavid Gibson } 173e97c3636SDavid Gibson 1740c115681SVladimir Sementsov-Ogievskiy static inline void kvmppc_error_append_smt_possible_hint(Error *const *errp) 175fa98fbfcSSam Bobroff { 176fa98fbfcSSam Bobroff return; 177fa98fbfcSSam Bobroff } 178fa98fbfcSSam Bobroff 179fa98fbfcSSam Bobroff static inline int kvmppc_set_smt_threads(int smt) 180fa98fbfcSSam Bobroff { 181fa98fbfcSSam Bobroff return 0; 182fa98fbfcSSam Bobroff } 183fa98fbfcSSam Bobroff 18431f2cb8fSBharat Bhushan static inline int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) 18531f2cb8fSBharat Bhushan { 18631f2cb8fSBharat Bhushan return 0; 18731f2cb8fSBharat Bhushan } 18831f2cb8fSBharat Bhushan 18931f2cb8fSBharat Bhushan static inline int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) 19031f2cb8fSBharat Bhushan { 19131f2cb8fSBharat Bhushan return 0; 19231f2cb8fSBharat Bhushan } 19331f2cb8fSBharat Bhushan 19431f2cb8fSBharat Bhushan static inline int kvmppc_set_tcr(PowerPCCPU *cpu) 19531f2cb8fSBharat Bhushan { 19631f2cb8fSBharat Bhushan return 0; 19731f2cb8fSBharat Bhushan } 19831f2cb8fSBharat Bhushan 19931f2cb8fSBharat Bhushan static inline int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu) 20031f2cb8fSBharat Bhushan { 20131f2cb8fSBharat Bhushan return -1; 20231f2cb8fSBharat Bhushan } 20331f2cb8fSBharat Bhushan 204b4db5413SSuraj Jitindar Singh static inline target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, 205b4db5413SSuraj Jitindar Singh bool radix, bool gtse, 206b4db5413SSuraj Jitindar Singh uint64_t proc_tbl) 207b4db5413SSuraj Jitindar Singh { 208b4db5413SSuraj Jitindar Singh return 0; 209b4db5413SSuraj Jitindar Singh } 210b4db5413SSuraj Jitindar Singh 211905db916SBharata B Rao static inline void kvmppc_svm_off(Error **errp) 212905db916SBharata B Rao { 213905db916SBharata B Rao return; 214905db916SBharata B Rao } 215905db916SBharata B Rao 216a84f7179SNikunj A Dadhania static inline void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, 217a84f7179SNikunj A Dadhania unsigned int online) 218a84f7179SNikunj A Dadhania { 219a84f7179SNikunj A Dadhania return; 220a84f7179SNikunj A Dadhania } 221a84f7179SNikunj A Dadhania 2229723295aSGreg Kurz static inline void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset) 2239723295aSGreg Kurz { 2249723295aSGreg Kurz } 2259723295aSGreg Kurz 22698efaf75SDavid Gibson #ifndef CONFIG_USER_ONLY 227da95324eSAlexey Kardashevskiy static inline bool kvmppc_spapr_use_multitce(void) 228da95324eSAlexey Kardashevskiy { 229da95324eSAlexey Kardashevskiy return false; 230da95324eSAlexey Kardashevskiy } 231da95324eSAlexey Kardashevskiy 2323dc410aeSAlexey Kardashevskiy static inline int kvmppc_spapr_enable_inkernel_multitce(void) 2333dc410aeSAlexey Kardashevskiy { 2343dc410aeSAlexey Kardashevskiy return -1; 2353dc410aeSAlexey Kardashevskiy } 2363dc410aeSAlexey Kardashevskiy 237d6ee2a7cSAlexey Kardashevskiy static inline void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, 238d6ee2a7cSAlexey Kardashevskiy uint64_t bus_offset, 239d6ee2a7cSAlexey Kardashevskiy uint32_t nb_table, 240d6ee2a7cSAlexey Kardashevskiy int *pfd, bool need_vfio) 2410f5cb298SDavid Gibson { 2420f5cb298SDavid Gibson return NULL; 2430f5cb298SDavid Gibson } 2440f5cb298SDavid Gibson 2450f5cb298SDavid Gibson static inline int kvmppc_remove_spapr_tce(void *table, int pfd, 246523e7b8aSAlexey Kardashevskiy uint32_t nb_table) 2470f5cb298SDavid Gibson { 2480f5cb298SDavid Gibson return -1; 2490f5cb298SDavid Gibson } 2507f763a5dSDavid Gibson 2517f763a5dSDavid Gibson static inline int kvmppc_reset_htab(int shift_hint) 2527f763a5dSDavid Gibson { 253a3166f8fSBharata B Rao return 0; 2547f763a5dSDavid Gibson } 2557f763a5dSDavid Gibson 2567f763a5dSDavid Gibson static inline uint64_t kvmppc_rma_size(uint64_t current_size, 2577f763a5dSDavid Gibson unsigned int hash_shift) 2587f763a5dSDavid Gibson { 2597f763a5dSDavid Gibson return ram_size; 2607f763a5dSDavid Gibson } 2617f763a5dSDavid Gibson 26224c6863cSDavid Gibson static inline bool kvmppc_hpt_needs_host_contiguous_pages(void) 26324c6863cSDavid Gibson { 26424c6863cSDavid Gibson return false; 26524c6863cSDavid Gibson } 26624c6863cSDavid Gibson 267e5ca28ecSDavid Gibson static inline void kvm_check_mmu(PowerPCCPU *cpu, Error **errp) 268e5ca28ecSDavid Gibson { 269e5ca28ecSDavid Gibson } 270e5ca28ecSDavid Gibson 2719ded780cSAlexey Kardashevskiy static inline bool kvmppc_has_cap_spapr_vfio(void) 2729ded780cSAlexey Kardashevskiy { 2739ded780cSAlexey Kardashevskiy return false; 2749ded780cSAlexey Kardashevskiy } 2759ded780cSAlexey Kardashevskiy 27698efaf75SDavid Gibson #endif /* !CONFIG_USER_ONLY */ 2770f5cb298SDavid Gibson 2783b961124SStuart Yoder static inline bool kvmppc_has_cap_epr(void) 2793b961124SStuart Yoder { 2803b961124SStuart Yoder return false; 2813b961124SStuart Yoder } 282e68cb8b4SAlexey Kardashevskiy 283feaa64c4SDavid Gibson static inline int kvmppc_define_rtas_kernel_token(uint32_t token, 284feaa64c4SDavid Gibson const char *function) 285feaa64c4SDavid Gibson { 286feaa64c4SDavid Gibson return -1; 287feaa64c4SDavid Gibson } 288feaa64c4SDavid Gibson 28914b0d748SGreg Kurz static inline int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp) 290e68cb8b4SAlexey Kardashevskiy { 291e68cb8b4SAlexey Kardashevskiy return -1; 292e68cb8b4SAlexey Kardashevskiy } 293e68cb8b4SAlexey Kardashevskiy 294e68cb8b4SAlexey Kardashevskiy static inline int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, 295e68cb8b4SAlexey Kardashevskiy int64_t max_ns) 296e68cb8b4SAlexey Kardashevskiy { 297e68cb8b4SAlexey Kardashevskiy abort(); 298e68cb8b4SAlexey Kardashevskiy } 299e68cb8b4SAlexey Kardashevskiy 300e68cb8b4SAlexey Kardashevskiy static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, 301e68cb8b4SAlexey Kardashevskiy uint16_t n_valid, uint16_t n_invalid) 302e68cb8b4SAlexey Kardashevskiy { 303e68cb8b4SAlexey Kardashevskiy abort(); 304e68cb8b4SAlexey Kardashevskiy } 305e68cb8b4SAlexey Kardashevskiy 3061ad9f0a4SDavid Gibson static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, 3071ad9f0a4SDavid Gibson hwaddr ptex, int n) 3087c43bca0SAneesh Kumar K.V { 3097c43bca0SAneesh Kumar K.V abort(); 3107c43bca0SAneesh Kumar K.V } 3117c43bca0SAneesh Kumar K.V 3121ad9f0a4SDavid Gibson static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1) 313c1385933SAneesh Kumar K.V { 314c1385933SAneesh Kumar K.V abort(); 315c1385933SAneesh Kumar K.V } 316c1385933SAneesh Kumar K.V 31787a91de6SAlexander Graf static inline bool kvmppc_has_cap_fixup_hcalls(void) 31887a91de6SAlexander Graf { 31987a91de6SAlexander Graf abort(); 32087a91de6SAlexander Graf } 32187a91de6SAlexander Graf 322bac3bf28SThomas Huth static inline bool kvmppc_has_cap_htm(void) 323bac3bf28SThomas Huth { 324bac3bf28SThomas Huth return false; 325bac3bf28SThomas Huth } 326bac3bf28SThomas Huth 327cf1c4cceSSam Bobroff static inline bool kvmppc_has_cap_mmu_radix(void) 328cf1c4cceSSam Bobroff { 329cf1c4cceSSam Bobroff return false; 330cf1c4cceSSam Bobroff } 331cf1c4cceSSam Bobroff 332cf1c4cceSSam Bobroff static inline bool kvmppc_has_cap_mmu_hash_v3(void) 333cf1c4cceSSam Bobroff { 334cf1c4cceSSam Bobroff return false; 335cf1c4cceSSam Bobroff } 336cf1c4cceSSam Bobroff 33738afd772SCédric Le Goater static inline bool kvmppc_has_cap_xive(void) 33838afd772SCédric Le Goater { 33938afd772SCédric Le Goater return false; 34038afd772SCédric Le Goater } 34138afd772SCédric Le Goater 3428acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_cache(void) 3438acc2ae5SSuraj Jitindar Singh { 3448acc2ae5SSuraj Jitindar Singh return 0; 3458acc2ae5SSuraj Jitindar Singh } 3468acc2ae5SSuraj Jitindar Singh 3478acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_bounds_check(void) 3488acc2ae5SSuraj Jitindar Singh { 3498acc2ae5SSuraj Jitindar Singh return 0; 3508acc2ae5SSuraj Jitindar Singh } 3518acc2ae5SSuraj Jitindar Singh 3528acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_indirect_branch(void) 3538acc2ae5SSuraj Jitindar Singh { 3548acc2ae5SSuraj Jitindar Singh return 0; 3558acc2ae5SSuraj Jitindar Singh } 3568acc2ae5SSuraj Jitindar Singh 3578ff43ee4SSuraj Jitindar Singh static inline int kvmppc_get_cap_count_cache_flush_assist(void) 3588ff43ee4SSuraj Jitindar Singh { 3598ff43ee4SSuraj Jitindar Singh return 0; 3608ff43ee4SSuraj Jitindar Singh } 3618ff43ee4SSuraj Jitindar Singh 362b9a477b7SSuraj Jitindar Singh static inline bool kvmppc_has_cap_nested_kvm_hv(void) 363b9a477b7SSuraj Jitindar Singh { 364b9a477b7SSuraj Jitindar Singh return false; 365b9a477b7SSuraj Jitindar Singh } 366b9a477b7SSuraj Jitindar Singh 367b9a477b7SSuraj Jitindar Singh static inline int kvmppc_set_cap_nested_kvm_hv(int enable) 368b9a477b7SSuraj Jitindar Singh { 369b9a477b7SSuraj Jitindar Singh return -1; 370b9a477b7SSuraj Jitindar Singh } 371b9a477b7SSuraj Jitindar Singh 3727d050527SSuraj Jitindar Singh static inline int kvmppc_get_cap_large_decr(void) 3737d050527SSuraj Jitindar Singh { 3747d050527SSuraj Jitindar Singh return 0; 3757d050527SSuraj Jitindar Singh } 3767d050527SSuraj Jitindar Singh 3777d050527SSuraj Jitindar Singh static inline int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable) 3787d050527SSuraj Jitindar Singh { 3797d050527SSuraj Jitindar Singh return -1; 3807d050527SSuraj Jitindar Singh } 3817d050527SSuraj Jitindar Singh 3824d9392beSThomas Huth static inline int kvmppc_enable_hwrng(void) 3834d9392beSThomas Huth { 3844d9392beSThomas Huth return -1; 3854d9392beSThomas Huth } 386e5c0d3ceSDavid Gibson 387e5c0d3ceSDavid Gibson static inline int kvmppc_put_books_sregs(PowerPCCPU *cpu) 388e5c0d3ceSDavid Gibson { 389e5c0d3ceSDavid Gibson abort(); 390e5c0d3ceSDavid Gibson } 39152b2519cSThomas Huth 39252b2519cSThomas Huth static inline PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) 39352b2519cSThomas Huth { 39452b2519cSThomas Huth return NULL; 39552b2519cSThomas Huth } 39652b2519cSThomas Huth 39730f4b05bSDavid Gibson static inline void kvmppc_check_papr_resize_hpt(Error **errp) 39830f4b05bSDavid Gibson { 39930f4b05bSDavid Gibson return; 40030f4b05bSDavid Gibson } 401b55d295eSDavid Gibson 402b55d295eSDavid Gibson static inline int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, 403b55d295eSDavid Gibson target_ulong flags, int shift) 404b55d295eSDavid Gibson { 405b55d295eSDavid Gibson return -ENOSYS; 406b55d295eSDavid Gibson } 407b55d295eSDavid Gibson 408b55d295eSDavid Gibson static inline int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, 409b55d295eSDavid Gibson target_ulong flags, int shift) 410b55d295eSDavid Gibson { 411b55d295eSDavid Gibson return -ENOSYS; 412b55d295eSDavid Gibson } 413b55d295eSDavid Gibson 414001d235cSGreg Kurz static inline bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu) 415001d235cSGreg Kurz { 416001d235cSGreg Kurz return false; 417001d235cSGreg Kurz } 418001d235cSGreg Kurz 419921e28dbSAlexander Graf #endif 420921e28dbSAlexander Graf 421b45d63b6SBen Herrenschmidt #ifndef CONFIG_KVM 4223240dd9aSThomas Huth 423b45d63b6SBen Herrenschmidt #define kvmppc_eieio() do { } while (0) 4243240dd9aSThomas Huth 4253240dd9aSThomas Huth static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4263240dd9aSThomas Huth { 4273240dd9aSThomas Huth } 4283240dd9aSThomas Huth 4293240dd9aSThomas Huth static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4303240dd9aSThomas Huth { 4313240dd9aSThomas Huth } 4323240dd9aSThomas Huth 4333240dd9aSThomas Huth #else /* CONFIG_KVM */ 4343240dd9aSThomas Huth 435b45d63b6SBen Herrenschmidt #define kvmppc_eieio() \ 436b45d63b6SBen Herrenschmidt do { \ 437b45d63b6SBen Herrenschmidt if (kvm_enabled()) { \ 438b45d63b6SBen Herrenschmidt asm volatile("eieio" : : : "memory"); \ 439b45d63b6SBen Herrenschmidt } \ 440b45d63b6SBen Herrenschmidt } while (0) 4413240dd9aSThomas Huth 4423240dd9aSThomas Huth /* Store data cache blocks back to memory */ 4433240dd9aSThomas Huth static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4443240dd9aSThomas Huth { 4453240dd9aSThomas Huth uint8_t *p; 4463240dd9aSThomas Huth 4473240dd9aSThomas Huth for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) { 4483240dd9aSThomas Huth asm volatile("dcbst 0,%0" : : "r"(p) : "memory"); 4493240dd9aSThomas Huth } 4503240dd9aSThomas Huth } 4513240dd9aSThomas Huth 4523240dd9aSThomas Huth /* Invalidate instruction cache blocks */ 4533240dd9aSThomas Huth static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4543240dd9aSThomas Huth { 4553240dd9aSThomas Huth uint8_t *p; 4563240dd9aSThomas Huth 4573240dd9aSThomas Huth for (p = addr; p < addr + len; p += cpu->env.icache_line_size) { 4583240dd9aSThomas Huth asm volatile("icbi 0,%0" : : "r"(p)); 4593240dd9aSThomas Huth } 4603240dd9aSThomas Huth } 4613240dd9aSThomas Huth 4623240dd9aSThomas Huth #endif /* CONFIG_KVM */ 463b45d63b6SBen Herrenschmidt 4642a6a4076SMarkus Armbruster #endif /* KVM_PPC_H */ 465