Christoffer Dall | 64a959d | 2015-11-24 16:51:12 +0100 | [diff] [blame] | 1 | /* |
| 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 Zyngier | 2b0cda8 | 2016-04-26 11:06:47 +0100 | [diff] [blame] | 19 | #define PRODUCT_ID_KVM 0x4b /* ASCII code K */ |
| 20 | #define IMPLEMENTER_ARM 0x43b |
| 21 | |
Eric Auger | e2c1f9a | 2015-12-21 16:36:04 +0100 | [diff] [blame] | 22 | #define VGIC_ADDR_UNDEF (-1) |
| 23 | #define IS_VGIC_ADDR_UNDEF(_x) ((_x) == VGIC_ADDR_UNDEF) |
| 24 | |
Andre Przywara | fd59ed3 | 2016-01-27 14:54:30 +0000 | [diff] [blame] | 25 | #define INTERRUPT_ID_BITS_SPIS 10 |
Andre Przywara | 055658b | 2015-12-01 14:34:02 +0000 | [diff] [blame] | 26 | #define VGIC_PRI_BITS 5 |
| 27 | |
Marc Zyngier | 0919e84 | 2015-11-26 17:19:25 +0000 | [diff] [blame] | 28 | #define vgic_irq_is_sgi(intid) ((intid) < VGIC_NR_SGIS) |
| 29 | |
Andre Przywara | e4823a7 | 2015-12-03 11:47:37 +0000 | [diff] [blame] | 30 | struct vgic_vmcr { |
| 31 | u32 ctlr; |
| 32 | u32 abpr; |
| 33 | u32 bpr; |
| 34 | u32 pmr; |
| 35 | }; |
| 36 | |
Christoffer Dall | 64a959d | 2015-11-24 16:51:12 +0100 | [diff] [blame] | 37 | struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu, |
| 38 | u32 intid); |
Christoffer Dall | 81eeb95 | 2015-11-25 10:02:16 -0800 | [diff] [blame] | 39 | bool vgic_queue_irq_unlock(struct kvm *kvm, struct vgic_irq *irq); |
Marc Zyngier | 2b0cda8 | 2016-04-26 11:06:47 +0100 | [diff] [blame] | 40 | void vgic_kick_vcpus(struct kvm *kvm); |
Christoffer Dall | 64a959d | 2015-11-24 16:51:12 +0100 | [diff] [blame] | 41 | |
Marc Zyngier | 140b086 | 2015-11-26 17:19:25 +0000 | [diff] [blame] | 42 | void vgic_v2_process_maintenance(struct kvm_vcpu *vcpu); |
| 43 | void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu); |
| 44 | void vgic_v2_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr); |
| 45 | void vgic_v2_clear_lr(struct kvm_vcpu *vcpu, int lr); |
| 46 | void vgic_v2_set_underflow(struct kvm_vcpu *vcpu); |
Eric Auger | f94591e | 2015-12-21 17:34:52 +0100 | [diff] [blame] | 47 | int vgic_v2_has_attr_regs(struct kvm_device *dev, struct kvm_device_attr *attr); |
Christoffer Dall | c3199f2 | 2016-04-25 01:11:37 +0200 | [diff] [blame] | 48 | int vgic_v2_dist_uaccess(struct kvm_vcpu *vcpu, bool is_write, |
| 49 | int offset, u32 *val); |
Andre Przywara | 878c569 | 2015-12-03 11:48:42 +0000 | [diff] [blame^] | 50 | int vgic_v2_cpuif_uaccess(struct kvm_vcpu *vcpu, bool is_write, |
| 51 | int offset, u32 *val); |
Andre Przywara | e4823a7 | 2015-12-03 11:47:37 +0000 | [diff] [blame] | 52 | void vgic_v2_set_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr); |
| 53 | void vgic_v2_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr); |
Andre Przywara | fb848db | 2016-04-26 21:32:49 +0100 | [diff] [blame] | 54 | int vgic_register_dist_iodev(struct kvm *kvm, gpa_t dist_base_address, |
| 55 | enum vgic_type); |
Marc Zyngier | 140b086 | 2015-11-26 17:19:25 +0000 | [diff] [blame] | 56 | |
Marc Zyngier | 59529f6 | 2015-11-30 13:09:53 +0000 | [diff] [blame] | 57 | #ifdef CONFIG_KVM_ARM_VGIC_V3 |
| 58 | void vgic_v3_process_maintenance(struct kvm_vcpu *vcpu); |
| 59 | void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu); |
| 60 | void vgic_v3_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr); |
| 61 | void vgic_v3_clear_lr(struct kvm_vcpu *vcpu, int lr); |
| 62 | void vgic_v3_set_underflow(struct kvm_vcpu *vcpu); |
Andre Przywara | e4823a7 | 2015-12-03 11:47:37 +0000 | [diff] [blame] | 63 | void vgic_v3_set_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr); |
| 64 | void vgic_v3_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr); |
Andre Przywara | ed9b8ce | 2015-12-01 14:34:34 +0000 | [diff] [blame] | 65 | int vgic_register_redist_iodevs(struct kvm *kvm, gpa_t dist_base_address); |
Marc Zyngier | 59529f6 | 2015-11-30 13:09:53 +0000 | [diff] [blame] | 66 | #else |
| 67 | static inline void vgic_v3_process_maintenance(struct kvm_vcpu *vcpu) |
| 68 | { |
| 69 | } |
| 70 | |
| 71 | static inline void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu) |
| 72 | { |
| 73 | } |
| 74 | |
| 75 | static inline void vgic_v3_populate_lr(struct kvm_vcpu *vcpu, |
| 76 | struct vgic_irq *irq, int lr) |
| 77 | { |
| 78 | } |
| 79 | |
| 80 | static inline void vgic_v3_clear_lr(struct kvm_vcpu *vcpu, int lr) |
| 81 | { |
| 82 | } |
| 83 | |
| 84 | static inline void vgic_v3_set_underflow(struct kvm_vcpu *vcpu) |
| 85 | { |
| 86 | } |
Andre Przywara | ed9b8ce | 2015-12-01 14:34:34 +0000 | [diff] [blame] | 87 | |
Andre Przywara | e4823a7 | 2015-12-03 11:47:37 +0000 | [diff] [blame] | 88 | static inline |
| 89 | void vgic_v3_set_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr) |
| 90 | { |
| 91 | } |
| 92 | |
| 93 | static inline |
| 94 | void vgic_v3_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr) |
| 95 | { |
| 96 | } |
| 97 | |
Andre Przywara | ed9b8ce | 2015-12-01 14:34:34 +0000 | [diff] [blame] | 98 | static inline int vgic_register_redist_iodevs(struct kvm *kvm, |
| 99 | gpa_t dist_base_address) |
| 100 | { |
| 101 | return -ENODEV; |
| 102 | } |
Marc Zyngier | 59529f6 | 2015-11-30 13:09:53 +0000 | [diff] [blame] | 103 | #endif |
| 104 | |
Eric Auger | c86c772 | 2015-11-30 14:01:58 +0100 | [diff] [blame] | 105 | void kvm_register_vgic_device(unsigned long type); |
| 106 | |
Christoffer Dall | 64a959d | 2015-11-24 16:51:12 +0100 | [diff] [blame] | 107 | #endif |