Comments
Patch
@@ -162,10 +162,24 @@ int kvm_handle_pf(struct pt_regs *regs, unsigned long error_code)
switch (reason) {
default:
return 0;
- case KVM_PV_REASON_PAGE_NP:
+ case KVM_PV_REASON_PAGE_NP: {
+ int cpu, idle;
+ cpu = get_cpu();
+ idle = idle_cpu(cpu);
+ put_cpu();
+
+ /*
+ * We cannot reschedule. Wait for page to be ready.
+ */
+ if (idle || preempt_count()) {
+ kvm_hypercall0(KVM_HC_WAIT_FOR_ASYNC_PF);
+ break;
+ }
+
/* real page is missing. */
apf_task_wait(current, token);
break;
+ }
case KVM_PV_REASON_PAGE_READY:
apf_task_wake(token);
break;
If async page fault is received by idle task or when preemp_count is not zero guest cannot reschedule, so make "wait for page" hypercall and comtinue only after a page is ready. Signed-off-by: Gleb Natapov <gleb@redhat.com> --- arch/x86/kernel/kvm.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-)