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 | |
| 17 | #include <linux/kvm.h> |
| 18 | #include <linux/kvm_host.h> |
| 19 | |
| 20 | #include "vgic.h" |
| 21 | |
| 22 | struct vgic_global __section(.hyp.text) kvm_vgic_global_state; |
| 23 | |
| 24 | struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu, |
| 25 | u32 intid) |
| 26 | { |
| 27 | /* SGIs and PPIs */ |
| 28 | if (intid <= VGIC_MAX_PRIVATE) |
| 29 | return &vcpu->arch.vgic_cpu.private_irqs[intid]; |
| 30 | |
| 31 | /* SPIs */ |
| 32 | if (intid <= VGIC_MAX_SPI) |
| 33 | return &kvm->arch.vgic.spis[intid - VGIC_NR_PRIVATE_IRQS]; |
| 34 | |
| 35 | /* LPIs are not yet covered */ |
| 36 | if (intid >= VGIC_MIN_LPI) |
| 37 | return NULL; |
| 38 | |
| 39 | WARN(1, "Looking up struct vgic_irq for reserved INTID"); |
| 40 | return NULL; |
| 41 | } |