]> xenbits.xensource.com Git - xen.git/commitdiff
viridian: allow vCPU hotplug for Windows VMs
authorIgor Druzhinin <igor.druzhinin@citrix.com>
Fri, 29 Jan 2021 13:18:43 +0000 (14:18 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 29 Jan 2021 13:18:43 +0000 (14:18 +0100)
If Viridian extensions are enabled, Windows wouldn't currently allow
a hotplugged vCPU to be brought up dynamically. We need to expose a special
bit to let the guest know we allow it. Hide it behind an option to stay
on the safe side regarding compatibility with existing guests but
nevertheless set the option on by default.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
docs/man/xl.cfg.5.pod.in
tools/include/libxl.h
tools/libs/light/libxl_types.idl
tools/libs/light/libxl_x86.c
xen/arch/x86/hvm/viridian/viridian.c
xen/include/public/hvm/params.h

index 3467eae2cd0ea4010e916ff660f319982babbce2..7cdb8595d32830c7f68cd9582e8a1dbd15bb3b30 100644 (file)
@@ -2267,11 +2267,16 @@ explicitly have any limits on the number of Virtual processors a guest
 is allowed to bring up. It is strongly recommended to keep this enabled
 for guests with more than 64 vCPUs.
 
+=item B<cpu_hotplug>
+
+This set enables dynamic changes to Virtual processor states in Windows
+guests effectively allowing vCPU hotplug.
+
 =item B<defaults>
 
 This is a special value that enables the default set of groups, which
 is currently the B<base>, B<freq>, B<time_ref_count>, B<apic_assist>,
-B<crash_ctl>, B<stimer> and B<no_vp_limit> groups.
+B<crash_ctl>, B<stimer>, B<no_vp_limit> and B<cpu_hotplug> groups.
 
 =item B<all>
 
index ee15c0495c8c6ade19e7362ffe12b51a10e2ac95..547ddd308535e135197c174ee9b9bcc91fa061bc 100644 (file)
  */
 #define LIBXL_HAVE_VIRIDIAN_NO_VP_LIMIT 1
 
+/*
+ * LIBXL_HAVE_VIRIDIAN_CPU_HOTPLUG indicates that the 'cpu_hotplug' value
+ * is present in the viridian enlightenment enumeration.
+ */
+#define LIBXL_HAVE_VIRIDIAN_CPU_HOTPLUG 1
+
 /*
  * LIBXL_HAVE_DEVICE_PCI_LIST_FREE indicates that the
  * libxl_device_pci_list_free() function is defined.
index 087a3db6e2c81e7d52a90a0b01a128a8176dec5a..37fe61f3ecdba646f7f8ca773cca845a8b75d41f 100644 (file)
@@ -240,6 +240,7 @@ libxl_viridian_enlightenment = Enumeration("viridian_enlightenment", [
     (9, "hcall_ipi"),
     (10, "ex_processor_masks"),
     (11, "no_vp_limit"),
+    (12, "cpu_hotplug"),
     ])
 
 libxl_hdtype = Enumeration("hdtype", [
index 5c4c194c65a4ab7b457e024d4810891bcfccbd83..91a9fc72ed819682c620cacff3a8cf2451dd7ad9 100644 (file)
@@ -310,6 +310,7 @@ static int hvm_set_viridian_features(libxl__gc *gc, uint32_t domid,
         libxl_bitmap_set(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_APIC_ASSIST);
         libxl_bitmap_set(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_CRASH_CTL);
         libxl_bitmap_set(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_NO_VP_LIMIT);
+        libxl_bitmap_set(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_CPU_HOTPLUG);
     }
 
     libxl_for_each_set_bit(v, info->u.hvm.viridian_enable) {
@@ -373,6 +374,9 @@ static int hvm_set_viridian_features(libxl__gc *gc, uint32_t domid,
     if (libxl_bitmap_test(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_NO_VP_LIMIT))
         mask |= HVMPV_no_vp_limit;
 
+    if (libxl_bitmap_test(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_CPU_HOTPLUG))
+        mask |= HVMPV_cpu_hotplug;
+
     if (mask != 0 &&
         xc_hvm_param_set(CTX->xch,
                          domid,
index ae1ea8630bf1ae8cc36e1175ea515573d140aa18..b906f7b86a74c52e7b95582fcee9501ace8c8391 100644 (file)
@@ -76,6 +76,7 @@ typedef union _HV_CRASH_CTL_REG_CONTENTS
 } HV_CRASH_CTL_REG_CONTENTS;
 
 /* Viridian CPUID leaf 3, Hypervisor Feature Indication */
+#define CPUID3D_CPU_DYNAMIC_PARTITIONING (1 << 3)
 #define CPUID3D_CRASH_MSRS (1 << 10)
 #define CPUID3D_SINT_POLLING (1 << 17)
 
@@ -179,8 +180,10 @@ void cpuid_viridian_leaves(const struct vcpu *v, uint32_t leaf,
         res->a = u.lo;
         res->b = u.hi;
 
+        if ( viridian_feature_mask(d) & HVMPV_cpu_hotplug )
+           res->d = CPUID3D_CPU_DYNAMIC_PARTITIONING;
         if ( viridian_feature_mask(d) & HVMPV_crash_ctl )
-            res->d = CPUID3D_CRASH_MSRS;
+            res->d |= CPUID3D_CRASH_MSRS;
         if ( viridian_feature_mask(d) & HVMPV_synic )
             res->d |= CPUID3D_SINT_POLLING;
 
index 805f4ca44c3742ffe09c55c12e7dbc8c5a3d3193..c9d6e70d7babc0bb5a0403639786cdcaa91e2679 100644 (file)
 #define _HVMPV_no_vp_limit 11
 #define HVMPV_no_vp_limit (1 << _HVMPV_no_vp_limit)
 
+/* Enable vCPU hotplug */
+#define _HVMPV_cpu_hotplug 12
+#define HVMPV_cpu_hotplug (1 << _HVMPV_cpu_hotplug)
+
 #define HVMPV_feature_mask \
         (HVMPV_base_freq | \
          HVMPV_no_freq | \
          HVMPV_stimer | \
          HVMPV_hcall_ipi | \
          HVMPV_ex_processor_masks | \
-         HVMPV_no_vp_limit)
+         HVMPV_no_vp_limit | \
+         HVMPV_cpu_hotplug)
 
 #endif