Skip to content

Commit 64a959d

Browse files
committed
KVM: arm/arm64: vgic-new: Add acccessor to new struct vgic_irq instance
The new VGIC implementation centers around a struct vgic_irq instance per virtual IRQ. Provide a function to retrieve the right instance for a given IRQ number and (in case of private interrupts) the right VCPU. Signed-off-by: Christoffer Dall <[email protected]> Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Eric Auger <[email protected]> Acked-by: Marc Zyngier <[email protected]>
1 parent b18b577 commit 64a959d

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

virt/kvm/arm/vgic/vgic.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
}

virt/kvm/arm/vgic/vgic.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
19+
struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu,
20+
u32 intid);
21+
22+
#endif

0 commit comments

Comments
 (0)