Skip to content

Commit b7e33cf

Browse files
Sebastien Boeufandreeaflorescu
authored andcommitted
vcpu: Return proper vector when receiving EOI
The vector value returned along with End Of Interrupt (EOI) VM exit is important as it indicates a userspace IOAPIC which interrupt needs to be deasserted. About KVM_EXIT_IOAPIC_EOI, KVM documentation mentions: ``` /* KVM_EXIT_IOAPIC_EOI */ struct { __u8 vector; } eoi; Indicates that the VCPU's in-kernel local APIC received an EOI for a level-triggered IOAPIC interrupt. This exit only triggers when the IOAPIC is implemented in userspace (i.e. KVM_CAP_SPLIT_IRQCHIP is enabled); the userspace IOAPIC should process the EOI and retrigger the interrupt if it is still asserted. Vector is the LAPIC interrupt vector for which the EOI was received. ``` Signed-off-by: Sebastien Boeuf <[email protected]>
1 parent d48fdaa commit b7e33cf

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/ioctls/vcpu.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub enum VcpuExit<'a> {
8787
/// Corresponds to KVM_EXIT_S390_STSI.
8888
S390Stsi,
8989
/// Corresponds to KVM_EXIT_IOAPIC_EOI.
90-
IoapicEoi,
90+
IoapicEoi(u8 /* vector */),
9191
/// Corresponds to KVM_EXIT_HYPERV.
9292
Hyperv,
9393
}
@@ -725,7 +725,12 @@ impl VcpuFd {
725725
KVM_EXIT_EPR => Ok(VcpuExit::Epr),
726726
KVM_EXIT_SYSTEM_EVENT => Ok(VcpuExit::SystemEvent),
727727
KVM_EXIT_S390_STSI => Ok(VcpuExit::S390Stsi),
728-
KVM_EXIT_IOAPIC_EOI => Ok(VcpuExit::IoapicEoi),
728+
KVM_EXIT_IOAPIC_EOI => {
729+
// Safe because the exit_reason (which comes from the kernel) told us which
730+
// union field to use.
731+
let eoi = unsafe { &mut run.__bindgen_anon_1.eoi };
732+
Ok(VcpuExit::IoapicEoi(eoi.vector))
733+
}
729734
KVM_EXIT_HYPERV => Ok(VcpuExit::Hyperv),
730735
r => panic!("unknown kvm exit reason: {}", r),
731736
}

tests/coverage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
91.3
1+
90.9

0 commit comments

Comments
 (0)