blob: de9dc7170c1b1e27a0a53676b9e4432b9fc3d44e [file] [log] [blame]
Christoffer Dall64a959d2015-11-24 16:51:12 +01001/*
2 * Copyright (C) 2015, 2016 ARM Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#ifndef __KVM_ARM_VGIC_NEW_H__
17#define __KVM_ARM_VGIC_NEW_H__
18
Marc Zyngier2b0cda82016-04-26 11:06:47 +010019#define PRODUCT_ID_KVM 0x4b /* ASCII code K */
20#define IMPLEMENTER_ARM 0x43b
21
Eric Augere2c1f9a2015-12-21 16:36:04 +010022#define VGIC_ADDR_UNDEF (-1)
23#define IS_VGIC_ADDR_UNDEF(_x) ((_x) == VGIC_ADDR_UNDEF)
24
Andre Przywarafd59ed32016-01-27 14:54:30 +000025#define INTERRUPT_ID_BITS_SPIS 10
Andre Przywara055658b2015-12-01 14:34:02 +000026#define VGIC_PRI_BITS 5
27
Marc Zyngier0919e842015-11-26 17:19:25 +000028#define vgic_irq_is_sgi(intid) ((intid) < VGIC_NR_SGIS)
29
Andre Przywarae4823a72015-12-03 11:47:37 +000030struct vgic_vmcr {
31 u32 ctlr;
32 u32 abpr;
33 u32 bpr;
34 u32 pmr;
35};
36
Christoffer Dall64a959d2015-11-24 16:51:12 +010037struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu,
38 u32 intid);
Christoffer Dall81eeb952015-11-25 10:02:16 -080039bool vgic_queue_irq_unlock(struct kvm *kvm, struct vgic_irq *irq);
Marc Zyngier2b0cda82016-04-26 11:06:47 +010040void vgic_kick_vcpus(struct kvm *kvm);
Christoffer Dall64a959d2015-11-24 16:51:12 +010041
Marc Zyngier140b0862015-11-26 17:19:25 +000042void vgic_v2_process_maintenance(struct kvm_vcpu *vcpu);
43void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu);
44void vgic_v2_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr);
45void vgic_v2_clear_lr(struct kvm_vcpu *vcpu, int lr);
46void vgic_v2_set_underflow(struct kvm_vcpu *vcpu);
Eric Augerf94591e2015-12-21 17:34:52 +010047int vgic_v2_has_attr_regs(struct kvm_device *dev, struct kvm_device_attr *attr);
Christoffer Dallc3199f22016-04-25 01:11:37 +020048int vgic_v2_dist_uaccess(struct kvm_vcpu *vcpu, bool is_write,
49 int offset, u32 *val);
Andre Przywara878c5692015-12-03 11:48:42 +000050int vgic_v2_cpuif_uaccess(struct kvm_vcpu *vcpu, bool is_write,
51 int offset, u32 *val);
Andre Przywarae4823a72015-12-03 11:47:37 +000052void vgic_v2_set_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr);
53void vgic_v2_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr);
Andre Przywarafb848db2016-04-26 21:32:49 +010054int vgic_register_dist_iodev(struct kvm *kvm, gpa_t dist_base_address,
55 enum vgic_type);
Marc Zyngier140b0862015-11-26 17:19:25 +000056
Marc Zyngier59529f62015-11-30 13:09:53 +000057#ifdef CONFIG_KVM_ARM_VGIC_V3
58void vgic_v3_process_maintenance(struct kvm_vcpu *vcpu);
59void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu);
60void vgic_v3_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr);
61void vgic_v3_clear_lr(struct kvm_vcpu *vcpu, int lr);
62void vgic_v3_set_underflow(struct kvm_vcpu *vcpu);
Andre Przywarae4823a72015-12-03 11:47:37 +000063void vgic_v3_set_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr);
64void vgic_v3_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr);
Andre Przywaraed9b8ce2015-12-01 14:34:34 +000065int vgic_register_redist_iodevs(struct kvm *kvm, gpa_t dist_base_address);
Marc Zyngier59529f62015-11-30 13:09:53 +000066#else
67static inline void vgic_v3_process_maintenance(struct kvm_vcpu *vcpu)
68{
69}
70
71static inline void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu)
72{
73}
74
75static inline void vgic_v3_populate_lr(struct kvm_vcpu *vcpu,
76 struct vgic_irq *irq, int lr)
77{
78}
79
80static inline void vgic_v3_clear_lr(struct kvm_vcpu *vcpu, int lr)
81{
82}
83
84static inline void vgic_v3_set_underflow(struct kvm_vcpu *vcpu)
85{
86}
Andre Przywaraed9b8ce2015-12-01 14:34:34 +000087
Andre Przywarae4823a72015-12-03 11:47:37 +000088static inline
89void vgic_v3_set_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr)
90{
91}
92
93static inline
94void vgic_v3_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr)
95{
96}
97
Andre Przywaraed9b8ce2015-12-01 14:34:34 +000098static inline int vgic_register_redist_iodevs(struct kvm *kvm,
99 gpa_t dist_base_address)
100{
101 return -ENODEV;
102}
Marc Zyngier59529f62015-11-30 13:09:53 +0000103#endif
104
Eric Augerc86c7722015-11-30 14:01:58 +0100105void kvm_register_vgic_device(unsigned long type);
106
Christoffer Dall64a959d2015-11-24 16:51:12 +0100107#endif