1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef __KVM_BOOKE_H__
21#define __KVM_BOOKE_H__
22
23#include <linux/types.h>
24#include <linux/kvm_host.h>
25#include <asm/kvm_ppc.h>
26#include <asm/switch_to.h>
27#include "timing.h"
28
29
30#define BOOKE_IRQPRIO_DATA_STORAGE 0
31#define BOOKE_IRQPRIO_INST_STORAGE 1
32#define BOOKE_IRQPRIO_ALIGNMENT 2
33#define BOOKE_IRQPRIO_PROGRAM 3
34#define BOOKE_IRQPRIO_FP_UNAVAIL 4
35#define BOOKE_IRQPRIO_SPE_UNAVAIL 5
36#define BOOKE_IRQPRIO_SPE_FP_DATA 6
37#define BOOKE_IRQPRIO_SPE_FP_ROUND 7
38#define BOOKE_IRQPRIO_SYSCALL 8
39#define BOOKE_IRQPRIO_AP_UNAVAIL 9
40#define BOOKE_IRQPRIO_DTLB_MISS 10
41#define BOOKE_IRQPRIO_ITLB_MISS 11
42#define BOOKE_IRQPRIO_MACHINE_CHECK 12
43#define BOOKE_IRQPRIO_DEBUG 13
44#define BOOKE_IRQPRIO_CRITICAL 14
45#define BOOKE_IRQPRIO_WATCHDOG 15
46#define BOOKE_IRQPRIO_EXTERNAL 16
47#define BOOKE_IRQPRIO_FIT 17
48#define BOOKE_IRQPRIO_DECREMENTER 18
49#define BOOKE_IRQPRIO_PERFORMANCE_MONITOR 19
50
51#define BOOKE_IRQPRIO_EXTERNAL_LEVEL 20
52#define BOOKE_IRQPRIO_DBELL 21
53#define BOOKE_IRQPRIO_DBELL_CRIT 22
54#define BOOKE_IRQPRIO_MAX 23
55
56#define BOOKE_IRQMASK_EE ((1 << BOOKE_IRQPRIO_EXTERNAL_LEVEL) | \
57 (1 << BOOKE_IRQPRIO_PERFORMANCE_MONITOR) | \
58 (1 << BOOKE_IRQPRIO_DBELL) | \
59 (1 << BOOKE_IRQPRIO_DECREMENTER) | \
60 (1 << BOOKE_IRQPRIO_FIT) | \
61 (1 << BOOKE_IRQPRIO_EXTERNAL))
62
63#define BOOKE_IRQMASK_CE ((1 << BOOKE_IRQPRIO_DBELL_CRIT) | \
64 (1 << BOOKE_IRQPRIO_WATCHDOG) | \
65 (1 << BOOKE_IRQPRIO_CRITICAL))
66
67extern unsigned long kvmppc_booke_handlers;
68extern unsigned long kvmppc_booke_handler_addr[];
69
70void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
71void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
72
73void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr);
74void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr);
75void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
76void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
77
78int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
79 unsigned int inst, int *advance);
80int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val);
81int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val);
82
83
84void kvmppc_load_guest_spe(struct kvm_vcpu *vcpu);
85void kvmppc_save_guest_spe(struct kvm_vcpu *vcpu);
86
87
88void kvmppc_vcpu_disable_spe(struct kvm_vcpu *vcpu);
89
90void kvmppc_booke_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
91void kvmppc_booke_vcpu_put(struct kvm_vcpu *vcpu);
92
93enum int_class {
94 INT_CLASS_NONCRIT,
95 INT_CLASS_CRIT,
96 INT_CLASS_MC,
97 INT_CLASS_DBG,
98};
99
100void kvmppc_set_pending_interrupt(struct kvm_vcpu *vcpu, enum int_class type);
101
102extern void kvmppc_mmu_destroy_44x(struct kvm_vcpu *vcpu);
103extern int kvmppc_core_emulate_op_44x(struct kvm_run *run, struct kvm_vcpu *vcpu,
104 unsigned int inst, int *advance);
105extern int kvmppc_core_emulate_mtspr_44x(struct kvm_vcpu *vcpu, int sprn,
106 ulong spr_val);
107extern int kvmppc_core_emulate_mfspr_44x(struct kvm_vcpu *vcpu, int sprn,
108 ulong *spr_val);
109extern void kvmppc_mmu_destroy_e500(struct kvm_vcpu *vcpu);
110extern int kvmppc_core_emulate_op_e500(struct kvm_run *run,
111 struct kvm_vcpu *vcpu,
112 unsigned int inst, int *advance);
113extern int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn,
114 ulong spr_val);
115extern int kvmppc_core_emulate_mfspr_e500(struct kvm_vcpu *vcpu, int sprn,
116 ulong *spr_val);
117extern void kvmppc_mmu_destroy_e500(struct kvm_vcpu *vcpu);
118extern int kvmppc_core_emulate_op_e500(struct kvm_run *run,
119 struct kvm_vcpu *vcpu,
120 unsigned int inst, int *advance);
121extern int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn,
122 ulong spr_val);
123extern int kvmppc_core_emulate_mfspr_e500(struct kvm_vcpu *vcpu, int sprn,
124 ulong *spr_val);
125
126
127
128
129
130
131
132
133
134
135static inline void kvmppc_load_guest_fp(struct kvm_vcpu *vcpu)
136{
137#ifdef CONFIG_PPC_FPU
138 if (vcpu->fpu_active && !(current->thread.regs->msr & MSR_FP)) {
139 enable_kernel_fp();
140 load_fp_state(&vcpu->arch.fp);
141 current->thread.fp_save_area = &vcpu->arch.fp;
142 current->thread.regs->msr |= MSR_FP;
143 }
144#endif
145}
146
147
148
149
150
151static inline void kvmppc_save_guest_fp(struct kvm_vcpu *vcpu)
152{
153#ifdef CONFIG_PPC_FPU
154 if (vcpu->fpu_active && (current->thread.regs->msr & MSR_FP))
155 giveup_fpu(current);
156 current->thread.fp_save_area = NULL;
157#endif
158}
159#endif
160