.. | .. |
---|
295 | 295 | if (atomic_read(&ps->reinject) == reinject) |
---|
296 | 296 | return; |
---|
297 | 297 | |
---|
| 298 | + /* |
---|
| 299 | + * AMD SVM AVIC accelerates EOI write and does not trap. |
---|
| 300 | + * This cause in-kernel PIT re-inject mode to fail |
---|
| 301 | + * since it checks ps->irq_ack before kvm_set_irq() |
---|
| 302 | + * and relies on the ack notifier to timely queue |
---|
| 303 | + * the pt->worker work iterm and reinject the missed tick. |
---|
| 304 | + * So, deactivate APICv when PIT is in reinject mode. |
---|
| 305 | + */ |
---|
298 | 306 | if (reinject) { |
---|
| 307 | + kvm_request_apicv_update(kvm, false, |
---|
| 308 | + APICV_INHIBIT_REASON_PIT_REINJ); |
---|
299 | 309 | /* The initial state is preserved while ps->reinject == 0. */ |
---|
300 | 310 | kvm_pit_reset_reinject(pit); |
---|
301 | 311 | kvm_register_irq_ack_notifier(kvm, &ps->irq_ack_notifier); |
---|
302 | 312 | kvm_register_irq_mask_notifier(kvm, 0, &pit->mask_notifier); |
---|
303 | 313 | } else { |
---|
| 314 | + kvm_request_apicv_update(kvm, true, |
---|
| 315 | + APICV_INHIBIT_REASON_PIT_REINJ); |
---|
304 | 316 | kvm_unregister_irq_ack_notifier(kvm, &ps->irq_ack_notifier); |
---|
305 | 317 | kvm_unregister_irq_mask_notifier(kvm, 0, &pit->mask_notifier); |
---|
306 | 318 | } |
---|
.. | .. |
---|
355 | 367 | { |
---|
356 | 368 | struct kvm_kpit_state *ps = &pit->pit_state; |
---|
357 | 369 | |
---|
358 | | - pr_debug("load_count val is %d, channel is %d\n", val, channel); |
---|
| 370 | + pr_debug("load_count val is %u, channel is %d\n", val, channel); |
---|
359 | 371 | |
---|
360 | 372 | /* |
---|
361 | 373 | * The largest possible initial count is 0; this is equivalent |
---|
.. | .. |
---|
450 | 462 | if (channel == 3) { |
---|
451 | 463 | /* Read-Back Command. */ |
---|
452 | 464 | for (channel = 0; channel < 3; channel++) { |
---|
453 | | - s = &pit_state->channels[channel]; |
---|
454 | 465 | if (val & (2 << channel)) { |
---|
455 | 466 | if (!(val & 0x20)) |
---|
456 | 467 | pit_latch_count(pit, channel); |
---|
.. | .. |
---|
653 | 664 | pid_t pid_nr; |
---|
654 | 665 | int ret; |
---|
655 | 666 | |
---|
656 | | - pit = kzalloc(sizeof(struct kvm_pit), GFP_KERNEL); |
---|
| 667 | + pit = kzalloc(sizeof(struct kvm_pit), GFP_KERNEL_ACCOUNT); |
---|
657 | 668 | if (!pit) |
---|
658 | 669 | return NULL; |
---|
659 | 670 | |
---|