kvm_book3s_asm.h 4.0 KB
Newer Older
A
Alexander Graf 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License, version 2, as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * Copyright SUSE Linux Products GmbH 2009
 *
 * Authors: Alexander Graf <agraf@suse.de>
 */

#ifndef __ASM_KVM_BOOK3S_ASM_H__
#define __ASM_KVM_BOOK3S_ASM_H__

23 24 25 26 27
/* XICS ICP register offsets */
#define XICS_XIRR		4
#define XICS_MFRR		0xc
#define XICS_IPI		2	/* interrupt source # for IPIs */

28 29 30 31 32 33
/* Maximum number of threads per physical core */
#define MAX_SMT_THREADS		8

/* Maximum number of subcores per physical core */
#define MAX_SUBCORES		4

34 35
#ifdef __ASSEMBLY__

36
#ifdef CONFIG_KVM_BOOK3S_HANDLER
A
Alexander Graf 已提交
37 38 39 40 41 42 43 44 45 46 47

#include <asm/kvm_asm.h>

.macro DO_KVM intno
	.if (\intno == BOOK3S_INTERRUPT_SYSTEM_RESET) || \
	    (\intno == BOOK3S_INTERRUPT_MACHINE_CHECK) || \
	    (\intno == BOOK3S_INTERRUPT_DATA_STORAGE) || \
	    (\intno == BOOK3S_INTERRUPT_INST_STORAGE) || \
	    (\intno == BOOK3S_INTERRUPT_DATA_SEGMENT) || \
	    (\intno == BOOK3S_INTERRUPT_INST_SEGMENT) || \
	    (\intno == BOOK3S_INTERRUPT_EXTERNAL) || \
48
	    (\intno == BOOK3S_INTERRUPT_EXTERNAL_HV) || \
A
Alexander Graf 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
	    (\intno == BOOK3S_INTERRUPT_ALIGNMENT) || \
	    (\intno == BOOK3S_INTERRUPT_PROGRAM) || \
	    (\intno == BOOK3S_INTERRUPT_FP_UNAVAIL) || \
	    (\intno == BOOK3S_INTERRUPT_DECREMENTER) || \
	    (\intno == BOOK3S_INTERRUPT_SYSCALL) || \
	    (\intno == BOOK3S_INTERRUPT_TRACE) || \
	    (\intno == BOOK3S_INTERRUPT_PERFMON) || \
	    (\intno == BOOK3S_INTERRUPT_ALTIVEC) || \
	    (\intno == BOOK3S_INTERRUPT_VSX)

	b	kvmppc_trampoline_\intno
kvmppc_resume_\intno:

	.endif
.endm

#else

.macro DO_KVM intno
.endm

70
#endif /* CONFIG_KVM_BOOK3S_HANDLER */
A
Alexander Graf 已提交
71

72 73
#else  /*__ASSEMBLY__ */

74 75 76 77 78 79 80 81 82 83 84 85 86
struct kvmppc_vcore;

/* Struct used for coordinating micro-threading (split-core) mode changes */
struct kvm_split_mode {
	unsigned long	rpr;
	unsigned long	pmmar;
	unsigned long	ldbar;
	u8		subcore_size;
	u8		do_nap;
	u8		napped[MAX_SMT_THREADS];
	struct kvmppc_vcore *master_vcs[MAX_SUBCORES];
};

87 88 89 90 91 92 93 94 95 96
/*
 * This struct goes in the PACA on 64-bit processors.  It is used
 * to store host state that needs to be saved when we enter a guest
 * and restored when we exit, but isn't specific to any particular
 * guest or vcpu.  It also has some scratch fields used by the guest
 * exit code.
 */
struct kvmppc_host_state {
	ulong host_r1;
	ulong host_r2;
97
	ulong host_msr;
98 99 100
	ulong vmhandler;
	ulong scratch0;
	ulong scratch1;
101
	ulong scratch2;
102
	u8 in_guest;
103
	u8 restore_hid5;
104
	u8 napping;
105

106
#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
107 108
	u8 hwthread_req;
	u8 hwthread_state;
109
	u8 host_ipi;
110
	u8 ptid;
111
	struct kvm_vcpu *kvm_vcpu;
112 113
	struct kvmppc_vcore *kvm_vcore;
	unsigned long xics_phys;
114
	u32 saved_xirr;
115
	u64 dabr;
116
	u64 host_mmcr[7];	/* MMCR 0,1,A, SIAR, SDAR, MMCR2, SIER */
117
	u32 host_pmc[8];
118 119 120 121
	u64 host_purr;
	u64 host_spurr;
	u64 host_dscr;
	u64 dec_expires;
122
	struct kvm_split_mode *kvm_split_mode;
123
#endif
124 125
#ifdef CONFIG_PPC_BOOK3S_64
	u64 cfar;
126
	u64 ppr;
127
	u64 host_fscr;
128
#endif
129 130
};

131
struct kvmppc_book3s_shadow_vcpu {
132
	bool in_use;
133 134 135
	ulong gpr[14];
	u32 cr;
	u32 xer;
136 137 138
	ulong ctr;
	ulong lr;
	ulong pc;
139

140 141
	ulong shadow_srr1;
	ulong fault_dar;
142 143
	u32 fault_dsisr;
	u32 last_inst;
144 145 146

#ifdef CONFIG_PPC_BOOK3S_32
	u32     sr[16];			/* Guest SRs */
147 148

	struct kvmppc_host_state hstate;
149
#endif
150

151 152 153 154 155 156
#ifdef CONFIG_PPC_BOOK3S_64
	u8 slb_max;			/* highest used guest slb entry */
	struct  {
		u64     esid;
		u64     vsid;
	} slb[64];			/* guest SLB */
157
	u64 shadow_fscr;
158
#endif
159 160 161 162
};

#endif /*__ASSEMBLY__ */

163 164 165 166 167
/* Values for kvm_state */
#define KVM_HWTHREAD_IN_KERNEL	0
#define KVM_HWTHREAD_IN_NAP	1
#define KVM_HWTHREAD_IN_KVM	2

A
Alexander Graf 已提交
168
#endif /* __ASM_KVM_BOOK3S_ASM_H__ */