Blame view

include/kvm/arm_vgic.h 10.7 KB
caab277b1   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-only */
1a89dd911   Marc Zyngier   ARM: KVM: Initial...
2
  /*
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
3
   * Copyright (C) 2015, 2016 ARM Ltd.
1a89dd911   Marc Zyngier   ARM: KVM: Initial...
4
   */
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
5
6
  #ifndef __KVM_ARM_VGIC_H
  #define __KVM_ARM_VGIC_H
b18b57787   Christoffer Dall   KVM: arm/arm64: v...
7

b47ef92af   Marc Zyngier   ARM: KVM: VGIC di...
8
9
  #include <linux/kernel.h>
  #include <linux/kvm.h>
b47ef92af   Marc Zyngier   ARM: KVM: VGIC di...
10
11
  #include <linux/irqreturn.h>
  #include <linux/spinlock.h>
fb5ee369c   Marc Zyngier   arm64: KVM: vgic-...
12
  #include <linux/static_key.h>
b47ef92af   Marc Zyngier   ARM: KVM: VGIC di...
13
  #include <linux/types.h>
6777f77f0   Andre Przywara   KVM: arm/arm64: i...
14
  #include <kvm/iodev.h>
424c33830   Andre Przywara   KVM: arm64: vgic-...
15
  #include <linux/list.h>
5a7a8426b   Vladimir Murzin   arm64: KVM: Use s...
16
  #include <linux/jump_label.h>
1a89dd911   Marc Zyngier   ARM: KVM: Initial...
17

74fe55dc9   Marc Zyngier   KVM: arm/arm64: G...
18
  #include <linux/irqchip/arm-gic-v4.h>
e25028c8d   Eric Auger   KVM: arm/arm64: B...
19
  #define VGIC_V3_MAX_CPUS	512
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
20
21
  #define VGIC_V2_MAX_CPUS	8
  #define VGIC_NR_IRQS_LEGACY     256
b47ef92af   Marc Zyngier   ARM: KVM: VGIC di...
22
23
24
  #define VGIC_NR_SGIS		16
  #define VGIC_NR_PPIS		16
  #define VGIC_NR_PRIVATE_IRQS	(VGIC_NR_SGIS + VGIC_NR_PPIS)
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
25
26
27
28
  #define VGIC_MAX_PRIVATE	(VGIC_NR_PRIVATE_IRQS - 1)
  #define VGIC_MAX_SPI		1019
  #define VGIC_MAX_RESERVED	1023
  #define VGIC_MIN_LPI		8192
180ae7b11   Eric Auger   KVM: arm/arm64: E...
29
  #define KVM_IRQCHIP_NUM_PINS	(1020 - 32)
8f186d522   Marc Zyngier   KVM: ARM: vgic: s...
30

3cba4af31   Christoffer Dall   KVM: arm/arm64: M...
31
  #define irq_is_ppi(irq) ((irq) >= VGIC_NR_SGIS && (irq) < VGIC_NR_PRIVATE_IRQS)
ebb127f2d   Christoffer Dall   KVM: arm/arm64: D...
32
33
  #define irq_is_spi(irq) ((irq) >= VGIC_NR_PRIVATE_IRQS && \
  			 (irq) <= VGIC_MAX_SPI)
3cba4af31   Christoffer Dall   KVM: arm/arm64: M...
34

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
35
36
37
38
  enum vgic_type {
  	VGIC_V2,		/* Good ol' GICv2 */
  	VGIC_V3,		/* New fancy GICv3 */
  };
b47ef92af   Marc Zyngier   ARM: KVM: VGIC di...
39

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
40
41
42
43
  /* same for all guests, as depending only on the _host's_ GIC model */
  struct vgic_global {
  	/* type of the host GIC */
  	enum vgic_type		type;
b47ef92af   Marc Zyngier   ARM: KVM: VGIC di...
44

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
45
46
  	/* Physical address of vgic virtual cpu interface */
  	phys_addr_t		vcpu_base;
b47ef92af   Marc Zyngier   ARM: KVM: VGIC di...
47

1bb32a44a   Marc Zyngier   KVM: arm/arm64: K...
48
  	/* GICV mapping, kernel VA */
bf8feb396   Marc Zyngier   arm64: KVM: vgic-...
49
  	void __iomem		*vcpu_base_va;
1bb32a44a   Marc Zyngier   KVM: arm/arm64: K...
50
51
  	/* GICV mapping, HYP VA */
  	void __iomem		*vcpu_hyp_va;
bf8feb396   Marc Zyngier   arm64: KVM: vgic-...
52

1bb32a44a   Marc Zyngier   KVM: arm/arm64: K...
53
  	/* virtual control interface mapping, kernel VA */
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
54
  	void __iomem		*vctrl_base;
1bb32a44a   Marc Zyngier   KVM: arm/arm64: K...
55
56
  	/* virtual control interface mapping, HYP VA */
  	void __iomem		*vctrl_hyp;
b47ef92af   Marc Zyngier   ARM: KVM: VGIC di...
57

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
58
59
  	/* Number of implemented list registers */
  	int			nr_lr;
8d5c6b06a   Marc Zyngier   KVM: ARM: vgic: i...
60

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
61
62
  	/* Maintenance IRQ number */
  	unsigned int		maint_irq;
1a9b13056   Marc Zyngier   arm64: KVM: split...
63

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
64
65
  	/* maximum number of VCPUs allowed (GICv2 limits us to 8) */
  	int			max_gic_vcpus;
8d5c6b06a   Marc Zyngier   KVM: ARM: vgic: i...
66

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
67
68
  	/* Only needed for the legacy KVM_CREATE_IRQCHIP */
  	bool			can_emulate_gicv2;
5a7a8426b   Vladimir Murzin   arm64: KVM: Use s...
69

e7c480592   Marc Zyngier   KVM: arm/arm64: G...
70
71
  	/* Hardware has GICv4? */
  	bool			has_gicv4;
5a7a8426b   Vladimir Murzin   arm64: KVM: Use s...
72
73
  	/* GIC system register CPU interface */
  	struct static_key_false gicv3_cpuif;
d017d7b0b   Vijaya Kumar K   KVM: arm/arm64: v...
74
75
  
  	u32			ich_vtr_el2;
8d5c6b06a   Marc Zyngier   KVM: ARM: vgic: i...
76
  };
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
77
  extern struct vgic_global kvm_vgic_global_state;
beee38b9d   Marc Zyngier   KVM: ARM: vgic: a...
78

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
79
80
81
  #define VGIC_V2_MAX_LRS		(1 << 6)
  #define VGIC_V3_MAX_LRS		16
  #define VGIC_V3_LR_INDEX(lr)	(VGIC_V3_MAX_LRS - 1 - lr)
8d5c6b06a   Marc Zyngier   KVM: ARM: vgic: i...
82

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
83
84
85
  enum vgic_irq_config {
  	VGIC_CONFIG_EDGE = 0,
  	VGIC_CONFIG_LEVEL
ca85f623e   Marc Zyngier   KVM: ARM: introdu...
86
  };
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
87
  struct vgic_irq {
8fa3adb8c   Julien Thierry   KVM: arm/arm64: v...
88
  	raw_spinlock_t irq_lock;	/* Protects the content of the struct */
3802411d0   Andre Przywara   KVM: arm64: vgic-...
89
  	struct list_head lpi_list;	/* Used to link all LPIs together */
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  	struct list_head ap_list;
  
  	struct kvm_vcpu *vcpu;		/* SGIs and PPIs: The VCPU
  					 * SPIs and LPIs: The VCPU whose ap_list
  					 * this is queued on.
  					 */
  
  	struct kvm_vcpu *target_vcpu;	/* The VCPU that this interrupt should
  					 * be sent to, as a result of the
  					 * targets reg (v2) or the
  					 * affinity reg (v3).
  					 */
  
  	u32 intid;			/* Guest visible INTID */
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
104
  	bool line_level;		/* Level only */
8694e4da6   Christoffer Dall   KVM: arm/arm64: R...
105
106
107
  	bool pending_latch;		/* The pending latch state used to calculate
  					 * the pending state for both level
  					 * and edge triggered IRQs. */
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
108
109
110
  	bool active;			/* not used for LPIs */
  	bool enabled;
  	bool hw;			/* Tied to HW IRQ */
5dd4b924e   Andre Przywara   KVM: arm/arm64: v...
111
  	struct kref refcount;		/* Used for LPIs */
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
112
  	u32 hwintid;			/* HW INTID number */
47bbd31f7   Eric Auger   KVM: arm/arm64: v...
113
  	unsigned int host_irq;		/* linux irq corresponding to hwintid */
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
114
115
116
117
118
  	union {
  		u8 targets;			/* GICv2 target VCPUs mask */
  		u32 mpidr;			/* GICv3 target VCPU */
  	};
  	u8 source;			/* GICv2 SGIs only */
53692908b   Marc Zyngier   KVM: arm/arm64: v...
119
  	u8 active_source;		/* GICv2 SGIs only */
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
120
  	u8 priority;
8df3c8f33   Christoffer Dall   KVM: arm/arm64: v...
121
  	u8 group;			/* 0 == group 0, 1 == group 1 */
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
122
  	enum vgic_irq_config config;	/* Level or edge */
c6ccd30e0   Christoffer Dall   KVM: arm/arm64: I...
123

b6909a659   Christoffer Dall   KVM: arm/arm64: S...
124
125
126
127
128
129
130
131
132
133
  	/*
  	 * Callback function pointer to in-kernel devices that can tell us the
  	 * state of the input level of mapped level-triggered IRQ faster than
  	 * peaking into the physical GIC.
  	 *
  	 * Always called in non-preemptible section and the functions can use
  	 * kvm_arm_get_running_vcpu() to get the vcpu pointer for private
  	 * IRQs.
  	 */
  	bool (*get_input_level)(int vintid);
c6ccd30e0   Christoffer Dall   KVM: arm/arm64: I...
134
135
  	void *owner;			/* Opaque pointer to reserve an interrupt
  					   for in-kernel devices. */
b26e5fdac   Andre Przywara   arm/arm64: KVM: i...
136
  };
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
137
  struct vgic_register_region;
59c5ab409   Andre Przywara   KVM: arm64: vgic-...
138
139
140
141
142
143
144
145
  struct vgic_its;
  
  enum iodev_type {
  	IODEV_CPUIF,
  	IODEV_DIST,
  	IODEV_REDIST,
  	IODEV_ITS
  };
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
146

6777f77f0   Andre Przywara   KVM: arm/arm64: i...
147
  struct vgic_io_device {
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
148
  	gpa_t base_addr;
59c5ab409   Andre Przywara   KVM: arm64: vgic-...
149
150
151
152
  	union {
  		struct kvm_vcpu *redist_vcpu;
  		struct vgic_its *its;
  	};
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
153
  	const struct vgic_register_region *regions;
59c5ab409   Andre Przywara   KVM: arm64: vgic-...
154
  	enum iodev_type iodev_type;
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
155
  	int nr_regions;
6777f77f0   Andre Przywara   KVM: arm/arm64: i...
156
157
  	struct kvm_io_device dev;
  };
59c5ab409   Andre Przywara   KVM: arm64: vgic-...
158
159
160
161
162
163
  struct vgic_its {
  	/* The base address of the ITS control register frame */
  	gpa_t			vgic_its_base;
  
  	bool			enabled;
  	struct vgic_io_device	iodev;
bb7176449   Marc Zyngier   KVM: arm64: vgic-...
164
  	struct kvm_device	*dev;
424c33830   Andre Przywara   KVM: arm64: vgic-...
165
166
167
168
169
170
171
172
173
174
  
  	/* These registers correspond to GITS_BASER{0,1} */
  	u64			baser_device_table;
  	u64			baser_coll_table;
  
  	/* Protects the command queue */
  	struct mutex		cmd_lock;
  	u64			cbaser;
  	u32			creadr;
  	u32			cwriter;
71afe470e   Eric Auger   KVM: arm64: vgic-...
175
176
  	/* migration ABI revision in use */
  	u32			abi_rev;
424c33830   Andre Przywara   KVM: arm64: vgic-...
177
178
179
180
  	/* Protects the device and collection lists */
  	struct mutex		its_lock;
  	struct list_head	device_list;
  	struct list_head	collection_list;
59c5ab409   Andre Przywara   KVM: arm64: vgic-...
181
  };
10f92c4c5   Christoffer Dall   KVM: arm/arm64: v...
182
  struct vgic_state_iter;
dbd9733ab   Eric Auger   KVM: arm/arm64: R...
183
184
185
186
187
188
189
  struct vgic_redist_region {
  	u32 index;
  	gpa_t base;
  	u32 count; /* number of redistributors or 0 if single region */
  	u32 free_index; /* index of the next free redistributor */
  	struct list_head list;
  };
1a89dd911   Marc Zyngier   ARM: KVM: Initial...
190
  struct vgic_dist {
f982cf4e9   Marc Zyngier   KVM: ARM: vgic: r...
191
  	bool			in_kernel;
01ac5e342   Marc Zyngier   ARM: KVM: VGIC in...
192
  	bool			ready;
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
193
  	bool			initialized;
b47ef92af   Marc Zyngier   ARM: KVM: VGIC di...
194

59892136c   Andre Przywara   arm/arm64: KVM: p...
195
196
  	/* vGIC model the kernel emulates for the guest (GICv2 or GICv3) */
  	u32			vgic_model;
aa075b0f3   Christoffer Dall   KVM: arm/arm64: v...
197
198
  	/* Implementation revision as reported in the GICD_IIDR */
  	u32			implementation_rev;
32f8777ed   Christoffer Dall   KVM: arm/arm64: v...
199
200
  	/* Userspace can write to GICv2 IGROUPR */
  	bool			v2_groups_user_writable;
0e4e82f15   Andre Przywara   KVM: arm64: vgic-...
201
202
  	/* Do injected MSIs require an additional device ID? */
  	bool			msis_require_devid;
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
203
  	int			nr_spis;
c1bfb577a   Marc Zyngier   arm/arm64: KVM: v...
204

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
205
206
  	/* base addresses in guest physical address space: */
  	gpa_t			vgic_dist_base;		/* distributor */
a0675c25d   Andre Przywara   arm/arm64: KVM: a...
207
  	union {
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
208
209
210
  		/* either a GICv2 CPU interface */
  		gpa_t			vgic_cpu_base;
  		/* or a number of GICv3 redistributor regions */
dbd9733ab   Eric Auger   KVM: arm/arm64: R...
211
  		struct list_head rd_regions;
a0675c25d   Andre Przywara   arm/arm64: KVM: a...
212
  	};
b47ef92af   Marc Zyngier   ARM: KVM: VGIC di...
213

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
214
215
  	/* distributor enabled */
  	bool			enabled;
47a98b15b   Christoffer Dall   arm/arm64: KVM: s...
216

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
217
  	struct vgic_irq		*spis;
b47ef92af   Marc Zyngier   ARM: KVM: VGIC di...
218

a9cf86f62   Andre Przywara   KVM: arm/arm64: p...
219
  	struct vgic_io_device	dist_iodev;
0aa1de573   Andre Przywara   KVM: arm64: vgic:...
220

1085fdc68   Andre Przywara   KVM: arm64: vgic-...
221
  	bool			has_its;
0aa1de573   Andre Przywara   KVM: arm64: vgic:...
222
223
224
225
226
227
228
  	/*
  	 * Contains the attributes and gpa of the LPI configuration table.
  	 * Since we report GICR_TYPER.CommonLPIAff as 0b00, we can share
  	 * one address across all redistributors.
  	 * GICv3 spec: 6.1.2 "LPI Configuration tables"
  	 */
  	u64			propbaser;
3802411d0   Andre Przywara   KVM: arm64: vgic-...
229
230
  
  	/* Protects the lpi_list and the count value below. */
fc3bc4752   Julien Thierry   KVM: arm/arm64: v...
231
  	raw_spinlock_t		lpi_list_lock;
3802411d0   Andre Przywara   KVM: arm64: vgic-...
232
233
  	struct list_head	lpi_list_head;
  	int			lpi_list_count;
10f92c4c5   Christoffer Dall   KVM: arm/arm64: v...
234

24cab82c3   Marc Zyngier   KVM: arm/arm64: v...
235
236
  	/* LPI translation cache */
  	struct list_head	lpi_translation_cache;
10f92c4c5   Christoffer Dall   KVM: arm/arm64: v...
237
238
  	/* used by vgic-debug */
  	struct vgic_state_iter *iter;
74fe55dc9   Marc Zyngier   KVM: arm/arm64: G...
239
240
241
242
243
244
245
246
247
  
  	/*
  	 * GICv4 ITS per-VM data, containing the IRQ domain, the VPE
  	 * array, the property table pointer as well as allocation
  	 * data. This essentially ties the Linux IRQ core and ITS
  	 * together, and avoids leaking KVM's data structures anywhere
  	 * else.
  	 */
  	struct its_vm		its_vm;
1a89dd911   Marc Zyngier   ARM: KVM: Initial...
248
  };
eede821db   Marc Zyngier   KVM: arm/arm64: v...
249
250
251
  struct vgic_v2_cpu_if {
  	u32		vgic_hcr;
  	u32		vgic_vmcr;
eede821db   Marc Zyngier   KVM: arm/arm64: v...
252
  	u32		vgic_apr;
8f186d522   Marc Zyngier   KVM: ARM: vgic: s...
253
  	u32		vgic_lr[VGIC_V2_MAX_LRS];
eede821db   Marc Zyngier   KVM: arm/arm64: v...
254
  };
b2fb1c0d3   Marc Zyngier   KVM: ARM: vgic: a...
255
  struct vgic_v3_cpu_if {
b2fb1c0d3   Marc Zyngier   KVM: ARM: vgic: a...
256
257
  	u32		vgic_hcr;
  	u32		vgic_vmcr;
2f5fa41a7   Andre Przywara   arm/arm64: KVM: m...
258
  	u32		vgic_sre;	/* Restored only, change ignored */
b2fb1c0d3   Marc Zyngier   KVM: ARM: vgic: a...
259
260
261
  	u32		vgic_ap0r[4];
  	u32		vgic_ap1r[4];
  	u64		vgic_lr[VGIC_V3_MAX_LRS];
74fe55dc9   Marc Zyngier   KVM: arm/arm64: G...
262
263
264
265
266
267
268
269
  
  	/*
  	 * GICv4 ITS per-VPE data, containing the doorbell IRQ, the
  	 * pending table pointer, the its_vm pointer and a few other
  	 * HW specific things. As for the its_vm structure, this is
  	 * linking the Linux IRQ subsystem and the ITS together.
  	 */
  	struct its_vpe	its_vpe;
b2fb1c0d3   Marc Zyngier   KVM: ARM: vgic: a...
270
  };
1a89dd911   Marc Zyngier   ARM: KVM: Initial...
271
  struct vgic_cpu {
9d949dce5   Marc Zyngier   ARM: KVM: VGIC vi...
272
  	/* CPU vif control registers for world switch */
eede821db   Marc Zyngier   KVM: arm/arm64: v...
273
274
  	union {
  		struct vgic_v2_cpu_if	vgic_v2;
b2fb1c0d3   Marc Zyngier   KVM: ARM: vgic: a...
275
  		struct vgic_v3_cpu_if	vgic_v3;
eede821db   Marc Zyngier   KVM: arm/arm64: v...
276
  	};
6c3d63c9a   Marc Zyngier   KVM: arm/arm64: v...
277

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
278
279
  	unsigned int used_lrs;
  	struct vgic_irq private_irqs[VGIC_NR_PRIVATE_IRQS];
1a89dd911   Marc Zyngier   ARM: KVM: Initial...
280

e08d8d296   Julien Thierry   KVM: arm/arm64: v...
281
  	raw_spinlock_t ap_list_lock;	/* Protects the ap_list */
9d949dce5   Marc Zyngier   ARM: KVM: VGIC vi...
282

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
283
284
285
286
287
288
289
  	/*
  	 * List of IRQs that this VCPU should consider because they are either
  	 * Active or Pending (hence the name; AP list), or because they recently
  	 * were one of the two and need to be migrated off this list to another
  	 * VCPU.
  	 */
  	struct list_head ap_list_head;
495dd859f   Marc Zyngier   KVM: ARM: vgic: a...
290

8f6cdc1c2   Andre Przywara   KVM: arm/arm64: v...
291
292
293
294
295
  	/*
  	 * Members below are used with GICv3 emulation only and represent
  	 * parts of the redistributor.
  	 */
  	struct vgic_io_device	rd_iodev;
dbd9733ab   Eric Auger   KVM: arm/arm64: R...
296
  	struct vgic_redist_region *rdreg;
0aa1de573   Andre Przywara   KVM: arm64: vgic:...
297
298
299
300
301
  
  	/* Contains the attributes and gpa of the LPI pending tables. */
  	u64 pendbaser;
  
  	bool lpis_enabled;
d017d7b0b   Vijaya Kumar K   KVM: arm/arm64: v...
302
303
304
305
306
307
  
  	/* Cache guest priority bits */
  	u32 num_pri_bits;
  
  	/* Cache guest interrupt ID bits */
  	u32 num_id_bits;
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
308
  };
1a89dd911   Marc Zyngier   ARM: KVM: Initial...
309

fb5ee369c   Marc Zyngier   arm64: KVM: vgic-...
310
  extern struct static_key_false vgic_v2_cpuif_trap;
59da1cbfd   Marc Zyngier   KVM: arm64: vgic-...
311
  extern struct static_key_false vgic_v3_cpuif_trap;
fb5ee369c   Marc Zyngier   arm64: KVM: vgic-...
312

ce01e4e88   Christoffer Dall   KVM: arm-vgic: Se...
313
  int kvm_vgic_addr(struct kvm *kvm, unsigned long type, u64 *addr, bool write);
6c3d63c9a   Marc Zyngier   KVM: arm/arm64: v...
314
  void kvm_vgic_early_init(struct kvm *kvm);
1aab6f468   Christoffer Dall   KVM: arm/arm64: R...
315
  int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu);
59892136c   Andre Przywara   arm/arm64: KVM: p...
316
  int kvm_vgic_create(struct kvm *kvm, u32 type);
c1bfb577a   Marc Zyngier   arm/arm64: KVM: v...
317
  void kvm_vgic_destroy(struct kvm *kvm);
c1bfb577a   Marc Zyngier   arm/arm64: KVM: v...
318
  void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu);
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
319
320
  int kvm_vgic_map_resources(struct kvm *kvm);
  int kvm_vgic_hyp_init(void);
5b0d2cc28   Christoffer Dall   KVM: arm64: Ensur...
321
  void kvm_vgic_init_cpu_hardware(void);
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
322
323
  
  int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int intid,
cb3f0ad88   Christoffer Dall   KVM: arm/arm64: D...
324
  			bool level, void *owner);
47bbd31f7   Eric Auger   KVM: arm/arm64: v...
325
  int kvm_vgic_map_phys_irq(struct kvm_vcpu *vcpu, unsigned int host_irq,
b6909a659   Christoffer Dall   KVM: arm/arm64: S...
326
  			  u32 vintid, bool (*get_input_level)(int vindid));
47bbd31f7   Eric Auger   KVM: arm/arm64: v...
327
328
  int kvm_vgic_unmap_phys_irq(struct kvm_vcpu *vcpu, unsigned int vintid);
  bool kvm_vgic_map_is_active(struct kvm_vcpu *vcpu, unsigned int vintid);
1a89dd911   Marc Zyngier   ARM: KVM: Initial...
329

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
330
  int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu);
328e56647   Christoffer Dall   KVM: arm/arm64: v...
331
332
  void kvm_vgic_load(struct kvm_vcpu *vcpu);
  void kvm_vgic_put(struct kvm_vcpu *vcpu);
5eeaf10ee   Marc Zyngier   KVM: arm/arm64: S...
333
  void kvm_vgic_vmcr_sync(struct kvm_vcpu *vcpu);
328e56647   Christoffer Dall   KVM: arm/arm64: v...
334

f982cf4e9   Marc Zyngier   KVM: ARM: vgic: r...
335
  #define irqchip_in_kernel(k)	(!!((k)->arch.vgic.in_kernel))
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
336
  #define vgic_initialized(k)	((k)->arch.vgic.initialized)
c52edf5f8   Christoffer Dall   arm/arm64: KVM: R...
337
  #define vgic_ready(k)		((k)->arch.vgic.ready)
2defaff48   Andre Przywara   KVM: arm/arm64: p...
338
  #define vgic_valid_spi(k, i)	(((i) >= VGIC_NR_PRIVATE_IRQS) && \
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
339
340
341
342
343
  			((i) < (k)->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS))
  
  bool kvm_vcpu_has_pending_irqs(struct kvm_vcpu *vcpu);
  void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu);
  void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu);
413aa807a   Christoffer Dall   KVM: arm/arm64: R...
344
  void kvm_vgic_reset_mapped_irq(struct kvm_vcpu *vcpu, u32 vintid);
9d949dce5   Marc Zyngier   ARM: KVM: VGIC vi...
345

6249f2a47   Marc Zyngier   KVM: arm/arm64: v...
346
  void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg, bool allow_group1);
8f186d522   Marc Zyngier   KVM: ARM: vgic: s...
347

50926d82f   Marc Zyngier   KVM: arm/arm64: T...
348
349
350
351
352
353
354
355
356
357
  /**
   * kvm_vgic_get_max_vcpus - Get the maximum number of VCPUs allowed by HW
   *
   * The host's GIC naturally limits the maximum amount of VCPUs a guest
   * can use.
   */
  static inline int kvm_vgic_get_max_vcpus(void)
  {
  	return kvm_vgic_global_state.max_gic_vcpus;
  }
0e4e82f15   Andre Przywara   KVM: arm64: vgic-...
358
  int kvm_send_userspace_msi(struct kvm *kvm, struct kvm_msi *msi);
180ae7b11   Eric Auger   KVM: arm/arm64: E...
359
360
361
362
363
  /**
   * kvm_vgic_setup_default_irq_routing:
   * Setup a default flat gsi routing table mapping all SPIs
   */
  int kvm_vgic_setup_default_irq_routing(struct kvm *kvm);
c6ccd30e0   Christoffer Dall   KVM: arm/arm64: I...
364
  int kvm_vgic_set_owner(struct kvm_vcpu *vcpu, unsigned int intid, void *owner);
196b13649   Marc Zyngier   KVM: arm/arm64: G...
365
366
367
368
369
370
371
  struct kvm_kernel_irq_routing_entry;
  
  int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int irq,
  			       struct kvm_kernel_irq_routing_entry *irq_entry);
  
  int kvm_vgic_v4_unset_forwarding(struct kvm *kvm, int irq,
  				 struct kvm_kernel_irq_routing_entry *irq_entry);
df9ba9599   Marc Zyngier   KVM: arm/arm64: G...
372
373
  void kvm_vgic_v4_enable_doorbell(struct kvm_vcpu *vcpu);
  void kvm_vgic_v4_disable_doorbell(struct kvm_vcpu *vcpu);
50926d82f   Marc Zyngier   KVM: arm/arm64: T...
374
  #endif /* __KVM_ARM_VGIC_H */