Sending of notification is done by exiting vcpu to user space if KVM_REQ_HV_CRASH is enabled for vcpu. At exit to user space the kvm_run structure contains system_event with type KVM_SYSTEM_EVENT_CRASH to notify about guest crash occurred.
Unified · Split
| @@ -3277,6 +3277,7 @@ should put the acknowledged interrupt vector into the 'epr' field. · 3276 unmodified lines | ||
| 3277 | 3277 | struct { |
| 3278 | 3278 | #define KVM_SYSTEM_EVENT_SHUTDOWN 1 |
| 3279 | 3279 | #define KVM_SYSTEM_EVENT_RESET 2 |
| 3280 | +#define KVM_SYSTEM_EVENT_CRASH 3 | |
| 3280 | 3281 | __u32 type; |
| 3281 | 3282 | __u64 flags; |
| 3282 | 3283 | } system_event; |
| @@ -3296,6 +3297,10 @@ Valid values for 'type' are: · 13 unmodified lines | ||
| 3296 | 3297 | KVM_SYSTEM_EVENT_RESET -- the guest has requested a reset of the VM. |
| 3297 | 3298 | As with SHUTDOWN, userspace can choose to ignore the request, or |
| 3298 | 3299 | to schedule the reset to occur in the future and may call KVM_RUN again. |
| 3300 | + KVM_SYSTEM_EVENT_CRASH -- the guest crash occurred and the guest | |
| 3301 | + has requested a crash condition maintenance. Userspace can choose | |
| 3302 | + to ignore the request, or to gather VM memory core dump and/or | |
| 3303 | + reset/shutdown of the VM. | |
| 3299 | 3304 | |
| 3300 | 3305 | /* Fix the size of the union. */ |
| 3301 | 3306 | char padding[256]; |
| @@ -6263,6 +6263,12 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) · 6262 unmodified lines | ||
| 6263 | 6263 | vcpu_scan_ioapic(vcpu); |
| 6264 | 6264 | if (kvm_check_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu)) |
| 6265 | 6265 | kvm_vcpu_reload_apic_access_page(vcpu); |
| 6266 | + if (kvm_check_request(KVM_REQ_HV_CRASH, vcpu)) { | |
| 6267 | + vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT; | |
| 6268 | + vcpu->run->system_event.type = KVM_SYSTEM_EVENT_CRASH; | |
| 6269 | + r = 0; | |
| 6270 | + goto out; | |
| 6271 | + } | |
| 6266 | 6272 | } |
| 6267 | 6273 | |
| 6268 | 6274 | if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) { |
| @@ -139,6 +139,7 @@ static inline bool is_error_page(struct page *page) · 138 unmodified lines | ||
| 139 | 139 | #define KVM_REQ_DISABLE_IBS 24 |
| 140 | 140 | #define KVM_REQ_APIC_PAGE_RELOAD 25 |
| 141 | 141 | #define KVM_REQ_SMI 26 |
| 142 | +#define KVM_REQ_HV_CRASH 27 | |
| 142 | 143 | |
| 143 | 144 | #define KVM_USERSPACE_IRQ_SOURCE_ID 0 |
| 144 | 145 | #define KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID 1 |
| @@ -317,6 +317,7 @@ struct kvm_run { · 316 unmodified lines | ||
| 317 | 317 | struct { |
| 318 | 318 | #define KVM_SYSTEM_EVENT_SHUTDOWN 1 |
| 319 | 319 | #define KVM_SYSTEM_EVENT_RESET 2 |
| 320 | +#define KVM_SYSTEM_EVENT_CRASH 3 | |
| 320 | 321 | __u32 type; |
| 321 | 322 | __u64 flags; |
| 322 | 323 | } system_event; |