xref: /openbmc/linux/arch/powerpc/include/asm/kvm_asm.h (revision d24ea8a7)
1b8b572e1SStephen Rothwell /*
2b8b572e1SStephen Rothwell  * This program is free software; you can redistribute it and/or modify
3b8b572e1SStephen Rothwell  * it under the terms of the GNU General Public License, version 2, as
4b8b572e1SStephen Rothwell  * published by the Free Software Foundation.
5b8b572e1SStephen Rothwell  *
6b8b572e1SStephen Rothwell  * This program is distributed in the hope that it will be useful,
7b8b572e1SStephen Rothwell  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8b8b572e1SStephen Rothwell  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9b8b572e1SStephen Rothwell  * GNU General Public License for more details.
10b8b572e1SStephen Rothwell  *
11b8b572e1SStephen Rothwell  * You should have received a copy of the GNU General Public License
12b8b572e1SStephen Rothwell  * along with this program; if not, write to the Free Software
13b8b572e1SStephen Rothwell  * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
14b8b572e1SStephen Rothwell  *
15b8b572e1SStephen Rothwell  * Copyright IBM Corp. 2008
16b8b572e1SStephen Rothwell  *
17b8b572e1SStephen Rothwell  * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18b8b572e1SStephen Rothwell  */
19b8b572e1SStephen Rothwell 
20b8b572e1SStephen Rothwell #ifndef __POWERPC_KVM_ASM_H__
21b8b572e1SStephen Rothwell #define __POWERPC_KVM_ASM_H__
22b8b572e1SStephen Rothwell 
233d4c6826SAlexander Graf #ifdef __ASSEMBLY__
24185e4188SVarun Sethi #ifdef CONFIG_64BIT
25185e4188SVarun Sethi #define PPC_STD(sreg, offset, areg)  std sreg, (offset)(areg)
26185e4188SVarun Sethi #define PPC_LD(treg, offset, areg)   ld treg, (offset)(areg)
27185e4188SVarun Sethi #else
28185e4188SVarun Sethi #define PPC_STD(sreg, offset, areg)  stw sreg, (offset+4)(areg)
29185e4188SVarun Sethi #define PPC_LD(treg, offset, areg)   lwz treg, (offset+4)(areg)
30185e4188SVarun Sethi #endif
313d4c6826SAlexander Graf #endif
32185e4188SVarun Sethi 
33b8b572e1SStephen Rothwell /* IVPR must be 64KiB-aligned. */
34b8b572e1SStephen Rothwell #define VCPU_SIZE_ORDER 4
35b8b572e1SStephen Rothwell #define VCPU_SIZE_LOG   (VCPU_SIZE_ORDER + 12)
36b8b572e1SStephen Rothwell #define VCPU_SIZE_BYTES (1<<VCPU_SIZE_LOG)
37b8b572e1SStephen Rothwell 
38b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_CRITICAL 0
39b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_MACHINE_CHECK 1
40b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_DATA_STORAGE 2
41b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_INST_STORAGE 3
42b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_EXTERNAL 4
43b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_ALIGNMENT 5
44b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_PROGRAM 6
45b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_FP_UNAVAIL 7
46b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_SYSCALL 8
47b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_AP_UNAVAIL 9
48b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_DECREMENTER 10
49b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_FIT 11
50b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_WATCHDOG 12
51b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_DTLB_MISS 13
52b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_ITLB_MISS 14
53b8b572e1SStephen Rothwell #define BOOKE_INTERRUPT_DEBUG 15
54bb3a8a17SHollis Blanchard 
55bb3a8a17SHollis Blanchard /* E500 */
56e9a94832SMihai Caraman #ifdef CONFIG_SPE_POSSIBLE
57e9a94832SMihai Caraman #define BOOKE_INTERRUPT_SPE_UNAVAIL 32
58e9a94832SMihai Caraman #define BOOKE_INTERRUPT_SPE_FP_DATA 33
59bb3a8a17SHollis Blanchard #define BOOKE_INTERRUPT_SPE_FP_ROUND 34
60e9a94832SMihai Caraman #endif
61e9a94832SMihai Caraman 
62e9a94832SMihai Caraman #ifdef CONFIG_PPC_E500MC
63e9a94832SMihai Caraman #define BOOKE_INTERRUPT_ALTIVEC_UNAVAIL 32
64e9a94832SMihai Caraman #define BOOKE_INTERRUPT_ALTIVEC_ASSIST 33
65e9a94832SMihai Caraman #endif
66e9a94832SMihai Caraman 
67bb3a8a17SHollis Blanchard #define BOOKE_INTERRUPT_PERFORMANCE_MONITOR 35
68d30f6e48SScott Wood #define BOOKE_INTERRUPT_DOORBELL 36
69d30f6e48SScott Wood #define BOOKE_INTERRUPT_DOORBELL_CRITICAL 37
70d30f6e48SScott Wood 
71d30f6e48SScott Wood /* booke_hv */
72d30f6e48SScott Wood #define BOOKE_INTERRUPT_GUEST_DBELL 38
73d30f6e48SScott Wood #define BOOKE_INTERRUPT_GUEST_DBELL_CRIT 39
74d30f6e48SScott Wood #define BOOKE_INTERRUPT_HV_SYSCALL 40
75d30f6e48SScott Wood #define BOOKE_INTERRUPT_HV_PRIV 41
76228b1a47SMihai Caraman #define BOOKE_INTERRUPT_LRAT_ERROR 42
77b8b572e1SStephen Rothwell 
7883cd259dSAlexander Graf /* book3s */
7983cd259dSAlexander Graf 
8083cd259dSAlexander Graf #define BOOK3S_INTERRUPT_SYSTEM_RESET	0x100
8183cd259dSAlexander Graf #define BOOK3S_INTERRUPT_MACHINE_CHECK	0x200
8283cd259dSAlexander Graf #define BOOK3S_INTERRUPT_DATA_STORAGE	0x300
8383cd259dSAlexander Graf #define BOOK3S_INTERRUPT_DATA_SEGMENT	0x380
8483cd259dSAlexander Graf #define BOOK3S_INTERRUPT_INST_STORAGE	0x400
8583cd259dSAlexander Graf #define BOOK3S_INTERRUPT_INST_SEGMENT	0x480
8683cd259dSAlexander Graf #define BOOK3S_INTERRUPT_EXTERNAL	0x500
87a5d4f3adSBenjamin Herrenschmidt #define BOOK3S_INTERRUPT_EXTERNAL_HV	0x502
8883cd259dSAlexander Graf #define BOOK3S_INTERRUPT_ALIGNMENT	0x600
8983cd259dSAlexander Graf #define BOOK3S_INTERRUPT_PROGRAM	0x700
9083cd259dSAlexander Graf #define BOOK3S_INTERRUPT_FP_UNAVAIL	0x800
9183cd259dSAlexander Graf #define BOOK3S_INTERRUPT_DECREMENTER	0x900
92de56a948SPaul Mackerras #define BOOK3S_INTERRUPT_HV_DECREMENTER	0x980
9340688909SPaul Mackerras #define BOOK3S_INTERRUPT_DOORBELL	0xa00
9483cd259dSAlexander Graf #define BOOK3S_INTERRUPT_SYSCALL	0xc00
9583cd259dSAlexander Graf #define BOOK3S_INTERRUPT_TRACE		0xd00
96de56a948SPaul Mackerras #define BOOK3S_INTERRUPT_H_DATA_STORAGE	0xe00
97de56a948SPaul Mackerras #define BOOK3S_INTERRUPT_H_INST_STORAGE	0xe20
98de56a948SPaul Mackerras #define BOOK3S_INTERRUPT_H_EMUL_ASSIST	0xe40
990869b6fdSMahesh Salgaonkar #define BOOK3S_INTERRUPT_HMI		0xe60
1005d00f66bSPaul Mackerras #define BOOK3S_INTERRUPT_H_DOORBELL	0xe80
10184f7139cSPaul Mackerras #define BOOK3S_INTERRUPT_H_VIRT		0xea0
10283cd259dSAlexander Graf #define BOOK3S_INTERRUPT_PERFMON	0xf00
10383cd259dSAlexander Graf #define BOOK3S_INTERRUPT_ALTIVEC	0xf20
10483cd259dSAlexander Graf #define BOOK3S_INTERRUPT_VSX		0xf40
105616dff86SAlexander Graf #define BOOK3S_INTERRUPT_FAC_UNAVAIL	0xf60
106bd3048b8SMichael Ellerman #define BOOK3S_INTERRUPT_H_FAC_UNAVAIL	0xf80
10783cd259dSAlexander Graf 
108f7af5209SSuresh Warrier /* book3s_hv */
109f7af5209SSuresh Warrier 
1104bb3c7a0SPaul Mackerras #define BOOK3S_INTERRUPT_HV_SOFTPATCH	0x1500
1114bb3c7a0SPaul Mackerras 
112f7af5209SSuresh Warrier /*
113f7af5209SSuresh Warrier  * Special trap used to indicate to host that this is a
114f7af5209SSuresh Warrier  * passthrough interrupt that could not be handled
115f7af5209SSuresh Warrier  * completely in the guest.
116f7af5209SSuresh Warrier  */
117f7af5209SSuresh Warrier #define BOOK3S_INTERRUPT_HV_RM_HARD	0x5555
118f7af5209SSuresh Warrier 
11983cd259dSAlexander Graf #define BOOK3S_IRQPRIO_SYSTEM_RESET		0
12083cd259dSAlexander Graf #define BOOK3S_IRQPRIO_DATA_SEGMENT		1
12183cd259dSAlexander Graf #define BOOK3S_IRQPRIO_INST_SEGMENT		2
12283cd259dSAlexander Graf #define BOOK3S_IRQPRIO_DATA_STORAGE		3
12383cd259dSAlexander Graf #define BOOK3S_IRQPRIO_INST_STORAGE		4
12483cd259dSAlexander Graf #define BOOK3S_IRQPRIO_ALIGNMENT		5
12583cd259dSAlexander Graf #define BOOK3S_IRQPRIO_PROGRAM			6
12683cd259dSAlexander Graf #define BOOK3S_IRQPRIO_FP_UNAVAIL		7
12783cd259dSAlexander Graf #define BOOK3S_IRQPRIO_ALTIVEC			8
12883cd259dSAlexander Graf #define BOOK3S_IRQPRIO_VSX			9
129616dff86SAlexander Graf #define BOOK3S_IRQPRIO_FAC_UNAVAIL		10
130616dff86SAlexander Graf #define BOOK3S_IRQPRIO_SYSCALL			11
131616dff86SAlexander Graf #define BOOK3S_IRQPRIO_MACHINE_CHECK		12
132616dff86SAlexander Graf #define BOOK3S_IRQPRIO_DEBUG			13
133616dff86SAlexander Graf #define BOOK3S_IRQPRIO_EXTERNAL			14
134616dff86SAlexander Graf #define BOOK3S_IRQPRIO_DECREMENTER		15
135616dff86SAlexander Graf #define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR	16
136d24ea8a7SPaul Mackerras #define BOOK3S_IRQPRIO_MAX			17
13783cd259dSAlexander Graf 
13883cd259dSAlexander Graf #define BOOK3S_HFLAG_DCBZ32			0x1
139e15a1137SAlexander Graf #define BOOK3S_HFLAG_SLB			0x2
1403c402a75SAlexander Graf #define BOOK3S_HFLAG_PAIRED_SINGLE		0x4
141b83d4a9cSAlexander Graf #define BOOK3S_HFLAG_NATIVE_PS			0x8
142a4a0f252SPaul Mackerras #define BOOK3S_HFLAG_MULTI_PGSIZE		0x10
143a4a0f252SPaul Mackerras #define BOOK3S_HFLAG_NEW_TLBIE			0x20
144c01e3f66SAlexander Graf #define BOOK3S_HFLAG_SPLIT_HACK			0x40
14583cd259dSAlexander Graf 
146b8b572e1SStephen Rothwell #define RESUME_FLAG_NV          (1<<0)  /* Reload guest nonvolatile state? */
147b8b572e1SStephen Rothwell #define RESUME_FLAG_HOST        (1<<1)  /* Resume host? */
148913d3ff9SPaul Mackerras #define RESUME_FLAG_ARCH1	(1<<2)
149f7af5209SSuresh Warrier #define RESUME_FLAG_ARCH2	(1<<3)
150b8b572e1SStephen Rothwell 
151b8b572e1SStephen Rothwell #define RESUME_GUEST            0
152b8b572e1SStephen Rothwell #define RESUME_GUEST_NV         RESUME_FLAG_NV
153b8b572e1SStephen Rothwell #define RESUME_HOST             RESUME_FLAG_HOST
154b8b572e1SStephen Rothwell #define RESUME_HOST_NV          (RESUME_FLAG_HOST|RESUME_FLAG_NV)
155b8b572e1SStephen Rothwell 
156b4433a7cSAlexander Graf #define KVM_GUEST_MODE_NONE	0
157b4433a7cSAlexander Graf #define KVM_GUEST_MODE_GUEST	1
158b4433a7cSAlexander Graf #define KVM_GUEST_MODE_SKIP	2
15944a3add8SPaul Mackerras #define KVM_GUEST_MODE_GUEST_HV	3
16044a3add8SPaul Mackerras #define KVM_GUEST_MODE_HOST_HV	4
161b4433a7cSAlexander Graf 
162b4433a7cSAlexander Graf #define KVM_INST_FETCH_FAILED	-1
163b4433a7cSAlexander Graf 
164b8b572e1SStephen Rothwell #endif /* __POWERPC_KVM_ASM_H__ */
165