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); 30ec010c00SNicholas Piggin bool kvmppc_get_fwnmi(void); 31aef92d87SLaurent Vivier int kvmppc_set_fwnmi(PowerPCCPU *cpu); 32e97c3636SDavid Gibson int kvmppc_smt_threads(void); 330c115681SVladimir Sementsov-Ogievskiy void kvmppc_error_append_smt_possible_hint(Error *const *errp); 34fa98fbfcSSam Bobroff int kvmppc_set_smt_threads(int smt); 3531f2cb8fSBharat Bhushan int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits); 3631f2cb8fSBharat Bhushan int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits); 3731f2cb8fSBharat Bhushan int kvmppc_set_tcr(PowerPCCPU *cpu); 3831f2cb8fSBharat Bhushan int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu); 39b4db5413SSuraj Jitindar Singh target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, 40b4db5413SSuraj Jitindar Singh bool radix, bool gtse, 41b4db5413SSuraj Jitindar Singh uint64_t proc_tbl); 42905db916SBharata B Rao void kvmppc_svm_off(Error **errp); 4398efaf75SDavid Gibson #ifndef CONFIG_USER_ONLY 44da95324eSAlexey Kardashevskiy bool kvmppc_spapr_use_multitce(void); 453dc410aeSAlexey Kardashevskiy int kvmppc_spapr_enable_inkernel_multitce(void); 46d6ee2a7cSAlexey Kardashevskiy void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, 47d6ee2a7cSAlexey Kardashevskiy uint64_t bus_offset, uint32_t nb_table, 48d6ee2a7cSAlexey Kardashevskiy int *pfd, bool need_vfio); 490f5cb298SDavid Gibson int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size); 507f763a5dSDavid Gibson int kvmppc_reset_htab(int shift_hint); 516a84737cSDavid Gibson uint64_t kvmppc_vrma_limit(unsigned int hash_shift); 529ded780cSAlexey Kardashevskiy bool kvmppc_has_cap_spapr_vfio(void); 5398efaf75SDavid Gibson #endif /* !CONFIG_USER_ONLY */ 543b961124SStuart Yoder bool kvmppc_has_cap_epr(void); 55feaa64c4SDavid Gibson int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function); 5614b0d748SGreg Kurz int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp); 57e68cb8b4SAlexey Kardashevskiy int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns); 58e68cb8b4SAlexey Kardashevskiy int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, 59*0a06e4d6SGreg Kurz uint16_t n_valid, uint16_t n_invalid, Error **errp); 601ad9f0a4SDavid Gibson void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, hwaddr ptex, int n); 611ad9f0a4SDavid Gibson void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1); 6287a91de6SAlexander Graf bool kvmppc_has_cap_fixup_hcalls(void); 63bac3bf28SThomas Huth bool kvmppc_has_cap_htm(void); 64cf1c4cceSSam Bobroff bool kvmppc_has_cap_mmu_radix(void); 65cf1c4cceSSam Bobroff bool kvmppc_has_cap_mmu_hash_v3(void); 6638afd772SCédric Le Goater bool kvmppc_has_cap_xive(void); 678acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_cache(void); 688acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_bounds_check(void); 698acc2ae5SSuraj Jitindar Singh int kvmppc_get_cap_safe_indirect_branch(void); 708ff43ee4SSuraj Jitindar Singh int kvmppc_get_cap_count_cache_flush_assist(void); 71b9a477b7SSuraj Jitindar Singh bool kvmppc_has_cap_nested_kvm_hv(void); 72b9a477b7SSuraj Jitindar Singh int kvmppc_set_cap_nested_kvm_hv(int enable); 737d050527SSuraj Jitindar Singh int kvmppc_get_cap_large_decr(void); 747d050527SSuraj Jitindar Singh int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable); 754d9392beSThomas Huth int kvmppc_enable_hwrng(void); 76e5c0d3ceSDavid Gibson int kvmppc_put_books_sregs(PowerPCCPU *cpu); 7752b2519cSThomas Huth PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void); 7830f4b05bSDavid Gibson void kvmppc_check_papr_resize_hpt(Error **errp); 79b55d295eSDavid Gibson int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, target_ulong flags, int shift); 80b55d295eSDavid Gibson int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulong flags, int shift); 81c363a37aSDaniel Henrique Barboza bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu); 82c1385933SAneesh Kumar K.V 8324c6863cSDavid Gibson bool kvmppc_hpt_needs_host_contiguous_pages(void); 84e5ca28ecSDavid Gibson void kvm_check_mmu(PowerPCCPU *cpu, Error **errp); 85a84f7179SNikunj A Dadhania void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, unsigned int online); 869723295aSGreg Kurz void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset); 87df587133SThomas Huth 889ac703acSAravinda Prasad int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run); 899ac703acSAravinda Prasad 90921e28dbSAlexander Graf #else 91921e28dbSAlexander Graf 92921e28dbSAlexander Graf static inline uint32_t kvmppc_get_tbfreq(void) 93921e28dbSAlexander Graf { 94921e28dbSAlexander Graf return 0; 95921e28dbSAlexander Graf } 96921e28dbSAlexander Graf 97ef951443SNikunj A Dadhania static inline bool kvmppc_get_host_model(char **buf) 98ef951443SNikunj A Dadhania { 99ef951443SNikunj A Dadhania return false; 100ef951443SNikunj A Dadhania } 101ef951443SNikunj A Dadhania 102ef951443SNikunj A Dadhania static inline bool kvmppc_get_host_serial(char **buf) 103ef951443SNikunj A Dadhania { 104ef951443SNikunj A Dadhania return false; 105ef951443SNikunj A Dadhania } 106ef951443SNikunj A Dadhania 107921e28dbSAlexander Graf static inline uint64_t kvmppc_get_clockfreq(void) 108921e28dbSAlexander Graf { 109921e28dbSAlexander Graf return 0; 110921e28dbSAlexander Graf } 111921e28dbSAlexander Graf 1126659394fSDavid Gibson static inline uint32_t kvmppc_get_vmx(void) 1136659394fSDavid Gibson { 1146659394fSDavid Gibson return 0; 1156659394fSDavid Gibson } 1166659394fSDavid Gibson 1176659394fSDavid Gibson static inline uint32_t kvmppc_get_dfp(void) 1186659394fSDavid Gibson { 1196659394fSDavid Gibson return 0; 1206659394fSDavid Gibson } 1216659394fSDavid Gibson 1221a61a9aeSStuart Yoder static inline int kvmppc_get_hasidle(CPUPPCState *env) 1231a61a9aeSStuart Yoder { 1241a61a9aeSStuart Yoder return 0; 1251a61a9aeSStuart Yoder } 1261a61a9aeSStuart Yoder 127c995e942SDavid Gibson static inline int kvmppc_get_hypercall(CPUPPCState *env, 128c995e942SDavid Gibson uint8_t *buf, int buf_len) 129921e28dbSAlexander Graf { 130921e28dbSAlexander Graf return -1; 131921e28dbSAlexander Graf } 132921e28dbSAlexander Graf 1331bc22652SAndreas Färber static inline int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level) 134921e28dbSAlexander Graf { 135921e28dbSAlexander Graf return -1; 136921e28dbSAlexander Graf } 137921e28dbSAlexander Graf 138026bfd89SDavid Gibson static inline void kvmppc_enable_logical_ci_hcalls(void) 139026bfd89SDavid Gibson { 140026bfd89SDavid Gibson } 141026bfd89SDavid Gibson 142ef9971ddSAlexey Kardashevskiy static inline void kvmppc_enable_set_mode_hcall(void) 143ef9971ddSAlexey Kardashevskiy { 144ef9971ddSAlexey Kardashevskiy } 145ef9971ddSAlexey Kardashevskiy 1465145ad4fSNathan Whitehorn static inline void kvmppc_enable_clear_ref_mod_hcalls(void) 1475145ad4fSNathan Whitehorn { 1485145ad4fSNathan Whitehorn } 1495145ad4fSNathan Whitehorn 15068f9f708SSuraj Jitindar Singh static inline void kvmppc_enable_h_page_init(void) 15168f9f708SSuraj Jitindar Singh { 15268f9f708SSuraj Jitindar Singh } 15368f9f708SSuraj Jitindar Singh 1541bc22652SAndreas Färber static inline void kvmppc_set_papr(PowerPCCPU *cpu) 155f61b4bedSAlexander Graf { 156f61b4bedSAlexander Graf } 157f61b4bedSAlexander Graf 158d6e166c0SDavid Gibson static inline int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr) 1596db5bb0fSAlexey Kardashevskiy { 1606db5bb0fSAlexey Kardashevskiy return 0; 1616db5bb0fSAlexey Kardashevskiy } 1626db5bb0fSAlexey Kardashevskiy 1635b95b8b9SAlexander Graf static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy) 1645b95b8b9SAlexander Graf { 1655b95b8b9SAlexander Graf } 1665b95b8b9SAlexander Graf 167ec010c00SNicholas Piggin static inline bool kvmppc_get_fwnmi(void) 168ec010c00SNicholas Piggin { 169ec010c00SNicholas Piggin return false; 170ec010c00SNicholas Piggin } 171ec010c00SNicholas Piggin 172aef92d87SLaurent Vivier static inline int kvmppc_set_fwnmi(PowerPCCPU *cpu) 1739d953ce4SAravinda Prasad { 1749d953ce4SAravinda Prasad return -1; 1759d953ce4SAravinda Prasad } 1769d953ce4SAravinda Prasad 177e97c3636SDavid Gibson static inline int kvmppc_smt_threads(void) 178e97c3636SDavid Gibson { 179e97c3636SDavid Gibson return 1; 180e97c3636SDavid Gibson } 181e97c3636SDavid Gibson 1820c115681SVladimir Sementsov-Ogievskiy static inline void kvmppc_error_append_smt_possible_hint(Error *const *errp) 183fa98fbfcSSam Bobroff { 184fa98fbfcSSam Bobroff return; 185fa98fbfcSSam Bobroff } 186fa98fbfcSSam Bobroff 187fa98fbfcSSam Bobroff static inline int kvmppc_set_smt_threads(int smt) 188fa98fbfcSSam Bobroff { 189fa98fbfcSSam Bobroff return 0; 190fa98fbfcSSam Bobroff } 191fa98fbfcSSam Bobroff 19231f2cb8fSBharat Bhushan static inline int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) 19331f2cb8fSBharat Bhushan { 19431f2cb8fSBharat Bhushan return 0; 19531f2cb8fSBharat Bhushan } 19631f2cb8fSBharat Bhushan 19731f2cb8fSBharat Bhushan static inline int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits) 19831f2cb8fSBharat Bhushan { 19931f2cb8fSBharat Bhushan return 0; 20031f2cb8fSBharat Bhushan } 20131f2cb8fSBharat Bhushan 20231f2cb8fSBharat Bhushan static inline int kvmppc_set_tcr(PowerPCCPU *cpu) 20331f2cb8fSBharat Bhushan { 20431f2cb8fSBharat Bhushan return 0; 20531f2cb8fSBharat Bhushan } 20631f2cb8fSBharat Bhushan 20731f2cb8fSBharat Bhushan static inline int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu) 20831f2cb8fSBharat Bhushan { 20931f2cb8fSBharat Bhushan return -1; 21031f2cb8fSBharat Bhushan } 21131f2cb8fSBharat Bhushan 212b4db5413SSuraj Jitindar Singh static inline target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, 213b4db5413SSuraj Jitindar Singh bool radix, bool gtse, 214b4db5413SSuraj Jitindar Singh uint64_t proc_tbl) 215b4db5413SSuraj Jitindar Singh { 216b4db5413SSuraj Jitindar Singh return 0; 217b4db5413SSuraj Jitindar Singh } 218b4db5413SSuraj Jitindar Singh 219905db916SBharata B Rao static inline void kvmppc_svm_off(Error **errp) 220905db916SBharata B Rao { 221905db916SBharata B Rao return; 222905db916SBharata B Rao } 223905db916SBharata B Rao 224a84f7179SNikunj A Dadhania static inline void kvmppc_set_reg_ppc_online(PowerPCCPU *cpu, 225a84f7179SNikunj A Dadhania unsigned int online) 226a84f7179SNikunj A Dadhania { 227a84f7179SNikunj A Dadhania return; 228a84f7179SNikunj A Dadhania } 229a84f7179SNikunj A Dadhania 2309723295aSGreg Kurz static inline void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset) 2319723295aSGreg Kurz { 2329723295aSGreg Kurz } 2339723295aSGreg Kurz 23498efaf75SDavid Gibson #ifndef CONFIG_USER_ONLY 235da95324eSAlexey Kardashevskiy static inline bool kvmppc_spapr_use_multitce(void) 236da95324eSAlexey Kardashevskiy { 237da95324eSAlexey Kardashevskiy return false; 238da95324eSAlexey Kardashevskiy } 239da95324eSAlexey Kardashevskiy 2403dc410aeSAlexey Kardashevskiy static inline int kvmppc_spapr_enable_inkernel_multitce(void) 2413dc410aeSAlexey Kardashevskiy { 2423dc410aeSAlexey Kardashevskiy return -1; 2433dc410aeSAlexey Kardashevskiy } 2443dc410aeSAlexey Kardashevskiy 245d6ee2a7cSAlexey Kardashevskiy static inline void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, 246d6ee2a7cSAlexey Kardashevskiy uint64_t bus_offset, 247d6ee2a7cSAlexey Kardashevskiy uint32_t nb_table, 248d6ee2a7cSAlexey Kardashevskiy int *pfd, bool need_vfio) 2490f5cb298SDavid Gibson { 2500f5cb298SDavid Gibson return NULL; 2510f5cb298SDavid Gibson } 2520f5cb298SDavid Gibson 2530f5cb298SDavid Gibson static inline int kvmppc_remove_spapr_tce(void *table, int pfd, 254523e7b8aSAlexey Kardashevskiy uint32_t nb_table) 2550f5cb298SDavid Gibson { 2560f5cb298SDavid Gibson return -1; 2570f5cb298SDavid Gibson } 2587f763a5dSDavid Gibson 2597f763a5dSDavid Gibson static inline int kvmppc_reset_htab(int shift_hint) 2607f763a5dSDavid Gibson { 261a3166f8fSBharata B Rao return 0; 2627f763a5dSDavid Gibson } 2637f763a5dSDavid Gibson 2646a84737cSDavid Gibson static inline uint64_t kvmppc_vrma_limit(unsigned int hash_shift) 2657f763a5dSDavid Gibson { 2666a84737cSDavid Gibson g_assert_not_reached(); 2677f763a5dSDavid Gibson } 2687f763a5dSDavid Gibson 26924c6863cSDavid Gibson static inline bool kvmppc_hpt_needs_host_contiguous_pages(void) 27024c6863cSDavid Gibson { 27124c6863cSDavid Gibson return false; 27224c6863cSDavid Gibson } 27324c6863cSDavid Gibson 274e5ca28ecSDavid Gibson static inline void kvm_check_mmu(PowerPCCPU *cpu, Error **errp) 275e5ca28ecSDavid Gibson { 276e5ca28ecSDavid Gibson } 277e5ca28ecSDavid Gibson 2789ded780cSAlexey Kardashevskiy static inline bool kvmppc_has_cap_spapr_vfio(void) 2799ded780cSAlexey Kardashevskiy { 2809ded780cSAlexey Kardashevskiy return false; 2819ded780cSAlexey Kardashevskiy } 2829ded780cSAlexey Kardashevskiy 283e89aac1aSPhilippe Mathieu-Daudé static inline void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, 284e89aac1aSPhilippe Mathieu-Daudé hwaddr ptex, int n) 285e89aac1aSPhilippe Mathieu-Daudé { 286e89aac1aSPhilippe Mathieu-Daudé abort(); 287e89aac1aSPhilippe Mathieu-Daudé } 288e89aac1aSPhilippe Mathieu-Daudé 289e89aac1aSPhilippe Mathieu-Daudé static inline void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1) 290e89aac1aSPhilippe Mathieu-Daudé { 291e89aac1aSPhilippe Mathieu-Daudé abort(); 292e89aac1aSPhilippe Mathieu-Daudé } 293e89aac1aSPhilippe Mathieu-Daudé 29498efaf75SDavid Gibson #endif /* !CONFIG_USER_ONLY */ 2950f5cb298SDavid Gibson 2963b961124SStuart Yoder static inline bool kvmppc_has_cap_epr(void) 2973b961124SStuart Yoder { 2983b961124SStuart Yoder return false; 2993b961124SStuart Yoder } 300e68cb8b4SAlexey Kardashevskiy 301feaa64c4SDavid Gibson static inline int kvmppc_define_rtas_kernel_token(uint32_t token, 302feaa64c4SDavid Gibson const char *function) 303feaa64c4SDavid Gibson { 304feaa64c4SDavid Gibson return -1; 305feaa64c4SDavid Gibson } 306feaa64c4SDavid Gibson 30714b0d748SGreg Kurz static inline int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp) 308e68cb8b4SAlexey Kardashevskiy { 309e68cb8b4SAlexey Kardashevskiy return -1; 310e68cb8b4SAlexey Kardashevskiy } 311e68cb8b4SAlexey Kardashevskiy 312e68cb8b4SAlexey Kardashevskiy static inline int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, 313e68cb8b4SAlexey Kardashevskiy int64_t max_ns) 314e68cb8b4SAlexey Kardashevskiy { 315e68cb8b4SAlexey Kardashevskiy abort(); 316e68cb8b4SAlexey Kardashevskiy } 317e68cb8b4SAlexey Kardashevskiy 318e68cb8b4SAlexey Kardashevskiy static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, 319*0a06e4d6SGreg Kurz uint16_t n_valid, uint16_t n_invalid, 320*0a06e4d6SGreg Kurz Error **errp) 321e68cb8b4SAlexey Kardashevskiy { 322e68cb8b4SAlexey Kardashevskiy abort(); 323e68cb8b4SAlexey Kardashevskiy } 324e68cb8b4SAlexey Kardashevskiy 32587a91de6SAlexander Graf static inline bool kvmppc_has_cap_fixup_hcalls(void) 32687a91de6SAlexander Graf { 32787a91de6SAlexander Graf abort(); 32887a91de6SAlexander Graf } 32987a91de6SAlexander Graf 330bac3bf28SThomas Huth static inline bool kvmppc_has_cap_htm(void) 331bac3bf28SThomas Huth { 332bac3bf28SThomas Huth return false; 333bac3bf28SThomas Huth } 334bac3bf28SThomas Huth 335cf1c4cceSSam Bobroff static inline bool kvmppc_has_cap_mmu_radix(void) 336cf1c4cceSSam Bobroff { 337cf1c4cceSSam Bobroff return false; 338cf1c4cceSSam Bobroff } 339cf1c4cceSSam Bobroff 340cf1c4cceSSam Bobroff static inline bool kvmppc_has_cap_mmu_hash_v3(void) 341cf1c4cceSSam Bobroff { 342cf1c4cceSSam Bobroff return false; 343cf1c4cceSSam Bobroff } 344cf1c4cceSSam Bobroff 34538afd772SCédric Le Goater static inline bool kvmppc_has_cap_xive(void) 34638afd772SCédric Le Goater { 34738afd772SCédric Le Goater return false; 34838afd772SCédric Le Goater } 34938afd772SCédric Le Goater 3508acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_cache(void) 3518acc2ae5SSuraj Jitindar Singh { 3528acc2ae5SSuraj Jitindar Singh return 0; 3538acc2ae5SSuraj Jitindar Singh } 3548acc2ae5SSuraj Jitindar Singh 3558acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_bounds_check(void) 3568acc2ae5SSuraj Jitindar Singh { 3578acc2ae5SSuraj Jitindar Singh return 0; 3588acc2ae5SSuraj Jitindar Singh } 3598acc2ae5SSuraj Jitindar Singh 3608acc2ae5SSuraj Jitindar Singh static inline int kvmppc_get_cap_safe_indirect_branch(void) 3618acc2ae5SSuraj Jitindar Singh { 3628acc2ae5SSuraj Jitindar Singh return 0; 3638acc2ae5SSuraj Jitindar Singh } 3648acc2ae5SSuraj Jitindar Singh 3658ff43ee4SSuraj Jitindar Singh static inline int kvmppc_get_cap_count_cache_flush_assist(void) 3668ff43ee4SSuraj Jitindar Singh { 3678ff43ee4SSuraj Jitindar Singh return 0; 3688ff43ee4SSuraj Jitindar Singh } 3698ff43ee4SSuraj Jitindar Singh 370b9a477b7SSuraj Jitindar Singh static inline bool kvmppc_has_cap_nested_kvm_hv(void) 371b9a477b7SSuraj Jitindar Singh { 372b9a477b7SSuraj Jitindar Singh return false; 373b9a477b7SSuraj Jitindar Singh } 374b9a477b7SSuraj Jitindar Singh 375b9a477b7SSuraj Jitindar Singh static inline int kvmppc_set_cap_nested_kvm_hv(int enable) 376b9a477b7SSuraj Jitindar Singh { 377b9a477b7SSuraj Jitindar Singh return -1; 378b9a477b7SSuraj Jitindar Singh } 379b9a477b7SSuraj Jitindar Singh 3807d050527SSuraj Jitindar Singh static inline int kvmppc_get_cap_large_decr(void) 3817d050527SSuraj Jitindar Singh { 3827d050527SSuraj Jitindar Singh return 0; 3837d050527SSuraj Jitindar Singh } 3847d050527SSuraj Jitindar Singh 3857d050527SSuraj Jitindar Singh static inline int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable) 3867d050527SSuraj Jitindar Singh { 3877d050527SSuraj Jitindar Singh return -1; 3887d050527SSuraj Jitindar Singh } 3897d050527SSuraj Jitindar Singh 3904d9392beSThomas Huth static inline int kvmppc_enable_hwrng(void) 3914d9392beSThomas Huth { 3924d9392beSThomas Huth return -1; 3934d9392beSThomas Huth } 394e5c0d3ceSDavid Gibson 395e5c0d3ceSDavid Gibson static inline int kvmppc_put_books_sregs(PowerPCCPU *cpu) 396e5c0d3ceSDavid Gibson { 397e5c0d3ceSDavid Gibson abort(); 398e5c0d3ceSDavid Gibson } 39952b2519cSThomas Huth 40052b2519cSThomas Huth static inline PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) 40152b2519cSThomas Huth { 40252b2519cSThomas Huth return NULL; 40352b2519cSThomas Huth } 40452b2519cSThomas Huth 40530f4b05bSDavid Gibson static inline void kvmppc_check_papr_resize_hpt(Error **errp) 40630f4b05bSDavid Gibson { 40730f4b05bSDavid Gibson return; 40830f4b05bSDavid Gibson } 409b55d295eSDavid Gibson 410b55d295eSDavid Gibson static inline int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, 411b55d295eSDavid Gibson target_ulong flags, int shift) 412b55d295eSDavid Gibson { 413b55d295eSDavid Gibson return -ENOSYS; 414b55d295eSDavid Gibson } 415b55d295eSDavid Gibson 416b55d295eSDavid Gibson static inline int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, 417b55d295eSDavid Gibson target_ulong flags, int shift) 418b55d295eSDavid Gibson { 419b55d295eSDavid Gibson return -ENOSYS; 420b55d295eSDavid Gibson } 421b55d295eSDavid Gibson 422001d235cSGreg Kurz static inline bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu) 423001d235cSGreg Kurz { 424001d235cSGreg Kurz return false; 425001d235cSGreg Kurz } 426001d235cSGreg Kurz 427921e28dbSAlexander Graf #endif 428921e28dbSAlexander Graf 429b45d63b6SBen Herrenschmidt #ifndef CONFIG_KVM 4303240dd9aSThomas Huth 431b45d63b6SBen Herrenschmidt #define kvmppc_eieio() do { } while (0) 4323240dd9aSThomas Huth 4333240dd9aSThomas Huth static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4343240dd9aSThomas Huth { 4353240dd9aSThomas Huth } 4363240dd9aSThomas Huth 4373240dd9aSThomas Huth static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4383240dd9aSThomas Huth { 4393240dd9aSThomas Huth } 4403240dd9aSThomas Huth 4413240dd9aSThomas Huth #else /* CONFIG_KVM */ 4423240dd9aSThomas Huth 443b45d63b6SBen Herrenschmidt #define kvmppc_eieio() \ 444b45d63b6SBen Herrenschmidt do { \ 445b45d63b6SBen Herrenschmidt if (kvm_enabled()) { \ 446b45d63b6SBen Herrenschmidt asm volatile("eieio" : : : "memory"); \ 447b45d63b6SBen Herrenschmidt } \ 448b45d63b6SBen Herrenschmidt } while (0) 4493240dd9aSThomas Huth 4503240dd9aSThomas Huth /* Store data cache blocks back to memory */ 4513240dd9aSThomas Huth static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4523240dd9aSThomas Huth { 4533240dd9aSThomas Huth uint8_t *p; 4543240dd9aSThomas Huth 4553240dd9aSThomas Huth for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) { 4563240dd9aSThomas Huth asm volatile("dcbst 0,%0" : : "r"(p) : "memory"); 4573240dd9aSThomas Huth } 4583240dd9aSThomas Huth } 4593240dd9aSThomas Huth 4603240dd9aSThomas Huth /* Invalidate instruction cache blocks */ 4613240dd9aSThomas Huth static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len) 4623240dd9aSThomas Huth { 4633240dd9aSThomas Huth uint8_t *p; 4643240dd9aSThomas Huth 4653240dd9aSThomas Huth for (p = addr; p < addr + len; p += cpu->env.icache_line_size) { 4663240dd9aSThomas Huth asm volatile("icbi 0,%0" : : "r"(p)); 4673240dd9aSThomas Huth } 4683240dd9aSThomas Huth } 4693240dd9aSThomas Huth 4703240dd9aSThomas Huth #endif /* CONFIG_KVM */ 471b45d63b6SBen Herrenschmidt 4722a6a4076SMarkus Armbruster #endif /* KVM_PPC_H */ 473