Skip to contentSkip to conversation

add privileged/unprivileged kernel feature indication

PATCH Superseded Jan Beulich 3 participants 17 messages Jul 19, 2011 – Jul 21, 2011

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 add privileged/unprivileged kernel feature indication

With our switching away from supporting 32-bit Dom0 operation, users complained that attempts (perhaps due to lack of knowledge of that change) to boot the no longer privileged kernel in Dom0 resulted in apparently silent failure. To make the mismatch explicit and visible, add feature flags that the kernel can set to indicate operation in what modes it supports. For backward compatibility, absence of both feature flags is taken to indicate a kernel that may be capable of operating in both modes.

v2: Due to the way elf_xen_parse_features() worked up to now (getting fixed here), adding features indications to the old, string based ELF note would make the respective kernel unusable on older hypervisors. For that reason, a new ELF Note is being introduced that allows specifying supported features as a bit array instead (with features unknown to the hypervisor simply ignored, as now also done by elf_xen_parse_features(), whereas here unknown kernel-required features still keep the kernel [and hence VM] from booting).

v3: Introduce and use elf_note_numeric_array() to be forward compatible (or else an old hypervisor wouldn't be able to parse kernel specified features occupying more than 64 bits - thanks, Ian!).

tools/libxc/xc_dom_elfloader.c +9 -0
@@ -286,6 +286,15 @@ static int xc_dom_parse_elf_kernel(struc
     if ( (rc = elf_xen_parse(elf, &dom->parms)) != 0 )
         return rc;
 
+    if ( elf_xen_feature_get(XENFEAT_privileged, dom->parms.f_required) ||
+         (elf_xen_feature_get(XENFEAT_privileged, dom->parms.f_supported) &&
+          !elf_xen_feature_get(XENFEAT_unprivileged, dom->parms.f_supported)) )
+    {
+        xc_dom_panic(dom->xch, XC_INVALID_KERNEL, "%s: Kernel does not"
+                     " support unprivileged (DomU) operation", __FUNCTION__);
+        return -EINVAL;
+    }
+
     /* find kernel segment */
     dom->kernel_seg.vstart = dom->parms.virt_kstart;
     dom->kernel_seg.vend   = dom->parms.virt_kend;
xen/arch/ia64/xen/domain.c +8 -0
@@ -2164,6 +2164,14 @@ int __init construct_dom0(struct domain 
 		return -1;
 	}
 
+	if (test_bit(XENFEAT_unprivileged, parms.f_required) ||
+	    (test_bit(XENFEAT_unprivileged, parms.f_supported) &&
+	     !test_bit(XENFEAT_privileged, parms.f_supported)))
+	{
+		printk("Kernel does not support Dom0 operation\n");
+		return -1;
+	}
+
 	p_start = parms.virt_base;
 	pkern_start = parms.virt_kstart;
 	pkern_end = parms.virt_kend;
xen/arch/x86/domain_build.c +8 -0
@@ -415,6 +415,14 @@ int __init construct_dom0(
         return -EINVAL;
     }
 
+    if ( test_bit(XENFEAT_unprivileged, parms.f_required) ||
+         (test_bit(XENFEAT_unprivileged, parms.f_supported) &&
+          !test_bit(XENFEAT_privileged, parms.f_supported)) )
+    {
+        printk("Kernel does not support Dom0 operation\n");
+        return -EINVAL;
+    }
+
 #if defined(__x86_64__)
     if ( compat32 )
     {
xen/common/kernel.c +2 -1
@@ -278,7 +278,8 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDL
         switch ( fi.submap_idx )
         {
         case 0:
-            fi.submap = 0;
+            fi.submap = 1U << (IS_PRIV(current->domain) ?
+                               XENFEAT_privileged : XENFEAT_unprivileged);
             if ( VM_ASSIST(d, VMASST_TYPE_pae_extended_cr3) )
                 fi.submap |= (1U << XENFEAT_pae_pgdir_above_4gb);
             if ( paging_mode_translate(current->domain) )
xen/common/libelf/libelf-dominfo.c +12 -2
@@ -26,7 +26,9 @@ static const char *const elf_xen_feature
     [XENFEAT_writable_descriptor_tables] = "writable_descriptor_tables",
     [XENFEAT_auto_translated_physmap] = "auto_translated_physmap",
     [XENFEAT_supervisor_mode_kernel] = "supervisor_mode_kernel",
-    [XENFEAT_pae_pgdir_above_4gb] = "pae_pgdir_above_4gb"
+    [XENFEAT_pae_pgdir_above_4gb] = "pae_pgdir_above_4gb",
+    [XENFEAT_privileged] = "privileged",
+    [XENFEAT_unprivileged] = "unprivileged"
 };
 static const int elf_xen_features =
 sizeof(elf_xen_feature_names) / sizeof(elf_xen_feature_names[0]);
@@ -83,7 +85,7 @@ int elf_xen_parse_features(const char *f
                 }
             }
         }
-        if ( i == elf_xen_features )
+        if ( i == elf_xen_features && required && feature[0] == '!' )
             return -1;
     }
 
@@ -114,6 +116,7 @@ int elf_xen_parse_note(struct elf_binary
         [XEN_ELFNOTE_LOADER] = { "LOADER", 1},
         [XEN_ELFNOTE_PAE_MODE] = { "PAE_MODE", 1},
         [XEN_ELFNOTE_FEATURES] = { "FEATURES", 1},
+        [XEN_ELFNOTE_SUPPORTED_FEATURES] = { "SUPPORTED_FEATURES", 0},
         [XEN_ELFNOTE_BSD_SYMTAB] = { "BSD_SYMTAB", 1},
         [XEN_ELFNOTE_SUSPEND_CANCEL] = { "SUSPEND_CANCEL", 0 },
         [XEN_ELFNOTE_MOD_START_PFN] = { "MOD_START_PFN", 0 },
@@ -122,6 +125,7 @@ int elf_xen_parse_note(struct elf_binary
 
     const char *str = NULL;
     uint64_t val = 0;
+    unsigned int i;
     int type = elf_uval(elf, note, type);
 
     if ( (type >= sizeof(note_desc) / sizeof(note_desc[0])) ||
@@ -200,6 +204,12 @@ int elf_xen_parse_note(struct elf_binary
             return -1;
         break;
 
+    case XEN_ELFNOTE_SUPPORTED_FEATURES:
+        for ( i = 0; i < XENFEAT_NR_SUBMAPS; ++i )
+            parms->f_supported[i] |= elf_note_numeric_array(
+                elf, note, sizeof(*parms->f_supported), i);
+        break;
+
     }
     return 0;
 }
xen/common/libelf/libelf-tools.c +21 -0
@@ -227,6 +227,27 @@ uint64_t elf_note_numeric(struct elf_bin
         return 0;
     }
 }
+
+uint64_t elf_note_numeric_array(struct elf_binary *elf, const elf_note *note,
+                                unsigned int unitsz, unsigned int idx)
+{
+    const void *desc = elf_note_desc(elf, note);
+    int descsz = elf_uval(elf, note, descsz);
+
+    if ( descsz % unitsz || idx >= descsz / unitsz )
+        return 0;
+    switch (unitsz)
+    {
+    case 1:
+    case 2:
+    case 4:
+    case 8:
+        return elf_access_unsigned(elf, desc, idx * unitsz, unitsz);
+    default:
+        return 0;
+    }
+}
+
 const elf_note *elf_note_next(struct elf_binary *elf, const elf_note * note)
 {
     int namesz = (elf_uval(elf, note, namesz) + 3) & ~3;
xen/include/public/elfnote.h +14 -1
@@ -179,9 +179,22 @@
 #define XEN_ELFNOTE_MOD_START_PFN 16
 
 /*
+ * The features supported by this kernel (numeric).
+ *
+ * Other than XEN_ELFNOTE_FEATURES on pre-4.2 Xen, this note allows a
+ * kernel to specify support for features that older hypervisors don't
+ * know about. The set of features 4.2 and newer hypervisors will
+ * consider supported by the kernel is the combination of the sets
+ * specified through this and the string note.
+ *
+ * LEGACY: FEATURES
+ */
+#define XEN_ELFNOTE_SUPPORTED_FEATURES 17
+
+/*
  * The number of the highest elfnote defined.
  */
-#define XEN_ELFNOTE_MAX XEN_ELFNOTE_MOD_START_PFN
+#define XEN_ELFNOTE_MAX XEN_ELFNOTE_SUPPORTED_FEATURES
 
 /*
  * System information exported through crash notes.
xen/include/public/features.h +7 -1
@@ -75,7 +75,13 @@
 #define XENFEAT_hvm_safe_pvclock           9
 
 /* x86: pirq can be used by HVM guests */
-#define XENFEAT_hvm_pirqs           10
+#define XENFEAT_hvm_pirqs                 10
+
+/* privileged operation is supported */
+#define XENFEAT_privileged                11
+
+/* un-privileged operation is supported */
+#define XENFEAT_unprivileged              12
 
 #define XENFEAT_NR_SUBMAPS 1
 
xen/include/xen/libelf.h +2 -0
@@ -179,6 +179,8 @@ const elf_sym *elf_sym_by_index(struct e
 const char *elf_note_name(struct elf_binary *elf, const elf_note * note);
 const void *elf_note_desc(struct elf_binary *elf, const elf_note * note);
 uint64_t elf_note_numeric(struct elf_binary *elf, const elf_note * note);
+uint64_t elf_note_numeric_array(struct elf_binary *, const elf_note *,
+                                unsigned int unitsz, unsigned int idx);
 const elf_note *elf_note_next(struct elf_binary *elf, const elf_note * note);
 
 int elf_is_elfbinary(const void *image);

With our switching away from supporting 32-bit Dom0 operation, users complained that attempts (perhaps due to lack of knowledge of that change) to boot the no longer privileged kernel in Dom0 resulted in apparently silent failure. To make the mismatch explicit and visible, add feature flags that the kernel can set to indicate operation in what modes it supports. For backward compatibility, absence of both feature flags is taken to indicate a kernel that may be capable of operating in both modes.

v2: Due to the way elf_xen_parse_features() worked up to now (getting fixed here), adding features indications to the old, string based ELF note would make the respective kernel unusable on older hypervisors. For that reason, a new ELF Note is being introduced that allows specifying supported features as a bit array instead (with features unknown to the hypervisor simply ignored, as now also done by elf_xen_parse_features(), whereas here unknown kernel-required features still keep the kernel [and hence VM] from booting).

v3: Introduce and use elf_note_numeric_array() to be forward compatible (or else an old hypervisor wouldn't be able to parse kernel specified features occupying more than 64 bits - thanks, Ian!).

tools/libxc/xc_dom_elfloader.c +9 -0
@@ -286,6 +286,15 @@ static int xc_dom_parse_elf_kernel(struc
     if ( (rc = elf_xen_parse(elf, &dom->parms)) != 0 )
         return rc;
 
+    if ( elf_xen_feature_get(XENFEAT_privileged, dom->parms.f_required) ||
+         (elf_xen_feature_get(XENFEAT_privileged, dom->parms.f_supported) &&
+          !elf_xen_feature_get(XENFEAT_unprivileged, dom->parms.f_supported)) )
+    {
+        xc_dom_panic(dom->xch, XC_INVALID_KERNEL, "%s: Kernel does not"
+                     " support unprivileged (DomU) operation", __FUNCTION__);
+        return -EINVAL;
+    }
+
     /* find kernel segment */
     dom->kernel_seg.vstart = dom->parms.virt_kstart;
     dom->kernel_seg.vend   = dom->parms.virt_kend;
xen/arch/ia64/xen/domain.c +8 -0
@@ -2164,6 +2164,14 @@ int __init construct_dom0(struct domain 
 		return -1;
 	}
 
+	if (test_bit(XENFEAT_unprivileged, parms.f_required) ||
+	    (test_bit(XENFEAT_unprivileged, parms.f_supported) &&
+	     !test_bit(XENFEAT_privileged, parms.f_supported)))
+	{
+		printk("Kernel does not support Dom0 operation\n");
+		return -1;
+	}
+
 	p_start = parms.virt_base;
 	pkern_start = parms.virt_kstart;
 	pkern_end = parms.virt_kend;
xen/arch/x86/domain_build.c +8 -0
@@ -415,6 +415,14 @@ int __init construct_dom0(
         return -EINVAL;
     }
 
+    if ( test_bit(XENFEAT_unprivileged, parms.f_required) ||
+         (test_bit(XENFEAT_unprivileged, parms.f_supported) &&
+          !test_bit(XENFEAT_privileged, parms.f_supported)) )
+    {
+        printk("Kernel does not support Dom0 operation\n");
+        return -EINVAL;
+    }
+
 #if defined(__x86_64__)
     if ( compat32 )
     {
xen/common/kernel.c +2 -1
@@ -278,7 +278,8 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDL
         switch ( fi.submap_idx )
         {
         case 0:
-            fi.submap = 0;
+            fi.submap = 1U << (IS_PRIV(current->domain) ?
+                               XENFEAT_privileged : XENFEAT_unprivileged);
             if ( VM_ASSIST(d, VMASST_TYPE_pae_extended_cr3) )
                 fi.submap |= (1U << XENFEAT_pae_pgdir_above_4gb);
             if ( paging_mode_translate(current->domain) )
xen/common/libelf/libelf-dominfo.c +12 -2
@@ -26,7 +26,9 @@ static const char *const elf_xen_feature
     [XENFEAT_writable_descriptor_tables] = "writable_descriptor_tables",
     [XENFEAT_auto_translated_physmap] = "auto_translated_physmap",
     [XENFEAT_supervisor_mode_kernel] = "supervisor_mode_kernel",
-    [XENFEAT_pae_pgdir_above_4gb] = "pae_pgdir_above_4gb"
+    [XENFEAT_pae_pgdir_above_4gb] = "pae_pgdir_above_4gb",
+    [XENFEAT_privileged] = "privileged",
+    [XENFEAT_unprivileged] = "unprivileged"
 };
 static const int elf_xen_features =
 sizeof(elf_xen_feature_names) / sizeof(elf_xen_feature_names[0]);
@@ -83,7 +85,7 @@ int elf_xen_parse_features(const char *f
                 }
             }
         }
-        if ( i == elf_xen_features )
+        if ( i == elf_xen_features && required && feature[0] == '!' )
             return -1;
     }
 
@@ -114,6 +116,7 @@ int elf_xen_parse_note(struct elf_binary
         [XEN_ELFNOTE_LOADER] = { "LOADER", 1},
         [XEN_ELFNOTE_PAE_MODE] = { "PAE_MODE", 1},
         [XEN_ELFNOTE_FEATURES] = { "FEATURES", 1},
+        [XEN_ELFNOTE_SUPPORTED_FEATURES] = { "SUPPORTED_FEATURES", 0},
         [XEN_ELFNOTE_BSD_SYMTAB] = { "BSD_SYMTAB", 1},
         [XEN_ELFNOTE_SUSPEND_CANCEL] = { "SUSPEND_CANCEL", 0 },
         [XEN_ELFNOTE_MOD_START_PFN] = { "MOD_START_PFN", 0 },
@@ -122,6 +125,7 @@ int elf_xen_parse_note(struct elf_binary
 
     const char *str = NULL;
     uint64_t val = 0;
+    unsigned int i;
     int type = elf_uval(elf, note, type);
 
     if ( (type >= sizeof(note_desc) / sizeof(note_desc[0])) ||
@@ -200,6 +204,12 @@ int elf_xen_parse_note(struct elf_binary
             return -1;
         break;
 
+    case XEN_ELFNOTE_SUPPORTED_FEATURES:
+        for ( i = 0; i < XENFEAT_NR_SUBMAPS; ++i )
+            parms->f_supported[i] |= elf_note_numeric_array(
+                elf, note, sizeof(*parms->f_supported), i);
+        break;
+
     }
     return 0;
 }
xen/common/libelf/libelf-tools.c +21 -0
@@ -227,6 +227,27 @@ uint64_t elf_note_numeric(struct elf_bin
         return 0;
     }
 }
+
+uint64_t elf_note_numeric_array(struct elf_binary *elf, const elf_note *note,
+                                unsigned int unitsz, unsigned int idx)
+{
+    const void *desc = elf_note_desc(elf, note);
+    int descsz = elf_uval(elf, note, descsz);
+
+    if ( descsz % unitsz || idx >= descsz / unitsz )
+        return 0;
+    switch (unitsz)
+    {
+    case 1:
+    case 2:
+    case 4:
+    case 8:
+        return elf_access_unsigned(elf, desc, idx * unitsz, unitsz);
+    default:
+        return 0;
+    }
+}
+
 const elf_note *elf_note_next(struct elf_binary *elf, const elf_note * note)
 {
     int namesz = (elf_uval(elf, note, namesz) + 3) & ~3;
xen/include/public/elfnote.h +14 -1
@@ -179,9 +179,22 @@
 #define XEN_ELFNOTE_MOD_START_PFN 16
 
 /*
+ * The features supported by this kernel (numeric).
+ *
+ * Other than XEN_ELFNOTE_FEATURES on pre-4.2 Xen, this note allows a
+ * kernel to specify support for features that older hypervisors don't
+ * know about. The set of features 4.2 and newer hypervisors will
+ * consider supported by the kernel is the combination of the sets
+ * specified through this and the string note.
+ *
+ * LEGACY: FEATURES
+ */
+#define XEN_ELFNOTE_SUPPORTED_FEATURES 17
+
+/*
  * The number of the highest elfnote defined.
  */
-#define XEN_ELFNOTE_MAX XEN_ELFNOTE_MOD_START_PFN
+#define XEN_ELFNOTE_MAX XEN_ELFNOTE_SUPPORTED_FEATURES
 
 /*
  * System information exported through crash notes.
xen/include/public/features.h +7 -1
@@ -75,7 +75,13 @@
 #define XENFEAT_hvm_safe_pvclock           9
 
 /* x86: pirq can be used by HVM guests */
-#define XENFEAT_hvm_pirqs           10
+#define XENFEAT_hvm_pirqs                 10
+
+/* privileged operation is supported */
+#define XENFEAT_privileged                11
+
+/* un-privileged operation is supported */
+#define XENFEAT_unprivileged              12
 
 #define XENFEAT_NR_SUBMAPS 1
 
xen/include/xen/libelf.h +2 -0
@@ -179,6 +179,8 @@ const elf_sym *elf_sym_by_index(struct e
 const char *elf_note_name(struct elf_binary *elf, const elf_note * note);
 const void *elf_note_desc(struct elf_binary *elf, const elf_note * note);
 uint64_t elf_note_numeric(struct elf_binary *elf, const elf_note * note);
+uint64_t elf_note_numeric_array(struct elf_binary *, const elf_note *,
+                                unsigned int unitsz, unsigned int idx);
 const elf_note *elf_note_next(struct elf_binary *elf, const elf_note * note);
 
 int elf_is_elfbinary(const void *image);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Oops, $subject should have said [PATCH, v3] ...

Quoted 229 lines
Quoted 1 line
Quoted 1 line · Jan Beulich

With our switching away from supporting 32-bit Dom0 operation, users complained that attempts (perhaps due to lack of knowledge of that change) to boot the no longer privileged kernel in Dom0 resulted in apparently silent failure. To make the mismatch explicit and visible, add feature flags that the kernel can set to indicate operation in what modes it supports. For backward compatibility, absence of both feature flags is taken to indicate a kernel that may be capable of operating in both modes.

v2: Due to the way elf_xen_parse_features() worked up to now (getting fixed here), adding features indications to the old, string based ELF note would make the respective kernel unusable on older hypervisors. For that reason, a new ELF Note is being introduced that allows specifying supported features as a bit array instead (with features unknown to the hypervisor simply ignored, as now also done by elf_xen_parse_features(), whereas here unknown kernel-required features still keep the kernel [and hence VM] from booting).

v3: Introduce and use elf_note_numeric_array() to be forward compatible (or else an old hypervisor wouldn't be able to parse kernel specified features occupying more than 64 bits - thanks, Ian!).

tools/libxc/xc_dom_elfloader.c +9 -0
@@ -286,6 +286,15 @@ static int xc_dom_parse_elf_kernel(struc
     if ( (rc = elf_xen_parse(elf, &dom->parms)) != 0 )
         return rc;
 
+    if ( elf_xen_feature_get(XENFEAT_privileged, dom->parms.f_required) ||
+         (elf_xen_feature_get(XENFEAT_privileged, dom->parms.f_supported) &&
+          !elf_xen_feature_get(XENFEAT_unprivileged, dom->parms.f_supported)) 
 )
+    {
+        xc_dom_panic(dom->xch, XC_INVALID_KERNEL, "%s: Kernel does not"
+                     " support unprivileged (DomU) operation", 
 __FUNCTION__);
+        return -EINVAL;
+    }
+
     /* find kernel segment */
     dom->kernel_seg.vstart = dom->parms.virt_kstart;
     dom->kernel_seg.vend   = dom->parms.virt_kend;
xen/arch/ia64/xen/domain.c +8 -0
@@ -2164,6 +2164,14 @@ int __init construct_dom0(struct domain 
 		return -1;
 	}
 
+	if (test_bit(XENFEAT_unprivileged, parms.f_required) ||
+	    (test_bit(XENFEAT_unprivileged, parms.f_supported) &&
+	     !test_bit(XENFEAT_privileged, parms.f_supported)))
+	{
+		printk("Kernel does not support Dom0 operation\n");
+		return -1;
+	}
+
 	p_start = parms.virt_base;
 	pkern_start = parms.virt_kstart;
 	pkern_end = parms.virt_kend;
xen/arch/x86/domain_build.c +8 -0
@@ -415,6 +415,14 @@ int __init construct_dom0(
         return -EINVAL;
     }
 
+    if ( test_bit(XENFEAT_unprivileged, parms.f_required) ||
+         (test_bit(XENFEAT_unprivileged, parms.f_supported) &&
+          !test_bit(XENFEAT_privileged, parms.f_supported)) )
+    {
+        printk("Kernel does not support Dom0 operation\n");
+        return -EINVAL;
+    }
+
 #if defined(__x86_64__)
     if ( compat32 )
     {
xen/common/kernel.c +2 -1
@@ -278,7 +278,8 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDL
         switch ( fi.submap_idx )
         {
         case 0:
-            fi.submap = 0;
+            fi.submap = 1U << (IS_PRIV(current->domain) ?
+                               XENFEAT_privileged : XENFEAT_unprivileged);
             if ( VM_ASSIST(d, VMASST_TYPE_pae_extended_cr3) )
                 fi.submap |= (1U << XENFEAT_pae_pgdir_above_4gb);
             if ( paging_mode_translate(current->domain) )
xen/common/libelf/libelf-dominfo.c +12 -2
@@ -26,7 +26,9 @@ static const char *const elf_xen_feature
     [XENFEAT_writable_descriptor_tables] = "writable_descriptor_tables",
     [XENFEAT_auto_translated_physmap] = "auto_translated_physmap",
     [XENFEAT_supervisor_mode_kernel] = "supervisor_mode_kernel",
-    [XENFEAT_pae_pgdir_above_4gb] = "pae_pgdir_above_4gb"
+    [XENFEAT_pae_pgdir_above_4gb] = "pae_pgdir_above_4gb",
+    [XENFEAT_privileged] = "privileged",
+    [XENFEAT_unprivileged] = "unprivileged"
 };
 static const int elf_xen_features =
 sizeof(elf_xen_feature_names) / sizeof(elf_xen_feature_names[0]);
@@ -83,7 +85,7 @@ int elf_xen_parse_features(const char *f
                 }
             }
         }
-        if ( i == elf_xen_features )
+        if ( i == elf_xen_features && required && feature[0] == '!' )
             return -1;
     }
 
@@ -114,6 +116,7 @@ int elf_xen_parse_note(struct elf_binary
         [XEN_ELFNOTE_LOADER] = { "LOADER", 1},
         [XEN_ELFNOTE_PAE_MODE] = { "PAE_MODE", 1},
         [XEN_ELFNOTE_FEATURES] = { "FEATURES", 1},
+        [XEN_ELFNOTE_SUPPORTED_FEATURES] = { "SUPPORTED_FEATURES", 0},
         [XEN_ELFNOTE_BSD_SYMTAB] = { "BSD_SYMTAB", 1},
         [XEN_ELFNOTE_SUSPEND_CANCEL] = { "SUSPEND_CANCEL", 0 },
         [XEN_ELFNOTE_MOD_START_PFN] = { "MOD_START_PFN", 0 },
@@ -122,6 +125,7 @@ int elf_xen_parse_note(struct elf_binary
 
     const char *str = NULL;
     uint64_t val = 0;
+    unsigned int i;
     int type = elf_uval(elf, note, type);
 
     if ( (type >= sizeof(note_desc) / sizeof(note_desc[0])) ||
@@ -200,6 +204,12 @@ int elf_xen_parse_note(struct elf_binary
             return -1;
         break;
 
+    case XEN_ELFNOTE_SUPPORTED_FEATURES:
+        for ( i = 0; i < XENFEAT_NR_SUBMAPS; ++i )
+            parms->f_supported[i] |= elf_note_numeric_array(
+                elf, note, sizeof(*parms->f_supported), i);
+        break;
+
     }
     return 0;
 }
xen/common/libelf/libelf-tools.c +21 -0
@@ -227,6 +227,27 @@ uint64_t elf_note_numeric(struct elf_bin
         return 0;
     }
 }
+
+uint64_t elf_note_numeric_array(struct elf_binary *elf, const elf_note 
 *note,
+                                unsigned int unitsz, unsigned int idx)
+{
+    const void *desc = elf_note_desc(elf, note);
+    int descsz = elf_uval(elf, note, descsz);
+
+    if ( descsz % unitsz || idx >= descsz / unitsz )
+        return 0;
+    switch (unitsz)
+    {
+    case 1:
+    case 2:
+    case 4:
+    case 8:
+        return elf_access_unsigned(elf, desc, idx * unitsz, unitsz);
+    default:
+        return 0;
+    }
+}
+
 const elf_note *elf_note_next(struct elf_binary *elf, const elf_note * 
 note)
 {
     int namesz = (elf_uval(elf, note, namesz) + 3) & ~3;
xen/include/public/elfnote.h +14 -1
@@ -179,9 +179,22 @@
 #define XEN_ELFNOTE_MOD_START_PFN 16
 
 /*
+ * The features supported by this kernel (numeric).
+ *
+ * Other than XEN_ELFNOTE_FEATURES on pre-4.2 Xen, this note allows a
+ * kernel to specify support for features that older hypervisors don't
+ * know about. The set of features 4.2 and newer hypervisors will
+ * consider supported by the kernel is the combination of the sets
+ * specified through this and the string note.
+ *
+ * LEGACY: FEATURES
+ */
+#define XEN_ELFNOTE_SUPPORTED_FEATURES 17
+
+/*
  * The number of the highest elfnote defined.
  */
-#define XEN_ELFNOTE_MAX XEN_ELFNOTE_MOD_START_PFN
+#define XEN_ELFNOTE_MAX XEN_ELFNOTE_SUPPORTED_FEATURES
 
 /*
  * System information exported through crash notes.
xen/include/public/features.h +7 -1
@@ -75,7 +75,13 @@
 #define XENFEAT_hvm_safe_pvclock           9
 
 /* x86: pirq can be used by HVM guests */
-#define XENFEAT_hvm_pirqs           10
+#define XENFEAT_hvm_pirqs                 10
+
+/* privileged operation is supported */
+#define XENFEAT_privileged                11
+
+/* un-privileged operation is supported */
+#define XENFEAT_unprivileged              12
 
 #define XENFEAT_NR_SUBMAPS 1
 
xen/include/xen/libelf.h +2 -0
@@ -179,6 +179,8 @@ const elf_sym *elf_sym_by_index(struct e
 const char *elf_note_name(struct elf_binary *elf, const elf_note * note);
 const void *elf_note_desc(struct elf_binary *elf, const elf_note * note);
 uint64_t elf_note_numeric(struct elf_binary *elf, const elf_note * note);
+uint64_t elf_note_numeric_array(struct elf_binary *, const elf_note *,
+                                unsigned int unitsz, unsigned int idx);
 const elf_note *elf_note_next(struct elf_binary *elf, const elf_note * 
 note);
 

int elf_is_elfbinary(const void *image);

#2 lore raw
Quoted 11 lines · Jan Beulich

Oops, $subject should have said [PATCH, v3] ...

Quoted 9 lines
Quoted 1 line
Quoted 1 line · Jan Beulich

With our switching away from supporting 32-bit Dom0 operation, users complained that attempts (perhaps due to lack of knowledge of that change) to boot the no longer privileged kernel in Dom0 resulted in apparently silent failure. To make the mismatch explicit and visible, add feature flags that the kernel can set to indicate operation in what modes it supports. For backward compatibility, absence of both feature flags is taken to indicate a kernel that may be capable of operating in both modes.

Actually, since you are introducing a new interface to the feature bits _and_ it is not possible to add these new bits to the old interface anyway can't we just have XENFEAT_privileged and require that guest kernels using the new interface ensure that bit correctly represents the configuration? IOW backwards compatilibilty is ensure through the presence/absence of XEN_ELFNOTE_SUPPORTED_FEATURES.

Ian.

Quoted 222 lines
Quoted 220 lines

v2: Due to the way elf_xen_parse_features() worked up to now (getting fixed here), adding features indications to the old, string based ELF note would make the respective kernel unusable on older hypervisors. For that reason, a new ELF Note is being introduced that allows specifying supported features as a bit array instead (with features unknown to the hypervisor simply ignored, as now also done by elf_xen_parse_features(), whereas here unknown kernel-required features still keep the kernel [and hence VM] from booting).

v3: Introduce and use elf_note_numeric_array() to be forward compatible (or else an old hypervisor wouldn't be able to parse kernel specified features occupying more than 64 bits - thanks, Ian!).

tools/libxc/xc_dom_elfloader.c +9 -0
@@ -286,6 +286,15 @@ static int xc_dom_parse_elf_kernel(struc
     if ( (rc = elf_xen_parse(elf, &dom->parms)) != 0 )
         return rc;
 
+    if ( elf_xen_feature_get(XENFEAT_privileged, dom->parms.f_required) ||
+         (elf_xen_feature_get(XENFEAT_privileged, dom->parms.f_supported) &&
+          !elf_xen_feature_get(XENFEAT_unprivileged, dom->parms.f_supported)) 
 )
+    {
+        xc_dom_panic(dom->xch, XC_INVALID_KERNEL, "%s: Kernel does not"
+                     " support unprivileged (DomU) operation", 
 __FUNCTION__);
+        return -EINVAL;
+    }
+
     /* find kernel segment */
     dom->kernel_seg.vstart = dom->parms.virt_kstart;
     dom->kernel_seg.vend   = dom->parms.virt_kend;
xen/arch/ia64/xen/domain.c +8 -0
@@ -2164,6 +2164,14 @@ int __init construct_dom0(struct domain 
 		return -1;
 	}
 
+	if (test_bit(XENFEAT_unprivileged, parms.f_required) ||
+	    (test_bit(XENFEAT_unprivileged, parms.f_supported) &&
+	     !test_bit(XENFEAT_privileged, parms.f_supported)))
+	{
+		printk("Kernel does not support Dom0 operation\n");
+		return -1;
+	}
+
 	p_start = parms.virt_base;
 	pkern_start = parms.virt_kstart;
 	pkern_end = parms.virt_kend;
xen/arch/x86/domain_build.c +8 -0
@@ -415,6 +415,14 @@ int __init construct_dom0(
         return -EINVAL;
     }
 
+    if ( test_bit(XENFEAT_unprivileged, parms.f_required) ||
+         (test_bit(XENFEAT_unprivileged, parms.f_supported) &&
+          !test_bit(XENFEAT_privileged, parms.f_supported)) )
+    {
+        printk("Kernel does not support Dom0 operation\n");
+        return -EINVAL;
+    }
+
 #if defined(__x86_64__)
     if ( compat32 )
     {
xen/common/kernel.c +2 -1
@@ -278,7 +278,8 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDL
         switch ( fi.submap_idx )
         {
         case 0:
-            fi.submap = 0;
+            fi.submap = 1U << (IS_PRIV(current->domain) ?
+                               XENFEAT_privileged : XENFEAT_unprivileged);
             if ( VM_ASSIST(d, VMASST_TYPE_pae_extended_cr3) )
                 fi.submap |= (1U << XENFEAT_pae_pgdir_above_4gb);
             if ( paging_mode_translate(current->domain) )
xen/common/libelf/libelf-dominfo.c +12 -2
@@ -26,7 +26,9 @@ static const char *const elf_xen_feature
     [XENFEAT_writable_descriptor_tables] = "writable_descriptor_tables",
     [XENFEAT_auto_translated_physmap] = "auto_translated_physmap",
     [XENFEAT_supervisor_mode_kernel] = "supervisor_mode_kernel",
-    [XENFEAT_pae_pgdir_above_4gb] = "pae_pgdir_above_4gb"
+    [XENFEAT_pae_pgdir_above_4gb] = "pae_pgdir_above_4gb",
+    [XENFEAT_privileged] = "privileged",
+    [XENFEAT_unprivileged] = "unprivileged"
 };
 static const int elf_xen_features =
 sizeof(elf_xen_feature_names) / sizeof(elf_xen_feature_names[0]);
@@ -83,7 +85,7 @@ int elf_xen_parse_features(const char *f
                 }
             }
         }
-        if ( i == elf_xen_features )
+        if ( i == elf_xen_features && required && feature[0] == '!' )
             return -1;
     }
 
@@ -114,6 +116,7 @@ int elf_xen_parse_note(struct elf_binary
         [XEN_ELFNOTE_LOADER] = { "LOADER", 1},
         [XEN_ELFNOTE_PAE_MODE] = { "PAE_MODE", 1},
         [XEN_ELFNOTE_FEATURES] = { "FEATURES", 1},
+        [XEN_ELFNOTE_SUPPORTED_FEATURES] = { "SUPPORTED_FEATURES", 0},
         [XEN_ELFNOTE_BSD_SYMTAB] = { "BSD_SYMTAB", 1},
         [XEN_ELFNOTE_SUSPEND_CANCEL] = { "SUSPEND_CANCEL", 0 },
         [XEN_ELFNOTE_MOD_START_PFN] = { "MOD_START_PFN", 0 },
@@ -122,6 +125,7 @@ int elf_xen_parse_note(struct elf_binary
 
     const char *str = NULL;
     uint64_t val = 0;
+    unsigned int i;
     int type = elf_uval(elf, note, type);
 
     if ( (type >= sizeof(note_desc) / sizeof(note_desc[0])) ||
@@ -200,6 +204,12 @@ int elf_xen_parse_note(struct elf_binary
             return -1;
         break;
 
+    case XEN_ELFNOTE_SUPPORTED_FEATURES:
+        for ( i = 0; i < XENFEAT_NR_SUBMAPS; ++i )
+            parms->f_supported[i] |= elf_note_numeric_array(
+                elf, note, sizeof(*parms->f_supported), i);
+        break;
+
     }
     return 0;
 }
xen/common/libelf/libelf-tools.c +21 -0
@@ -227,6 +227,27 @@ uint64_t elf_note_numeric(struct elf_bin
         return 0;
     }
 }
+
+uint64_t elf_note_numeric_array(struct elf_binary *elf, const elf_note 
 *note,
+                                unsigned int unitsz, unsigned int idx)
+{
+    const void *desc = elf_note_desc(elf, note);
+    int descsz = elf_uval(elf, note, descsz);
+
+    if ( descsz % unitsz || idx >= descsz / unitsz )
+        return 0;
+    switch (unitsz)
+    {
+    case 1:
+    case 2:
+    case 4:
+    case 8:
+        return elf_access_unsigned(elf, desc, idx * unitsz, unitsz);
+    default:
+        return 0;
+    }
+}
+
 const elf_note *elf_note_next(struct elf_binary *elf, const elf_note * 
 note)
 {
     int namesz = (elf_uval(elf, note, namesz) + 3) & ~3;
xen/include/public/elfnote.h +14 -1
@@ -179,9 +179,22 @@
 #define XEN_ELFNOTE_MOD_START_PFN 16
 
 /*
+ * The features supported by this kernel (numeric).
+ *
+ * Other than XEN_ELFNOTE_FEATURES on pre-4.2 Xen, this note allows a
+ * kernel to specify support for features that older hypervisors don't
+ * know about. The set of features 4.2 and newer hypervisors will
+ * consider supported by the kernel is the combination of the sets
+ * specified through this and the string note.
+ *
+ * LEGACY: FEATURES
+ */
+#define XEN_ELFNOTE_SUPPORTED_FEATURES 17
+
+/*
  * The number of the highest elfnote defined.
  */
-#define XEN_ELFNOTE_MAX XEN_ELFNOTE_MOD_START_PFN
+#define XEN_ELFNOTE_MAX XEN_ELFNOTE_SUPPORTED_FEATURES
 
 /*
  * System information exported through crash notes.
xen/include/public/features.h +7 -1
@@ -75,7 +75,13 @@
 #define XENFEAT_hvm_safe_pvclock           9
 
 /* x86: pirq can be used by HVM guests */
-#define XENFEAT_hvm_pirqs           10
+#define XENFEAT_hvm_pirqs                 10
+
+/* privileged operation is supported */
+#define XENFEAT_privileged                11
+
+/* un-privileged operation is supported */
+#define XENFEAT_unprivileged              12
 
 #define XENFEAT_NR_SUBMAPS 1
 
xen/include/xen/libelf.h +2 -0
@@ -179,6 +179,8 @@ const elf_sym *elf_sym_by_index(struct e
 const char *elf_note_name(struct elf_binary *elf, const elf_note * note);
 const void *elf_note_desc(struct elf_binary *elf, const elf_note * note);
 uint64_t elf_note_numeric(struct elf_binary *elf, const elf_note * note);
+uint64_t elf_note_numeric_array(struct elf_binary *, const elf_note *,
+                                unsigned int unitsz, unsigned int idx);
 const elf_note *elf_note_next(struct elf_binary *elf, const elf_note * 
 note);
 

int elf_is_elfbinary(const void *image);

#3 lore raw
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 11 lines · Jan Beulich

Oops, $subject should have said [PATCH, v3] ...

Quoted 9 lines
Quoted 1 line
Quoted 1 line · Jan Beulich

With our switching away from supporting 32-bit Dom0 operation, users complained that attempts (perhaps due to lack of knowledge of that change) to boot the no longer privileged kernel in Dom0 resulted in apparently silent failure. To make the mismatch explicit and visible, add feature flags that the kernel can set to indicate operation in what modes it supports. For backward compatibility, absence of both feature flags is taken to indicate a kernel that may be capable of operating in both modes.

Quoted 6 lines

Actually, since you are introducing a new interface to the feature bits _and_ it is not possible to add these new bits to the old interface anyway can't we just have XENFEAT_privileged and require that guest kernels using the new interface ensure that bit correctly represents the configuration? IOW backwards compatilibilty is ensure through the presence/absence of XEN_ELFNOTE_SUPPORTED_FEATURES.

At the risk of repeating myself - the notion of "privileged" implying ability to run unprivileged is a Linux one, and I don't want to embed such an implication in the interface.

Jan

#4 lore raw
Quoted 21 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 11 lines · Jan Beulich

Oops, $subject should have said [PATCH, v3] ...

Quoted 9 lines
Quoted 1 line
Quoted 1 line · Jan Beulich

With our switching away from supporting 32-bit Dom0 operation, users complained that attempts (perhaps due to lack of knowledge of that change) to boot the no longer privileged kernel in Dom0 resulted in apparently silent failure. To make the mismatch explicit and visible, add feature flags that the kernel can set to indicate operation in what modes it supports. For backward compatibility, absence of both feature flags is taken to indicate a kernel that may be capable of operating in both modes.

Quoted 6 lines

Actually, since you are introducing a new interface to the feature bits _and_ it is not possible to add these new bits to the old interface anyway can't we just have XENFEAT_privileged and require that guest kernels using the new interface ensure that bit correctly represents the configuration? IOW backwards compatilibilty is ensure through the presence/absence of XEN_ELFNOTE_SUPPORTED_FEATURES.

Quoted 3 lines

At the risk of repeating myself - the notion of "privileged" implying ability to run unprivileged is a Linux one, and I don't want to embed such an implication in the interface.

At the risk of repeating myself -- which functionality does domU require which is not also already necessary for a dom0 -- at least to the point of failing gracefully during boot?

You also have not explained _why_ a dom0-only guest would be a useful thing to have and to add extra complexity to our interfaces for, it's obviously very much a corner case.

If we choose to do so we can decree that a dom0-only capable guest must also have sufficient domU functionality to print a message when running as domU and if they choose not to do this then it only impacts that guest and its users (which IMHO provides sufficient pressure on guest implementers to do the right thing).

You say it is a Linux notion that dom0 implies domU but I am not aware of any PV OS which supports dom0 that doesn't also support domU, do you have specific examples of OSes which are dom0-only?

Ian.

#5 lore raw
Quoted 23 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 21 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 11 lines · Jan Beulich

Oops, $subject should have said [PATCH, v3] ...

Quoted 9 lines
Quoted 1 line
Quoted 1 line · Jan Beulich

With our switching away from supporting 32-bit Dom0 operation, users complained that attempts (perhaps due to lack of knowledge of that change) to boot the no longer privileged kernel in Dom0 resulted in apparently silent failure. To make the mismatch explicit and visible, add feature flags that the kernel can set to indicate operation in what modes it supports. For backward compatibility, absence of both feature flags is taken to indicate a kernel that may be capable of operating in both modes.

Actually, since you are introducing a new interface to the feature bits _and_ it is not possible to add these new bits to the old interface anyway can't we just have XENFEAT_privileged and require that guest kernels using the new interface ensure that bit correctly represents the configuration? IOW backwards compatilibilty is ensure through the presence/absence of XEN_ELFNOTE_SUPPORTED_FEATURES.

Quoted 7 lines
Quoted 3 lines

At the risk of repeating myself - the notion of "privileged" implying ability to run unprivileged is a Linux one, and I don't want to embed such an implication in the interface.

At the risk of repeating myself -- which functionality does domU require which is not also already necessary for a dom0 -- at least to the point of failing gracefully during boot?

Graceful failure requires access to some user visible output device. A Dom0-only kernel may e.g. not have any frontend drivers (particularly no xenfb one, and the guest and/or kernel config may not allow other virtualized output mechanisms).

Quoted 3 lines

You also have not explained _why_ a dom0-only guest would be a useful thing to have and to add extra complexity to our interfaces for, it's obviously very much a corner case.

It's really a decision between having efficient code (i.e. as little unused code as possible in a kernel suiting a particular need) and having a (relatively) general-purpose kernel.

Quoted 9 lines

If we choose to do so we can decree that a dom0-only capable guest must also have sufficient domU functionality to print a message when running as domU and if they choose not to do this then it only impacts that guest and its users (which IMHO provides sufficient pressure on guest implementers to do the right thing).

You say it is a Linux notion that dom0 implies domU but I am not aware of any PV OS which supports dom0 that doesn't also support domU, do you have specific examples of OSes which are dom0-only?

No, I'm not aware of any existing ones, but I also wasn't in favor of the move to imply unprivileged capabilities when Linux is configured as privileged guest (iirc this wasn't the case from the very beginning).

And again, imo an interface like the hypervisor's shouldn't dictate any kind of policy on the guest OSes.

Jan

#6 lore raw
Quoted 27 lines · Jan Beulich
Quoted 27 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 24 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 11 lines · Jan Beulich

Oops, $subject should have said [PATCH, v3] ...

Quoted 9 lines
Quoted 1 line
Quoted 1 line · Jan Beulich

With our switching away from supporting 32-bit Dom0 operation, users complained that attempts (perhaps due to lack of knowledge of that change) to boot the no longer privileged kernel in Dom0 resulted in apparently silent failure. To make the mismatch explicit and visible, add feature flags that the kernel can set to indicate operation in what modes it supports. For backward compatibility, absence of both feature flags is taken to indicate a kernel that may be capable of operating in both modes.

Quoted 6 lines

Actually, since you are introducing a new interface to the feature bits _and_ it is not possible to add these new bits to the old interface anyway can't we just have XENFEAT_privileged and require that guest kernels using the new interface ensure that bit correctly represents the configuration? IOW backwards compatilibilty is ensure through the presence/absence of XEN_ELFNOTE_SUPPORTED_FEATURES.

At the risk of repeating myself - the notion of "privileged" implying ability to run unprivileged is a Linux one, and I don't want to embed such an implication in the interface.

Quoted 8 lines
Quoted 3 lines

At the risk of repeating myself -- which functionality does domU require which is not also already necessary for a dom0 -- at least to the point of failing gracefully during boot?

Graceful failure requires access to some user visible output device. A Dom0-only kernel may e.g. not have any frontend drivers (particularly no xenfb one, and the guest and/or kernel config may not allow other virtualized output mechanisms).

Your Linux side patch sets the unprivileged guest feature independently of CONFIG_XEN_FRAMEBUFFER and/or CONFIG_HVC_XEN so the proposed interface is already providing opportunities for confusion/ambiguity.

Quoted 7 lines
Quoted 3 lines

You also have not explained _why_ a dom0-only guest would be a useful thing to have and to add extra complexity to our interfaces for, it's obviously very much a corner case.

It's really a decision between having efficient code (i.e. as little unused code as possible in a kernel suiting a particular need) and having a (relatively) general-purpose kernel.

We are talking about half a dozen lines of code to spit out a static string ("I don't support domU operation") to the domU and/or a guest side decision to omit sch code on the understanding that the disadvantage will be less error reporting when a minimal kernel suiting a particular need is used in some other context.

Quoted 10 lines
Quoted 9 lines

If we choose to do so we can decree that a dom0-only capable guest must also have sufficient domU functionality to print a message when running as domU and if they choose not to do this then it only impacts that guest and its users (which IMHO provides sufficient pressure on guest implementers to do the right thing).

You say it is a Linux notion that dom0 implies domU but I am not aware of any PV OS which supports dom0 that doesn't also support domU, do you have specific examples of OSes which are dom0-only?

Quoted 6 lines

No, I'm not aware of any existing ones, but I also wasn't in favor of the move to imply unprivileged capabilities when Linux is configured as privileged guest (iirc this wasn't the case from the very beginning).

And again, imo an interface like the hypervisor's shouldn't dictate any kind of policy on the guest OSes.

The only policy here is "if you want to be user friendly you must minimally arrange to output a simple domU console message indicating lack of domU support if you support dom0 operation only".

That's not so much a policy as pushing responsibility down into the guest kernel in an extremely unlikely configuration.

Ian.

#7 lore raw
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 4 lines · Jan Beulich
Quoted 3 lines

You also have not explained _why_ a dom0-only guest would be a useful thing to have and to add extra complexity to our interfaces for, it's obviously very much a corner case.

Quoted 6 lines
Quoted 3 lines

It's really a decision between having efficient code (i.e. as little unused code as possible in a kernel suiting a particular need) and having a (relatively) general-purpose kernel.

We are talking about half a dozen lines of code to spit out a static string ("I don't support domU operation") to the domU and/or a guest

You still didn't tell where such a message would show up: Printing such a message isn't a big deal, but pointless if it goes into no-where. If instead the hypervisor (for Dom0) or the tools (for DomU-s) print something, this will be visible in a known place.

Jan

#8 lore raw
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 7 lines · Jan Beulich
Quoted 3 lines

You also have not explained _why_ a dom0-only guest would be a useful thing to have and to add extra complexity to our interfaces for, it's obviously very much a corner case.

It's really a decision between having efficient code (i.e. as little unused code as possible in a kernel suiting a particular need) and having a (relatively) general-purpose kernel.

Quoted 7 lines
Quoted 2 lines

We are talking about half a dozen lines of code to spit out a static string ("I don't support domU operation") to the domU and/or a guest

You still didn't tell where such a message would show up: Printing such a message isn't a big deal, but pointless if it goes into no-where. If instead the hypervisor (for Dom0) or the tools (for DomU-s) print something, this will be visible in a known place.

If someone runs a dom0-only kernel as a domU (presumably by mistake) then they are naturally going to look in the domU console ring for error messages when it doesn't work (because they thought they were running a domU, where else would they look?). Placing that message there is basically a memcpy and an evtchn_notify.

If someone runs a domU only kernel as a dom0 then the XENFEAT_privileged (or whatever it gets called) is precisely enough to allow the hypervisor to say something useful in that case.

Ian.

#9 lore raw
In reply to Jan Beulich
Quoted 10 lines · Jan Beulich
Quoted 3 lines

You say it is a Linux notion that dom0 implies domU but I am not aware of any PV OS which supports dom0 that doesn't also support domU, do you have specific examples of OSes which are dom0-only?

No, I'm not aware of any existing ones, but I also wasn't in favor of the move to imply unprivileged capabilities when Linux is configured as privileged guest (iirc this wasn't the case from the very beginning).

And again, imo an interface like the hypervisor's shouldn't dictate any kind of policy on the guest OSes.

My own issue with the unprivileged flag is that I'm not clear what it actually means. When would you *not* set it? I mean it looks in the Linux side you set it unconditionally right now. What's the point? Why not remove the flag and introduce it when we have good reason and can attach meaningful semantics to it?

There we are, we're two against one now ;-)

-- Keir

#10 lore raw
Quoted 10 lines · Keir Fraser
Quoted 8 lines · Jan Beulich
Quoted 3 lines

You say it is a Linux notion that dom0 implies domU but I am not aware of any PV OS which supports dom0 that doesn't also support domU, do you have specific examples of OSes which are dom0-only?

No, I'm not aware of any existing ones, but I also wasn't in favor of the move to imply unprivileged capabilities when Linux is configured as privileged guest (iirc this wasn't the case from the very beginning).

Quoted 8 lines
Quoted 2 lines

And again, imo an interface like the hypervisor's shouldn't dictate any kind of policy on the guest OSes.

My own issue with the unprivileged flag is that I'm not clear what it actually means. When would you *not* set it? I mean it looks in the Linux side you set it unconditionally right now. What's the point? Why not remove the flag and introduce it when we have good reason and can attach meaningful semantics to it?

A further killing blow: the hypervisor patch defined unprivileged as !dom0. Well, there are many different capabilities and devices that a domU may be granted. You might be passing through a VGA adaptor and SRIOV NIC and run out of ramdisk for example, in which case the domU might quite validly have no PV frontend devices.

Another thing, given that privileged is quite a broad term, I wonder whether the 'privileged' feature should be called something else? Like 'dom0_interface'? It would be a more precise definition maybe? Passing through devices to a domU could be termed a privilege after all, for example.

-- Keir

Quoted 5 lines

There we are, we're two against one now ;-)

-- Keir

#11 lore raw
Quoted 28 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 10 lines · Keir Fraser
Quoted 8 lines · Jan Beulich
Quoted 3 lines

You say it is a Linux notion that dom0 implies domU but I am not aware of any PV OS which supports dom0 that doesn't also support domU, do you have specific examples of OSes which are dom0-only?

No, I'm not aware of any existing ones, but I also wasn't in favor of the move to imply unprivileged capabilities when Linux is configured as privileged guest (iirc this wasn't the case from the very beginning).

Quoted 8 lines
Quoted 2 lines

And again, imo an interface like the hypervisor's shouldn't dictate any kind of policy on the guest OSes.

My own issue with the unprivileged flag is that I'm not clear what it actually means. When would you *not* set it? I mean it looks in the Linux side you set it unconditionally right now. What's the point? Why not remove the flag and introduce it when we have good reason and can attach meaningful semantics to it?

A further killing blow: the hypervisor patch defined unprivileged as !dom0. Well, there are many different capabilities and devices that a domU may be granted. You might be passing through a VGA adaptor and SRIOV NIC and run out of ramdisk for example, in which case the domU might quite validly have no PV frontend devices.

Quoted 5 lines

Another thing, given that privileged is quite a broad term, I wonder whether the 'privileged' feature should be called something else? Like 'dom0_interface'? It would be a more precise definition maybe? Passing through devices to a domU could be termed a privilege after all, for example.

I agree that if we're going to go with just a single flag, then renaming it the way you suggest certainly makes sense.

Jan

#12 lore raw
In reply to Keir Fraser
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 8 lines · Jan Beulich
Quoted 3 lines

You say it is a Linux notion that dom0 implies domU but I am not aware of any PV OS which supports dom0 that doesn't also support domU, do you have specific examples of OSes which are dom0-only?

No, I'm not aware of any existing ones, but I also wasn't in favor of the move to imply unprivileged capabilities when Linux is configured as privileged guest (iirc this wasn't the case from the very beginning).

Quoted 8 lines
Quoted 2 lines

And again, imo an interface like the hypervisor's shouldn't dictate any kind of policy on the guest OSes.

My own issue with the unprivileged flag is that I'm not clear what it actually means. When would you *not* set it? I mean it looks in the Linux side you set it unconditionally right now. What's the point? Why not remove the flag and introduce it when we have good reason and can attach meaningful semantics to it?

Again - you're talking about an actual guest side implementation (which, in this particular case, has to honor how the rest of the implementation is done, i.e. it has to set the flag unconditionally). I'm talking about an abstract interface definition that should suit everyone (existing as well as yet to come).

Quoted 1 line

There we are, we're two against one now ;-)

Still hoping you both get my point. If not, I'll have to give in without being convinced.

Jan

#13 lore raw
Quoted 11 lines · Jan Beulich
Quoted 5 lines

My own issue with the unprivileged flag is that I'm not clear what it actually means. When would you *not* set it? I mean it looks in the Linux side you set it unconditionally right now. What's the point? Why not remove the flag and introduce it when we have good reason and can attach meaningful semantics to it?

Again - you're talking about an actual guest side implementation (which, in this particular case, has to honor how the rest of the implementation is done, i.e. it has to set the flag unconditionally). I'm talking about an abstract interface definition that should suit everyone (existing as well as yet to come).

I'm afraid my view is that !dom0 operation is a mode that every PV guest is capable of -- that's the definition of what a PV guest is, to my mind!

Like I said in my other email, pinning it down more precisely -- e.g., must have PV drivers -- will have counterexamples.

I don't know though --- maybe a distro could have dom0 and domU separate kernel builds, and want to set the flags differently for each. I wonder how much of a long shot that use case is.

-- Keir

#14 lore raw
Quoted 17 lines · Keir Fraser
Quoted 11 lines · Jan Beulich
Quoted 5 lines

My own issue with the unprivileged flag is that I'm not clear what it actually means. When would you *not* set it? I mean it looks in the Linux side you set it unconditionally right now. What's the point? Why not remove the flag and introduce it when we have good reason and can attach meaningful semantics to it?

Again - you're talking about an actual guest side implementation (which, in this particular case, has to honor how the rest of the implementation is done, i.e. it has to set the flag unconditionally). I'm talking about an abstract interface definition that should suit everyone (existing as well as yet to come).

I'm afraid my view is that !dom0 operation is a mode that every PV guest is capable of -- that's the definition of what a PV guest is, to my mind!

Quoted 6 lines

Like I said in my other email, pinning it down more precisely -- e.g., must have PV drivers -- will have counterexamples.

I don't know though --- maybe a distro could have dom0 and domU separate kernel builds, and want to set the flags differently for each. I wonder how much of a long shot that use case is.

How about having a XEN_ELFNOTE_REQUIRED_FEATURES as well as supported_features? Then you can define just one flag, XENFEAT_dom0_interface or somesuch, and:
Dom0 only: required_features |= dom0_interface Dom0/DomU: supported_features |= dom0_interface DomU only: n/a

In the hypervisor/tools, gate the acceptance check on new enough kernel (i.e., based on whether the kernel has XEN_ELFNOTE_SUPPORTED_FEATURES and/or XEN_ELFNOTE_REQUIRED_FEATURES, and turn that into a guest_has_modern_feature_flags boolean which you can integrate into various acceptance checks).

-- Keir

Quoted 3 lines

-- Keir

#15 lore raw
Quoted 33 lines · Keir Fraser
Quoted 17 lines · Keir Fraser
Quoted 11 lines · Jan Beulich
Quoted 5 lines

My own issue with the unprivileged flag is that I'm not clear what it actually means. When would you *not* set it? I mean it looks in the Linux side you set it unconditionally right now. What's the point? Why not remove the flag and introduce it when we have good reason and can attach meaningful semantics to it?

Again - you're talking about an actual guest side implementation (which, in this particular case, has to honor how the rest of the implementation is done, i.e. it has to set the flag unconditionally). I'm talking about an abstract interface definition that should suit everyone (existing as well as yet to come).

I'm afraid my view is that !dom0 operation is a mode that every PV guest is capable of -- that's the definition of what a PV guest is, to my mind!

Quoted 6 lines

Like I said in my other email, pinning it down more precisely -- e.g., must have PV drivers -- will have counterexamples.

I don't know though --- maybe a distro could have dom0 and domU separate kernel builds, and want to set the flags differently for each. I wonder how much of a long shot that use case is.

How about having a XEN_ELFNOTE_REQUIRED_FEATURES as well as supported_features? Then you can define just one flag, XENFEAT_dom0_interface or somesuch, and:
Dom0 only: required_features |= dom0_interface Dom0/DomU: supported_features |= dom0_interface DomU only: n/a

Quoted 5 lines

In the hypervisor/tools, gate the acceptance check on new enough kernel (i.e., based on whether the kernel has XEN_ELFNOTE_SUPPORTED_FEATURES and/or XEN_ELFNOTE_REQUIRED_FEATURES, and turn that into a guest_has_modern_feature_flags boolean which you can integrate into various acceptance checks).

That sounds reasonable to me.

Ian.

#16 lore raw
In reply to Keir Fraser
Quoted 23 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 20 lines · Keir Fraser
Quoted 11 lines · Jan Beulich
Quoted 5 lines

My own issue with the unprivileged flag is that I'm not clear what it actually means. When would you *not* set it? I mean it looks in the Linux side you set it unconditionally right now. What's the point? Why not remove the flag and introduce it when we have good reason and can attach meaningful semantics to it?

Again - you're talking about an actual guest side implementation (which, in this particular case, has to honor how the rest of the implementation is done, i.e. it has to set the flag unconditionally). I'm talking about an abstract interface definition that should suit everyone (existing as well as yet to come).

I'm afraid my view is that !dom0 operation is a mode that every PV guest is capable of -- that's the definition of what a PV guest is, to my mind!

Like I said in my other email, pinning it down more precisely -- e.g., must have PV drivers -- will have counterexamples.

Quoted 6 lines
Quoted 3 lines

I don't know though --- maybe a distro could have dom0 and domU separate kernel builds, and want to set the flags differently for each. I wonder how much of a long shot that use case is.

How about having a XEN_ELFNOTE_REQUIRED_FEATURES as well as supported_features? Then you can define just one flag,

Since there doesn't seem to be any use of the "required" marker so far, I didn't want to introduce these. But we certainly could (though for the moment I'm preparing an updated patch with just the _SUPPORTED_ part).

Quoted 4 lines

XENFEAT_dom0_interface or somesuch, and:
Dom0 only: required_features |= dom0_interface
Dom0/DomU: supported_features |= dom0_interface
DomU only: n/a

Yes, that's what I basically did now.

Jan

Quoted 11 lines

In the hypervisor/tools, gate the acceptance check on new enough kernel (i.e., based on whether the kernel has XEN_ELFNOTE_SUPPORTED_FEATURES and/or XEN_ELFNOTE_REQUIRED_FEATURES, and turn that into a guest_has_modern_feature_flags boolean which you can integrate into various acceptance checks).

-- Keir

Quoted 3 lines

-- Keir