Merge tag 'smp-urgent-2023-09-02' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / arch / powerpc / include / asm / kvm_asm.h
CommitLineData
d94d71cb 1/* SPDX-License-Identifier: GPL-2.0-only */
bbf45ba5 2/*
bbf45ba5
HB
3 *
4 * Copyright IBM Corp. 2008
5 *
6 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
7 */
8
9#ifndef __POWERPC_KVM_ASM_H__
10#define __POWERPC_KVM_ASM_H__
11
3d4c6826 12#ifdef __ASSEMBLY__
185e4188
VS
13#ifdef CONFIG_64BIT
14#define PPC_STD(sreg, offset, areg) std sreg, (offset)(areg)
15#define PPC_LD(treg, offset, areg) ld treg, (offset)(areg)
16#else
17#define PPC_STD(sreg, offset, areg) stw sreg, (offset+4)(areg)
18#define PPC_LD(treg, offset, areg) lwz treg, (offset+4)(areg)
19#endif
3d4c6826 20#endif
185e4188 21
bbf45ba5
HB
22/* IVPR must be 64KiB-aligned. */
23#define VCPU_SIZE_ORDER 4
24#define VCPU_SIZE_LOG (VCPU_SIZE_ORDER + 12)
bbf45ba5
HB
25#define VCPU_SIZE_BYTES (1<<VCPU_SIZE_LOG)
26
27#define BOOKE_INTERRUPT_CRITICAL 0
28#define BOOKE_INTERRUPT_MACHINE_CHECK 1
29#define BOOKE_INTERRUPT_DATA_STORAGE 2
30#define BOOKE_INTERRUPT_INST_STORAGE 3
31#define BOOKE_INTERRUPT_EXTERNAL 4
32#define BOOKE_INTERRUPT_ALIGNMENT 5
33#define BOOKE_INTERRUPT_PROGRAM 6
34#define BOOKE_INTERRUPT_FP_UNAVAIL 7
35#define BOOKE_INTERRUPT_SYSCALL 8
36#define BOOKE_INTERRUPT_AP_UNAVAIL 9
37#define BOOKE_INTERRUPT_DECREMENTER 10
38#define BOOKE_INTERRUPT_FIT 11
39#define BOOKE_INTERRUPT_WATCHDOG 12
40#define BOOKE_INTERRUPT_DTLB_MISS 13
41#define BOOKE_INTERRUPT_ITLB_MISS 14
42#define BOOKE_INTERRUPT_DEBUG 15
bb3a8a17
HB
43
44/* E500 */
e9a94832
MC
45#ifdef CONFIG_SPE_POSSIBLE
46#define BOOKE_INTERRUPT_SPE_UNAVAIL 32
47#define BOOKE_INTERRUPT_SPE_FP_DATA 33
bb3a8a17 48#define BOOKE_INTERRUPT_SPE_FP_ROUND 34
e9a94832
MC
49#endif
50
51#ifdef CONFIG_PPC_E500MC
52#define BOOKE_INTERRUPT_ALTIVEC_UNAVAIL 32
53#define BOOKE_INTERRUPT_ALTIVEC_ASSIST 33
54#endif
55
bb3a8a17 56#define BOOKE_INTERRUPT_PERFORMANCE_MONITOR 35
d30f6e48
SW
57#define BOOKE_INTERRUPT_DOORBELL 36
58#define BOOKE_INTERRUPT_DOORBELL_CRITICAL 37
59
60/* booke_hv */
61#define BOOKE_INTERRUPT_GUEST_DBELL 38
62#define BOOKE_INTERRUPT_GUEST_DBELL_CRIT 39
63#define BOOKE_INTERRUPT_HV_SYSCALL 40
64#define BOOKE_INTERRUPT_HV_PRIV 41
228b1a47 65#define BOOKE_INTERRUPT_LRAT_ERROR 42
bbf45ba5 66
83cd259d
AG
67/* book3s */
68
69#define BOOK3S_INTERRUPT_SYSTEM_RESET 0x100
70#define BOOK3S_INTERRUPT_MACHINE_CHECK 0x200
71#define BOOK3S_INTERRUPT_DATA_STORAGE 0x300
72#define BOOK3S_INTERRUPT_DATA_SEGMENT 0x380
73#define BOOK3S_INTERRUPT_INST_STORAGE 0x400
74#define BOOK3S_INTERRUPT_INST_SEGMENT 0x480
75#define BOOK3S_INTERRUPT_EXTERNAL 0x500
a5d4f3ad 76#define BOOK3S_INTERRUPT_EXTERNAL_HV 0x502
83cd259d
AG
77#define BOOK3S_INTERRUPT_ALIGNMENT 0x600
78#define BOOK3S_INTERRUPT_PROGRAM 0x700
79#define BOOK3S_INTERRUPT_FP_UNAVAIL 0x800
80#define BOOK3S_INTERRUPT_DECREMENTER 0x900
de56a948 81#define BOOK3S_INTERRUPT_HV_DECREMENTER 0x980
46dea77f 82#define BOOK3S_INTERRUPT_NESTED_HV_DECREMENTER 0x1980
40688909 83#define BOOK3S_INTERRUPT_DOORBELL 0xa00
83cd259d
AG
84#define BOOK3S_INTERRUPT_SYSCALL 0xc00
85#define BOOK3S_INTERRUPT_TRACE 0xd00
de56a948
PM
86#define BOOK3S_INTERRUPT_H_DATA_STORAGE 0xe00
87#define BOOK3S_INTERRUPT_H_INST_STORAGE 0xe20
88#define BOOK3S_INTERRUPT_H_EMUL_ASSIST 0xe40
0869b6fd 89#define BOOK3S_INTERRUPT_HMI 0xe60
5d00f66b 90#define BOOK3S_INTERRUPT_H_DOORBELL 0xe80
84f7139c 91#define BOOK3S_INTERRUPT_H_VIRT 0xea0
83cd259d
AG
92#define BOOK3S_INTERRUPT_PERFMON 0xf00
93#define BOOK3S_INTERRUPT_ALTIVEC 0xf20
94#define BOOK3S_INTERRUPT_VSX 0xf40
616dff86 95#define BOOK3S_INTERRUPT_FAC_UNAVAIL 0xf60
bd3048b8 96#define BOOK3S_INTERRUPT_H_FAC_UNAVAIL 0xf80
83cd259d 97
f7af5209
SW
98/* book3s_hv */
99
4bb3c7a0
PM
100#define BOOK3S_INTERRUPT_HV_SOFTPATCH 0x1500
101
f7af5209
SW
102/*
103 * Special trap used to indicate to host that this is a
104 * passthrough interrupt that could not be handled
105 * completely in the guest.
106 */
107#define BOOK3S_INTERRUPT_HV_RM_HARD 0x5555
108
83cd259d
AG
109#define BOOK3S_IRQPRIO_SYSTEM_RESET 0
110#define BOOK3S_IRQPRIO_DATA_SEGMENT 1
111#define BOOK3S_IRQPRIO_INST_SEGMENT 2
112#define BOOK3S_IRQPRIO_DATA_STORAGE 3
113#define BOOK3S_IRQPRIO_INST_STORAGE 4
114#define BOOK3S_IRQPRIO_ALIGNMENT 5
115#define BOOK3S_IRQPRIO_PROGRAM 6
116#define BOOK3S_IRQPRIO_FP_UNAVAIL 7
117#define BOOK3S_IRQPRIO_ALTIVEC 8
118#define BOOK3S_IRQPRIO_VSX 9
616dff86
AG
119#define BOOK3S_IRQPRIO_FAC_UNAVAIL 10
120#define BOOK3S_IRQPRIO_SYSCALL 11
121#define BOOK3S_IRQPRIO_MACHINE_CHECK 12
122#define BOOK3S_IRQPRIO_DEBUG 13
123#define BOOK3S_IRQPRIO_EXTERNAL 14
124#define BOOK3S_IRQPRIO_DECREMENTER 15
125#define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR 16
d24ea8a7 126#define BOOK3S_IRQPRIO_MAX 17
83cd259d
AG
127
128#define BOOK3S_HFLAG_DCBZ32 0x1
e15a1137 129#define BOOK3S_HFLAG_SLB 0x2
3c402a75 130#define BOOK3S_HFLAG_PAIRED_SINGLE 0x4
b83d4a9c 131#define BOOK3S_HFLAG_NATIVE_PS 0x8
a4a0f252
PM
132#define BOOK3S_HFLAG_MULTI_PGSIZE 0x10
133#define BOOK3S_HFLAG_NEW_TLBIE 0x20
c01e3f66 134#define BOOK3S_HFLAG_SPLIT_HACK 0x40
83cd259d 135
bbf45ba5
HB
136#define RESUME_FLAG_NV (1<<0) /* Reload guest nonvolatile state? */
137#define RESUME_FLAG_HOST (1<<1) /* Resume host? */
913d3ff9 138#define RESUME_FLAG_ARCH1 (1<<2)
f7af5209 139#define RESUME_FLAG_ARCH2 (1<<3)
bbf45ba5
HB
140
141#define RESUME_GUEST 0
142#define RESUME_GUEST_NV RESUME_FLAG_NV
143#define RESUME_HOST RESUME_FLAG_HOST
144#define RESUME_HOST_NV (RESUME_FLAG_HOST|RESUME_FLAG_NV)
145
b4433a7c
AG
146#define KVM_GUEST_MODE_NONE 0
147#define KVM_GUEST_MODE_GUEST 1
148#define KVM_GUEST_MODE_SKIP 2
44a3add8
PM
149#define KVM_GUEST_MODE_GUEST_HV 3
150#define KVM_GUEST_MODE_HOST_HV 4
0bf7e1b2 151#define KVM_GUEST_MODE_HV_P9 5 /* ISA >= v3.0 path */
b4433a7c
AG
152
153#define KVM_INST_FETCH_FAILED -1
154
1dff3064
GR
155/* Extract PO and XOP opcode fields */
156#define PO_XOP_OPCODE_MASK 0xfc0007fe
157
bbf45ba5 158#endif /* __POWERPC_KVM_ASM_H__ */