blob: 1bd92fd43cfb7fc8a14f0bfeeaed62f50700f07d [file] [log] [blame]
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -05001/*
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
Alexander Graf3d4c6822012-04-25 13:48:54 +020023#ifdef __ASSEMBLY__
Varun Sethi185e4182012-04-25 01:26:43 +000024#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
Alexander Graf3d4c6822012-04-25 13:48:54 +020031#endif
Varun Sethi185e4182012-04-25 01:26:43 +000032
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -050033/* IVPR must be 64KiB-aligned. */
34#define VCPU_SIZE_ORDER 4
35#define VCPU_SIZE_LOG (VCPU_SIZE_ORDER + 12)
36#define VCPU_TLB_PGSZ PPC44x_TLB_64K
37#define VCPU_SIZE_BYTES (1<<VCPU_SIZE_LOG)
38
39#define BOOKE_INTERRUPT_CRITICAL 0
40#define BOOKE_INTERRUPT_MACHINE_CHECK 1
41#define BOOKE_INTERRUPT_DATA_STORAGE 2
42#define BOOKE_INTERRUPT_INST_STORAGE 3
43#define BOOKE_INTERRUPT_EXTERNAL 4
44#define BOOKE_INTERRUPT_ALIGNMENT 5
45#define BOOKE_INTERRUPT_PROGRAM 6
46#define BOOKE_INTERRUPT_FP_UNAVAIL 7
47#define BOOKE_INTERRUPT_SYSCALL 8
48#define BOOKE_INTERRUPT_AP_UNAVAIL 9
49#define BOOKE_INTERRUPT_DECREMENTER 10
50#define BOOKE_INTERRUPT_FIT 11
51#define BOOKE_INTERRUPT_WATCHDOG 12
52#define BOOKE_INTERRUPT_DTLB_MISS 13
53#define BOOKE_INTERRUPT_ITLB_MISS 14
54#define BOOKE_INTERRUPT_DEBUG 15
Hollis Blanchardbb3a8a12009-01-03 16:23:13 -060055
56/* E500 */
Mihai Caraman4edd1ae2013-06-06 19:16:29 -050057#define BOOKE_INTERRUPT_SPE_ALTIVEC_UNAVAIL 32
58#define BOOKE_INTERRUPT_SPE_FP_DATA_ALTIVEC_ASSIST 33
59/*
60 * TODO: Unify 32-bit and 64-bit kernel exception handlers to use same defines
61 */
62#define BOOKE_INTERRUPT_SPE_UNAVAIL BOOKE_INTERRUPT_SPE_ALTIVEC_UNAVAIL
63#define BOOKE_INTERRUPT_SPE_FP_DATA BOOKE_INTERRUPT_SPE_FP_DATA_ALTIVEC_ASSIST
64#define BOOKE_INTERRUPT_ALTIVEC_UNAVAIL BOOKE_INTERRUPT_SPE_ALTIVEC_UNAVAIL
65#define BOOKE_INTERRUPT_ALTIVEC_ASSIST \
66 BOOKE_INTERRUPT_SPE_FP_DATA_ALTIVEC_ASSIST
Hollis Blanchardbb3a8a12009-01-03 16:23:13 -060067#define BOOKE_INTERRUPT_SPE_FP_ROUND 34
68#define BOOKE_INTERRUPT_PERFORMANCE_MONITOR 35
Scott Woodd30f6e42011-12-20 15:34:43 +000069#define BOOKE_INTERRUPT_DOORBELL 36
70#define BOOKE_INTERRUPT_DOORBELL_CRITICAL 37
71
72/* booke_hv */
73#define BOOKE_INTERRUPT_GUEST_DBELL 38
74#define BOOKE_INTERRUPT_GUEST_DBELL_CRIT 39
75#define BOOKE_INTERRUPT_HV_SYSCALL 40
76#define BOOKE_INTERRUPT_HV_PRIV 41
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -050077
Alexander Graf83cd2592009-10-30 05:47:03 +000078/* 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
Alexander Graf17bd1582010-08-30 10:44:15 +020087#define BOOK3S_INTERRUPT_EXTERNAL_LEVEL 0x501
Benjamin Herrenschmidta5d4f3a2011-04-05 14:20:31 +100088#define BOOK3S_INTERRUPT_EXTERNAL_HV 0x502
Alexander Graf83cd2592009-10-30 05:47:03 +000089#define BOOK3S_INTERRUPT_ALIGNMENT 0x600
90#define BOOK3S_INTERRUPT_PROGRAM 0x700
91#define BOOK3S_INTERRUPT_FP_UNAVAIL 0x800
92#define BOOK3S_INTERRUPT_DECREMENTER 0x900
Paul Mackerrasde56a942011-06-29 00:21:34 +000093#define BOOK3S_INTERRUPT_HV_DECREMENTER 0x980
Alexander Graf83cd2592009-10-30 05:47:03 +000094#define BOOK3S_INTERRUPT_SYSCALL 0xc00
95#define BOOK3S_INTERRUPT_TRACE 0xd00
Paul Mackerrasde56a942011-06-29 00:21:34 +000096#define BOOK3S_INTERRUPT_H_DATA_STORAGE 0xe00
97#define BOOK3S_INTERRUPT_H_INST_STORAGE 0xe20
98#define BOOK3S_INTERRUPT_H_EMUL_ASSIST 0xe40
Alexander Graf83cd2592009-10-30 05:47:03 +000099#define BOOK3S_INTERRUPT_PERFMON 0xf00
100#define BOOK3S_INTERRUPT_ALTIVEC 0xf20
101#define BOOK3S_INTERRUPT_VSX 0xf40
102
103#define BOOK3S_IRQPRIO_SYSTEM_RESET 0
104#define BOOK3S_IRQPRIO_DATA_SEGMENT 1
105#define BOOK3S_IRQPRIO_INST_SEGMENT 2
106#define BOOK3S_IRQPRIO_DATA_STORAGE 3
107#define BOOK3S_IRQPRIO_INST_STORAGE 4
108#define BOOK3S_IRQPRIO_ALIGNMENT 5
109#define BOOK3S_IRQPRIO_PROGRAM 6
110#define BOOK3S_IRQPRIO_FP_UNAVAIL 7
111#define BOOK3S_IRQPRIO_ALTIVEC 8
112#define BOOK3S_IRQPRIO_VSX 9
113#define BOOK3S_IRQPRIO_SYSCALL 10
114#define BOOK3S_IRQPRIO_MACHINE_CHECK 11
115#define BOOK3S_IRQPRIO_DEBUG 12
116#define BOOK3S_IRQPRIO_EXTERNAL 13
117#define BOOK3S_IRQPRIO_DECREMENTER 14
118#define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR 15
Alexander Graf17bd1582010-08-30 10:44:15 +0200119#define BOOK3S_IRQPRIO_EXTERNAL_LEVEL 16
120#define BOOK3S_IRQPRIO_MAX 17
Alexander Graf83cd2592009-10-30 05:47:03 +0000121
122#define BOOK3S_HFLAG_DCBZ32 0x1
Alexander Grafe15a1132009-11-30 03:02:02 +0000123#define BOOK3S_HFLAG_SLB 0x2
Alexander Graf3c402a72010-02-19 11:00:32 +0100124#define BOOK3S_HFLAG_PAIRED_SINGLE 0x4
Alexander Grafb83d4a92010-04-20 02:49:54 +0200125#define BOOK3S_HFLAG_NATIVE_PS 0x8
Paul Mackerrasa4a0f252013-09-20 14:52:44 +1000126#define BOOK3S_HFLAG_MULTI_PGSIZE 0x10
127#define BOOK3S_HFLAG_NEW_TLBIE 0x20
Alexander Graf83cd2592009-10-30 05:47:03 +0000128
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500129#define RESUME_FLAG_NV (1<<0) /* Reload guest nonvolatile state? */
130#define RESUME_FLAG_HOST (1<<1) /* Resume host? */
Paul Mackerras913d3ff9a2012-10-15 01:16:48 +0000131#define RESUME_FLAG_ARCH1 (1<<2)
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500132
133#define RESUME_GUEST 0
134#define RESUME_GUEST_NV RESUME_FLAG_NV
135#define RESUME_HOST RESUME_FLAG_HOST
136#define RESUME_HOST_NV (RESUME_FLAG_HOST|RESUME_FLAG_NV)
137
Alexander Grafb4433a72010-01-08 02:58:04 +0100138#define KVM_GUEST_MODE_NONE 0
139#define KVM_GUEST_MODE_GUEST 1
140#define KVM_GUEST_MODE_SKIP 2
Paul Mackerras44a3add2013-10-04 21:45:04 +1000141#define KVM_GUEST_MODE_GUEST_HV 3
142#define KVM_GUEST_MODE_HOST_HV 4
Alexander Grafb4433a72010-01-08 02:58:04 +0100143
144#define KVM_INST_FETCH_FAILED -1
145
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500146#endif /* __POWERPC_KVM_ASM_H__ */