* 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. */
| 2486 | * to the host_cpu to cause the vcpu to trap into the hypervisor. |
| 2487 | */ |
| 2488 | static void |
| 2489 | vcpu_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 | |
| 2519 | void |
| 2520 | vcpu_notify_event(struct vm *vm, int vcpuid, bool lapic_intr) |
no test coverage detected