arch/arm64/kvm/vgic/vgic-v2.c
Source file repositories/reference/linux-study-clean/arch/arm64/kvm/vgic/vgic-v2.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/kvm/vgic/vgic-v2.c- Extension
.c- Size
- 16614 bytes
- Lines
- 623
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/irqchip/arm-gic.hlinux/kvm.hlinux/kvm_host.hkvm/arm_vgic.hasm/kvm_mmu.hvgic-mmio.hvgic.h
Detected Declarations
function Copyrightfunction vgic_v2_init_lrsfunction vgic_v2_configure_hcrfunction lr_signals_eoi_mifunction vgic_v2_fold_lrfunction scoped_guardfunction vgic_v2_fold_lr_statefunction vgic_v2_deactivatefunction vgic_v2_compute_lrfunction vgic_v2_populate_lrfunction vgic_v2_clear_lrfunction vgic_v2_set_vmcrfunction vgic_v2_get_vmcrfunction vgic_v2_resetfunction vgic_v2_check_basefunction vgic_v2_map_resourcesfunction vgic_v2_probefunction save_lrsfunction vgic_v2_save_statefunction vgic_v2_restore_statefunction vgic_v2_loadfunction vgic_v2_put
Annotated Snippet
if (!eoicount) {
break;
} else {
guard(raw_spinlock)(&irq->irq_lock);
if (!(likely(vgic_target_oracle(irq) == vcpu) &&
irq->active))
continue;
lr = vgic_v2_compute_lr(vcpu, irq) & ~GICH_LR_ACTIVE_BIT;
}
if (lr & GICH_LR_HW)
writel_relaxed(FIELD_GET(GICH_LR_PHYSID_CPUID, lr),
kvm_vgic_global_state.gicc_base + GIC_CPU_DEACTIVATE);
vgic_v2_fold_lr(vcpu, lr);
eoicount--;
}
cpuif->used_lrs = 0;
}
void vgic_v2_deactivate(struct kvm_vcpu *vcpu, u32 val)
{
struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
struct vgic_v2_cpu_if *cpuif = &vgic_cpu->vgic_v2;
struct kvm_vcpu *target_vcpu = NULL;
bool mmio = false;
struct vgic_irq *irq;
unsigned long flags;
u64 lr = 0;
u8 cpuid;
/* Snapshot CPUID, and remove it from the INTID */
cpuid = FIELD_GET(GENMASK_ULL(12, 10), val);
val &= ~GENMASK_ULL(12, 10);
/* We only deal with DIR when EOIMode==1 */
if (!(cpuif->vgic_vmcr & GICH_VMCR_EOI_MODE_MASK))
return;
/* Make sure we're in the same context as LR handling */
local_irq_save(flags);
irq = vgic_get_vcpu_irq(vcpu, val);
if (WARN_ON_ONCE(!irq))
goto out;
/* See the corresponding v3 code for the rationale */
scoped_guard(raw_spinlock, &irq->irq_lock) {
target_vcpu = irq->vcpu;
/* Not on any ap_list? */
if (!target_vcpu)
goto put;
/*
* Urgh. We're deactivating something that we cannot
* observe yet... Big hammer time.
*/
if (irq->on_lr) {
mmio = true;
goto put;
}
/* SGI: check that the cpuid matches */
if (val < VGIC_NR_SGIS && irq->active_source != cpuid) {
target_vcpu = NULL;
goto put;
}
/* (with a Dalek voice) DEACTIVATE!!!! */
lr = vgic_v2_compute_lr(vcpu, irq) & ~GICH_LR_ACTIVE_BIT;
}
if (lr & GICH_LR_HW)
writel_relaxed(FIELD_GET(GICH_LR_PHYSID_CPUID, lr),
kvm_vgic_global_state.gicc_base + GIC_CPU_DEACTIVATE);
vgic_v2_fold_lr(vcpu, lr);
put:
vgic_put_irq(vcpu->kvm, irq);
out:
local_irq_restore(flags);
if (mmio)
vgic_mmio_write_cactive(vcpu, (val / 32) * 4, 4, BIT(val % 32));
Annotation
- Immediate include surface: `linux/irqchip/arm-gic.h`, `linux/kvm.h`, `linux/kvm_host.h`, `kvm/arm_vgic.h`, `asm/kvm_mmu.h`, `vgic-mmio.h`, `vgic.h`.
- Detected declarations: `function Copyright`, `function vgic_v2_init_lrs`, `function vgic_v2_configure_hcr`, `function lr_signals_eoi_mi`, `function vgic_v2_fold_lr`, `function scoped_guard`, `function vgic_v2_fold_lr_state`, `function vgic_v2_deactivate`, `function vgic_v2_compute_lr`, `function vgic_v2_populate_lr`.
- Atlas domain: Architecture Layer / arch/arm64.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.