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

[PATCH v5 4/4] xl: introduce a 'xen-abi-features' option...



From: Paul Durrant <pdurrant@xxxxxxxxxx>

... to control which features of the Xen ABI are enabled in
'libxl_domain_build_info', and hence exposed to the guest.

Signed-off-by: Paul Durrant <pdurrant@xxxxxxxxxx>
---
Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx>
Cc: Wei Liu <wl@xxxxxxx>
Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>

v5:
 - New in v5
---
 docs/man/xl.cfg.5.pod.in | 50 ++++++++++++++++++++++++++++++++++++++++
 tools/xl/xl_parse.c      | 50 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 98 insertions(+), 2 deletions(-)

diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
index 3f0f8de1e988..b42ab8ba9f60 100644
--- a/docs/man/xl.cfg.5.pod.in
+++ b/docs/man/xl.cfg.5.pod.in
@@ -1649,6 +1649,56 @@ This feature is a B<technology preview>.
 
 =back
 
+=item B<xen_abi_features=[ "STRING", "STRING", ...]>
+
+The features of the Xen ABI exposed to the guest. The following features
+may be specified:
+
+=over 4
+
+=item B<evtchn_fifo>
+
+A new event channel ABI was introduced in Xen 4.4. Moving a guest from an
+earlier Xen to Xen 4.4 onwards may expose bugs in the guest support for
+this ABI. Disabling this feature hides the ABI from the guest and hence
+may be used as a workaround for such bugs.
+
+The festure is enabled by default.
+
+=item B<evcthn_upcall>
+
+B<x86 HVM only>. A new hypercall to specify per-VCPU interrupt vectors to use
+for event channel upcalls in HVM guests was added in Xen 4.6. Moving a guest
+from an earlier Xen to Xen 4.6 onwards may expose bugs in the guest support
+for this hypercall. Disabling this feature hides the hypercall from the
+guest and hence may be used as a workaround for such bugs.
+
+The festure is enabled by default for B<x86 HVM> guests. Note that it is
+considered an error to enable this feature for B<Arm> or B<x86 PV> guests.
+
+=item B<all>
+
+This is a special value that enables all available features.
+
+=back
+
+Features can be disabled by prefixing the name with '!'. So, for example,
+to enable all features except B<evtchn_upcall>, specify:
+
+=over 4
+
+B<xen-abi-features=[ "all", "!evtchn_upcall" ]>
+
+=back
+
+Or, to simply enable default features except B<evtchn_fifo>, specify:
+
+=over 4
+
+B<xen-abi-features=[ "!evtchn_fifo" ]>
+
+=back
+
 =back
 
 =head2 Paravirtualised (PV) Guest Specific Options
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index cae8eb679c5a..566e09f938f4 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -1216,8 +1216,9 @@ void parse_config_data(const char *config_source,
     XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms,
                    *usbctrls, *usbdevs, *p9devs, *vdispls, *pvcallsifs_devs;
     XLU_ConfigList *channels, *ioports, *irqs, *iomem, *viridian, *dtdevs,
-                   *mca_caps;
-    int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian, num_mca_caps;
+                   *mca_caps, *features;
+    int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian, num_mca_caps,
+        num_features;
     int pci_power_mgmt = 0;
     int pci_msitranslate = 0;
     int pci_permissive = 0;
@@ -2737,6 +2738,51 @@ skip_usbdev:
     xlu_cfg_get_defbool(config, "xend_suspend_evtchn_compat",
                         &c_info->xend_suspend_evtchn_compat, 0);
 
+    switch (xlu_cfg_get_list(config, "xen_abi_features",
+                             &features, &num_features, 1))
+    {
+    case 0: /* Success */
+        if (num_features) {
+            libxl_bitmap_alloc(ctx, &b_info->feature_enable,
+                               LIBXL_BUILDINFO_FEATURE_ENABLE_DISABLE_WIDTH);
+            libxl_bitmap_alloc(ctx, &b_info->feature_disable,
+                               LIBXL_BUILDINFO_FEATURE_ENABLE_DISABLE_WIDTH);
+        }
+        for (i = 0; i < num_features; i++) {
+            if (strcmp(buf, "all") == 0)
+                libxl_bitmap_set_any(&b_info->feature_enable);
+            else {
+                libxl_bitmap *s = &b_info->feature_enable;
+                libxl_bitmap *r = &b_info->feature_disable;
+                libxl_xen_abi_feature f;
+
+                buf = xlu_cfg_get_listitem(features, i);
+
+                if (*buf == '!') {
+                    s = &b_info->feature_disable;
+                    r = &b_info->feature_enable;
+                    buf++;
+                }
+
+                e = libxl_xen_abi_feature_from_string(buf, &f);
+                if (e) {
+                    fprintf(stderr,
+                            "xl: Unknown Xen ABI feature '%s'\n",
+                            buf);
+                    exit(-ERROR_FAIL);
+                }
+
+                libxl_bitmap_set(s, f);
+                libxl_bitmap_reset(r, f);
+            }
+        }
+        break;
+    case ESRCH: break; /* Option not present */
+    default:
+        fprintf(stderr,"xl: Unable to parse Xen ABI features.\n");
+        exit(-ERROR_FAIL);
+    }
+
     xlu_cfg_destroy(config);
 }
 
-- 
2.20.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.