]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/powerpc/kvm/booke.h
KVM: PPC: Book3S HV: Provide mode where all vCPUs on a core must be the same VM
[mirror_ubuntu-bionic-kernel.git] / arch / powerpc / kvm / booke.h
CommitLineData
75f74f0d
HB
1/*
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 __KVM_BOOKE_H__
21#define __KVM_BOOKE_H__
22
23#include <linux/types.h>
24#include <linux/kvm_host.h>
d0c7dc03 25#include <asm/kvm_ppc.h>
8fae845f 26#include <asm/switch_to.h>
73e75b41 27#include "timing.h"
75f74f0d 28
d4cf3892
HB
29/* interrupt priortity ordering */
30#define BOOKE_IRQPRIO_DATA_STORAGE 0
31#define BOOKE_IRQPRIO_INST_STORAGE 1
32#define BOOKE_IRQPRIO_ALIGNMENT 2
33#define BOOKE_IRQPRIO_PROGRAM 3
34#define BOOKE_IRQPRIO_FP_UNAVAIL 4
95d80a29 35#ifdef CONFIG_SPE_POSSIBLE
bb3a8a17
HB
36#define BOOKE_IRQPRIO_SPE_UNAVAIL 5
37#define BOOKE_IRQPRIO_SPE_FP_DATA 6
38#define BOOKE_IRQPRIO_SPE_FP_ROUND 7
95d80a29
MC
39#endif
40#ifdef CONFIG_PPC_E500MC
41#define BOOKE_IRQPRIO_ALTIVEC_UNAVAIL 5
42#define BOOKE_IRQPRIO_ALTIVEC_ASSIST 6
43#endif
bb3a8a17
HB
44#define BOOKE_IRQPRIO_SYSCALL 8
45#define BOOKE_IRQPRIO_AP_UNAVAIL 9
46#define BOOKE_IRQPRIO_DTLB_MISS 10
47#define BOOKE_IRQPRIO_ITLB_MISS 11
48#define BOOKE_IRQPRIO_MACHINE_CHECK 12
49#define BOOKE_IRQPRIO_DEBUG 13
50#define BOOKE_IRQPRIO_CRITICAL 14
51#define BOOKE_IRQPRIO_WATCHDOG 15
52#define BOOKE_IRQPRIO_EXTERNAL 16
53#define BOOKE_IRQPRIO_FIT 17
54#define BOOKE_IRQPRIO_DECREMENTER 18
55#define BOOKE_IRQPRIO_PERFORMANCE_MONITOR 19
c5335f17
AG
56/* Internal pseudo-irqprio for level triggered externals */
57#define BOOKE_IRQPRIO_EXTERNAL_LEVEL 20
d30f6e48
SW
58#define BOOKE_IRQPRIO_DBELL 21
59#define BOOKE_IRQPRIO_DBELL_CRIT 22
60#define BOOKE_IRQPRIO_MAX 23
61
62#define BOOKE_IRQMASK_EE ((1 << BOOKE_IRQPRIO_EXTERNAL_LEVEL) | \
63 (1 << BOOKE_IRQPRIO_PERFORMANCE_MONITOR) | \
64 (1 << BOOKE_IRQPRIO_DBELL) | \
65 (1 << BOOKE_IRQPRIO_DECREMENTER) | \
66 (1 << BOOKE_IRQPRIO_FIT) | \
67 (1 << BOOKE_IRQPRIO_EXTERNAL))
68
69#define BOOKE_IRQMASK_CE ((1 << BOOKE_IRQPRIO_DBELL_CRIT) | \
70 (1 << BOOKE_IRQPRIO_WATCHDOG) | \
71 (1 << BOOKE_IRQPRIO_CRITICAL))
bb3a8a17
HB
72
73extern unsigned long kvmppc_booke_handlers;
1d542d9c 74extern unsigned long kvmppc_booke_handler_addr[];
d4cf3892 75
4cd35f67 76void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
dd9ebf1f 77void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
75f74f0d 78
38f98824 79void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr);
dfd4d47e
SW
80void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr);
81void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
82void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
83
d0c7dc03
HB
84int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
85 unsigned int inst, int *advance);
54771e62
AG
86int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val);
87int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val);
d0c7dc03 88
4cd35f67
SW
89/* low-level asm code to transfer guest state */
90void kvmppc_load_guest_spe(struct kvm_vcpu *vcpu);
91void kvmppc_save_guest_spe(struct kvm_vcpu *vcpu);
92
93/* high-level function, manages flags, host state */
94void kvmppc_vcpu_disable_spe(struct kvm_vcpu *vcpu);
95
94fa9d99
SW
96void kvmppc_booke_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
97void kvmppc_booke_vcpu_put(struct kvm_vcpu *vcpu);
98
d30f6e48
SW
99enum int_class {
100 INT_CLASS_NONCRIT,
101 INT_CLASS_CRIT,
102 INT_CLASS_MC,
103 INT_CLASS_DBG,
104};
105
106void kvmppc_set_pending_interrupt(struct kvm_vcpu *vcpu, enum int_class type);
107
3a167bea
AK
108extern void kvmppc_mmu_destroy_e500(struct kvm_vcpu *vcpu);
109extern int kvmppc_core_emulate_op_e500(struct kvm_run *run,
110 struct kvm_vcpu *vcpu,
111 unsigned int inst, int *advance);
112extern int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn,
113 ulong spr_val);
114extern int kvmppc_core_emulate_mfspr_e500(struct kvm_vcpu *vcpu, int sprn,
115 ulong *spr_val);
116extern void kvmppc_mmu_destroy_e500(struct kvm_vcpu *vcpu);
117extern int kvmppc_core_emulate_op_e500(struct kvm_run *run,
118 struct kvm_vcpu *vcpu,
119 unsigned int inst, int *advance);
120extern int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn,
121 ulong spr_val);
122extern int kvmppc_core_emulate_mfspr_e500(struct kvm_vcpu *vcpu, int sprn,
123 ulong *spr_val);
124
ce11e48b
BB
125static inline void kvmppc_clear_dbsr(void)
126{
127 mtspr(SPRN_DBSR, mfspr(SPRN_DBSR));
128}
75f74f0d 129#endif /* __KVM_BOOKE_H__ */