arch/arm64/kvm/vgic/vgic-its.c
Source file repositories/reference/linux-study-clean/arch/arm64/kvm/vgic/vgic-its.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/kvm/vgic/vgic-its.c- Extension
.c- Size
- 72030 bytes
- Lines
- 2819
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/cpu.hlinux/kvm.hlinux/kvm_host.hlinux/interrupt.hlinux/list.hlinux/uaccess.hlinux/list_sort.hlinux/irqchip/arm-gic-v3.hasm/kvm_emulate.hasm/kvm_arm.hasm/kvm_mmu.hvgic.hvgic-mmio.h
Detected Declarations
struct vgic_its_abifunction newfunction vgic_its_set_abifunction entryfunction list_for_each_entryfunction list_for_each_entryfunction update_lpi_configfunction update_affinityfunction ITTEfunction update_affinity_collectionfunction for_each_lpi_itsfunction max_lpis_propbaserfunction its_sync_lpi_pending_tablefunction xa_for_eachfunction vgic_mmio_read_its_typerfunction vgic_mmio_read_its_iidrfunction vgic_mmio_uaccess_write_its_iidrfunction vgic_mmio_read_its_idregsfunction vgic_its_cache_keyfunction vgic_its_cache_translationfunction vgic_its_invalidate_cachefunction xa_for_eachfunction vgic_its_invalidate_all_cachesfunction list_for_each_entry_rcufunction vgic_its_resolve_lpifunction vgic_its_trigger_msifunction vgic_its_inject_cached_translationfunction vgic_its_trigger_msifunction its_free_itefunction scoped_guardfunction its_cmd_mask_fieldfunction Entryfunction vgic_its_cmd_handle_movifunction __is_visible_gfn_lockedfunction validfunction vgic_its_check_event_idfunction vgic_its_alloc_collectionfunction vgic_its_free_collectionfunction vgic_its_cmd_handle_mapifunction vgic_its_free_devicefunction vgic_its_free_device_listfunction vgic_its_free_collection_listfunction Tablesfunction vgic_its_cmd_handle_mapcfunction vgic_its_cmd_handle_clearfunction vgic_its_inv_lpifunction vgic_its_cmd_handle_invfunction vgic_its_invall
Annotated Snippet
struct vgic_its_abi {
int cte_esz;
int dte_esz;
int ite_esz;
int (*save_tables)(struct vgic_its *its);
int (*restore_tables)(struct vgic_its *its);
void (*commit)(struct vgic_its *its);
};
#define ABI_0_ESZ 8
#define ESZ_MAX ABI_0_ESZ
static const struct vgic_its_abi its_table_abi_versions[] = {
[0] = {
.cte_esz = ABI_0_ESZ,
.dte_esz = ABI_0_ESZ,
.ite_esz = ABI_0_ESZ,
.save_tables = vgic_its_save_tables_v0,
.restore_tables = vgic_its_restore_tables_v0,
.commit = vgic_its_commit_v0,
},
};
#define NR_ITS_ABIS ARRAY_SIZE(its_table_abi_versions)
inline const struct vgic_its_abi *vgic_its_get_abi(struct vgic_its *its)
{
return &its_table_abi_versions[its->abi_rev];
}
static void vgic_its_set_abi(struct vgic_its *its, u32 rev)
{
const struct vgic_its_abi *abi;
its->abi_rev = rev;
abi = vgic_its_get_abi(its);
abi->commit(its);
}
/*
* Find and returns a device in the device table for an ITS.
* Must be called with the its_lock mutex held.
*/
static struct its_device *find_its_device(struct vgic_its *its, u32 device_id)
{
struct its_device *device;
list_for_each_entry(device, &its->device_list, dev_list)
if (device_id == device->device_id)
return device;
return NULL;
}
/*
* Find and returns an interrupt translation table entry (ITTE) for a given
* Device ID/Event ID pair on an ITS.
* Must be called with the its_lock mutex held.
*/
static struct its_ite *find_ite(struct vgic_its *its, u32 device_id,
u32 event_id)
{
struct its_device *device;
struct its_ite *ite;
device = find_its_device(its, device_id);
if (device == NULL)
return NULL;
list_for_each_entry(ite, &device->itt_head, ite_list)
if (ite->event_id == event_id)
return ite;
return NULL;
}
/* To be used as an iterator this macro misses the enclosing parentheses */
#define for_each_lpi_its(dev, ite, its) \
list_for_each_entry(dev, &(its)->device_list, dev_list) \
list_for_each_entry(ite, &(dev)->itt_head, ite_list)
#define GIC_LPI_OFFSET 8192
#define VITS_TYPER_IDBITS 16
#define VITS_MAX_EVENTID (BIT(VITS_TYPER_IDBITS) - 1)
#define VITS_TYPER_DEVBITS 16
#define VITS_MAX_DEVID (BIT(VITS_TYPER_DEVBITS) - 1)
#define VITS_DTE_MAX_DEVID_OFFSET (BIT(14) - 1)
#define VITS_ITE_MAX_EVENTID_OFFSET (BIT(16) - 1)
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/kvm.h`, `linux/kvm_host.h`, `linux/interrupt.h`, `linux/list.h`, `linux/uaccess.h`, `linux/list_sort.h`, `linux/irqchip/arm-gic-v3.h`.
- Detected declarations: `struct vgic_its_abi`, `function new`, `function vgic_its_set_abi`, `function entry`, `function list_for_each_entry`, `function list_for_each_entry`, `function update_lpi_config`, `function update_affinity`, `function ITTE`, `function update_affinity_collection`.
- Atlas domain: Architecture Layer / arch/arm64.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.