14e342025SAlexander Graf /* 24e342025SAlexander Graf * This program is free software; you can redistribute it and/or modify 34e342025SAlexander Graf * it under the terms of the GNU General Public License, version 2, as 44e342025SAlexander Graf * published by the Free Software Foundation. 54e342025SAlexander Graf * 64e342025SAlexander Graf * This program is distributed in the hope that it will be useful, 74e342025SAlexander Graf * but WITHOUT ANY WARRANTY; without even the implied warranty of 84e342025SAlexander Graf * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 94e342025SAlexander Graf * GNU General Public License for more details. 104e342025SAlexander Graf * 114e342025SAlexander Graf * You should have received a copy of the GNU General Public License 124e342025SAlexander Graf * along with this program; if not, write to the Free Software 134e342025SAlexander Graf * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 144e342025SAlexander Graf * 154e342025SAlexander Graf * Copyright SUSE Linux Products GmbH 2009 164e342025SAlexander Graf * 174e342025SAlexander Graf * Authors: Alexander Graf <agraf@suse.de> 184e342025SAlexander Graf */ 194e342025SAlexander Graf 204e342025SAlexander Graf #ifndef __ASM_KVM_BOOK3S_H__ 214e342025SAlexander Graf #define __ASM_KVM_BOOK3S_H__ 224e342025SAlexander Graf 234e342025SAlexander Graf #include <linux/types.h> 244e342025SAlexander Graf #include <linux/kvm_host.h> 252191d657SAlexander Graf #include <asm/kvm_book3s_asm.h> 264e342025SAlexander Graf 274e342025SAlexander Graf struct kvmppc_bat { 28e15a1137SAlexander Graf u64 raw; 294e342025SAlexander Graf u32 bepi; 304e342025SAlexander Graf u32 bepi_mask; 314e342025SAlexander Graf u32 brpn; 324e342025SAlexander Graf u8 wimg; 334e342025SAlexander Graf u8 pp; 343ed9c6d2SAlexander Graf bool vs : 1; 353ed9c6d2SAlexander Graf bool vp : 1; 364e342025SAlexander Graf }; 374e342025SAlexander Graf 384e342025SAlexander Graf struct kvmppc_sid_map { 394e342025SAlexander Graf u64 guest_vsid; 404e342025SAlexander Graf u64 guest_esid; 414e342025SAlexander Graf u64 host_vsid; 423ed9c6d2SAlexander Graf bool valid : 1; 434e342025SAlexander Graf }; 444e342025SAlexander Graf 454e342025SAlexander Graf #define SID_MAP_BITS 9 464e342025SAlexander Graf #define SID_MAP_NUM (1 << SID_MAP_BITS) 474e342025SAlexander Graf #define SID_MAP_MASK (SID_MAP_NUM - 1) 484e342025SAlexander Graf 498b6db3bcSAlexander Graf #ifdef CONFIG_PPC_BOOK3S_64 508b6db3bcSAlexander Graf #define SID_CONTEXTS 1 518b6db3bcSAlexander Graf #else 528b6db3bcSAlexander Graf #define SID_CONTEXTS 128 538b6db3bcSAlexander Graf #define VSID_POOL_SIZE (SID_CONTEXTS * 16) 548b6db3bcSAlexander Graf #endif 558b6db3bcSAlexander Graf 56c4befc58SPaul Mackerras struct hpte_cache { 57c4befc58SPaul Mackerras struct hlist_node list_pte; 58c4befc58SPaul Mackerras struct hlist_node list_pte_long; 59c4befc58SPaul Mackerras struct hlist_node list_vpte; 60c4befc58SPaul Mackerras struct hlist_node list_vpte_long; 61a4a0f252SPaul Mackerras #ifdef CONFIG_PPC_BOOK3S_64 62a4a0f252SPaul Mackerras struct hlist_node list_vpte_64k; 63a4a0f252SPaul Mackerras #endif 64c4befc58SPaul Mackerras struct rcu_head rcu_head; 655524a27dSAneesh Kumar K.V u64 host_vpn; 66c4befc58SPaul Mackerras u64 pfn; 67c4befc58SPaul Mackerras ulong slot; 68c4befc58SPaul Mackerras struct kvmppc_pte pte; 69c9029c34SPaul Mackerras int pagesize; 70c4befc58SPaul Mackerras }; 71c4befc58SPaul Mackerras 72e64fb7e2SSuraj Jitindar Singh /* 73e64fb7e2SSuraj Jitindar Singh * Struct for a virtual core. 74e64fb7e2SSuraj Jitindar Singh * Note: entry_exit_map combines a bitmap of threads that have entered 75e64fb7e2SSuraj Jitindar Singh * in the bottom 8 bits and a bitmap of threads that have exited in the 76e64fb7e2SSuraj Jitindar Singh * next 8 bits. This is so that we can atomically set the entry bit 77e64fb7e2SSuraj Jitindar Singh * iff the exit map is 0 without taking a lock. 78e64fb7e2SSuraj Jitindar Singh */ 79e64fb7e2SSuraj Jitindar Singh struct kvmppc_vcore { 80e64fb7e2SSuraj Jitindar Singh int n_runnable; 81e64fb7e2SSuraj Jitindar Singh int num_threads; 82e64fb7e2SSuraj Jitindar Singh int entry_exit_map; 83e64fb7e2SSuraj Jitindar Singh int napping_threads; 84e64fb7e2SSuraj Jitindar Singh int first_vcpuid; 85e64fb7e2SSuraj Jitindar Singh u16 pcpu; 86e64fb7e2SSuraj Jitindar Singh u16 last_cpu; 87e64fb7e2SSuraj Jitindar Singh u8 vcore_state; 88e64fb7e2SSuraj Jitindar Singh u8 in_guest; 89e64fb7e2SSuraj Jitindar Singh struct kvmppc_vcore *master_vcore; 907b5f8272SSuraj Jitindar Singh struct kvm_vcpu *runnable_threads[MAX_SMT_THREADS]; 91e64fb7e2SSuraj Jitindar Singh struct list_head preempt_list; 92e64fb7e2SSuraj Jitindar Singh spinlock_t lock; 93e64fb7e2SSuraj Jitindar Singh struct swait_queue_head wq; 94e64fb7e2SSuraj Jitindar Singh spinlock_t stoltb_lock; /* protects stolen_tb and preempt_tb */ 95e64fb7e2SSuraj Jitindar Singh u64 stolen_tb; 96e64fb7e2SSuraj Jitindar Singh u64 preempt_tb; 97e64fb7e2SSuraj Jitindar Singh struct kvm_vcpu *runner; 98e64fb7e2SSuraj Jitindar Singh struct kvm *kvm; 99e64fb7e2SSuraj Jitindar Singh u64 tb_offset; /* guest timebase - host timebase */ 100e64fb7e2SSuraj Jitindar Singh ulong lpcr; 101e64fb7e2SSuraj Jitindar Singh u32 arch_compat; 102e64fb7e2SSuraj Jitindar Singh ulong pcr; 103e64fb7e2SSuraj Jitindar Singh ulong dpdes; /* doorbell state (POWER8) */ 104e64fb7e2SSuraj Jitindar Singh ulong conferring_threads; 105e64fb7e2SSuraj Jitindar Singh }; 106e64fb7e2SSuraj Jitindar Singh 1074e342025SAlexander Graf struct kvmppc_vcpu_book3s { 1084e342025SAlexander Graf struct kvmppc_sid_map sid_map[SID_MAP_NUM]; 1094e342025SAlexander Graf struct { 1104e342025SAlexander Graf u64 esid; 1114e342025SAlexander Graf u64 vsid; 1124e342025SAlexander Graf } slb_shadow[64]; 1134e342025SAlexander Graf u8 slb_shadow_max; 1144e342025SAlexander Graf struct kvmppc_bat ibat[8]; 1154e342025SAlexander Graf struct kvmppc_bat dbat[8]; 1164e342025SAlexander Graf u64 hid[6]; 117d6d549b2SAlexander Graf u64 gqr[8]; 1184e342025SAlexander Graf u64 sdr1; 1194e342025SAlexander Graf u64 hior; 1204e342025SAlexander Graf u64 msr_mask; 1218b6db3bcSAlexander Graf #ifdef CONFIG_PPC_BOOK3S_32 1228b6db3bcSAlexander Graf u32 vsid_pool[VSID_POOL_SIZE]; 123ffe36492SBenjamin Herrenschmidt u32 vsid_next; 1248b6db3bcSAlexander Graf #else 125ffe36492SBenjamin Herrenschmidt u64 proto_vsid_first; 126ffe36492SBenjamin Herrenschmidt u64 proto_vsid_max; 127ffe36492SBenjamin Herrenschmidt u64 proto_vsid_next; 1288b6db3bcSAlexander Graf #endif 1298b6db3bcSAlexander Graf int context_id[SID_CONTEXTS]; 130c4befc58SPaul Mackerras 1311022fc3dSAlexander Graf bool hior_explicit; /* HIOR is set by ioctl, not PVR */ 1321022fc3dSAlexander Graf 133c4befc58SPaul Mackerras struct hlist_head hpte_hash_pte[HPTEG_HASH_NUM_PTE]; 134c4befc58SPaul Mackerras struct hlist_head hpte_hash_pte_long[HPTEG_HASH_NUM_PTE_LONG]; 135c4befc58SPaul Mackerras struct hlist_head hpte_hash_vpte[HPTEG_HASH_NUM_VPTE]; 136c4befc58SPaul Mackerras struct hlist_head hpte_hash_vpte_long[HPTEG_HASH_NUM_VPTE_LONG]; 137a4a0f252SPaul Mackerras #ifdef CONFIG_PPC_BOOK3S_64 138a4a0f252SPaul Mackerras struct hlist_head hpte_hash_vpte_64k[HPTEG_HASH_NUM_VPTE_64K]; 139a4a0f252SPaul Mackerras #endif 140c4befc58SPaul Mackerras int hpte_cache_count; 141c4befc58SPaul Mackerras spinlock_t mmu_lock; 1424e342025SAlexander Graf }; 1434e342025SAlexander Graf 144c9029c34SPaul Mackerras #define VSID_REAL 0x07ffffffffc00000ULL 145c9029c34SPaul Mackerras #define VSID_BAT 0x07ffffffffb00000ULL 146c9029c34SPaul Mackerras #define VSID_64K 0x0800000000000000ULL 1470f296829SPaul Mackerras #define VSID_1T 0x1000000000000000ULL 148f7bc74e1SAlexander Graf #define VSID_REAL_DR 0x2000000000000000ULL 149f7bc74e1SAlexander Graf #define VSID_REAL_IR 0x4000000000000000ULL 1505a1b419fSAlexander Graf #define VSID_PR 0x8000000000000000ULL 1514e342025SAlexander Graf 152af7b4d10SAlexander Graf extern void kvmppc_mmu_pte_flush(struct kvm_vcpu *vcpu, ulong ea, ulong ea_mask); 1534e342025SAlexander Graf extern void kvmppc_mmu_pte_vflush(struct kvm_vcpu *vcpu, u64 vp, u64 vp_mask); 154af7b4d10SAlexander Graf extern void kvmppc_mmu_pte_pflush(struct kvm_vcpu *vcpu, ulong pa_start, ulong pa_end); 1554e342025SAlexander Graf extern void kvmppc_set_msr(struct kvm_vcpu *vcpu, u64 new_msr); 1564e342025SAlexander Graf extern void kvmppc_mmu_book3s_64_init(struct kvm_vcpu *vcpu); 1574e342025SAlexander Graf extern void kvmppc_mmu_book3s_32_init(struct kvm_vcpu *vcpu); 158de56a948SPaul Mackerras extern void kvmppc_mmu_book3s_hv_init(struct kvm_vcpu *vcpu); 15993b159b4SPaul Mackerras extern int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte, 16093b159b4SPaul Mackerras bool iswrite); 16193b159b4SPaul Mackerras extern void kvmppc_mmu_unmap_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte); 1624e342025SAlexander Graf extern int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr); 1630f296829SPaul Mackerras extern void kvmppc_mmu_flush_segment(struct kvm_vcpu *vcpu, ulong eaddr, ulong seg_size); 1644e342025SAlexander Graf extern void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu); 165697d3899SPaul Mackerras extern int kvmppc_book3s_hv_page_fault(struct kvm_run *run, 166697d3899SPaul Mackerras struct kvm_vcpu *vcpu, unsigned long addr, 167697d3899SPaul Mackerras unsigned long status); 168697d3899SPaul Mackerras extern long kvmppc_hv_find_lock_hpte(struct kvm *kvm, gva_t eaddr, 169697d3899SPaul Mackerras unsigned long slb_v, unsigned long valid); 170fef093beSAlexander Graf 171fef093beSAlexander Graf extern void kvmppc_mmu_hpte_cache_map(struct kvm_vcpu *vcpu, struct hpte_cache *pte); 172fef093beSAlexander Graf extern struct hpte_cache *kvmppc_mmu_hpte_cache_next(struct kvm_vcpu *vcpu); 173d78bca72SPaul Mackerras extern void kvmppc_mmu_hpte_cache_free(struct hpte_cache *pte); 174fef093beSAlexander Graf extern void kvmppc_mmu_hpte_destroy(struct kvm_vcpu *vcpu); 175fef093beSAlexander Graf extern int kvmppc_mmu_hpte_init(struct kvm_vcpu *vcpu); 176fef093beSAlexander Graf extern void kvmppc_mmu_invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte); 177fef093beSAlexander Graf extern int kvmppc_mmu_hpte_sysinit(void); 178fef093beSAlexander Graf extern void kvmppc_mmu_hpte_sysexit(void); 179de56a948SPaul Mackerras extern int kvmppc_mmu_hv_init(void); 180ae2113a4SPaul Mackerras extern int kvmppc_book3s_hcall_implemented(struct kvm *kvm, unsigned long hc); 181fef093beSAlexander Graf 18235c4a733SAlexander Graf /* XXX remove this export when load_last_inst() is generic */ 1835467a97dSAlexander Graf extern int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, bool data); 1844e342025SAlexander Graf extern void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec); 185bc5ad3f3SBenjamin Herrenschmidt extern void kvmppc_book3s_dequeue_irqprio(struct kvm_vcpu *vcpu, 186bc5ad3f3SBenjamin Herrenschmidt unsigned int vec); 187de56a948SPaul Mackerras extern void kvmppc_inject_interrupt(struct kvm_vcpu *vcpu, int vec, u64 flags); 188e15a1137SAlexander Graf extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat, 189e15a1137SAlexander Graf bool upper, u32 val); 190aba3bd7fSAlexander Graf extern void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr); 191831317b6SAlexander Graf extern int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu); 192ba049e93SDan Williams extern kvm_pfn_t kvmppc_gpa_to_pfn(struct kvm_vcpu *vcpu, gpa_t gpa, 193ba049e93SDan Williams bool writing, bool *writable); 194342d3db7SPaul Mackerras extern void kvmppc_add_revmap_chain(struct kvm *kvm, struct revmap_entry *rev, 195342d3db7SPaul Mackerras unsigned long *rmap, long pte_index, int realmode); 19608fe1e7bSPaul Mackerras extern void kvmppc_update_rmap_change(unsigned long *rmap, unsigned long psize); 1976f22bd32SAlexander Graf extern void kvmppc_invalidate_hpte(struct kvm *kvm, __be64 *hptep, 198342d3db7SPaul Mackerras unsigned long pte_index); 1996f22bd32SAlexander Graf void kvmppc_clear_ref_hpte(struct kvm *kvm, __be64 *hptep, 20055514893SPaul Mackerras unsigned long pte_index); 20193e60249SPaul Mackerras extern void *kvmppc_pin_guest_page(struct kvm *kvm, unsigned long addr, 20293e60249SPaul Mackerras unsigned long *nb_ret); 203c35635efSPaul Mackerras extern void kvmppc_unpin_guest_page(struct kvm *kvm, void *addr, 204c35635efSPaul Mackerras unsigned long gpa, bool dirty); 2057ed661bfSPaul Mackerras extern long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags, 2067ed661bfSPaul Mackerras long pte_index, unsigned long pteh, unsigned long ptel, 2077ed661bfSPaul Mackerras pgd_t *pgdir, bool realmode, unsigned long *idx_ret); 2086b445ad4SPaul Mackerras extern long kvmppc_do_h_remove(struct kvm *kvm, unsigned long flags, 2096b445ad4SPaul Mackerras unsigned long pte_index, unsigned long avpn, 2106b445ad4SPaul Mackerras unsigned long *hpret); 21182ed3616SPaul Mackerras extern long kvmppc_hv_get_dirty_log(struct kvm *kvm, 212dfe49dbdSPaul Mackerras struct kvm_memory_slot *memslot, unsigned long *map); 213a0144e2aSPaul Mackerras extern void kvmppc_update_lpcr(struct kvm *kvm, unsigned long lpcr, 214a0144e2aSPaul Mackerras unsigned long mask); 2158e6afa36SAlexander Graf extern void kvmppc_set_fscr(struct kvm_vcpu *vcpu, u64 fscr); 2164e342025SAlexander Graf 21702143947SPaul Mackerras extern void kvmppc_entry_trampoline(void); 218de56a948SPaul Mackerras extern void kvmppc_hv_entry_trampoline(void); 219ca7f4203SAlexander Graf extern u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst); 220ca7f4203SAlexander Graf extern ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst); 2210254f074SAlexander Graf extern int kvmppc_h_pr(struct kvm_vcpu *vcpu, unsigned long cmd); 222699a0ea0SPaul Mackerras extern void kvmppc_pr_init_default_hcalls(struct kvm *kvm); 223ae2113a4SPaul Mackerras extern int kvmppc_hcall_impl_pr(unsigned long cmd); 224ae2113a4SPaul Mackerras extern int kvmppc_hcall_impl_hv_realmode(unsigned long cmd); 225c9dad7f9SAlexander Graf extern void kvmppc_copy_to_svcpu(struct kvmppc_book3s_shadow_vcpu *svcpu, 226c9dad7f9SAlexander Graf struct kvm_vcpu *vcpu); 227c9dad7f9SAlexander Graf extern void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu, 228c9dad7f9SAlexander Graf struct kvmppc_book3s_shadow_vcpu *svcpu); 2294e342025SAlexander Graf 2304e342025SAlexander Graf static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu) 2314e342025SAlexander Graf { 2323ff95502SPaul Mackerras return vcpu->arch.book3s; 2334e342025SAlexander Graf } 2344e342025SAlexander Graf 235de56a948SPaul Mackerras /* Also add subarch specific defines */ 236de56a948SPaul Mackerras 237de56a948SPaul Mackerras #ifdef CONFIG_KVM_BOOK3S_32_HANDLER 238de56a948SPaul Mackerras #include <asm/kvm_book3s_32.h> 239de56a948SPaul Mackerras #endif 240de56a948SPaul Mackerras #ifdef CONFIG_KVM_BOOK3S_64_HANDLER 241de56a948SPaul Mackerras #include <asm/kvm_book3s_64.h> 242de56a948SPaul Mackerras #endif 243de56a948SPaul Mackerras 244de56a948SPaul Mackerras static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val) 245de56a948SPaul Mackerras { 246de56a948SPaul Mackerras vcpu->arch.gpr[num] = val; 247de56a948SPaul Mackerras } 248de56a948SPaul Mackerras 249de56a948SPaul Mackerras static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num) 250de56a948SPaul Mackerras { 251de56a948SPaul Mackerras return vcpu->arch.gpr[num]; 252de56a948SPaul Mackerras } 253de56a948SPaul Mackerras 254de56a948SPaul Mackerras static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val) 255de56a948SPaul Mackerras { 256de56a948SPaul Mackerras vcpu->arch.cr = val; 257de56a948SPaul Mackerras } 258de56a948SPaul Mackerras 259de56a948SPaul Mackerras static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu) 260de56a948SPaul Mackerras { 261de56a948SPaul Mackerras return vcpu->arch.cr; 262de56a948SPaul Mackerras } 263de56a948SPaul Mackerras 264c63517c2SSam bobroff static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val) 265de56a948SPaul Mackerras { 266de56a948SPaul Mackerras vcpu->arch.xer = val; 267de56a948SPaul Mackerras } 268de56a948SPaul Mackerras 269c63517c2SSam bobroff static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu) 270de56a948SPaul Mackerras { 271de56a948SPaul Mackerras return vcpu->arch.xer; 272de56a948SPaul Mackerras } 273de56a948SPaul Mackerras 274de56a948SPaul Mackerras static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val) 275de56a948SPaul Mackerras { 276de56a948SPaul Mackerras vcpu->arch.ctr = val; 277de56a948SPaul Mackerras } 278de56a948SPaul Mackerras 279de56a948SPaul Mackerras static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu) 280de56a948SPaul Mackerras { 281de56a948SPaul Mackerras return vcpu->arch.ctr; 282de56a948SPaul Mackerras } 283de56a948SPaul Mackerras 284de56a948SPaul Mackerras static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val) 285de56a948SPaul Mackerras { 286de56a948SPaul Mackerras vcpu->arch.lr = val; 287de56a948SPaul Mackerras } 288de56a948SPaul Mackerras 289de56a948SPaul Mackerras static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu) 290de56a948SPaul Mackerras { 291de56a948SPaul Mackerras return vcpu->arch.lr; 292de56a948SPaul Mackerras } 293de56a948SPaul Mackerras 294de56a948SPaul Mackerras static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val) 295de56a948SPaul Mackerras { 296de56a948SPaul Mackerras vcpu->arch.pc = val; 297de56a948SPaul Mackerras } 298de56a948SPaul Mackerras 299de56a948SPaul Mackerras static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu) 300de56a948SPaul Mackerras { 301de56a948SPaul Mackerras return vcpu->arch.pc; 302de56a948SPaul Mackerras } 303de56a948SPaul Mackerras 3045deb8e7aSAlexander Graf static inline u64 kvmppc_get_msr(struct kvm_vcpu *vcpu); 30573601775SCédric Le Goater static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu) 306de56a948SPaul Mackerras { 3075deb8e7aSAlexander Graf return (kvmppc_get_msr(vcpu) & MSR_LE) != (MSR_KERNEL & MSR_LE); 30873601775SCédric Le Goater } 309de56a948SPaul Mackerras 310de56a948SPaul Mackerras static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu) 311de56a948SPaul Mackerras { 312de56a948SPaul Mackerras return vcpu->arch.fault_dar; 313de56a948SPaul Mackerras } 314de56a948SPaul Mackerras 315e59d24e6SGreg Kurz static inline bool is_kvmppc_resume_guest(int r) 316e59d24e6SGreg Kurz { 317e59d24e6SGreg Kurz return (r == RESUME_GUEST || r == RESUME_GUEST_NV); 318e59d24e6SGreg Kurz } 319e59d24e6SGreg Kurz 320c12fb43cSAlexander Graf static inline bool is_kvmppc_hv_enabled(struct kvm *kvm); 321c12fb43cSAlexander Graf static inline bool kvmppc_supports_magic_page(struct kvm_vcpu *vcpu) 322c12fb43cSAlexander Graf { 323c12fb43cSAlexander Graf /* Only PR KVM supports the magic page */ 324c12fb43cSAlexander Graf return !is_kvmppc_hv_enabled(vcpu->kvm); 325c12fb43cSAlexander Graf } 326c12fb43cSAlexander Graf 32799342cf8SDavid Gibson extern int kvmppc_h_logical_ci_load(struct kvm_vcpu *vcpu); 32899342cf8SDavid Gibson extern int kvmppc_h_logical_ci_store(struct kvm_vcpu *vcpu); 32999342cf8SDavid Gibson 330ad0a048bSAlexander Graf /* Magic register values loaded into r3 and r4 before the 'sc' assembly 331ad0a048bSAlexander Graf * instruction for the OSI hypercalls */ 332ad0a048bSAlexander Graf #define OSI_SC_MAGIC_R3 0x113724FA 333ad0a048bSAlexander Graf #define OSI_SC_MAGIC_R4 0x77810F9B 334ad0a048bSAlexander Graf 3354e342025SAlexander Graf #define INS_DCBZ 0x7c0007ec 3368c32a2eaSBharat Bhushan /* TO = 31 for unconditional trap */ 3378c32a2eaSBharat Bhushan #define INS_TW 0x7fe00008 3384e342025SAlexander Graf 339043cc4d7SScott Wood /* LPIDs we support with this build -- runtime limit may be lower */ 340043cc4d7SScott Wood #define KVMPPC_NR_LPIDS (LPID_RSVD + 1) 341043cc4d7SScott Wood 342c01e3f66SAlexander Graf #define SPLIT_HACK_MASK 0xff000000 343c01e3f66SAlexander Graf #define SPLIT_HACK_OFFS 0xfb000000 344c01e3f66SAlexander Graf 3454e342025SAlexander Graf #endif /* __ASM_KVM_BOOK3S_H__ */ 346