MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vcpu_notify_event_locked

Function vcpu_notify_event_locked

freebsd/amd64/vmm/vmm.c:2488–2517  ·  view source on GitHub ↗

* This function is called to ensure that a vcpu "sees" a pending event * as soon as possible: * - If the vcpu thread is sleeping then it is woken up. * - If the vcpu is running on a different host_cpu then an IPI will be directed * to the host_cpu to cause the vcpu to trap into the hypervisor. */

Source from the content-addressed store, hash-verified

2486 * to the host_cpu to cause the vcpu to trap into the hypervisor.
2487 */
2488static void
2489vcpu_notify_event_locked(struct vcpu *vcpu, bool lapic_intr)
2490{
2491 int hostcpu;
2492
2493 hostcpu = vcpu->hostcpu;
2494 if (vcpu->state == VCPU_RUNNING) {
2495 KASSERT(hostcpu != NOCPU, ("vcpu running on invalid hostcpu"));
2496 if (hostcpu != curcpu) {
2497 if (lapic_intr) {
2498 vlapic_post_intr(vcpu->vlapic, hostcpu,
2499 vmm_ipinum);
2500 } else {
2501 ipi_cpu(hostcpu, vmm_ipinum);
2502 }
2503 } else {
2504 /*
2505 * If the 'vcpu' is running on 'curcpu' then it must
2506 * be sending a notification to itself (e.g. SELF_IPI).
2507 * The pending event will be picked up when the vcpu
2508 * transitions back to guest context.
2509 */
2510 }
2511 } else {
2512 KASSERT(hostcpu == NOCPU, ("vcpu state %d not consistent "
2513 "with hostcpu %d", vcpu->state, hostcpu));
2514 if (vcpu->state == VCPU_SLEEPING)
2515 wakeup_one(vcpu);
2516 }
2517}
2518
2519void
2520vcpu_notify_event(struct vm *vm, int vcpuid, bool lapic_intr)

Callers 2

vcpu_set_state_lockedFunction · 0.85
vcpu_notify_eventFunction · 0.85

Calls 3

vlapic_post_intrFunction · 0.85
ipi_cpuFunction · 0.50
wakeup_oneFunction · 0.50

Tested by

no test coverage detected