kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 0/2] qemu support for pvclock vsyscall
@ 2012-10-24 13:19 Marcelo Tosatti
  2012-10-24 13:19 ` [patch 1/2] kvm: sync kernel headers Marcelo Tosatti
  2012-10-24 13:19 ` [patch 2/2] kvm: x86: support pvclock userspace time msr Marcelo Tosatti
  0 siblings, 2 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2012-10-24 13:19 UTC (permalink / raw)
  To: kvm

$SUBJECT



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [patch 1/2] kvm: sync kernel headers
  2012-10-24 13:19 [patch 0/2] qemu support for pvclock vsyscall Marcelo Tosatti
@ 2012-10-24 13:19 ` Marcelo Tosatti
  2012-10-24 13:19 ` [patch 2/2] kvm: x86: support pvclock userspace time msr Marcelo Tosatti
  1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2012-10-24 13:19 UTC (permalink / raw)
  To: kvm; +Cc: Marcelo Tosatti

[-- Attachment #1: 00-update-linuxheader --]
[-- Type: text/plain, Size: 3265 bytes --]

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu-kvm-vsyscall/linux-headers/asm-x86/kvm_para.h
===================================================================
--- qemu-kvm-vsyscall.orig/linux-headers/asm-x86/kvm_para.h
+++ qemu-kvm-vsyscall/linux-headers/asm-x86/kvm_para.h
@@ -22,6 +22,8 @@
 #define KVM_FEATURE_CLOCKSOURCE2        3
 #define KVM_FEATURE_ASYNC_PF		4
 #define KVM_FEATURE_STEAL_TIME		5
+#define KVM_FEATURE_PV_EOI		6
+#define KVM_FEATURE_USERSPACE_CLOCKSOURCE 7
 
 /* The last 8 bits are used to indicate how to interpret the flags field
  * in pvclock structure. If no bits are set, all flags are ignored.
@@ -37,6 +39,8 @@
 #define MSR_KVM_SYSTEM_TIME_NEW 0x4b564d01
 #define MSR_KVM_ASYNC_PF_EN 0x4b564d02
 #define MSR_KVM_STEAL_TIME  0x4b564d03
+#define MSR_KVM_PV_EOI_EN      0x4b564d04
+#define MSR_KVM_USERSPACE_TIME      0x4b564d05
 
 struct kvm_steal_time {
 	__u64 steal;
@@ -89,5 +93,10 @@ struct kvm_vcpu_pv_apf_data {
 	__u32 enabled;
 };
 
+#define KVM_PV_EOI_BIT 0
+#define KVM_PV_EOI_MASK (0x1 << KVM_PV_EOI_BIT)
+#define KVM_PV_EOI_ENABLED KVM_PV_EOI_MASK
+#define KVM_PV_EOI_DISABLED 0x0
+
 
 #endif /* _ASM_X86_KVM_PARA_H */
Index: qemu-kvm-vsyscall/linux-headers/linux/kvm.h
===================================================================
--- qemu-kvm-vsyscall.orig/linux-headers/linux/kvm.h
+++ qemu-kvm-vsyscall/linux-headers/linux/kvm.h
@@ -101,9 +101,13 @@ struct kvm_userspace_memory_region {
 	__u64 userspace_addr; /* start of the userspace allocated memory */
 };
 
-/* for kvm_memory_region::flags */
-#define KVM_MEM_LOG_DIRTY_PAGES  1UL
-#define KVM_MEMSLOT_INVALID      (1UL << 1)
+/*
+ * The bit 0 ~ bit 15 of kvm_memory_region::flags are visible for userspace,
+ * other bits are reserved for kvm internal use which are defined in
+ * include/linux/kvm_host.h.
+ */
+#define KVM_MEM_LOG_DIRTY_PAGES	(1UL << 0)
+#define KVM_MEM_READONLY	(1UL << 1)
 
 /* for KVM_IRQ_LINE */
 struct kvm_irq_level {
@@ -617,6 +621,12 @@ struct kvm_ppc_smmu_info {
 #define KVM_CAP_SIGNAL_MSI 77
 #define KVM_CAP_PPC_GET_SMMU_INFO 78
 #define KVM_CAP_S390_COW 79
+#define KVM_CAP_PPC_ALLOC_HTAB 80
+#ifdef __KVM_HAVE_READONLY_MEM
+#define KVM_CAP_READONLY_MEM 81
+#endif
+#define KVM_CAP_IRQFD_RESAMPLE 82
+#define KVM_CAP_USERSPACE_CLOCKSOURCE 83
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
@@ -682,12 +692,21 @@ struct kvm_xen_hvm_config {
 #endif
 
 #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0)
+/*
+ * Available with KVM_CAP_IRQFD_RESAMPLE
+ *
+ * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies
+ * the irqfd to operate in resampling mode for level triggered interrupt
+ * emlation.  See Documentation/virtual/kvm/api.txt.
+ */
+#define KVM_IRQFD_FLAG_RESAMPLE (1 << 1)
 
 struct kvm_irqfd {
 	__u32 fd;
 	__u32 gsi;
 	__u32 flags;
-	__u8  pad[20];
+	__u32 resamplefd;
+	__u8  pad[16];
 };
 
 struct kvm_clock_data {
@@ -828,6 +847,8 @@ struct kvm_s390_ucas_mapping {
 #define KVM_SIGNAL_MSI            _IOW(KVMIO,  0xa5, struct kvm_msi)
 /* Available with KVM_CAP_PPC_GET_SMMU_INFO */
 #define KVM_PPC_GET_SMMU_INFO	  _IOR(KVMIO,  0xa6, struct kvm_ppc_smmu_info)
+/* Available with KVM_CAP_PPC_ALLOC_HTAB */
+#define KVM_PPC_ALLOCATE_HTAB	  _IOWR(KVMIO, 0xa7, __u32)
 
 /*
  * ioctls for vcpu fds



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [patch 2/2] kvm: x86: support pvclock userspace time msr
  2012-10-24 13:19 [patch 0/2] qemu support for pvclock vsyscall Marcelo Tosatti
  2012-10-24 13:19 ` [patch 1/2] kvm: sync kernel headers Marcelo Tosatti
@ 2012-10-24 13:19 ` Marcelo Tosatti
  1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2012-10-24 13:19 UTC (permalink / raw)
  To: kvm; +Cc: Marcelo Tosatti

[-- Attachment #1: 01-pvclock-pvsyscall-qemu --]
[-- Type: text/plain, Size: 4552 bytes --]

Save/restore MSR if enabled, name cpuid bit.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu-kvm-vsyscall/target-i386/cpu.h
===================================================================
--- qemu-kvm-vsyscall.orig/target-i386/cpu.h
+++ qemu-kvm-vsyscall/target-i386/cpu.h
@@ -700,6 +700,8 @@ typedef struct CPUX86State {
     uint64_t wall_clock_msr;
     uint64_t async_pf_en_msr;
 
+    uint64_t userspace_time_msr;
+
     uint64_t tsc;
     uint64_t tsc_deadline;
 
Index: qemu-kvm-vsyscall/target-i386/kvm.c
===================================================================
--- qemu-kvm-vsyscall.orig/target-i386/kvm.c
+++ qemu-kvm-vsyscall/target-i386/kvm.c
@@ -65,6 +65,7 @@ static bool has_msr_hsave_pa;
 static bool has_msr_tsc_deadline;
 static bool has_msr_async_pf_en;
 static bool has_msr_misc_enable;
+static bool has_msr_userspace_time;
 static int lm_capable_kernel;
 
 bool kvm_allows_irq0_override(void)
@@ -105,6 +106,7 @@ struct kvm_para_features {
     { KVM_CAP_NOP_IO_DELAY, KVM_FEATURE_NOP_IO_DELAY },
     { KVM_CAP_PV_MMU, KVM_FEATURE_MMU_OP },
     { KVM_CAP_ASYNC_PF, KVM_FEATURE_ASYNC_PF },
+    { KVM_CAP_USERSPACE_CLOCKSOURCE, KVM_FEATURE_USERSPACE_CLOCKSOURCE },
     { -1, -1 }
 };
 
@@ -455,6 +457,7 @@ int kvm_arch_init_vcpu(CPUX86State *env)
     }
 
     has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
+    has_msr_userspace_time = c->eax & (1 << KVM_FEATURE_USERSPACE_CLOCKSOURCE);
 
     cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);
 
@@ -1014,6 +1017,10 @@ static int kvm_put_msrs(CPUX86State *env
         kvm_msr_entry_set(&msrs[n++], MSR_KVM_SYSTEM_TIME,
                           env->system_time_msr);
         kvm_msr_entry_set(&msrs[n++], MSR_KVM_WALL_CLOCK, env->wall_clock_msr);
+        if (has_msr_userspace_time) {
+            kvm_msr_entry_set(&msrs[n++], MSR_KVM_USERSPACE_TIME,
+				         env->userspace_time_msr);
+        }
         if (has_msr_async_pf_en) {
             kvm_msr_entry_set(&msrs[n++], MSR_KVM_ASYNC_PF_EN,
                               env->async_pf_en_msr);
@@ -1260,6 +1267,9 @@ static int kvm_get_msrs(CPUX86State *env
     if (has_msr_async_pf_en) {
         msrs[n++].index = MSR_KVM_ASYNC_PF_EN;
     }
+    if (has_msr_userspace_time) {
+        msrs[n++].index = MSR_KVM_USERSPACE_TIME;
+    }
 
     if (env->mcg_cap) {
         msrs[n++].index = MSR_MCG_STATUS;
@@ -1339,6 +1349,9 @@ static int kvm_get_msrs(CPUX86State *env
         case MSR_KVM_ASYNC_PF_EN:
             env->async_pf_en_msr = msrs[i].data;
             break;
+        case MSR_KVM_USERSPACE_TIME:
+            env->userspace_time_msr = msrs[i].data;
+            break;
         }
     }
 
Index: qemu-kvm-vsyscall/target-i386/machine.c
===================================================================
--- qemu-kvm-vsyscall.orig/target-i386/machine.c
+++ qemu-kvm-vsyscall/target-i386/machine.c
@@ -346,6 +346,24 @@ static const VMStateDescription vmstate_
     }
 };
 
+static bool utime_needed(void *opaque)
+{
+    CPUX86State *env = opaque;
+
+    return env->userspace_time_msr != 0;
+}
+
+static const VMStateDescription vmstate_userspace_time_msr = {
+    .name = "cpu/userspace_time_msr",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields      = (VMStateField []) {
+        VMSTATE_UINT64(userspace_time_msr, CPUX86State),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static const VMStateDescription vmstate_cpu = {
     .name = "cpu",
     .version_id = CPU_SAVE_VERSION,
@@ -462,6 +480,9 @@ static const VMStateDescription vmstate_
         }, {
             .vmsd = &vmstate_msr_ia32_misc_enable,
             .needed = misc_enable_needed,
+        }, {
+            .vmsd = &vmstate_userspace_time_msr,
+            .needed = utime_needed,
         } , {
             /* empty */
         }
Index: qemu-kvm-vsyscall/target-i386/cpu.c
===================================================================
--- qemu-kvm-vsyscall.orig/target-i386/cpu.c
+++ qemu-kvm-vsyscall/target-i386/cpu.c
@@ -80,7 +80,7 @@ static const char *ext3_feature_name[] =
 };
 
 static const char *kvm_feature_name[] = {
-    "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock", "kvm_asyncpf", NULL, "kvm_pv_eoi", NULL,
+    "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock", "kvm_asyncpf", NULL, "kvm_pv_eoi", "kvm_userspace_clock",
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-24 13:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-24 13:19 [patch 0/2] qemu support for pvclock vsyscall Marcelo Tosatti
2012-10-24 13:19 ` [patch 1/2] kvm: sync kernel headers Marcelo Tosatti
2012-10-24 13:19 ` [patch 2/2] kvm: x86: support pvclock userspace time msr Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).