1 /* SPDX-License-Identifier: GPL-2.0-only */
4 * Copyright SUSE Linux Products GmbH 2009
6 * Authors: Alexander Graf <agraf@suse.de>
9 #ifndef __ASM_KVM_BOOK3S_ASM_H__
10 #define __ASM_KVM_BOOK3S_ASM_H__
12 /* XICS ICP register offsets */
15 #define XICS_IPI 2 /* interrupt source # for IPIs */
17 /* LPIDs we support with this build -- runtime limit may be lower */
18 #define KVMPPC_NR_LPIDS (LPID_RSVD + 1)
20 /* Maximum number of threads per physical core */
21 #define MAX_SMT_THREADS 8
23 /* Maximum number of subcores per physical core */
24 #define MAX_SUBCORES 4
28 #ifdef CONFIG_KVM_BOOK3S_HANDLER
30 #include <asm/kvm_asm.h>
33 .if (\intno
== BOOK3S_INTERRUPT_SYSTEM_RESET
) || \
34 (\intno
== BOOK3S_INTERRUPT_MACHINE_CHECK
) || \
35 (\intno
== BOOK3S_INTERRUPT_DATA_STORAGE
) || \
36 (\intno
== BOOK3S_INTERRUPT_INST_STORAGE
) || \
37 (\intno
== BOOK3S_INTERRUPT_DATA_SEGMENT
) || \
38 (\intno
== BOOK3S_INTERRUPT_INST_SEGMENT
) || \
39 (\intno
== BOOK3S_INTERRUPT_EXTERNAL
) || \
40 (\intno
== BOOK3S_INTERRUPT_EXTERNAL_HV
) || \
41 (\intno
== BOOK3S_INTERRUPT_ALIGNMENT
) || \
42 (\intno
== BOOK3S_INTERRUPT_PROGRAM
) || \
43 (\intno
== BOOK3S_INTERRUPT_FP_UNAVAIL
) || \
44 (\intno
== BOOK3S_INTERRUPT_DECREMENTER
) || \
45 (\intno
== BOOK3S_INTERRUPT_SYSCALL
) || \
46 (\intno
== BOOK3S_INTERRUPT_TRACE
) || \
47 (\intno
== BOOK3S_INTERRUPT_PERFMON
) || \
48 (\intno
== BOOK3S_INTERRUPT_ALTIVEC
) || \
49 (\intno
== BOOK3S_INTERRUPT_VSX
)
51 b kvmppc_trampoline_\intno
62 #endif /* CONFIG_KVM_BOOK3S_HANDLER */
64 #else /*__ASSEMBLY__ */
68 /* Struct used for coordinating micro-threading (split-core) mode changes */
69 struct kvm_split_mode
{
75 u8 napped
[MAX_SMT_THREADS
];
76 struct kvmppc_vcore
*vc
[MAX_SUBCORES
];
77 /* Bits for changing lpcr on P9 */
78 unsigned long lpcr_req
;
79 unsigned long lpidr_req
;
80 unsigned long host_lpcr
;
90 * This struct goes in the PACA on 64-bit processors. It is used
91 * to store host state that needs to be saved when we enter a guest
92 * and restored when we exit, but isn't specific to any particular
93 * guest or vcpu. It also has some scratch fields used by the guest
96 struct kvmppc_host_state
{
108 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
112 u8 ptid
; /* thread number within subcore when split */
113 u8 tid
; /* thread number within whole core */
115 struct kvm_vcpu
*kvm_vcpu
;
116 struct kvmppc_vcore
*kvm_vcore
;
117 void __iomem
*xics_phys
;
118 void __iomem
*xive_tima_phys
;
119 void __iomem
*xive_tima_virt
;
122 u64 host_mmcr
[10]; /* MMCR 0,1,A, SIAR, SDAR, MMCR2, SIER, MMCR3, SIER2/3 */
128 struct kvm_split_mode
*kvm_split_mode
;
130 #ifdef CONFIG_PPC_BOOK3S_64
137 struct kvmppc_book3s_shadow_vcpu
{
151 #ifdef CONFIG_PPC_BOOK3S_32
152 u32 sr
[16]; /* Guest SRs */
154 struct kvmppc_host_state hstate
;
157 #ifdef CONFIG_PPC_BOOK3S_64
158 u8 slb_max
; /* highest used guest slb entry */
162 } slb
[64]; /* guest SLB */
167 #endif /*__ASSEMBLY__ */
169 /* Values for kvm_state */
170 #define KVM_HWTHREAD_IN_KERNEL 0
171 #define KVM_HWTHREAD_IN_IDLE 1
172 #define KVM_HWTHREAD_IN_KVM 2
174 #endif /* __ASM_KVM_BOOK3S_ASM_H__ */