Re: [PATCH v2 02/12] Add PV MSR to enable asynchronous page faults delivery.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/23/2009 04:05 PM, Gleb Natapov wrote:
Signed-off-by: Gleb Natapov<gleb@xxxxxxxxxx>
---
  arch/x86/include/asm/kvm_host.h |    3 ++
  arch/x86/include/asm/kvm_para.h |    2 +
  arch/x86/kvm/x86.c              |   42 +++++++++++++++++++++++++++++++++++++-
  include/linux/kvm.h             |    1 +
  4 files changed, 46 insertions(+), 2 deletions(-)

  #define MSR_KVM_WALL_CLOCK  0x11
  #define MSR_KVM_SYSTEM_TIME 0x12
+#define MSR_KVM_ASYNC_PF_EN 0x13

Please use MSRs from the range 0x4b564dxx. The numbers below are reserved by Intel (and in fact used by the old Pentiums).

Need documentation for the new MSR, say in Documentation/kvm/msr.txt.

+static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)
+{
+	u64 gpa = data&  ~0x3f;
+	int offset = offset_in_page(gpa);
+	unsigned long addr;
+
+	addr = gfn_to_hva(vcpu->kvm, gpa>>  PAGE_SHIFT);
+	if (kvm_is_error_hva(addr))
+		return 1;
+
+	vcpu->arch.apf_data = (u32 __user*)(addr + offset);
+
+	/* check if address is mapped */
+	if (get_user(offset, vcpu->arch.apf_data)) {
+		vcpu->arch.apf_data = NULL;
+		return 1;
+	}

What if the memory slot arrangement changes? This needs to be revalidated (and gfn_to_hva() called again).

+	return 0;
+}
+
  int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
  {
  	switch (msr) {
@@ -1029,6 +1049,14 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
  		kvm_request_guest_time_update(vcpu);
  		break;
  	}
+	case MSR_KVM_ASYNC_PF_EN:
+		vcpu->arch.apf_msr_val = data;
+		if (data&  1) {
+			if (kvm_pv_enable_async_pf(vcpu, data))
+				return 1;

Need to check before setting the msr value, so subsequent reads return the old value.

+		} else
+			vcpu->arch.apf_data = NULL;

Need to check that bits 1:5 are zero. I think it's cleaner to move all of the code to kvm_pv_enable_async_pf(), to have everything in one place.


--
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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux