xref: /openbmc/linux/arch/powerpc/kvm/booke.h (revision d30f6e480055e5be12e7a03fd11ea912a451daa5)
175f74f0dSHollis Blanchard /*
275f74f0dSHollis Blanchard  * This program is free software; you can redistribute it and/or modify
375f74f0dSHollis Blanchard  * it under the terms of the GNU General Public License, version 2, as
475f74f0dSHollis Blanchard  * published by the Free Software Foundation.
575f74f0dSHollis Blanchard  *
675f74f0dSHollis Blanchard  * This program is distributed in the hope that it will be useful,
775f74f0dSHollis Blanchard  * but WITHOUT ANY WARRANTY; without even the implied warranty of
875f74f0dSHollis Blanchard  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
975f74f0dSHollis Blanchard  * GNU General Public License for more details.
1075f74f0dSHollis Blanchard  *
1175f74f0dSHollis Blanchard  * You should have received a copy of the GNU General Public License
1275f74f0dSHollis Blanchard  * along with this program; if not, write to the Free Software
1375f74f0dSHollis Blanchard  * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
1475f74f0dSHollis Blanchard  *
1575f74f0dSHollis Blanchard  * Copyright IBM Corp. 2008
1675f74f0dSHollis Blanchard  *
1775f74f0dSHollis Blanchard  * Authors: Hollis Blanchard <hollisb@us.ibm.com>
1875f74f0dSHollis Blanchard  */
1975f74f0dSHollis Blanchard 
2075f74f0dSHollis Blanchard #ifndef __KVM_BOOKE_H__
2175f74f0dSHollis Blanchard #define __KVM_BOOKE_H__
2275f74f0dSHollis Blanchard 
2375f74f0dSHollis Blanchard #include <linux/types.h>
2475f74f0dSHollis Blanchard #include <linux/kvm_host.h>
25d0c7dc03SHollis Blanchard #include <asm/kvm_ppc.h>
2673e75b41SHollis Blanchard #include "timing.h"
2775f74f0dSHollis Blanchard 
28d4cf3892SHollis Blanchard /* interrupt priortity ordering */
29d4cf3892SHollis Blanchard #define BOOKE_IRQPRIO_DATA_STORAGE 0
30d4cf3892SHollis Blanchard #define BOOKE_IRQPRIO_INST_STORAGE 1
31d4cf3892SHollis Blanchard #define BOOKE_IRQPRIO_ALIGNMENT 2
32d4cf3892SHollis Blanchard #define BOOKE_IRQPRIO_PROGRAM 3
33d4cf3892SHollis Blanchard #define BOOKE_IRQPRIO_FP_UNAVAIL 4
34bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_SPE_UNAVAIL 5
35bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_SPE_FP_DATA 6
36bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_SPE_FP_ROUND 7
37bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_SYSCALL 8
38bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_AP_UNAVAIL 9
39bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_DTLB_MISS 10
40bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_ITLB_MISS 11
41bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_MACHINE_CHECK 12
42bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_DEBUG 13
43bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_CRITICAL 14
44bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_WATCHDOG 15
45bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_EXTERNAL 16
46bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_FIT 17
47bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_DECREMENTER 18
48bb3a8a17SHollis Blanchard #define BOOKE_IRQPRIO_PERFORMANCE_MONITOR 19
49c5335f17SAlexander Graf /* Internal pseudo-irqprio for level triggered externals */
50c5335f17SAlexander Graf #define BOOKE_IRQPRIO_EXTERNAL_LEVEL 20
51*d30f6e48SScott Wood #define BOOKE_IRQPRIO_DBELL 21
52*d30f6e48SScott Wood #define BOOKE_IRQPRIO_DBELL_CRIT 22
53*d30f6e48SScott Wood #define BOOKE_IRQPRIO_MAX 23
54*d30f6e48SScott Wood 
55*d30f6e48SScott Wood #define BOOKE_IRQMASK_EE ((1 << BOOKE_IRQPRIO_EXTERNAL_LEVEL) | \
56*d30f6e48SScott Wood 			  (1 << BOOKE_IRQPRIO_PERFORMANCE_MONITOR) | \
57*d30f6e48SScott Wood 			  (1 << BOOKE_IRQPRIO_DBELL) | \
58*d30f6e48SScott Wood 			  (1 << BOOKE_IRQPRIO_DECREMENTER) | \
59*d30f6e48SScott Wood 			  (1 << BOOKE_IRQPRIO_FIT) | \
60*d30f6e48SScott Wood 			  (1 << BOOKE_IRQPRIO_EXTERNAL))
61*d30f6e48SScott Wood 
62*d30f6e48SScott Wood #define BOOKE_IRQMASK_CE ((1 << BOOKE_IRQPRIO_DBELL_CRIT) | \
63*d30f6e48SScott Wood 			  (1 << BOOKE_IRQPRIO_WATCHDOG) | \
64*d30f6e48SScott Wood 			  (1 << BOOKE_IRQPRIO_CRITICAL))
65bb3a8a17SHollis Blanchard 
66bb3a8a17SHollis Blanchard extern unsigned long kvmppc_booke_handlers;
67d4cf3892SHollis Blanchard 
684cd35f67SScott Wood void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
69dd9ebf1fSLiu Yu void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
7075f74f0dSHollis Blanchard 
71dfd4d47eSScott Wood void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr);
72dfd4d47eSScott Wood void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
73dfd4d47eSScott Wood void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
74dfd4d47eSScott Wood 
75d0c7dc03SHollis Blanchard int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
76d0c7dc03SHollis Blanchard                             unsigned int inst, int *advance);
77d0c7dc03SHollis Blanchard int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt);
78d0c7dc03SHollis Blanchard int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs);
79d0c7dc03SHollis Blanchard 
804cd35f67SScott Wood /* low-level asm code to transfer guest state */
814cd35f67SScott Wood void kvmppc_load_guest_spe(struct kvm_vcpu *vcpu);
824cd35f67SScott Wood void kvmppc_save_guest_spe(struct kvm_vcpu *vcpu);
834cd35f67SScott Wood 
844cd35f67SScott Wood /* high-level function, manages flags, host state */
854cd35f67SScott Wood void kvmppc_vcpu_disable_spe(struct kvm_vcpu *vcpu);
864cd35f67SScott Wood 
8794fa9d99SScott Wood void kvmppc_booke_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
8894fa9d99SScott Wood void kvmppc_booke_vcpu_put(struct kvm_vcpu *vcpu);
8994fa9d99SScott Wood 
90*d30f6e48SScott Wood enum int_class {
91*d30f6e48SScott Wood 	INT_CLASS_NONCRIT,
92*d30f6e48SScott Wood 	INT_CLASS_CRIT,
93*d30f6e48SScott Wood 	INT_CLASS_MC,
94*d30f6e48SScott Wood 	INT_CLASS_DBG,
95*d30f6e48SScott Wood };
96*d30f6e48SScott Wood 
97*d30f6e48SScott Wood void kvmppc_set_pending_interrupt(struct kvm_vcpu *vcpu, enum int_class type);
98*d30f6e48SScott Wood 
9975f74f0dSHollis Blanchard #endif /* __KVM_BOOKE_H__ */
100