Lines Matching +full:guest +full:- +full:side

1 // SPDX-License-Identifier: GPL-2.0-only
13 #include <linux/irqchip/arm-gic-v4.h>
17 * intricacies of GICv3, GICv4, and how a guest's view of a GICv3 gets
25 * agnostic actually means KVM-specific - what were you thinking?).
30 * - Any guest-visible VLPI is backed by a Linux interrupt (and a
31 * physical LPI which gets unmapped when the guest maps the
33 * mapped to the LPI (host) or the VLPI (guest). Note that this is
36 * - Enabling/disabling a VLPI is done by issuing mask/unmask calls.
38 * - Guest INT/CLEAR commands are implemented through
41 * - The *bizarre* stuff (mapping/unmapping an interrupt to a VLPI, or
59 * But handling VLPIs is only one side of the job of the GICv4
60 * code. The other (darker) side is to take care of the doorbell
61 * interrupts which are delivered when a VLPI targeting a non-running
70 * - VMs (or rather the VM abstraction that matters to the GIC)
75 * - mask/unmask do what is expected on the doorbell interrupt.
77 * - irq_set_affinity is used to move a VPE from one redistributor to
80 * - irq_set_vcpu_affinity once again gets hijacked for the purpose of
81 * creating a new sub-API, namely scheduling/descheduling a VPE
126 name = kasprintf(GFP_KERNEL, "GICv4-sgi-%d", task_pid_nr(current)); in its_alloc_vcpu_sgis()
130 vpe->fwnode = irq_domain_alloc_named_id_fwnode(name, idx); in its_alloc_vcpu_sgis()
131 if (!vpe->fwnode) in its_alloc_vcpu_sgis()
137 vpe->sgi_domain = irq_domain_create_linear(vpe->fwnode, 16, in its_alloc_vcpu_sgis()
139 if (!vpe->sgi_domain) in its_alloc_vcpu_sgis()
142 sgi_base = __irq_domain_alloc_irqs(vpe->sgi_domain, -1, 16, in its_alloc_vcpu_sgis()
151 if (vpe->sgi_domain) in its_alloc_vcpu_sgis()
152 irq_domain_remove(vpe->sgi_domain); in its_alloc_vcpu_sgis()
153 if (vpe->fwnode) in its_alloc_vcpu_sgis()
154 irq_domain_free_fwnode(vpe->fwnode); in its_alloc_vcpu_sgis()
156 return -ENOMEM; in its_alloc_vcpu_sgis()
163 vm->fwnode = irq_domain_alloc_named_id_fwnode("GICv4-vpe", in its_alloc_vcpu_irqs()
165 if (!vm->fwnode) in its_alloc_vcpu_irqs()
168 vm->domain = irq_domain_create_hierarchy(gic_domain, 0, vm->nr_vpes, in its_alloc_vcpu_irqs()
169 vm->fwnode, vpe_domain_ops, in its_alloc_vcpu_irqs()
171 if (!vm->domain) in its_alloc_vcpu_irqs()
174 for (i = 0; i < vm->nr_vpes; i++) { in its_alloc_vcpu_irqs()
175 vm->vpes[i]->its_vm = vm; in its_alloc_vcpu_irqs()
176 vm->vpes[i]->idai = true; in its_alloc_vcpu_irqs()
179 vpe_base_irq = __irq_domain_alloc_irqs(vm->domain, -1, vm->nr_vpes, in its_alloc_vcpu_irqs()
185 for (i = 0; i < vm->nr_vpes; i++) { in its_alloc_vcpu_irqs()
187 vm->vpes[i]->irq = vpe_base_irq + i; in its_alloc_vcpu_irqs()
188 ret = its_alloc_vcpu_sgis(vm->vpes[i], i); in its_alloc_vcpu_irqs()
196 if (vm->domain) in its_alloc_vcpu_irqs()
197 irq_domain_remove(vm->domain); in its_alloc_vcpu_irqs()
198 if (vm->fwnode) in its_alloc_vcpu_irqs()
199 irq_domain_free_fwnode(vm->fwnode); in its_alloc_vcpu_irqs()
201 return -ENOMEM; in its_alloc_vcpu_irqs()
211 for (i = 0; i < vm->nr_vpes; i++) { in its_free_sgi_irqs()
212 unsigned int irq = irq_find_mapping(vm->vpes[i]->sgi_domain, 0); in its_free_sgi_irqs()
218 irq_domain_remove(vm->vpes[i]->sgi_domain); in its_free_sgi_irqs()
219 irq_domain_free_fwnode(vm->vpes[i]->fwnode); in its_free_sgi_irqs()
226 irq_domain_free_irqs(vm->vpes[0]->irq, vm->nr_vpes); in its_free_vcpu_irqs()
227 irq_domain_remove(vm->domain); in its_free_vcpu_irqs()
228 irq_domain_free_fwnode(vm->fwnode); in its_free_vcpu_irqs()
233 return irq_set_vcpu_affinity(vpe->irq, info); in its_send_vpe_cmd()
238 struct irq_desc *desc = irq_to_desc(vpe->irq); in its_make_vpe_non_resident()
250 while (db && irqd_irq_disabled(&desc->irq_data)) in its_make_vpe_non_resident()
251 enable_irq(vpe->irq); in its_make_vpe_non_resident()
256 vpe->resident = false; in its_make_vpe_non_resident()
258 vpe->ready = false; in its_make_vpe_non_resident()
275 /* Disabled the doorbell, as we're about to enter the guest */ in its_make_vpe_resident()
276 disable_irq_nosync(vpe->irq); in its_make_vpe_resident()
281 vpe->resident = true; in its_make_vpe_resident()
297 vpe->ready = true; in its_commit_vpe()
391 return -ENODEV; in its_init_v4()