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_book3s_64_asm.h>
36 bool large
; /* PTEs are 16MB */
37 bool tb
; /* 1TB segment */
60 struct kvmppc_sid_map
{
67 #define SID_MAP_BITS 9
68 #define SID_MAP_NUM (1 << SID_MAP_BITS)
69 #define SID_MAP_MASK (SID_MAP_NUM - 1)
71 struct kvmppc_vcpu_book3s
{
73 struct kvmppc_book3s_shadow_vcpu shadow_vcpu
;
74 struct kvmppc_sid_map sid_map
[SID_MAP_NUM
];
75 struct kvmppc_slb slb
[64];
81 struct kvmppc_sr sr
[16];
82 struct kvmppc_bat ibat
[8];
83 struct kvmppc_bat dbat
[8];
94 ulong prog_flags
; /* flags to inject when giving a 700 trap */
97 #define CONTEXT_HOST 0
98 #define CONTEXT_GUEST 1
99 #define CONTEXT_GUEST_END 2
101 #define VSID_REAL 0xfffffffffff00000
102 #define VSID_REAL_DR 0xffffffffffe00000
103 #define VSID_REAL_IR 0xffffffffffd00000
104 #define VSID_BAT 0xffffffffffc00000
105 #define VSID_PR 0x8000000000000000
107 extern void kvmppc_mmu_pte_flush(struct kvm_vcpu
*vcpu
, u64 ea
, u64 ea_mask
);
108 extern void kvmppc_mmu_pte_vflush(struct kvm_vcpu
*vcpu
, u64 vp
, u64 vp_mask
);
109 extern void kvmppc_mmu_pte_pflush(struct kvm_vcpu
*vcpu
, u64 pa_start
, u64 pa_end
);
110 extern void kvmppc_set_msr(struct kvm_vcpu
*vcpu
, u64 new_msr
);
111 extern void kvmppc_mmu_book3s_64_init(struct kvm_vcpu
*vcpu
);
112 extern void kvmppc_mmu_book3s_32_init(struct kvm_vcpu
*vcpu
);
113 extern int kvmppc_mmu_map_page(struct kvm_vcpu
*vcpu
, struct kvmppc_pte
*pte
);
114 extern int kvmppc_mmu_map_segment(struct kvm_vcpu
*vcpu
, ulong eaddr
);
115 extern void kvmppc_mmu_flush_segments(struct kvm_vcpu
*vcpu
);
116 extern struct kvmppc_pte
*kvmppc_mmu_find_pte(struct kvm_vcpu
*vcpu
, u64 ea
, bool data
);
117 extern int kvmppc_ld(struct kvm_vcpu
*vcpu
, ulong eaddr
, int size
, void *ptr
, bool data
);
118 extern int kvmppc_st(struct kvm_vcpu
*vcpu
, ulong eaddr
, int size
, void *ptr
);
119 extern void kvmppc_book3s_queue_irqprio(struct kvm_vcpu
*vcpu
, unsigned int vec
);
120 extern void kvmppc_set_bat(struct kvm_vcpu
*vcpu
, struct kvmppc_bat
*bat
,
121 bool upper
, u32 val
);
123 extern u32 kvmppc_trampoline_lowmem
;
124 extern u32 kvmppc_trampoline_enter
;
125 extern void kvmppc_rmcall(ulong srr0
, ulong srr1
);
126 extern void kvmppc_load_up_fpu(void);
127 extern void kvmppc_load_up_altivec(void);
128 extern void kvmppc_load_up_vsx(void);
130 static inline struct kvmppc_vcpu_book3s
*to_book3s(struct kvm_vcpu
*vcpu
)
132 return container_of(vcpu
, struct kvmppc_vcpu_book3s
, vcpu
);
135 static inline ulong
dsisr(void)
138 asm ( "mfdsisr %0 " : "=r" (r
) );
142 extern void kvm_return_point(void);
144 #define INS_DCBZ 0x7c0007ec
146 #endif /* __ASM_KVM_BOOK3S_H__ */