arch/arm64/kvm/vgic/vgic-mmio-v3.c
Source file repositories/reference/linux-study-clean/arch/arm64/kvm/vgic/vgic-mmio-v3.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/kvm/vgic/vgic-mmio-v3.c- Extension
.c- Size
- 32401 bytes
- Lines
- 1173
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/irqchip/arm-gic-v3.hlinux/kvm.hlinux/kvm_host.hlinux/interrupt.hkvm/iodev.hkvm/arm_vgic.hasm/kvm_emulate.hasm/kvm_arm.hasm/kvm_mmu.hvgic.hvgic-mmio.h
Detected Declarations
function extract_bytesfunction update_64bit_regfunction vgic_has_itsfunction vgic_supports_direct_msisfunction system_supports_direct_sgisfunction vgic_supports_direct_sgisfunction vgic_mmio_read_v3_miscfunction vgic_mmio_write_v3_miscfunction vgic_mmio_uaccess_write_v3_miscfunction vgic_mmio_read_irouterfunction vgic_mmio_write_irouterfunction vgic_lpis_enabledfunction vgic_mmio_read_v3r_ctlrfunction vgic_mmio_write_v3r_ctlrfunction vgic_mmio_vcpu_rdist_is_lastfunction list_for_each_entryfunction vgic_mmio_read_v3r_typerfunction vgic_mmio_read_v3r_iidrfunction vgic_mmio_read_v3_idregsfunction vgic_v3_uaccess_write_pendingfunction vgic_sanitise_shareabilityfunction vgic_sanitise_inner_cacheabilityfunction vgic_sanitise_outer_cacheabilityfunction vgic_sanitise_fieldfunction GENMASK_ULLfunction vgic_sanitise_propbaserfunction vgic_mmio_read_propbasefunction vgic_mmio_write_propbasefunction vgic_mmio_read_pendbasefunction vgic_mmio_write_pendbasefunction vgic_mmio_read_syncfunction vgic_set_rdist_busyfunction vgic_mmio_write_invlpifunction vgic_mmio_write_invallfunction vgic_v3_init_dist_iodevfunction vgic_register_redist_iodevfunction vgic_unregister_redist_iodevfunction vgic_register_all_redist_iodevsfunction kvm_for_each_vcpufunction vgic_v3_alloc_redist_regionfunction vgic_v3_free_redist_regionfunction vgic_v3_set_redist_basefunction vgic_v3_has_attr_regsfunction vgic_v3_queue_sgifunction GICv3function kvm_for_each_vcpufunction for_each_set_bitfunction vgic_v3_dist_uaccess
Annotated Snippet
if (vgic_has_its(vcpu->kvm)) {
value |= (INTERRUPT_ID_BITS_ITS - 1) << 19;
value |= GICD_TYPER_LPIS;
} else {
value |= (INTERRUPT_ID_BITS_SPIS - 1) << 19;
}
break;
case GICD_TYPER2:
if (vgic_supports_direct_sgis(vcpu->kvm))
value = GICD_TYPER2_nASSGIcap;
break;
case GICD_IIDR:
value = (PRODUCT_ID_KVM << GICD_IIDR_PRODUCT_ID_SHIFT) |
(vgic->implementation_rev << GICD_IIDR_REVISION_SHIFT) |
(IMPLEMENTER_ARM << GICD_IIDR_IMPLEMENTER_SHIFT);
break;
default:
return 0;
}
return value;
}
static void vgic_mmio_write_v3_misc(struct kvm_vcpu *vcpu,
gpa_t addr, unsigned int len,
unsigned long val)
{
struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
switch (addr & 0x0c) {
case GICD_CTLR: {
bool was_enabled, is_hwsgi;
mutex_lock(&vcpu->kvm->arch.config_lock);
was_enabled = dist->enabled;
is_hwsgi = dist->nassgireq;
dist->enabled = val & GICD_CTLR_ENABLE_SS_G1;
/* Not a GICv4.1? No HW SGIs */
if (!vgic_supports_direct_sgis(vcpu->kvm))
val &= ~GICD_CTLR_nASSGIreq;
/* Dist stays enabled? nASSGIreq is RO */
if (was_enabled && dist->enabled) {
val &= ~GICD_CTLR_nASSGIreq;
val |= FIELD_PREP(GICD_CTLR_nASSGIreq, is_hwsgi);
}
/* Switching HW SGIs? */
dist->nassgireq = val & GICD_CTLR_nASSGIreq;
if (is_hwsgi != dist->nassgireq)
vgic_v4_configure_vsgis(vcpu->kvm);
if (vgic_supports_direct_sgis(vcpu->kvm) &&
was_enabled != dist->enabled)
kvm_make_all_cpus_request(vcpu->kvm, KVM_REQ_RELOAD_GICv4);
else if (!was_enabled && dist->enabled)
vgic_kick_vcpus(vcpu->kvm);
mutex_unlock(&vcpu->kvm->arch.config_lock);
break;
}
case GICD_TYPER:
case GICD_TYPER2:
case GICD_IIDR:
/* This is at best for documentation purposes... */
return;
}
}
static int vgic_mmio_uaccess_write_v3_misc(struct kvm_vcpu *vcpu,
gpa_t addr, unsigned int len,
unsigned long val)
{
struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
u32 reg;
switch (addr & 0x0c) {
case GICD_TYPER2:
reg = vgic_mmio_read_v3_misc(vcpu, addr, len);
if (reg == val)
return 0;
if (vgic_initialized(vcpu->kvm))
return -EBUSY;
if ((reg ^ val) & ~GICD_TYPER2_nASSGIcap)
return -EINVAL;
if (!system_supports_direct_sgis() && val)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/irqchip/arm-gic-v3.h`, `linux/kvm.h`, `linux/kvm_host.h`, `linux/interrupt.h`, `kvm/iodev.h`, `kvm/arm_vgic.h`, `asm/kvm_emulate.h`.
- Detected declarations: `function extract_bytes`, `function update_64bit_reg`, `function vgic_has_its`, `function vgic_supports_direct_msis`, `function system_supports_direct_sgis`, `function vgic_supports_direct_sgis`, `function vgic_mmio_read_v3_misc`, `function vgic_mmio_write_v3_misc`, `function vgic_mmio_uaccess_write_v3_misc`, `function vgic_mmio_read_irouter`.
- Atlas domain: Architecture Layer / arch/arm64.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.