arch/x86/kvm/ioapic.c
Source file repositories/reference/linux-study-clean/arch/x86/kvm/ioapic.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kvm/ioapic.c- Extension
.c- Size
- 21404 bytes
- Lines
- 780
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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/kvm_host.hlinux/kvm.hlinux/mm.hlinux/highmem.hlinux/smp.hlinux/hrtimer.hlinux/io.hlinux/slab.hlinux/export.hlinux/nospec.hasm/processor.hasm/page.hasm/current.hioapic.hlapic.hirq.htrace.h
Detected Declarations
function ioapic_read_indirectfunction rtc_irq_eoi_tracking_resetfunction rtc_status_pending_eoi_check_validfunction __rtc_irq_eoi_tracking_restore_onefunction kvm_rtc_eoi_tracking_restore_onefunction kvm_rtc_eoi_tracking_restore_allfunction rtc_irq_eoifunction rtc_irq_check_coalescedfunction ioapic_lazy_update_eoifunction kvm_for_each_vcpufunction ioapic_set_irqfunction rtc_irq_check_coalescedfunction kvm_ioapic_inject_allfunction kvm_ioapic_scan_entryfunction kvm_arch_post_irq_ack_notifier_list_updatefunction kvm_register_irq_mask_notifierfunction kvm_unregister_irq_mask_notifierfunction kvm_fire_mask_notifiersfunction ioapic_write_indirectfunction ioapic_servicefunction kvm_ioapic_set_irqfunction kvm_ioapic_eoi_inject_workfunction kvm_ioapic_update_eoi_onefunction kvm_ioapic_update_eoifunction ioapic_in_rangefunction ioapic_mmio_readfunction ioapic_mmio_writefunction kvm_ioapic_resetfunction kvm_ioapic_initfunction kvm_ioapic_destroyfunction kvm_get_ioapicfunction kvm_set_ioapic
Annotated Snippet
if (redir_index < IOAPIC_NUM_PINS) {
u32 index = array_index_nospec(
redir_index, IOAPIC_NUM_PINS);
redir_content = ioapic->redirtbl[index].bits;
}
result = (ioapic->ioregsel & 0x1) ?
(redir_content >> 32) & 0xffffffff :
redir_content & 0xffffffff;
break;
}
}
return result;
}
static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic *ioapic)
{
ioapic->rtc_status.pending_eoi = 0;
bitmap_zero(ioapic->rtc_status.map, KVM_MAX_VCPU_IDS);
}
static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic);
static void rtc_status_pending_eoi_check_valid(struct kvm_ioapic *ioapic)
{
if (WARN_ON(ioapic->rtc_status.pending_eoi < 0))
kvm_rtc_eoi_tracking_restore_all(ioapic);
}
static void __rtc_irq_eoi_tracking_restore_one(struct kvm_vcpu *vcpu)
{
bool new_val, old_val;
struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic;
struct rtc_status *status = &ioapic->rtc_status;
union kvm_ioapic_redirect_entry *e;
e = &ioapic->redirtbl[RTC_GSI];
if (!kvm_apic_match_dest(vcpu, NULL, APIC_DEST_NOSHORT,
e->fields.dest_id,
kvm_lapic_irq_dest_mode(!!e->fields.dest_mode)))
return;
new_val = kvm_apic_pending_eoi(vcpu, e->fields.vector);
old_val = test_bit(vcpu->vcpu_id, status->map);
if (new_val == old_val)
return;
if (new_val) {
__set_bit(vcpu->vcpu_id, status->map);
status->vectors[vcpu->vcpu_id] = e->fields.vector;
ioapic->rtc_status.pending_eoi++;
} else {
__clear_bit(vcpu->vcpu_id, status->map);
ioapic->rtc_status.pending_eoi--;
rtc_status_pending_eoi_check_valid(ioapic);
}
}
void kvm_rtc_eoi_tracking_restore_one(struct kvm_vcpu *vcpu)
{
struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic;
spin_lock(&ioapic->lock);
__rtc_irq_eoi_tracking_restore_one(vcpu);
spin_unlock(&ioapic->lock);
}
static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic)
{
struct kvm_vcpu *vcpu;
unsigned long i;
if (RTC_GSI >= IOAPIC_NUM_PINS)
return;
rtc_irq_eoi_tracking_reset(ioapic);
kvm_for_each_vcpu(i, vcpu, ioapic->kvm)
__rtc_irq_eoi_tracking_restore_one(vcpu);
}
static void rtc_irq_eoi(struct kvm_ioapic *ioapic, struct kvm_vcpu *vcpu,
int vector)
{
struct rtc_status *status = &ioapic->rtc_status;
/* RTC special handling */
if (test_bit(vcpu->vcpu_id, status->map) &&
Annotation
- Immediate include surface: `linux/kvm_host.h`, `linux/kvm.h`, `linux/mm.h`, `linux/highmem.h`, `linux/smp.h`, `linux/hrtimer.h`, `linux/io.h`, `linux/slab.h`.
- Detected declarations: `function ioapic_read_indirect`, `function rtc_irq_eoi_tracking_reset`, `function rtc_status_pending_eoi_check_valid`, `function __rtc_irq_eoi_tracking_restore_one`, `function kvm_rtc_eoi_tracking_restore_one`, `function kvm_rtc_eoi_tracking_restore_all`, `function rtc_irq_eoi`, `function rtc_irq_check_coalesced`, `function ioapic_lazy_update_eoi`, `function kvm_for_each_vcpu`.
- Atlas domain: Architecture Layer / arch/x86.
- 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.