Merge tag 'trace-3.8-rc3-regression-fix' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / powerpc / kvm / booke.h
blobe9b88e433f64a3d835d8b8970ab6ff6a6d0ebf56
1 /*
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 IBM Corp. 2008
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
20 #ifndef __KVM_BOOKE_H__
21 #define __KVM_BOOKE_H__
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"
29 /* interrupt priortity ordering */
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 /* Internal pseudo-irqprio for level triggered externals */
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
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))
63 #define BOOKE_IRQMASK_CE ((1 << BOOKE_IRQPRIO_DBELL_CRIT) | \
64 (1 << BOOKE_IRQPRIO_WATCHDOG) | \
65 (1 << BOOKE_IRQPRIO_CRITICAL))
67 extern unsigned long kvmppc_booke_handlers;
69 void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
70 void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
72 void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr);
73 void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr);
74 void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
75 void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
77 int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
78 unsigned int inst, int *advance);
79 int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val);
80 int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val);
82 /* low-level asm code to transfer guest state */
83 void kvmppc_load_guest_spe(struct kvm_vcpu *vcpu);
84 void kvmppc_save_guest_spe(struct kvm_vcpu *vcpu);
86 /* high-level function, manages flags, host state */
87 void kvmppc_vcpu_disable_spe(struct kvm_vcpu *vcpu);
89 void kvmppc_booke_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
90 void kvmppc_booke_vcpu_put(struct kvm_vcpu *vcpu);
92 enum int_class {
93 INT_CLASS_NONCRIT,
94 INT_CLASS_CRIT,
95 INT_CLASS_MC,
96 INT_CLASS_DBG,
99 void kvmppc_set_pending_interrupt(struct kvm_vcpu *vcpu, enum int_class type);
102 * Load up guest vcpu FP state if it's needed.
103 * It also set the MSR_FP in thread so that host know
104 * we're holding FPU, and then host can help to save
105 * guest vcpu FP state if other threads require to use FPU.
106 * This simulates an FP unavailable fault.
108 * It requires to be called with preemption disabled.
110 static inline void kvmppc_load_guest_fp(struct kvm_vcpu *vcpu)
112 #ifdef CONFIG_PPC_FPU
113 if (vcpu->fpu_active && !(current->thread.regs->msr & MSR_FP)) {
114 load_up_fpu();
115 current->thread.regs->msr |= MSR_FP;
117 #endif
121 * Save guest vcpu FP state into thread.
122 * It requires to be called with preemption disabled.
124 static inline void kvmppc_save_guest_fp(struct kvm_vcpu *vcpu)
126 #ifdef CONFIG_PPC_FPU
127 if (vcpu->fpu_active && (current->thread.regs->msr & MSR_FP))
128 giveup_fpu(current);
129 #endif
131 #endif /* __KVM_BOOKE_H__ */