arch/x86/kvm/i8259.c
Source file repositories/reference/linux-study-clean/arch/x86/kvm/i8259.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kvm/i8259.c- Extension
.c- Size
- 14868 bytes
- Lines
- 656
- 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/mm.hlinux/slab.hlinux/bitops.hioapic.hirq.hlinux/kvm_host.htrace.h
Detected Declarations
function pic_lockfunction pic_unlockfunction pic_clear_isrfunction pic_set_irq1function maskfunction pic_get_irqfunction pic_update_irqfunction kvm_pic_update_irqfunction kvm_pic_set_irqfunction pic_intackfunction kvm_pic_read_irqfunction kvm_pic_resetfunction kvm_for_each_vcpufunction pic_ioport_writefunction pic_poll_readfunction pic_ioport_readfunction elcr_ioport_writefunction elcr_ioport_readfunction picdev_writefunction picdev_readfunction picdev_master_writefunction picdev_master_readfunction picdev_slave_writefunction picdev_slave_readfunction picdev_elcr_writefunction picdev_elcr_readfunction pic_irq_requestfunction kvm_pic_initfunction kvm_pic_destroy
Annotated Snippet
kvm_for_each_vcpu(i, vcpu, s->kvm) {
if (kvm_apic_accept_pic_intr(vcpu)) {
kvm_make_request(KVM_REQ_EVENT, vcpu);
kvm_vcpu_kick(vcpu);
return;
}
}
}
}
static void pic_clear_isr(struct kvm_kpic_state *s, int irq)
{
s->isr &= ~(1 << irq);
if (s != &s->pics_state->pics[0])
irq += 8;
/*
* We are dropping lock while calling ack notifiers since ack
* notifier callbacks for assigned devices call into PIC recursively.
* Other interrupt may be delivered to PIC while lock is dropped but
* it should be safe since PIC state is already updated at this stage.
*/
pic_unlock(s->pics_state);
kvm_notify_acked_irq(s->pics_state->kvm, SELECT_PIC(irq), irq);
pic_lock(s->pics_state);
}
/*
* set irq level. If an edge is detected, then the IRR is set to 1
*/
static inline int pic_set_irq1(struct kvm_kpic_state *s, int irq, int level)
{
int mask, ret = 1;
mask = 1 << irq;
if (s->elcr & mask) /* level triggered */
if (level) {
ret = !(s->irr & mask);
s->irr |= mask;
s->last_irr |= mask;
} else {
s->irr &= ~mask;
s->last_irr &= ~mask;
}
else /* edge triggered */
if (level) {
if ((s->last_irr & mask) == 0) {
ret = !(s->irr & mask);
s->irr |= mask;
}
s->last_irr |= mask;
} else
s->last_irr &= ~mask;
return (s->imr & mask) ? -1 : ret;
}
/*
* return the highest priority found in mask (highest = smallest
* number). Return 8 if no irq
*/
static inline int get_priority(struct kvm_kpic_state *s, int mask)
{
int priority;
if (mask == 0)
return 8;
priority = 0;
while ((mask & (1 << ((priority + s->priority_add) & 7))) == 0)
priority++;
return priority;
}
/*
* return the pic wanted interrupt. return -1 if none
*/
static int pic_get_irq(struct kvm_kpic_state *s)
{
int mask, cur_priority, priority;
mask = s->irr & ~s->imr;
priority = get_priority(s, mask);
if (priority == 8)
return -1;
/*
* compute current priority. If special fully nested mode on the
* master, the IRQ coming from the slave is not taken into account
* for the priority computation.
*/
mask = s->isr;
if (s->special_fully_nested_mode && s == &s->pics_state->pics[0])
mask &= ~(1 << 2);
cur_priority = get_priority(s, mask);
Annotation
- Immediate include surface: `linux/mm.h`, `linux/slab.h`, `linux/bitops.h`, `ioapic.h`, `irq.h`, `linux/kvm_host.h`, `trace.h`.
- Detected declarations: `function pic_lock`, `function pic_unlock`, `function pic_clear_isr`, `function pic_set_irq1`, `function mask`, `function pic_get_irq`, `function pic_update_irq`, `function kvm_pic_update_irq`, `function kvm_pic_set_irq`, `function pic_intack`.
- 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.