xref: /openbmc/linux/arch/powerpc/include/asm/kvm_asm.h (revision 2359ccdd)
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.
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 __POWERPC_KVM_ASM_H__
21 #define __POWERPC_KVM_ASM_H__
22 
23 #ifdef __ASSEMBLY__
24 #ifdef CONFIG_64BIT
25 #define PPC_STD(sreg, offset, areg)  std sreg, (offset)(areg)
26 #define PPC_LD(treg, offset, areg)   ld treg, (offset)(areg)
27 #else
28 #define PPC_STD(sreg, offset, areg)  stw sreg, (offset+4)(areg)
29 #define PPC_LD(treg, offset, areg)   lwz treg, (offset+4)(areg)
30 #endif
31 #endif
32 
33 /* IVPR must be 64KiB-aligned. */
34 #define VCPU_SIZE_ORDER 4
35 #define VCPU_SIZE_LOG   (VCPU_SIZE_ORDER + 12)
36 #define VCPU_SIZE_BYTES (1<<VCPU_SIZE_LOG)
37 
38 #define BOOKE_INTERRUPT_CRITICAL 0
39 #define BOOKE_INTERRUPT_MACHINE_CHECK 1
40 #define BOOKE_INTERRUPT_DATA_STORAGE 2
41 #define BOOKE_INTERRUPT_INST_STORAGE 3
42 #define BOOKE_INTERRUPT_EXTERNAL 4
43 #define BOOKE_INTERRUPT_ALIGNMENT 5
44 #define BOOKE_INTERRUPT_PROGRAM 6
45 #define BOOKE_INTERRUPT_FP_UNAVAIL 7
46 #define BOOKE_INTERRUPT_SYSCALL 8
47 #define BOOKE_INTERRUPT_AP_UNAVAIL 9
48 #define BOOKE_INTERRUPT_DECREMENTER 10
49 #define BOOKE_INTERRUPT_FIT 11
50 #define BOOKE_INTERRUPT_WATCHDOG 12
51 #define BOOKE_INTERRUPT_DTLB_MISS 13
52 #define BOOKE_INTERRUPT_ITLB_MISS 14
53 #define BOOKE_INTERRUPT_DEBUG 15
54 
55 /* E500 */
56 #ifdef CONFIG_SPE_POSSIBLE
57 #define BOOKE_INTERRUPT_SPE_UNAVAIL 32
58 #define BOOKE_INTERRUPT_SPE_FP_DATA 33
59 #define BOOKE_INTERRUPT_SPE_FP_ROUND 34
60 #endif
61 
62 #ifdef CONFIG_PPC_E500MC
63 #define BOOKE_INTERRUPT_ALTIVEC_UNAVAIL 32
64 #define BOOKE_INTERRUPT_ALTIVEC_ASSIST 33
65 #endif
66 
67 #define BOOKE_INTERRUPT_PERFORMANCE_MONITOR 35
68 #define BOOKE_INTERRUPT_DOORBELL 36
69 #define BOOKE_INTERRUPT_DOORBELL_CRITICAL 37
70 
71 /* booke_hv */
72 #define BOOKE_INTERRUPT_GUEST_DBELL 38
73 #define BOOKE_INTERRUPT_GUEST_DBELL_CRIT 39
74 #define BOOKE_INTERRUPT_HV_SYSCALL 40
75 #define BOOKE_INTERRUPT_HV_PRIV 41
76 #define BOOKE_INTERRUPT_LRAT_ERROR 42
77 
78 /* book3s */
79 
80 #define BOOK3S_INTERRUPT_SYSTEM_RESET	0x100
81 #define BOOK3S_INTERRUPT_MACHINE_CHECK	0x200
82 #define BOOK3S_INTERRUPT_DATA_STORAGE	0x300
83 #define BOOK3S_INTERRUPT_DATA_SEGMENT	0x380
84 #define BOOK3S_INTERRUPT_INST_STORAGE	0x400
85 #define BOOK3S_INTERRUPT_INST_SEGMENT	0x480
86 #define BOOK3S_INTERRUPT_EXTERNAL	0x500
87 #define BOOK3S_INTERRUPT_EXTERNAL_LEVEL	0x501
88 #define BOOK3S_INTERRUPT_EXTERNAL_HV	0x502
89 #define BOOK3S_INTERRUPT_ALIGNMENT	0x600
90 #define BOOK3S_INTERRUPT_PROGRAM	0x700
91 #define BOOK3S_INTERRUPT_FP_UNAVAIL	0x800
92 #define BOOK3S_INTERRUPT_DECREMENTER	0x900
93 #define BOOK3S_INTERRUPT_HV_DECREMENTER	0x980
94 #define BOOK3S_INTERRUPT_DOORBELL	0xa00
95 #define BOOK3S_INTERRUPT_SYSCALL	0xc00
96 #define BOOK3S_INTERRUPT_TRACE		0xd00
97 #define BOOK3S_INTERRUPT_H_DATA_STORAGE	0xe00
98 #define BOOK3S_INTERRUPT_H_INST_STORAGE	0xe20
99 #define BOOK3S_INTERRUPT_H_EMUL_ASSIST	0xe40
100 #define BOOK3S_INTERRUPT_HMI		0xe60
101 #define BOOK3S_INTERRUPT_H_DOORBELL	0xe80
102 #define BOOK3S_INTERRUPT_H_VIRT		0xea0
103 #define BOOK3S_INTERRUPT_PERFMON	0xf00
104 #define BOOK3S_INTERRUPT_ALTIVEC	0xf20
105 #define BOOK3S_INTERRUPT_VSX		0xf40
106 #define BOOK3S_INTERRUPT_FAC_UNAVAIL	0xf60
107 #define BOOK3S_INTERRUPT_H_FAC_UNAVAIL	0xf80
108 
109 /* book3s_hv */
110 
111 #define BOOK3S_INTERRUPT_HV_SOFTPATCH	0x1500
112 
113 /*
114  * Special trap used to indicate to host that this is a
115  * passthrough interrupt that could not be handled
116  * completely in the guest.
117  */
118 #define BOOK3S_INTERRUPT_HV_RM_HARD	0x5555
119 
120 #define BOOK3S_IRQPRIO_SYSTEM_RESET		0
121 #define BOOK3S_IRQPRIO_DATA_SEGMENT		1
122 #define BOOK3S_IRQPRIO_INST_SEGMENT		2
123 #define BOOK3S_IRQPRIO_DATA_STORAGE		3
124 #define BOOK3S_IRQPRIO_INST_STORAGE		4
125 #define BOOK3S_IRQPRIO_ALIGNMENT		5
126 #define BOOK3S_IRQPRIO_PROGRAM			6
127 #define BOOK3S_IRQPRIO_FP_UNAVAIL		7
128 #define BOOK3S_IRQPRIO_ALTIVEC			8
129 #define BOOK3S_IRQPRIO_VSX			9
130 #define BOOK3S_IRQPRIO_FAC_UNAVAIL		10
131 #define BOOK3S_IRQPRIO_SYSCALL			11
132 #define BOOK3S_IRQPRIO_MACHINE_CHECK		12
133 #define BOOK3S_IRQPRIO_DEBUG			13
134 #define BOOK3S_IRQPRIO_EXTERNAL			14
135 #define BOOK3S_IRQPRIO_DECREMENTER		15
136 #define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR	16
137 #define BOOK3S_IRQPRIO_EXTERNAL_LEVEL		17
138 #define BOOK3S_IRQPRIO_MAX			18
139 
140 #define BOOK3S_HFLAG_DCBZ32			0x1
141 #define BOOK3S_HFLAG_SLB			0x2
142 #define BOOK3S_HFLAG_PAIRED_SINGLE		0x4
143 #define BOOK3S_HFLAG_NATIVE_PS			0x8
144 #define BOOK3S_HFLAG_MULTI_PGSIZE		0x10
145 #define BOOK3S_HFLAG_NEW_TLBIE			0x20
146 #define BOOK3S_HFLAG_SPLIT_HACK			0x40
147 
148 #define RESUME_FLAG_NV          (1<<0)  /* Reload guest nonvolatile state? */
149 #define RESUME_FLAG_HOST        (1<<1)  /* Resume host? */
150 #define RESUME_FLAG_ARCH1	(1<<2)
151 #define RESUME_FLAG_ARCH2	(1<<3)
152 
153 #define RESUME_GUEST            0
154 #define RESUME_GUEST_NV         RESUME_FLAG_NV
155 #define RESUME_HOST             RESUME_FLAG_HOST
156 #define RESUME_HOST_NV          (RESUME_FLAG_HOST|RESUME_FLAG_NV)
157 
158 #define KVM_GUEST_MODE_NONE	0
159 #define KVM_GUEST_MODE_GUEST	1
160 #define KVM_GUEST_MODE_SKIP	2
161 #define KVM_GUEST_MODE_GUEST_HV	3
162 #define KVM_GUEST_MODE_HOST_HV	4
163 
164 #define KVM_INST_FETCH_FAILED	-1
165 
166 #endif /* __POWERPC_KVM_ASM_H__ */
167