2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2, as
4 * published by the Free Software Foundation.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 * Copyright SUSE Linux Products GmbH 2009
17 * Authors: Alexander Graf <agraf@suse.de>
20 #ifndef __ASM_KVM_BOOK3S_H__
21 #define __ASM_KVM_BOOK3S_H__
23 #include <linux/types.h>
24 #include <linux/kvm_host.h>
25 #include <asm/kvm_ppc.h>
59 struct kvmppc_sid_map {
66 #define SID_MAP_BITS 9
67 #define SID_MAP_NUM (1 << SID_MAP_BITS)
68 #define SID_MAP_MASK (SID_MAP_NUM - 1)
70 struct kvmppc_vcpu_book3s {
72 struct kvmppc_sid_map sid_map[SID_MAP_NUM];
73 struct kvmppc_slb slb[64];
79 struct kvmppc_sr sr[16];
80 struct kvmppc_bat ibat[8];
81 struct kvmppc_bat dbat[8];
94 #define CONTEXT_HOST 0
95 #define CONTEXT_GUEST 1
96 #define CONTEXT_GUEST_END 2
98 #define VSID_REAL 0xfffffffffff00000
99 #define VSID_REAL_DR 0xffffffffffe00000
100 #define VSID_REAL_IR 0xffffffffffd00000
101 #define VSID_BAT 0xffffffffffc00000
102 #define VSID_PR 0x8000000000000000
104 extern void kvmppc_mmu_pte_flush(struct kvm_vcpu *vcpu, u64 ea, u64 ea_mask);
105 extern void kvmppc_mmu_pte_vflush(struct kvm_vcpu *vcpu, u64 vp, u64 vp_mask);
106 extern void kvmppc_mmu_pte_pflush(struct kvm_vcpu *vcpu, u64 pa_start, u64 pa_end);
107 extern void kvmppc_set_msr(struct kvm_vcpu *vcpu, u64 new_msr);
108 extern void kvmppc_mmu_book3s_64_init(struct kvm_vcpu *vcpu);
109 extern void kvmppc_mmu_book3s_32_init(struct kvm_vcpu *vcpu);
110 extern int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte);
111 extern int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr);
112 extern void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu);
113 extern struct kvmppc_pte *kvmppc_mmu_find_pte(struct kvm_vcpu *vcpu, u64 ea, bool data);
114 extern int kvmppc_ld(struct kvm_vcpu *vcpu, ulong eaddr, int size, void *ptr, bool data);
115 extern int kvmppc_st(struct kvm_vcpu *vcpu, ulong eaddr, int size, void *ptr);
116 extern void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec);
117 extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat,
118 bool upper, u32 val);
120 extern u32 kvmppc_trampoline_lowmem;
121 extern u32 kvmppc_trampoline_enter;
123 static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu)
125 return container_of(vcpu, struct kvmppc_vcpu_book3s, vcpu);
128 static inline ulong dsisr(void)
131 asm ( "mfdsisr %0 " : "=r" (r) );
135 extern void kvm_return_point(void);
137 #define INS_DCBZ 0x7c0007ec
139 #endif /* __ASM_KVM_BOOK3S_H__ */