On 07/19/2010 06:30 PM, Gleb Natapov wrote:
Enable async PF in a guest if async PF capability is discovered.

Signed-off-by: Gleb Natapov<g...@redhat.com>
---
  arch/x86/include/asm/kvm_para.h |    5 +++
  arch/x86/kernel/kvm.c           |   68 +++++++++++++++++++++++++++++++++++++++
  2 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
index 5b05e9f..f1662d7 100644
--- a/arch/x86/include/asm/kvm_para.h
+++ b/arch/x86/include/asm/kvm_para.h
@@ -65,6 +65,11 @@ struct kvm_mmu_op_release_pt {
        __u64 pt_phys;
  };

+struct kvm_vcpu_pv_apf_data {
+       __u32 reason;
+       __u32 enabled;
+};
+

The guest will have to align this on a 64 byte boundary, should this be marked __aligned(64) here?

@@ -231,12 +235,72 @@ static void __init paravirt_ops_setup(void)
  #endif
  }

+void __cpuinit kvm_guest_cpu_init(void)
+{
+       if (!kvm_para_available())
+               return;
+
+       if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF)) {
+               u64 pa = __pa(&__get_cpu_var(apf_reason));
+
+               if (native_write_msr_safe(MSR_KVM_ASYNC_PF_EN,
+                                         pa | KVM_ASYNC_PF_ENABLED, pa>>  32))
+                       return;
+               __get_cpu_var(apf_reason).enabled = 1;
+               printk(KERN_INFO"KVM setup async PF for cpu %d\n",
+                      smp_processor_id());
+       }
+}

Need a way to disable apf from the guest kernel command line.

+
+static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
+                                   unsigned long action, void *hcpu)
+{
+       switch (action) {
+       case CPU_ONLINE:
+       case CPU_ONLINE_FROZEN:
+               kvm_guest_cpu_init();
+               break;
+       default:
+               break;

Should we disable apf if the cpu is dying here?

+       }
+       return NOTIFY_OK;
+}
+

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to