public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/7] Initial support for Microsoft Hyper-V
@ 2011-10-09 18:52 Vadim Rozenfeld
  2011-10-09 18:52 ` [RFC PATCH 1/7] [hyper-v] Add hyper-v parameters block Vadim Rozenfeld
                   ` (7 more replies)
  0 siblings, 8 replies; 24+ messages in thread
From: Vadim Rozenfeld @ 2011-10-09 18:52 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, Vadim Rozenfeld

Enable some basic Hyper-V enlightenment functionalites,
including relaxed timing, spinlock, and virtual APIC. 

Vadim Rozenfeld (7):
  [hyper-v] Add hyper-v parameters block.
  [hyper-v] add hyper-v placeholders.
  [hyper-v] make Hyper-V option configurable.
  [hyper-v] hyper-v parameters
  [hyper-v] hyper-v helper functions
  [hyper-v] parse hyper-v parameters.
  [hyper-v] init hyper-v cpuid leafs

 Makefile.target   |    1 +
 configure         |   11 +++++++++
 hyperv.c          |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 hyperv.h          |   19 ++++++++++++++++
 qemu-config.c     |   19 ++++++++++++++++
 qemu-config.h     |    1 +
 qemu-options.hx   |   23 +++++++++++++++++++
 target-i386/kvm.c |   53 +++++++++++++++++++++++++++++++++++++++++++-
 vl.c              |   12 ++++++++++
 9 files changed, 201 insertions(+), 1 deletions(-)
 create mode 100644 hyperv.c
 create mode 100644 hyperv.h

-- 
1.7.4.4


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

* [RFC PATCH 1/7] [hyper-v] Add hyper-v parameters block.
  2011-10-09 18:52 [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Vadim Rozenfeld
@ 2011-10-09 18:52 ` Vadim Rozenfeld
  2011-10-10  6:54   ` Jan Kiszka
  2011-10-11  7:35   ` Paolo Bonzini
  2011-10-09 18:52 ` [RFC PATCH 2/7] [hyper-v] add hyper-v placeholders Vadim Rozenfeld
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 24+ messages in thread
From: Vadim Rozenfeld @ 2011-10-09 18:52 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, Vadim Rozenfeld

---
 qemu-options.hx |   23 +++++++++++++++++++++++
 vl.c            |    2 ++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 3a13533..9f60059 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2483,6 +2483,29 @@ DEF("kvm-shadow-memory", HAS_ARG, QEMU_OPTION_kvm_shadow_memory,
     "                allocate MEGABYTES for kvm mmu shadowing\n",
     QEMU_ARCH_I386)
 
+DEF("hyperv", HAS_ARG, QEMU_OPTION_hyperv,
+    "-hyperv [vapic=on|off][,spinlock=retries][,wd=on|off]\n"
+    "                enable Hyper-V Enlightenment\n",
+        QEMU_ARCH_ALL)
+STEXI
+@item -hyperv 
+@findex -hyperv
+@item vapic=@var{vapic}
+@var{vapic} is "on" or "off" and allows for using virtual APIC.
+Default is "off".
+@findex vapic
+@item spinlock=@var{spinlock}
+@var{spinlock} is a recommended number of attempts to retry
+a spinlock failure befor notifying the hypervisor.
+Default is 0xFFFFFFFF (never to retry).
+@findex spinlock
+:@item wd=@var{wd}
+@var{wd} is "on" or "off" and recommends using relaxed timing.
+Default is "off"
+@findex wd
+Simulate Hyper-V Enlightenment. Disable by default.
+ETEXI
+
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
 @end table
diff --git a/vl.c b/vl.c
index b0358e9..a6d1fc0 100644
--- a/vl.c
+++ b/vl.c
@@ -3185,6 +3185,8 @@ int main(int argc, char **argv, char **envp)
                     fclose(fp);
                     break;
                 }
+            case QEMU_OPTION_hyperv:
+                break;
             default:
                 os_parse_cmd_args(popt->index, optarg);
             }
-- 
1.7.4.4


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

* [RFC PATCH 2/7] [hyper-v] add hyper-v placeholders.
  2011-10-09 18:52 [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Vadim Rozenfeld
  2011-10-09 18:52 ` [RFC PATCH 1/7] [hyper-v] Add hyper-v parameters block Vadim Rozenfeld
@ 2011-10-09 18:52 ` Vadim Rozenfeld
  2011-10-11  7:40   ` Paolo Bonzini
  2011-10-09 18:52 ` [RFC PATCH 3/7] [hyper-v] make Hyper-V option configurable Vadim Rozenfeld
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 24+ messages in thread
From: Vadim Rozenfeld @ 2011-10-09 18:52 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, Vadim Rozenfeld

---
 hyperv.c |    3 +++
 hyperv.h |   10 ++++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)
 create mode 100644 hyperv.c
 create mode 100644 hyperv.h

diff --git a/hyperv.c b/hyperv.c
new file mode 100644
index 0000000..968ce89
--- /dev/null
+++ b/hyperv.c
@@ -0,0 +1,3 @@
+#include "hyperv.h"
+#include "qemu-common.h"
+
diff --git a/hyperv.h b/hyperv.h
new file mode 100644
index 0000000..a15ba90
--- /dev/null
+++ b/hyperv.h
@@ -0,0 +1,10 @@
+#ifndef QEMU_HW_HYPERV_H
+#define QEMU_HW_HYPERV_H 1
+/*
+ * public hyper-v header
+ */
+
+#include <asm/hyperv.h>
+
+#endif /* QEMU_HW_HYPERV_H */
+
-- 
1.7.4.4


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

* [RFC PATCH 3/7] [hyper-v] make Hyper-V option configurable.
  2011-10-09 18:52 [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Vadim Rozenfeld
  2011-10-09 18:52 ` [RFC PATCH 1/7] [hyper-v] Add hyper-v parameters block Vadim Rozenfeld
  2011-10-09 18:52 ` [RFC PATCH 2/7] [hyper-v] add hyper-v placeholders Vadim Rozenfeld
@ 2011-10-09 18:52 ` Vadim Rozenfeld
  2011-10-10  6:54   ` Jan Kiszka
  2011-10-09 18:52 ` [RFC PATCH 4/7] [hyper-v] hyper-v parameters Vadim Rozenfeld
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 24+ messages in thread
From: Vadim Rozenfeld @ 2011-10-09 18:52 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, Vadim Rozenfeld

---
 Makefile.target |    1 +
 configure       |   11 +++++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index f84d8cb..3581480 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -199,6 +199,7 @@ obj-$(CONFIG_VHOST_NET) += vhost.o
 obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/virtio-9p-device.o
 obj-$(CONFIG_KVM) += kvm.o kvm-all.o
 obj-$(CONFIG_NO_KVM) += kvm-stub.o
+obj-$(CONFIG_HYPERV) += hyperv.o
 obj-y += memory.o
 LIBS+=-lz
 
diff --git a/configure b/configure
index 94c7d31..f5ecfd7 100755
--- a/configure
+++ b/configure
@@ -150,6 +150,7 @@ debug="no"
 strip_opt="yes"
 bigendian="no"
 mingw32="no"
+hyperv="no"
 EXESUF=""
 prefix="/usr/local"
 mandir="\${prefix}/share/man"
@@ -762,6 +763,10 @@ for opt do
   ;;
   --enable-vhost-net) vhost_net="yes"
   ;;
+  --disable-hyperv) hyperv="no"
+  ;;
+  --enable-hyperv) hyperv="yes"
+  ;;
   --disable-opengl) opengl="no"
   ;;
   --enable-opengl) opengl="yes"
@@ -1062,6 +1067,8 @@ echo "  --enable-docs            enable documentation build"
 echo "  --disable-docs           disable documentation build"
 echo "  --disable-vhost-net      disable vhost-net acceleration support"
 echo "  --enable-vhost-net       enable vhost-net acceleration support"
+echo "  --enable-hyperv          enable Hyper-V support"
+echo "  --disable-hyperv         disable Hyper-V support"
 echo "  --enable-trace-backend=B Set trace backend"
 echo "                           Available backends:" $("$source_path"/scripts/tracetool --list-backends)
 echo "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
@@ -2737,6 +2744,7 @@ echo "madvise           $madvise"
 echo "posix_madvise     $posix_madvise"
 echo "uuid support      $uuid"
 echo "vhost-net support $vhost_net"
+echo "Hyper-V support   $hyperv"
 echo "Trace backend     $trace_backend"
 echo "Trace output file $trace_file-<pid>"
 echo "spice support     $spice"
@@ -3424,6 +3432,9 @@ case "$target_arch2" in
       if test $kvm_cap_device_assignment = "yes" ; then
         echo "CONFIG_KVM_DEVICE_ASSIGNMENT=y" >> $config_target_mak
       fi
+      if test "$hyperv" = "yes" ; then
+        echo "CONFIG_HYPERV=y" >> $config_target_mak
+      fi
     fi
 esac
 if test "$target_bigendian" = "yes" ; then
-- 
1.7.4.4


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

* [RFC PATCH 4/7] [hyper-v] hyper-v parameters
  2011-10-09 18:52 [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Vadim Rozenfeld
                   ` (2 preceding siblings ...)
  2011-10-09 18:52 ` [RFC PATCH 3/7] [hyper-v] make Hyper-V option configurable Vadim Rozenfeld
@ 2011-10-09 18:52 ` Vadim Rozenfeld
  2011-10-09 18:52 ` [RFC PATCH 5/7] [hyper-v] hyper-v helper functions Vadim Rozenfeld
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: Vadim Rozenfeld @ 2011-10-09 18:52 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, Vadim Rozenfeld

---
 hyperv.c      |   16 ++++++++++++++++
 hyperv.h      |    2 ++
 qemu-config.c |   19 +++++++++++++++++++
 qemu-config.h |    1 +
 4 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/hyperv.c b/hyperv.c
index 968ce89..a17f879 100644
--- a/hyperv.c
+++ b/hyperv.c
@@ -1,3 +1,19 @@
 #include "hyperv.h"
 #include "qemu-common.h"
+#include "qemu-option.h"
+#include "qemu-config.h"
 
+void hyperv_init(void)
+{
+    QemuOpts *opts = QTAILQ_FIRST(&qemu_hyperv_opts.head);
+    
+    if (!opts) {
+        return;
+    }
+}
+
+static void hyperv_initialize(void)
+{
+    hyperv_init();
+}
+device_init(hyperv_initialize);
diff --git a/hyperv.h b/hyperv.h
index a15ba90..eaf974a 100644
--- a/hyperv.h
+++ b/hyperv.h
@@ -6,5 +6,7 @@
 
 #include <asm/hyperv.h>
 
+void hyperv_init(void);
+
 #endif /* QEMU_HW_HYPERV_H */
 
diff --git a/qemu-config.c b/qemu-config.c
index acab438..a1f9689 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -512,6 +512,24 @@ QemuOptsList qemu_boot_opts = {
     },
 };
 
+QemuOptsList qemu_hyperv_opts = {
+    .name = "hyperv",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_hyperv_opts.head),
+    .desc = {
+        {
+            .name = "vapic",
+            .type = QEMU_OPT_BOOL,
+        }, {
+            .name = "wd",
+            .type = QEMU_OPT_BOOL,
+        }, {
+            .name = "spinlock",
+            .type = QEMU_OPT_NUMBER,
+        },
+        { /* end of list */ }
+    },
+};
+
 static QemuOptsList *vm_config_groups[32] = {
     &qemu_drive_opts,
     &qemu_chardev_opts,
@@ -526,6 +544,7 @@ static QemuOptsList *vm_config_groups[32] = {
     &qemu_option_rom_opts,
     &qemu_machine_opts,
     &qemu_boot_opts,
+    &qemu_hyperv_opts,
     NULL,
 };
 
diff --git a/qemu-config.h b/qemu-config.h
index 20d707f..c7d57d4 100644
--- a/qemu-config.h
+++ b/qemu-config.h
@@ -4,6 +4,7 @@
 extern QemuOptsList qemu_fsdev_opts;
 extern QemuOptsList qemu_virtfs_opts;
 extern QemuOptsList qemu_spice_opts;
+extern QemuOptsList qemu_hyperv_opts;
 
 QemuOptsList *qemu_find_opts(const char *group);
 void qemu_add_opts(QemuOptsList *list);
-- 
1.7.4.4


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

* [RFC PATCH 5/7] [hyper-v] hyper-v helper functions
  2011-10-09 18:52 [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Vadim Rozenfeld
                   ` (3 preceding siblings ...)
  2011-10-09 18:52 ` [RFC PATCH 4/7] [hyper-v] hyper-v parameters Vadim Rozenfeld
@ 2011-10-09 18:52 ` Vadim Rozenfeld
  2011-10-09 19:01   ` Alon Levy
  2011-10-09 18:52 ` [RFC PATCH 6/7] [hyper-v] parse hyper-v parameters Vadim Rozenfeld
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 24+ messages in thread
From: Vadim Rozenfeld @ 2011-10-09 18:52 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, Vadim Rozenfeld

---
 hyperv.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 hyperv.h |    7 +++++++
 2 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/hyperv.c b/hyperv.c
index a17f879..57915b9 100644
--- a/hyperv.c
+++ b/hyperv.c
@@ -3,6 +3,10 @@
 #include "qemu-option.h"
 #include "qemu-config.h"
 
+static int hyperv_apic;
+static int hyperv_wd;
+static int hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
+
 void hyperv_init(void)
 {
     QemuOpts *opts = QTAILQ_FIRST(&qemu_hyperv_opts.head);
@@ -10,6 +14,46 @@ void hyperv_init(void)
     if (!opts) {
         return;
     }
+
+    hyperv_spinlock_attempts = qemu_opt_get_number(opts, "spinlock", 
+                                                   HYPERV_SPINLOCK_NEVER_RETRY
+                                                  );
+    hyperv_wd = qemu_opt_get_bool(opts, "wd", 0);
+    hyperv_apic = qemu_opt_get_bool(opts, "vapic", 0);
+
+}
+
+int hyperv_enabled(void)
+{
+    return hyperv_hypercall_available() | hyperv_relaxed_timing();
+}
+
+int hyperv_hypercall_available(void)
+{
+    if (hyperv_apic ||
+        (hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_RETRY)) {
+      return 1;
+    }
+    return 0;
+}
+
+int hyperv_relaxed_timing(void)
+{
+    return !hyperv_wd;
+}
+
+int hyperv_apic_recommended(void)
+{
+#ifdef KVM_CAP_IRQCHIP
+    return hyperv_apic;
+#else
+    return 0;
+#endif
+}
+
+int hyperv_spinlock_retries(void)
+{
+    return hyperv_spinlock_attempts;
 }
 
 static void hyperv_initialize(void)
diff --git a/hyperv.h b/hyperv.h
index eaf974a..27d2e6e 100644
--- a/hyperv.h
+++ b/hyperv.h
@@ -6,7 +6,14 @@
 
 #include <asm/hyperv.h>
 
+#define HYPERV_SPINLOCK_NEVER_RETRY             0xFFFFFFFF
+
 void hyperv_init(void);
+int hyperv_enabled(void);
+int hyperv_hypercall_available(void);
+int hyperv_relaxed_timing(void);
+int hyperv_apic_recommended(void);
+int hyperv_spinlock_retries(void);
 
 #endif /* QEMU_HW_HYPERV_H */
 
-- 
1.7.4.4


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

* [RFC PATCH 6/7] [hyper-v] parse hyper-v parameters.
  2011-10-09 18:52 [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Vadim Rozenfeld
                   ` (4 preceding siblings ...)
  2011-10-09 18:52 ` [RFC PATCH 5/7] [hyper-v] hyper-v helper functions Vadim Rozenfeld
@ 2011-10-09 18:52 ` Vadim Rozenfeld
  2011-10-09 18:52 ` [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs Vadim Rozenfeld
  2011-10-10  6:53 ` [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Jan Kiszka
  7 siblings, 0 replies; 24+ messages in thread
From: Vadim Rozenfeld @ 2011-10-09 18:52 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, Vadim Rozenfeld

---
 vl.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/vl.c b/vl.c
index a6d1fc0..d9d4547 100644
--- a/vl.c
+++ b/vl.c
@@ -3186,6 +3186,16 @@ int main(int argc, char **argv, char **envp)
                     break;
                 }
             case QEMU_OPTION_hyperv:
+                olist = qemu_find_opts("hyperv");
+                if (!olist) {
+                    fprintf(stderr, "Hyper-V is not supported by this qemu build.\n");
+                    exit(1);
+                }
+                opts = qemu_opts_parse(olist, optarg, 0);
+                if (!opts) {
+                    fprintf(stderr, "parse error: %s\n", optarg);
+                    exit(1);
+                }
                 break;
             default:
                 os_parse_cmd_args(popt->index, optarg);
-- 
1.7.4.4


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

* [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs
  2011-10-09 18:52 [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Vadim Rozenfeld
                   ` (5 preceding siblings ...)
  2011-10-09 18:52 ` [RFC PATCH 6/7] [hyper-v] parse hyper-v parameters Vadim Rozenfeld
@ 2011-10-09 18:52 ` Vadim Rozenfeld
  2011-10-11  7:38   ` Paolo Bonzini
  2011-10-10  6:53 ` [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Jan Kiszka
  7 siblings, 1 reply; 24+ messages in thread
From: Vadim Rozenfeld @ 2011-10-09 18:52 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, Vadim Rozenfeld

---
 target-i386/kvm.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 52 insertions(+), 1 deletions(-)

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 3840255..74fcc9a 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -29,6 +29,7 @@
 #include "hw/pc.h"
 #include "hw/apic.h"
 #include "ioport.h"
+#include "hyperv.h"
 
 //#define DEBUG_KVM
 
@@ -379,11 +380,21 @@ int kvm_arch_init_vcpu(CPUState *env)
     cpuid_i = 0;
 
     /* Paravirtualization CPUIDs */
-    memcpy(signature, "KVMKVMKVM\0\0\0", 12);
     c = &cpuid_data.entries[cpuid_i++];
     memset(c, 0, sizeof(*c));
     c->function = KVM_CPUID_SIGNATURE;
+#ifndef CONFIG_HYPERV
+    memcpy(signature, "KVMKVMKVM\0\0\0", 12);
     c->eax = 0;
+#else
+    if (!hyperv_enabled()) {
+        memcpy(signature, "KVMKVMKVM\0\0\0", 12);
+        c->eax = 0;
+    } else {
+        memcpy(signature, "Microsoft Hv", 12);
+        c->eax = HYPERV_CPUID_MIN;
+    }
+#endif
     c->ebx = signature[0];
     c->ecx = signature[1];
     c->edx = signature[2];
@@ -393,6 +404,46 @@ int kvm_arch_init_vcpu(CPUState *env)
     c->function = KVM_CPUID_FEATURES;
     c->eax = env->cpuid_kvm_features &
         kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX);
+#ifdef CONFIG_HYPERV
+    if (hyperv_enabled()) {
+        memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12);
+        c->eax = signature[0];
+
+        c = &cpuid_data.entries[cpuid_i++];
+        memset(c, 0, sizeof(*c));
+        c->function = HYPERV_CPUID_VERSION;
+        c->eax = 0x00001bbc;
+        c->ebx = 0x00060001;
+
+        c = &cpuid_data.entries[cpuid_i++];
+        memset(c, 0, sizeof(*c));
+        c->function = HYPERV_CPUID_FEATURES;
+        if (hyperv_relaxed_timing()) {
+            c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
+        }
+        if (hyperv_apic_recommended()) {
+            c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
+            c->eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE;
+        }
+
+        c = &cpuid_data.entries[cpuid_i++];
+        memset(c, 0, sizeof(*c));
+        c->function = HYPERV_CPUID_ENLIGHTMENT_INFO;
+        if (hyperv_relaxed_timing()) {
+            c->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;
+        }
+        if (hyperv_apic_recommended()) {
+            c->eax |= HV_X64_APIC_ACCESS_RECOMMENDED;
+        }
+        c->ebx = hyperv_spinlock_retries();
+
+        c = &cpuid_data.entries[cpuid_i++];
+        memset(c, 0, sizeof(*c));
+        c->function = HYPERV_CPUID_IMPLEMENT_LIMITS;
+        c->eax = 0x40;
+        c->ebx = 0x40;
+    }
+#endif
 
     has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
 
-- 
1.7.4.4


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

* Re: [RFC PATCH 5/7] [hyper-v] hyper-v helper functions
  2011-10-09 18:52 ` [RFC PATCH 5/7] [hyper-v] hyper-v helper functions Vadim Rozenfeld
@ 2011-10-09 19:01   ` Alon Levy
  2011-10-10  6:45     ` Vadim Rozenfeld
  0 siblings, 1 reply; 24+ messages in thread
From: Alon Levy @ 2011-10-09 19:01 UTC (permalink / raw)
  To: Vadim Rozenfeld; +Cc: kvm, Avi Kivity

On Sun, Oct 09, 2011 at 08:52:53PM +0200, Vadim Rozenfeld wrote:
> ---
>  hyperv.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
>  hyperv.h |    7 +++++++
>  2 files changed, 51 insertions(+), 0 deletions(-)
> 
> diff --git a/hyperv.c b/hyperv.c
> index a17f879..57915b9 100644
> --- a/hyperv.c
> +++ b/hyperv.c
> @@ -3,6 +3,10 @@
>  #include "qemu-option.h"
>  #include "qemu-config.h"
>  
> +static int hyperv_apic;
> +static int hyperv_wd;
> +static int hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
> +
>  void hyperv_init(void)
>  {
>      QemuOpts *opts = QTAILQ_FIRST(&qemu_hyperv_opts.head);
> @@ -10,6 +14,46 @@ void hyperv_init(void)
>      if (!opts) {
>          return;
>      }
> +
> +    hyperv_spinlock_attempts = qemu_opt_get_number(opts, "spinlock", 
> +                                                   HYPERV_SPINLOCK_NEVER_RETRY
> +                                                  );
> +    hyperv_wd = qemu_opt_get_bool(opts, "wd", 0);
> +    hyperv_apic = qemu_opt_get_bool(opts, "vapic", 0);
> +
> +}
> +
> +int hyperv_enabled(void)
> +{
> +    return hyperv_hypercall_available() | hyperv_relaxed_timing();
Shouldn't this be a logical or?

> +}
> +
> +int hyperv_hypercall_available(void)
> +{
> +    if (hyperv_apic ||
> +        (hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_RETRY)) {
> +      return 1;
> +    }
> +    return 0;
> +}
> +
> +int hyperv_relaxed_timing(void)
> +{
> +    return !hyperv_wd;
> +}
> +
> +int hyperv_apic_recommended(void)
> +{
> +#ifdef KVM_CAP_IRQCHIP
> +    return hyperv_apic;
> +#else
> +    return 0;
> +#endif
> +}
> +
> +int hyperv_spinlock_retries(void)
> +{
> +    return hyperv_spinlock_attempts;
>  }
>  
>  static void hyperv_initialize(void)
> diff --git a/hyperv.h b/hyperv.h
> index eaf974a..27d2e6e 100644
> --- a/hyperv.h
> +++ b/hyperv.h
> @@ -6,7 +6,14 @@
>  
>  #include <asm/hyperv.h>
>  
> +#define HYPERV_SPINLOCK_NEVER_RETRY             0xFFFFFFFF
> +
>  void hyperv_init(void);
> +int hyperv_enabled(void);
> +int hyperv_hypercall_available(void);
> +int hyperv_relaxed_timing(void);
> +int hyperv_apic_recommended(void);
> +int hyperv_spinlock_retries(void);
>  
>  #endif /* QEMU_HW_HYPERV_H */
>  
> -- 
> 1.7.4.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [RFC PATCH 5/7] [hyper-v] hyper-v helper functions
  2011-10-09 19:01   ` Alon Levy
@ 2011-10-10  6:45     ` Vadim Rozenfeld
  0 siblings, 0 replies; 24+ messages in thread
From: Vadim Rozenfeld @ 2011-10-10  6:45 UTC (permalink / raw)
  To: Alon Levy; +Cc: kvm, Avi Kivity

On Sun, 2011-10-09 at 21:01 +0200, Alon Levy wrote:
> On Sun, Oct 09, 2011 at 08:52:53PM +0200, Vadim Rozenfeld wrote:
> > ---
> >  hyperv.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
> >  hyperv.h |    7 +++++++
> >  2 files changed, 51 insertions(+), 0 deletions(-)
> > 
> > diff --git a/hyperv.c b/hyperv.c
> > index a17f879..57915b9 100644
> > --- a/hyperv.c
> > +++ b/hyperv.c
> > @@ -3,6 +3,10 @@
> >  #include "qemu-option.h"
> >  #include "qemu-config.h"
> >  
> > +static int hyperv_apic;
> > +static int hyperv_wd;
> > +static int hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
> > +
> >  void hyperv_init(void)
> >  {
> >      QemuOpts *opts = QTAILQ_FIRST(&qemu_hyperv_opts.head);
> > @@ -10,6 +14,46 @@ void hyperv_init(void)
> >      if (!opts) {
> >          return;
> >      }
> > +
> > +    hyperv_spinlock_attempts = qemu_opt_get_number(opts, "spinlock", 
> > +                                                   HYPERV_SPINLOCK_NEVER_RETRY
> > +                                                  );
> > +    hyperv_wd = qemu_opt_get_bool(opts, "wd", 0);
> > +    hyperv_apic = qemu_opt_get_bool(opts, "vapic", 0);
> > +
> > +}
> > +
> > +int hyperv_enabled(void)
> > +{
> > +    return hyperv_hypercall_available() | hyperv_relaxed_timing();
> Shouldn't this be a logical or?
Sure, thanks.
> 
> > +}
> > +
> > +int hyperv_hypercall_available(void)
> > +{
> > +    if (hyperv_apic ||
> > +        (hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_RETRY)) {
> > +      return 1;
> > +    }
> > +    return 0;
> > +}
> > +
> > +int hyperv_relaxed_timing(void)
> > +{
> > +    return !hyperv_wd;
> > +}
> > +
> > +int hyperv_apic_recommended(void)
> > +{
> > +#ifdef KVM_CAP_IRQCHIP
> > +    return hyperv_apic;
> > +#else
> > +    return 0;
> > +#endif
> > +}
> > +
> > +int hyperv_spinlock_retries(void)
> > +{
> > +    return hyperv_spinlock_attempts;
> >  }
> >  
> >  static void hyperv_initialize(void)
> > diff --git a/hyperv.h b/hyperv.h
> > index eaf974a..27d2e6e 100644
> > --- a/hyperv.h
> > +++ b/hyperv.h
> > @@ -6,7 +6,14 @@
> >  
> >  #include <asm/hyperv.h>
> >  
> > +#define HYPERV_SPINLOCK_NEVER_RETRY             0xFFFFFFFF
> > +
> >  void hyperv_init(void);
> > +int hyperv_enabled(void);
> > +int hyperv_hypercall_available(void);
> > +int hyperv_relaxed_timing(void);
> > +int hyperv_apic_recommended(void);
> > +int hyperv_spinlock_retries(void);
> >  
> >  #endif /* QEMU_HW_HYPERV_H */
> >  
> > -- 
> > 1.7.4.4
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe kvm" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



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

* Re: [RFC PATCH 0/7] Initial support for Microsoft Hyper-V
  2011-10-09 18:52 [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Vadim Rozenfeld
                   ` (6 preceding siblings ...)
  2011-10-09 18:52 ` [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs Vadim Rozenfeld
@ 2011-10-10  6:53 ` Jan Kiszka
  2011-10-10  9:39   ` Vadim Rozenfeld
  7 siblings, 1 reply; 24+ messages in thread
From: Jan Kiszka @ 2011-10-10  6:53 UTC (permalink / raw)
  To: Vadim Rozenfeld; +Cc: kvm, Avi Kivity

[-- Attachment #1: Type: text/plain, Size: 402 bytes --]

On 2011-10-09 20:52, Vadim Rozenfeld wrote:
> Enable some basic Hyper-V enlightenment functionalites,
> including relaxed timing, spinlock, and virtual APIC. 

This targets uq/master, correct? Then you should CC qemu-devel on the
next round.

I think this series could also be distributed over 3 or 4 patches
without loosing bisectability. And please spend a bit time on commit logs.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

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

* Re: [RFC PATCH 1/7] [hyper-v] Add hyper-v parameters block.
  2011-10-09 18:52 ` [RFC PATCH 1/7] [hyper-v] Add hyper-v parameters block Vadim Rozenfeld
@ 2011-10-10  6:54   ` Jan Kiszka
  2011-10-10  9:40     ` Vadim Rozenfeld
  2011-10-11  7:35   ` Paolo Bonzini
  1 sibling, 1 reply; 24+ messages in thread
From: Jan Kiszka @ 2011-10-10  6:54 UTC (permalink / raw)
  To: Vadim Rozenfeld; +Cc: kvm, Avi Kivity

[-- Attachment #1: Type: text/plain, Size: 962 bytes --]

On 2011-10-09 20:52, Vadim Rozenfeld wrote:
> ---
>  qemu-options.hx |   23 +++++++++++++++++++++++
>  vl.c            |    2 ++
>  2 files changed, 25 insertions(+), 0 deletions(-)
> 
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 3a13533..9f60059 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2483,6 +2483,29 @@ DEF("kvm-shadow-memory", HAS_ARG, QEMU_OPTION_kvm_shadow_memory,
>      "                allocate MEGABYTES for kvm mmu shadowing\n",
>      QEMU_ARCH_I386)
>  
> +DEF("hyperv", HAS_ARG, QEMU_OPTION_hyperv,
> +    "-hyperv [vapic=on|off][,spinlock=retries][,wd=on|off]\n"
> +    "                enable Hyper-V Enlightenment\n",
> +        QEMU_ARCH_ALL)

These are CPU feature, so -cpu +/-hv_vapic,+/-hv_spinlock etc. looks
more appropriate than a new command line parameter.

BTW, documentation and maybe also option processing should make clear
that this is limited to KVM mode for now.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

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

* Re: [RFC PATCH 3/7] [hyper-v] make Hyper-V option configurable.
  2011-10-09 18:52 ` [RFC PATCH 3/7] [hyper-v] make Hyper-V option configurable Vadim Rozenfeld
@ 2011-10-10  6:54   ` Jan Kiszka
  0 siblings, 0 replies; 24+ messages in thread
From: Jan Kiszka @ 2011-10-10  6:54 UTC (permalink / raw)
  To: Vadim Rozenfeld; +Cc: kvm, Avi Kivity

[-- Attachment #1: Type: text/plain, Size: 2714 bytes --]

On 2011-10-09 20:52, Vadim Rozenfeld wrote:
> ---
>  Makefile.target |    1 +
>  configure       |   11 +++++++++++
>  2 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/Makefile.target b/Makefile.target
> index f84d8cb..3581480 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -199,6 +199,7 @@ obj-$(CONFIG_VHOST_NET) += vhost.o
>  obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/virtio-9p-device.o
>  obj-$(CONFIG_KVM) += kvm.o kvm-all.o
>  obj-$(CONFIG_NO_KVM) += kvm-stub.o
> +obj-$(CONFIG_HYPERV) += hyperv.o
>  obj-y += memory.o
>  LIBS+=-lz
>  
> diff --git a/configure b/configure
> index 94c7d31..f5ecfd7 100755
> --- a/configure
> +++ b/configure
> @@ -150,6 +150,7 @@ debug="no"
>  strip_opt="yes"
>  bigendian="no"
>  mingw32="no"
> +hyperv="no"
>  EXESUF=""
>  prefix="/usr/local"
>  mandir="\${prefix}/share/man"
> @@ -762,6 +763,10 @@ for opt do
>    ;;
>    --enable-vhost-net) vhost_net="yes"
>    ;;
> +  --disable-hyperv) hyperv="no"
> +  ;;
> +  --enable-hyperv) hyperv="yes"
> +  ;;
>    --disable-opengl) opengl="no"
>    ;;
>    --enable-opengl) opengl="yes"
> @@ -1062,6 +1067,8 @@ echo "  --enable-docs            enable documentation build"
>  echo "  --disable-docs           disable documentation build"
>  echo "  --disable-vhost-net      disable vhost-net acceleration support"
>  echo "  --enable-vhost-net       enable vhost-net acceleration support"
> +echo "  --enable-hyperv          enable Hyper-V support"
> +echo "  --disable-hyperv         disable Hyper-V support"
>  echo "  --enable-trace-backend=B Set trace backend"
>  echo "                           Available backends:" $("$source_path"/scripts/tracetool --list-backends)
>  echo "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
> @@ -2737,6 +2744,7 @@ echo "madvise           $madvise"
>  echo "posix_madvise     $posix_madvise"
>  echo "uuid support      $uuid"
>  echo "vhost-net support $vhost_net"
> +echo "Hyper-V support   $hyperv"
>  echo "Trace backend     $trace_backend"
>  echo "Trace output file $trace_file-<pid>"
>  echo "spice support     $spice"
> @@ -3424,6 +3432,9 @@ case "$target_arch2" in
>        if test $kvm_cap_device_assignment = "yes" ; then
>          echo "CONFIG_KVM_DEVICE_ASSIGNMENT=y" >> $config_target_mak
>        fi
> +      if test "$hyperv" = "yes" ; then
> +        echo "CONFIG_HYPERV=y" >> $config_target_mak
> +      fi
>      fi
>  esac
>  if test "$target_bigendian" = "yes" ; then

Why do I want to --disable-hyperv? It rather looks like we could
perfectly live with this feature built by default. Would also allow to
drop the nasty #ifdefs from the code.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

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

* Re: [RFC PATCH 0/7] Initial support for Microsoft Hyper-V
  2011-10-10  6:53 ` [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Jan Kiszka
@ 2011-10-10  9:39   ` Vadim Rozenfeld
  0 siblings, 0 replies; 24+ messages in thread
From: Vadim Rozenfeld @ 2011-10-10  9:39 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: kvm, Avi Kivity

On Mon, 2011-10-10 at 08:53 +0200, Jan Kiszka wrote:
> On 2011-10-09 20:52, Vadim Rozenfeld wrote:
> > Enable some basic Hyper-V enlightenment functionalites,
> > including relaxed timing, spinlock, and virtual APIC. 
> 
> This targets uq/master, correct? Then you should CC qemu-devel on the
> next round.
> 
> I think this series could also be distributed over 3 or 4 patches
> without loosing bisectability. And please spend a bit time on commit logs.
> 
OK.
> Jan
> 



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

* Re: [RFC PATCH 1/7] [hyper-v] Add hyper-v parameters block.
  2011-10-10  6:54   ` Jan Kiszka
@ 2011-10-10  9:40     ` Vadim Rozenfeld
  2011-10-10 10:25       ` Jan Kiszka
  0 siblings, 1 reply; 24+ messages in thread
From: Vadim Rozenfeld @ 2011-10-10  9:40 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: kvm, Avi Kivity

On Mon, 2011-10-10 at 08:54 +0200, Jan Kiszka wrote:
> On 2011-10-09 20:52, Vadim Rozenfeld wrote:
> > ---
> >  qemu-options.hx |   23 +++++++++++++++++++++++
> >  vl.c            |    2 ++
> >  2 files changed, 25 insertions(+), 0 deletions(-)
> > 
> > diff --git a/qemu-options.hx b/qemu-options.hx
> > index 3a13533..9f60059 100644
> > --- a/qemu-options.hx
> > +++ b/qemu-options.hx
> > @@ -2483,6 +2483,29 @@ DEF("kvm-shadow-memory", HAS_ARG, QEMU_OPTION_kvm_shadow_memory,
> >      "                allocate MEGABYTES for kvm mmu shadowing\n",
> >      QEMU_ARCH_I386)
> >  
> > +DEF("hyperv", HAS_ARG, QEMU_OPTION_hyperv,
> > +    "-hyperv [vapic=on|off][,spinlock=retries][,wd=on|off]\n"
> > +    "                enable Hyper-V Enlightenment\n",
> > +        QEMU_ARCH_ALL)
> 
> These are CPU feature, so -cpu +/-hv_vapic,+/-hv_spinlock etc. looks
> more appropriate than a new command line parameter.
> 
I would like to keep hyper-v settings apart from cpu features for a very
simple reason: if hyper-v VMBus support will be added one day, it won't
be a CPU only feature anymore.   
> BTW, documentation and maybe also option processing should make clear
> that this is limited to KVM mode for now.
> 
Will add it.
Vadim
> Jan
> 



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

* Re: [RFC PATCH 1/7] [hyper-v] Add hyper-v parameters block.
  2011-10-10  9:40     ` Vadim Rozenfeld
@ 2011-10-10 10:25       ` Jan Kiszka
  0 siblings, 0 replies; 24+ messages in thread
From: Jan Kiszka @ 2011-10-10 10:25 UTC (permalink / raw)
  To: Vadim Rozenfeld; +Cc: kvm, Avi Kivity

On 2011-10-10 11:40, Vadim Rozenfeld wrote:
> On Mon, 2011-10-10 at 08:54 +0200, Jan Kiszka wrote:
>> On 2011-10-09 20:52, Vadim Rozenfeld wrote:
>>> ---
>>>  qemu-options.hx |   23 +++++++++++++++++++++++
>>>  vl.c            |    2 ++
>>>  2 files changed, 25 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/qemu-options.hx b/qemu-options.hx
>>> index 3a13533..9f60059 100644
>>> --- a/qemu-options.hx
>>> +++ b/qemu-options.hx
>>> @@ -2483,6 +2483,29 @@ DEF("kvm-shadow-memory", HAS_ARG, QEMU_OPTION_kvm_shadow_memory,
>>>      "                allocate MEGABYTES for kvm mmu shadowing\n",
>>>      QEMU_ARCH_I386)
>>>  
>>> +DEF("hyperv", HAS_ARG, QEMU_OPTION_hyperv,
>>> +    "-hyperv [vapic=on|off][,spinlock=retries][,wd=on|off]\n"
>>> +    "                enable Hyper-V Enlightenment\n",
>>> +        QEMU_ARCH_ALL)
>>
>> These are CPU feature, so -cpu +/-hv_vapic,+/-hv_spinlock etc. looks
>> more appropriate than a new command line parameter.
>>
> I would like to keep hyper-v settings apart from cpu features for a very
> simple reason: if hyper-v VMBus support will be added one day, it won't
> be a CPU only feature anymore.   

Then that feature would be controlled by adding the corresponding
device. There is no need for -hyperv.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

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

* Re: [RFC PATCH 1/7] [hyper-v] Add hyper-v parameters block.
  2011-10-09 18:52 ` [RFC PATCH 1/7] [hyper-v] Add hyper-v parameters block Vadim Rozenfeld
  2011-10-10  6:54   ` Jan Kiszka
@ 2011-10-11  7:35   ` Paolo Bonzini
  2011-10-11  7:42     ` Paolo Bonzini
  1 sibling, 1 reply; 24+ messages in thread
From: Paolo Bonzini @ 2011-10-11  7:35 UTC (permalink / raw)
  To: Vadim Rozenfeld; +Cc: kvm, Avi Kivity

On 10/09/2011 08:52 PM, Vadim Rozenfeld wrote:
> ---
>   qemu-options.hx |   23 +++++++++++++++++++++++
>   vl.c            |    2 ++
>   2 files changed, 25 insertions(+), 0 deletions(-)
>
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 3a13533..9f60059 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2483,6 +2483,29 @@ DEF("kvm-shadow-memory", HAS_ARG, QEMU_OPTION_kvm_shadow_memory,
>       "                allocate MEGABYTES for kvm mmu shadowing\n",
>       QEMU_ARCH_I386)
>
> +DEF("hyperv", HAS_ARG, QEMU_OPTION_hyperv,
> +    "-hyperv [vapic=on|off][,spinlock=retries][,wd=on|off]\n"
> +    "                enable Hyper-V Enlightenment\n",
> +        QEMU_ARCH_ALL)
> +STEXI
> +@item -hyperv
> +@findex -hyperv
> +@item vapic=@var{vapic}
> +@var{vapic} is "on" or "off" and allows for using virtual APIC.
> +Default is "off".
> +@findex vapic
> +@item spinlock=@var{spinlock}
> +@var{spinlock} is a recommended number of attempts to retry
> +a spinlock failure befor notifying the hypervisor.
> +Default is 0xFFFFFFFF (never to retry).
> +@findex spinlock
> +:@item wd=@var{wd}
> +@var{wd} is "on" or "off" and recommends using relaxed timing.
> +Default is "off"
> +@findex wd
> +Simulate Hyper-V Enlightenment. Disable by default.
> +ETEXI
> +
>   HXCOMM This is the last statement. Insert new options before this line!
>   STEXI
>   @end table
> diff --git a/vl.c b/vl.c
> index b0358e9..a6d1fc0 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3185,6 +3185,8 @@ int main(int argc, char **argv, char **envp)
>                       fclose(fp);
>                       break;
>                   }
> +            case QEMU_OPTION_hyperv:
> +                break;
>               default:
>                   os_parse_cmd_args(popt->index, optarg);
>               }

I think these could be sub-options of -machine.

Paolo

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

* Re: [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs
  2011-10-09 18:52 ` [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs Vadim Rozenfeld
@ 2011-10-11  7:38   ` Paolo Bonzini
  2011-10-11 13:46     ` Vadim Rozenfeld
  0 siblings, 1 reply; 24+ messages in thread
From: Paolo Bonzini @ 2011-10-11  7:38 UTC (permalink / raw)
  To: Vadim Rozenfeld; +Cc: kvm, Avi Kivity

On 10/09/2011 08:52 PM, Vadim Rozenfeld wrote:
> ---
>   target-i386/kvm.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 files changed, 52 insertions(+), 1 deletions(-)
>
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 3840255..74fcc9a 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -29,6 +29,7 @@
>   #include "hw/pc.h"
>   #include "hw/apic.h"
>   #include "ioport.h"
> +#include "hyperv.h"
>
>   //#define DEBUG_KVM
>
> @@ -379,11 +380,21 @@ int kvm_arch_init_vcpu(CPUState *env)
>       cpuid_i = 0;
>
>       /* Paravirtualization CPUIDs */
> -    memcpy(signature, "KVMKVMKVM\0\0\0", 12);

These should not be KVM-specific.  You should be able to add 
enlightenments to a TCG VM.  At the same time, the KVM leaves could be 
moved to 0x40000100 when enlightenments are active, similar to what Xen 
does.

Paolo

>       c =&cpuid_data.entries[cpuid_i++];
>       memset(c, 0, sizeof(*c));
>       c->function = KVM_CPUID_SIGNATURE;
> +#ifndef CONFIG_HYPERV
> +    memcpy(signature, "KVMKVMKVM\0\0\0", 12);
>       c->eax = 0;
> +#else
> +    if (!hyperv_enabled()) {
> +        memcpy(signature, "KVMKVMKVM\0\0\0", 12);
> +        c->eax = 0;
> +    } else {
> +        memcpy(signature, "Microsoft Hv", 12);
> +        c->eax = HYPERV_CPUID_MIN;
> +    }
> +#endif
>       c->ebx = signature[0];
>       c->ecx = signature[1];
>       c->edx = signature[2];
> @@ -393,6 +404,46 @@ int kvm_arch_init_vcpu(CPUState *env)
>       c->function = KVM_CPUID_FEATURES;
>       c->eax = env->cpuid_kvm_features&
>           kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX);
> +#ifdef CONFIG_HYPERV
> +    if (hyperv_enabled()) {
> +        memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12);
> +        c->eax = signature[0];
> +
> +        c =&cpuid_data.entries[cpuid_i++];
> +        memset(c, 0, sizeof(*c));
> +        c->function = HYPERV_CPUID_VERSION;
> +        c->eax = 0x00001bbc;
> +        c->ebx = 0x00060001;
> +
> +        c =&cpuid_data.entries[cpuid_i++];
> +        memset(c, 0, sizeof(*c));
> +        c->function = HYPERV_CPUID_FEATURES;
> +        if (hyperv_relaxed_timing()) {
> +            c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
> +        }
> +        if (hyperv_apic_recommended()) {
> +            c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
> +            c->eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE;
> +        }
> +
> +        c =&cpuid_data.entries[cpuid_i++];
> +        memset(c, 0, sizeof(*c));
> +        c->function = HYPERV_CPUID_ENLIGHTMENT_INFO;
> +        if (hyperv_relaxed_timing()) {
> +            c->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;
> +        }
> +        if (hyperv_apic_recommended()) {
> +            c->eax |= HV_X64_APIC_ACCESS_RECOMMENDED;
> +        }
> +        c->ebx = hyperv_spinlock_retries();
> +
> +        c =&cpuid_data.entries[cpuid_i++];
> +        memset(c, 0, sizeof(*c));
> +        c->function = HYPERV_CPUID_IMPLEMENT_LIMITS;
> +        c->eax = 0x40;
> +        c->ebx = 0x40;
> +    }
> +#endif
>
>       has_msr_async_pf_en = c->eax&  (1<<  KVM_FEATURE_ASYNC_PF);
>


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

* Re: [RFC PATCH 2/7] [hyper-v] add hyper-v placeholders.
  2011-10-09 18:52 ` [RFC PATCH 2/7] [hyper-v] add hyper-v placeholders Vadim Rozenfeld
@ 2011-10-11  7:40   ` Paolo Bonzini
  0 siblings, 0 replies; 24+ messages in thread
From: Paolo Bonzini @ 2011-10-11  7:40 UTC (permalink / raw)
  To: Vadim Rozenfeld; +Cc: kvm, Avi Kivity

On 10/09/2011 08:52 PM, Vadim Rozenfeld wrote:
> ---
>   hyperv.c |    3 +++
>   hyperv.h |   10 ++++++++++

Please move these to target-i386, and add a license header.

Also, I don't think it is necessary to add a new configure option; just 
leave it enabled by default and add CONFIG_HYPERV=y to 
default-configs/i386-softmmu.mak and default-configs/x86_64-softmmu.mak.

Paolo

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

* Re: [RFC PATCH 1/7] [hyper-v] Add hyper-v parameters block.
  2011-10-11  7:35   ` Paolo Bonzini
@ 2011-10-11  7:42     ` Paolo Bonzini
  0 siblings, 0 replies; 24+ messages in thread
From: Paolo Bonzini @ 2011-10-11  7:42 UTC (permalink / raw)
  Cc: Vadim Rozenfeld, kvm, Avi Kivity

On 10/11/2011 09:35 AM, Paolo Bonzini wrote:
>
> I think these could be sub-options of -machine.

Oops, I obviously meant -cpu like Jan said.

Paolo

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

* Re: [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs
  2011-10-11  7:38   ` Paolo Bonzini
@ 2011-10-11 13:46     ` Vadim Rozenfeld
  2011-10-11 15:52       ` Paolo Bonzini
  0 siblings, 1 reply; 24+ messages in thread
From: Vadim Rozenfeld @ 2011-10-11 13:46 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Avi Kivity

On Tue, 2011-10-11 at 09:38 +0200, Paolo Bonzini wrote:
> On 10/09/2011 08:52 PM, Vadim Rozenfeld wrote:
> > ---
> >   target-i386/kvm.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
> >   1 files changed, 52 insertions(+), 1 deletions(-)
> >
> > diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> > index 3840255..74fcc9a 100644
> > --- a/target-i386/kvm.c
> > +++ b/target-i386/kvm.c
> > @@ -29,6 +29,7 @@
> >   #include "hw/pc.h"
> >   #include "hw/apic.h"
> >   #include "ioport.h"
> > +#include "hyperv.h"
> >
> >   //#define DEBUG_KVM
> >
> > @@ -379,11 +380,21 @@ int kvm_arch_init_vcpu(CPUState *env)
> >       cpuid_i = 0;
> >
> >       /* Paravirtualization CPUIDs */
> > -    memcpy(signature, "KVMKVMKVM\0\0\0", 12);
> 
> These should not be KVM-specific.  You should be able to add 
> enlightenments to a TCG VM.  At the same time, the KVM leaves could be 
> moved to 0x40000100 when enlightenments are active, similar to what Xen 
> does.
> 

IMO, adding Hyper-V features without KVM support has little, if any,
meaning. Relaxed timing is the only one thing, which can be activated
without help from hypervisor.
    
> Paolo
> 
> >       c =&cpuid_data.entries[cpuid_i++];
> >       memset(c, 0, sizeof(*c));
> >       c->function = KVM_CPUID_SIGNATURE;
> > +#ifndef CONFIG_HYPERV
> > +    memcpy(signature, "KVMKVMKVM\0\0\0", 12);
> >       c->eax = 0;
> > +#else
> > +    if (!hyperv_enabled()) {
> > +        memcpy(signature, "KVMKVMKVM\0\0\0", 12);
> > +        c->eax = 0;
> > +    } else {
> > +        memcpy(signature, "Microsoft Hv", 12);
> > +        c->eax = HYPERV_CPUID_MIN;
> > +    }
> > +#endif
> >       c->ebx = signature[0];
> >       c->ecx = signature[1];
> >       c->edx = signature[2];
> > @@ -393,6 +404,46 @@ int kvm_arch_init_vcpu(CPUState *env)
> >       c->function = KVM_CPUID_FEATURES;
> >       c->eax = env->cpuid_kvm_features&
> >           kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX);
> > +#ifdef CONFIG_HYPERV
> > +    if (hyperv_enabled()) {
> > +        memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12);
> > +        c->eax = signature[0];
> > +
> > +        c =&cpuid_data.entries[cpuid_i++];
> > +        memset(c, 0, sizeof(*c));
> > +        c->function = HYPERV_CPUID_VERSION;
> > +        c->eax = 0x00001bbc;
> > +        c->ebx = 0x00060001;
> > +
> > +        c =&cpuid_data.entries[cpuid_i++];
> > +        memset(c, 0, sizeof(*c));
> > +        c->function = HYPERV_CPUID_FEATURES;
> > +        if (hyperv_relaxed_timing()) {
> > +            c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
> > +        }
> > +        if (hyperv_apic_recommended()) {
> > +            c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
> > +            c->eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE;
> > +        }
> > +
> > +        c =&cpuid_data.entries[cpuid_i++];
> > +        memset(c, 0, sizeof(*c));
> > +        c->function = HYPERV_CPUID_ENLIGHTMENT_INFO;
> > +        if (hyperv_relaxed_timing()) {
> > +            c->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;
> > +        }
> > +        if (hyperv_apic_recommended()) {
> > +            c->eax |= HV_X64_APIC_ACCESS_RECOMMENDED;
> > +        }
> > +        c->ebx = hyperv_spinlock_retries();
> > +
> > +        c =&cpuid_data.entries[cpuid_i++];
> > +        memset(c, 0, sizeof(*c));
> > +        c->function = HYPERV_CPUID_IMPLEMENT_LIMITS;
> > +        c->eax = 0x40;
> > +        c->ebx = 0x40;
> > +    }
> > +#endif
> >
> >       has_msr_async_pf_en = c->eax&  (1<<  KVM_FEATURE_ASYNC_PF);
> >
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



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

* Re: [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs
  2011-10-11 13:46     ` Vadim Rozenfeld
@ 2011-10-11 15:52       ` Paolo Bonzini
  2011-10-11 16:09         ` Vadim Rozenfeld
  0 siblings, 1 reply; 24+ messages in thread
From: Paolo Bonzini @ 2011-10-11 15:52 UTC (permalink / raw)
  To: Vadim Rozenfeld; +Cc: kvm, Avi Kivity

On 10/11/2011 03:46 PM, Vadim Rozenfeld wrote:
> >  These should not be KVM-specific.  You should be able to add
> >  enlightenments to a TCG VM.  At the same time, the KVM leaves could be
> >  moved to 0x40000100 when enlightenments are active, similar to what Xen
> >  does.
> >
>
> IMO, adding Hyper-V features without KVM support has little, if any,
> meaning. Relaxed timing is the only one thing, which can be activated
> without help from hypervisor.

Spinlocks too.  TCG does its own round-robin scheduling, so having zero 
retries could be the best setting.  But even if it is not useful for 
TCG, there's nothing KVM-specific, and that's the important point.

Paolo

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

* Re: [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs
  2011-10-11 15:52       ` Paolo Bonzini
@ 2011-10-11 16:09         ` Vadim Rozenfeld
  2011-10-11 16:17           ` Paolo Bonzini
  0 siblings, 1 reply; 24+ messages in thread
From: Vadim Rozenfeld @ 2011-10-11 16:09 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Avi Kivity

On Tue, 2011-10-11 at 17:52 +0200, Paolo Bonzini wrote:
> On 10/11/2011 03:46 PM, Vadim Rozenfeld wrote:
> > >  These should not be KVM-specific.  You should be able to add
> > >  enlightenments to a TCG VM.  At the same time, the KVM leaves could be
> > >  moved to 0x40000100 when enlightenments are active, similar to what Xen
> > >  does.
> > >
> >
> > IMO, adding Hyper-V features without KVM support has little, if any,
> > meaning. Relaxed timing is the only one thing, which can be activated
> > without help from hypervisor.
> 
> Spinlocks too.  TCG does its own round-robin scheduling, so having zero 
How? You need hypercall page for it.
Best,
Vadim.
> retries could be the best setting.  But even if it is not useful for 
> TCG, there's nothing KVM-specific, and that's the important point.
> 
> Paolo



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

* Re: [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs
  2011-10-11 16:09         ` Vadim Rozenfeld
@ 2011-10-11 16:17           ` Paolo Bonzini
  0 siblings, 0 replies; 24+ messages in thread
From: Paolo Bonzini @ 2011-10-11 16:17 UTC (permalink / raw)
  To: Vadim Rozenfeld; +Cc: kvm, Avi Kivity

On 10/11/2011 06:09 PM, Vadim Rozenfeld wrote:
> >  Spinlocks too.  TCG does its own round-robin scheduling, so having zero
> How? You need hypercall page for it.

I'm not saying you should implement it, :) in principle TCG could have a 
hypercall page.

Paolo

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

end of thread, other threads:[~2011-10-11 16:17 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-09 18:52 [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Vadim Rozenfeld
2011-10-09 18:52 ` [RFC PATCH 1/7] [hyper-v] Add hyper-v parameters block Vadim Rozenfeld
2011-10-10  6:54   ` Jan Kiszka
2011-10-10  9:40     ` Vadim Rozenfeld
2011-10-10 10:25       ` Jan Kiszka
2011-10-11  7:35   ` Paolo Bonzini
2011-10-11  7:42     ` Paolo Bonzini
2011-10-09 18:52 ` [RFC PATCH 2/7] [hyper-v] add hyper-v placeholders Vadim Rozenfeld
2011-10-11  7:40   ` Paolo Bonzini
2011-10-09 18:52 ` [RFC PATCH 3/7] [hyper-v] make Hyper-V option configurable Vadim Rozenfeld
2011-10-10  6:54   ` Jan Kiszka
2011-10-09 18:52 ` [RFC PATCH 4/7] [hyper-v] hyper-v parameters Vadim Rozenfeld
2011-10-09 18:52 ` [RFC PATCH 5/7] [hyper-v] hyper-v helper functions Vadim Rozenfeld
2011-10-09 19:01   ` Alon Levy
2011-10-10  6:45     ` Vadim Rozenfeld
2011-10-09 18:52 ` [RFC PATCH 6/7] [hyper-v] parse hyper-v parameters Vadim Rozenfeld
2011-10-09 18:52 ` [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs Vadim Rozenfeld
2011-10-11  7:38   ` Paolo Bonzini
2011-10-11 13:46     ` Vadim Rozenfeld
2011-10-11 15:52       ` Paolo Bonzini
2011-10-11 16:09         ` Vadim Rozenfeld
2011-10-11 16:17           ` Paolo Bonzini
2011-10-10  6:53 ` [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Jan Kiszka
2011-10-10  9:39   ` Vadim Rozenfeld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox