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#ifdef CONFIG_SPE_POSSIBLE
36#define BOOKE_IRQPRIO_SPE_UNAVAIL 5
37#define BOOKE_IRQPRIO_SPE_FP_DATA 6
38#define BOOKE_IRQPRIO_SPE_FP_ROUND 7
39#endif
40#ifdef CONFIG_PPC_E500MC
41#define BOOKE_IRQPRIO_ALTIVEC_UNAVAIL 5
42#define BOOKE_IRQPRIO_ALTIVEC_ASSIST 6
43#endif
44#define BOOKE_IRQPRIO_SYSCALL 8
45#define BOOKE_IRQPRIO_AP_UNAVAIL 9
46#define BOOKE_IRQPRIO_DTLB_MISS 10
47#define BOOKE_IRQPRIO_ITLB_MISS 11
48#define BOOKE_IRQPRIO_MACHINE_CHECK 12
49#define BOOKE_IRQPRIO_DEBUG 13
50#define BOOKE_IRQPRIO_CRITICAL 14
51#define BOOKE_IRQPRIO_WATCHDOG 15
52#define BOOKE_IRQPRIO_EXTERNAL 16
53#define BOOKE_IRQPRIO_FIT 17
54#define BOOKE_IRQPRIO_DECREMENTER 18
55#define BOOKE_IRQPRIO_PERFORMANCE_MONITOR 19
56
57#define BOOKE_IRQPRIO_EXTERNAL_LEVEL 20
58#define BOOKE_IRQPRIO_DBELL 21
59#define BOOKE_IRQPRIO_DBELL_CRIT 22
60#define BOOKE_IRQPRIO_MAX 23
61
62#define BOOKE_IRQMASK_EE ((1 << BOOKE_IRQPRIO_EXTERNAL_LEVEL) | \
63 (1 << BOOKE_IRQPRIO_PERFORMANCE_MONITOR) | \
64 (1 << BOOKE_IRQPRIO_DBELL) | \
65 (1 << BOOKE_IRQPRIO_DECREMENTER) | \
66 (1 << BOOKE_IRQPRIO_FIT) | \
67 (1 << BOOKE_IRQPRIO_EXTERNAL))
68
69#define BOOKE_IRQMASK_CE ((1 << BOOKE_IRQPRIO_DBELL_CRIT) | \
70 (1 << BOOKE_IRQPRIO_WATCHDOG) | \
71 (1 << BOOKE_IRQPRIO_CRITICAL))
72
73extern unsigned long kvmppc_booke_handlers;
74extern unsigned long kvmppc_booke_handler_addr[];
75
76void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
77void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
78
79void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr);
80void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr);
81void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
82void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
83
84int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
85 unsigned int inst, int *advance);
86int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val);
87int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val);
88
89
90void kvmppc_load_guest_spe(struct kvm_vcpu *vcpu);
91void kvmppc_save_guest_spe(struct kvm_vcpu *vcpu);
92
93
94void kvmppc_vcpu_disable_spe(struct kvm_vcpu *vcpu);
95
96void kvmppc_booke_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
97void kvmppc_booke_vcpu_put(struct kvm_vcpu *vcpu);
98
99enum int_class {
100 INT_CLASS_NONCRIT,
101 INT_CLASS_CRIT,
102 INT_CLASS_MC,
103 INT_CLASS_DBG,
104};
105
106void kvmppc_set_pending_interrupt(struct kvm_vcpu *vcpu, enum int_class type);
107
108extern void kvmppc_mmu_destroy_e500(struct kvm_vcpu *vcpu);
109extern int kvmppc_core_emulate_op_e500(struct kvm_run *run,
110 struct kvm_vcpu *vcpu,
111 unsigned int inst, int *advance);
112extern int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn,
113 ulong spr_val);
114extern int kvmppc_core_emulate_mfspr_e500(struct kvm_vcpu *vcpu, int sprn,
115 ulong *spr_val);
116extern void kvmppc_mmu_destroy_e500(struct kvm_vcpu *vcpu);
117extern int kvmppc_core_emulate_op_e500(struct kvm_run *run,
118 struct kvm_vcpu *vcpu,
119 unsigned int inst, int *advance);
120extern int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn,
121 ulong spr_val);
122extern int kvmppc_core_emulate_mfspr_e500(struct kvm_vcpu *vcpu, int sprn,
123 ulong *spr_val);
124
125static inline void kvmppc_clear_dbsr(void)
126{
127 mtspr(SPRN_DBSR, mfspr(SPRN_DBSR));
128}
129#endif
130