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];
80 * This struct goes in the PACA on 64-bit processors. It is used
81 * to store host state that needs to be saved when we enter a guest
82 * and restored when we exit, but isn't specific to any particular
83 * guest or vcpu. It also has some scratch fields used by the guest
86 struct kvmppc_host_state {
98 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
102 u8 ptid; /* thread number within subcore when split */
104 struct kvm_vcpu *kvm_vcpu;
105 struct kvmppc_vcore *kvm_vcore;
106 void __iomem *xics_phys;
107 void __iomem *xive_tima_phys;
108 void __iomem *xive_tima_virt;
111 u64 host_mmcr[10]; /* MMCR 0,1,A, SIAR, SDAR, MMCR2, SIER, MMCR3, SIER2/3 */
117 struct kvm_split_mode *kvm_split_mode;
119 #ifdef CONFIG_PPC_BOOK3S_64
126 struct kvmppc_book3s_shadow_vcpu {
140 #ifdef CONFIG_PPC_BOOK3S_32
141 u32 sr[16]; /* Guest SRs */
143 struct kvmppc_host_state hstate;
146 #ifdef CONFIG_PPC_BOOK3S_64
147 u8 slb_max; /* highest used guest slb entry */
151 } slb[64]; /* guest SLB */
156 #endif /*__ASSEMBLY__ */
158 /* Values for kvm_state */
159 #define KVM_HWTHREAD_IN_KERNEL 0
160 #define KVM_HWTHREAD_IN_IDLE 1
161 #define KVM_HWTHREAD_IN_KVM 2
163 #endif /* __ASM_KVM_BOOK3S_ASM_H__ */