blob: 22ba08ea68e9a9259720e5690e4592640e4b2835 [file] [log] [blame]
Hollis Blanchard75f74f02008-11-05 09:36:16 -06001/*
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.
5 *
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.
10 *
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.
14 *
15 * Copyright IBM Corp. 2008
16 *
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18 */
19
20#ifndef __KVM_BOOKE_H__
21#define __KVM_BOOKE_H__
22
23#include <linux/types.h>
24#include <linux/kvm_host.h>
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060025#include <asm/kvm_ppc.h>
Scott Wood8fae8452011-12-20 15:34:45 +000026#include <asm/switch_to.h>
Hollis Blanchard73e75b42008-12-02 15:51:57 -060027#include "timing.h"
Hollis Blanchard75f74f02008-11-05 09:36:16 -060028
Hollis Blanchardd4cf3892008-11-05 09:36:23 -060029/* 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
Mihai Caraman95d80a22014-08-20 16:36:23 +030035#ifdef CONFIG_SPE_POSSIBLE
Hollis Blanchardbb3a8a12009-01-03 16:23:13 -060036#define BOOKE_IRQPRIO_SPE_UNAVAIL 5
37#define BOOKE_IRQPRIO_SPE_FP_DATA 6
38#define BOOKE_IRQPRIO_SPE_FP_ROUND 7
Mihai Caraman95d80a22014-08-20 16:36:23 +030039#endif
40#ifdef CONFIG_PPC_E500MC
41#define BOOKE_IRQPRIO_ALTIVEC_UNAVAIL 5
42#define BOOKE_IRQPRIO_ALTIVEC_ASSIST 6
43#endif
Hollis Blanchardbb3a8a12009-01-03 16:23:13 -060044#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
Alexander Grafc5335f12010-08-30 14:03:24 +020056/* Internal pseudo-irqprio for level triggered externals */
57#define BOOKE_IRQPRIO_EXTERNAL_LEVEL 20
Scott Woodd30f6e42011-12-20 15:34:43 +000058#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))
Hollis Blanchardbb3a8a12009-01-03 16:23:13 -060072
73extern unsigned long kvmppc_booke_handlers;
Bharat Bhushan1d542d92013-01-15 22:24:39 +000074extern unsigned long kvmppc_booke_handler_addr[];
Hollis Blanchardd4cf3892008-11-05 09:36:23 -060075
Scott Wood4cd35f62011-06-14 18:34:31 -050076void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
Liu Yudd9ebf1f2011-06-14 18:35:14 -050077void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
Hollis Blanchard75f74f02008-11-05 09:36:16 -060078
Mihai Caraman38f98822012-10-11 06:13:27 +000079void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr);
Scott Wooddfd4d472011-11-17 12:39:59 +000080void 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
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060084int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
85 unsigned int inst, int *advance);
Alexander Graf54771e62012-05-04 14:55:12 +020086int 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);
Hollis Blanchardd0c7dc02009-01-03 16:23:06 -060088
Scott Wood4cd35f62011-06-14 18:34:31 -050089/* low-level asm code to transfer guest state */
90void kvmppc_load_guest_spe(struct kvm_vcpu *vcpu);
91void kvmppc_save_guest_spe(struct kvm_vcpu *vcpu);
92
93/* high-level function, manages flags, host state */
94void kvmppc_vcpu_disable_spe(struct kvm_vcpu *vcpu);
95
Scott Wood94fa9d92011-12-20 15:34:22 +000096void kvmppc_booke_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
97void kvmppc_booke_vcpu_put(struct kvm_vcpu *vcpu);
98
Scott Woodd30f6e42011-12-20 15:34:43 +000099enum 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
Aneesh Kumar K.V3a167bea2013-10-07 22:17:53 +0530108extern 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
Bharat Bhushance11e482013-07-04 12:27:47 +0530125static inline void kvmppc_clear_dbsr(void)
126{
127 mtspr(SPRN_DBSR, mfspr(SPRN_DBSR));
128}
Hollis Blanchard75f74f02008-11-05 09:36:16 -0600129#endif /* __KVM_BOOKE_H__ */