aboutsummaryrefslogtreecommitdiffstats
path: root/include/kvm/arm_vgic.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/kvm/arm_vgic.h')
-rw-r--r--include/kvm/arm_vgic.h43
1 files changed, 38 insertions, 5 deletions
diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
index ac4888dc86bc..7c55dd5dd2c9 100644
--- a/include/kvm/arm_vgic.h
+++ b/include/kvm/arm_vgic.h
@@ -33,10 +33,11 @@
33#define VGIC_V2_MAX_LRS (1 << 6) 33#define VGIC_V2_MAX_LRS (1 << 6)
34#define VGIC_V3_MAX_LRS 16 34#define VGIC_V3_MAX_LRS 16
35#define VGIC_MAX_IRQS 1024 35#define VGIC_MAX_IRQS 1024
36#define VGIC_V2_MAX_CPUS 8
36 37
37/* Sanity checks... */ 38/* Sanity checks... */
38#if (KVM_MAX_VCPUS > 8) 39#if (KVM_MAX_VCPUS > 255)
39#error Invalid number of CPU interfaces 40#error Too many KVM VCPUs, the VGIC only supports up to 255 VCPUs for now
40#endif 41#endif
41 42
42#if (VGIC_NR_IRQS_LEGACY & 31) 43#if (VGIC_NR_IRQS_LEGACY & 31)
@@ -132,6 +133,18 @@ struct vgic_params {
132 unsigned int maint_irq; 133 unsigned int maint_irq;
133 /* Virtual control interface base address */ 134 /* Virtual control interface base address */
134 void __iomem *vctrl_base; 135 void __iomem *vctrl_base;
136 int max_gic_vcpus;
137 /* Only needed for the legacy KVM_CREATE_IRQCHIP */
138 bool can_emulate_gicv2;
139};
140
141struct vgic_vm_ops {
142 bool (*handle_mmio)(struct kvm_vcpu *, struct kvm_run *,
143 struct kvm_exit_mmio *);
144 bool (*queue_sgi)(struct kvm_vcpu *, int irq);
145 void (*add_sgi_source)(struct kvm_vcpu *, int irq, int source);
146 int (*init_model)(struct kvm *);
147 int (*map_resources)(struct kvm *, const struct vgic_params *);
135}; 148};
136 149
137struct vgic_dist { 150struct vgic_dist {
@@ -140,6 +153,9 @@ struct vgic_dist {
140 bool in_kernel; 153 bool in_kernel;
141 bool ready; 154 bool ready;
142 155
156 /* vGIC model the kernel emulates for the guest (GICv2 or GICv3) */
157 u32 vgic_model;
158
143 int nr_cpus; 159 int nr_cpus;
144 int nr_irqs; 160 int nr_irqs;
145 161
@@ -148,7 +164,11 @@ struct vgic_dist {
148 164
149 /* Distributor and vcpu interface mapping in the guest */ 165 /* Distributor and vcpu interface mapping in the guest */
150 phys_addr_t vgic_dist_base; 166 phys_addr_t vgic_dist_base;
151 phys_addr_t vgic_cpu_base; 167 /* GICv2 and GICv3 use different mapped register blocks */
168 union {
169 phys_addr_t vgic_cpu_base;
170 phys_addr_t vgic_redist_base;
171 };
152 172
153 /* Distributor enabled */ 173 /* Distributor enabled */
154 u32 enabled; 174 u32 enabled;
@@ -210,8 +230,13 @@ struct vgic_dist {
210 */ 230 */
211 struct vgic_bitmap *irq_spi_target; 231 struct vgic_bitmap *irq_spi_target;
212 232
233 /* Target MPIDR for each IRQ (needed for GICv3 IROUTERn) only */
234 u32 *irq_spi_mpidr;
235
213 /* Bitmap indicating which CPU has something pending */ 236 /* Bitmap indicating which CPU has something pending */
214 unsigned long *irq_pending_on_cpu; 237 unsigned long *irq_pending_on_cpu;
238
239 struct vgic_vm_ops vm_ops;
215#endif 240#endif
216}; 241};
217 242
@@ -229,6 +254,7 @@ struct vgic_v3_cpu_if {
229#ifdef CONFIG_ARM_GIC_V3 254#ifdef CONFIG_ARM_GIC_V3
230 u32 vgic_hcr; 255 u32 vgic_hcr;
231 u32 vgic_vmcr; 256 u32 vgic_vmcr;
257 u32 vgic_sre; /* Restored only, change ignored */
232 u32 vgic_misr; /* Saved only */ 258 u32 vgic_misr; /* Saved only */
233 u32 vgic_eisr; /* Saved only */ 259 u32 vgic_eisr; /* Saved only */
234 u32 vgic_elrsr; /* Saved only */ 260 u32 vgic_elrsr; /* Saved only */
@@ -275,13 +301,15 @@ struct kvm_exit_mmio;
275int kvm_vgic_addr(struct kvm *kvm, unsigned long type, u64 *addr, bool write); 301int kvm_vgic_addr(struct kvm *kvm, unsigned long type, u64 *addr, bool write);
276int kvm_vgic_hyp_init(void); 302int kvm_vgic_hyp_init(void);
277int kvm_vgic_map_resources(struct kvm *kvm); 303int kvm_vgic_map_resources(struct kvm *kvm);
278int kvm_vgic_create(struct kvm *kvm); 304int kvm_vgic_get_max_vcpus(void);
305int kvm_vgic_create(struct kvm *kvm, u32 type);
279void kvm_vgic_destroy(struct kvm *kvm); 306void kvm_vgic_destroy(struct kvm *kvm);
280void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu); 307void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu);
281void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu); 308void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu);
282void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu); 309void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu);
283int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num, 310int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num,
284 bool level); 311 bool level);
312void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg);
285int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu); 313int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu);
286bool vgic_handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run, 314bool vgic_handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run,
287 struct kvm_exit_mmio *mmio); 315 struct kvm_exit_mmio *mmio);
@@ -327,7 +355,7 @@ static inline int kvm_vgic_map_resources(struct kvm *kvm)
327 return 0; 355 return 0;
328} 356}
329 357
330static inline int kvm_vgic_create(struct kvm *kvm) 358static inline int kvm_vgic_create(struct kvm *kvm, u32 type)
331{ 359{
332 return 0; 360 return 0;
333} 361}
@@ -379,6 +407,11 @@ static inline bool vgic_ready(struct kvm *kvm)
379{ 407{
380 return true; 408 return true;
381} 409}
410
411static inline int kvm_vgic_get_max_vcpus(void)
412{
413 return KVM_MAX_VCPUS;
414}
382#endif 415#endif
383 416
384#endif 417#endif