Skip to contentSkip to conversation

Support for modifying parameters at runtime

PATCH In review Juergen Gross 2 participants 17 messages Aug 28, 2017

lore
Share & tools
lore
#1 lore raw

PATCH v5 1/15 xen/arch/x86/psr.c: let custom parameter parsing routines return errno

In reply to Juergen Gross

Modify the custom parameter parsing routines in:

xen/arch/x86/psr.c

to indicate whether the parameter value was parsed successfully.

Cc Jan Beulich <[email protected]>
Cc Andrew Cooper <[email protected]>

---
V5:
- rename variable (value -> delim, val_str -> val_delim) (Jan Beulich)

---
 xen/arch/x86/psr.c | 58 ++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 37 insertions(+), 21 deletions(-)
xen/arch/x86/psr.c +37 -21
index 25a85b65b2..4515100785 100644
@@ -418,50 +418,66 @@ static const struct feat_props l2_cat_props = {
     .write_msr = l2_cat_write_msr,
 };
 
-static void __init parse_psr_bool(char *s, char *value, char *feature,
+static bool __init parse_psr_bool(const char *s, const char *delim,
+                                  const char *ss, const char *feature,
                                   unsigned int mask)
 {
-    if ( !strcmp(s, feature) )
+    if ( !strncmp(s, feature, delim - s) )
     {
-        if ( !value )
+        if ( !*delim )
             opt_psr |= mask;
         else
         {
-            int val_int = parse_bool(value, NULL);
+            int val_int = parse_bool(delim + 1, ss);
 
             if ( val_int == 0 )
                 opt_psr &= ~mask;
             else if ( val_int == 1 )
                 opt_psr |= mask;
+            else
+                return false;
         }
+        return true;
     }
+    return false;
 }
 
-static void __init parse_psr_param(char *s)
+static int __init parse_psr_param(const char *s)
 {
-    char *ss, *val_str;
+    const char *ss, *val_delim;
+    const char *q;
+    int rc = 0;
 
     do {
         ss = strchr(s, ',');
-        if ( ss )
-            *ss = '\0';
-
-        val_str = strchr(s, ':');
-        if ( val_str )
-            *val_str++ = '\0';
+        if ( !ss )
+            ss = strchr(s, '\0');
 
-        parse_psr_bool(s, val_str, "cmt", PSR_CMT);
-        parse_psr_bool(s, val_str, "cat", PSR_CAT);
-        parse_psr_bool(s, val_str, "cdp", PSR_CDP);
+        val_delim = strchr(s, ':');
+        if ( !val_delim )
+            val_delim = strchr(s, '\0');
 
-        if ( val_str && !strcmp(s, "rmid_max") )
-            opt_rmid_max = simple_strtoul(val_str, NULL, 0);
-
-        if ( val_str && !strcmp(s, "cos_max") )
-            opt_cos_max = simple_strtoul(val_str, NULL, 0);
+        if ( *val_delim && !strncmp(s, "rmid_max", val_delim - s) )
+        {
+            opt_rmid_max = simple_strtoul(val_delim + 1, &q, 0);
+            if ( *q && *q != ',' )
+                rc = -EINVAL;
+        }
+        else if ( *val_delim && !strncmp(s, "cos_max", val_delim - s) )
+        {
+            opt_cos_max = simple_strtoul(val_delim + 1, &q, 0);
+            if ( *q && *q != ',' )
+                rc = -EINVAL;
+        }
+        else if ( !parse_psr_bool(s, val_delim, ss, "cmt", PSR_CMT) &&
+                  !parse_psr_bool(s, val_delim, ss, "cat", PSR_CAT) &&
+                  !parse_psr_bool(s, val_delim, ss, "cdp", PSR_CDP) )
+            rc = -EINVAL;
 
         s = ss + 1;
-    } while ( ss );
+    } while ( *ss );
+
+    return rc;
 }
 custom_param("psr", parse_psr_param);
 
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#3 lore raw

PATCH v5 2/15 xen: check parameter validity when parsing command line

In reply to Juergen Gross

Where possible check validity of parameters in _cmdline_parse() and issue a warning message in case of an error detected.

In order to make sure a custom parameter parsing function really returns a value (error or success), don't use a void pointer for storing the function address, but a proper typed function pointer.

Cc Andrew Cooper <[email protected]>
Cc George Dunlap <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Tim Deegan <[email protected]>
Cc Wei Liu <[email protected]>

---
V4:
- removed test for empty string from parse_bool() again, avoid calling parse_bool() in that case (Jan Beulich)
- print error number in failure case (Jan Beulich)
- limit scope of some variables (Jan Beulich)
- use type bool for bool_assert (Jan Beulich)

V3:
- use function pointer in struct kernel_param (Jan Beulich)
- better range check in assign_integer_param() (Jan Beulich)
- dont assign int values in case of overflow (Jan Beulich)
- allow multiple handlers for a parameter (Jan Beulich)

V2:
- replaced literal 8 by BITS_PER_BYTE (Wei Liu)
- added test for empty string to parse_bool()

---
 xen/common/kernel.c     | 68 ++++++++++++++++++++++++++++++++++++++-----------
 xen/include/xen/init.h  | 30 +++++++++++++++++-----
 xen/include/xen/types.h |  3 +++
 3 files changed, 80 insertions(+), 21 deletions(-)
xen/common/kernel.c +53 -15
index 71bc547d17..a0611d6c7c 100644
@@ -23,34 +23,43 @@ enum system_state system_state = SYS_STATE_early_boot;
 xen_commandline_t saved_cmdline;
 static const char __initconst opt_builtin_cmdline[] = CONFIG_CMDLINE;
 
-static void __init assign_integer_param(
+static int __init assign_integer_param(
     const struct kernel_param *param, uint64_t val)
 {
     switch ( param->len )
     {
     case sizeof(uint8_t):
-        *(uint8_t *)param->var = val;
+        if ( val > UINT8_MAX && val < (uint64_t)INT8_MIN )
+            return -EOVERFLOW;
+        *(uint8_t *)param->par.var = val;
         break;
     case sizeof(uint16_t):
-        *(uint16_t *)param->var = val;
+        if ( val > UINT16_MAX && val < (uint64_t)INT16_MIN )
+            return -EOVERFLOW;
+        *(uint16_t *)param->par.var = val;
         break;
     case sizeof(uint32_t):
-        *(uint32_t *)param->var = val;
+        if ( val > UINT32_MAX && val < (uint64_t)INT32_MIN )
+            return -EOVERFLOW;
+        *(uint32_t *)param->par.var = val;
         break;
     case sizeof(uint64_t):
-        *(uint64_t *)param->var = val;
+        *(uint64_t *)param->par.var = val;
         break;
     default:
         BUG();
     }
+
+    return 0;
 }
 
 static void __init _cmdline_parse(const char *cmdline)
 {
     char opt[128], *optval, *optkey, *q;
-    const char *p = cmdline;
+    const char *p = cmdline, *key;
     const struct kernel_param *param;
-    int bool_assert;
+    int rc;
+    bool bool_assert, found;
 
     for ( ; ; )
     {
@@ -84,46 +93,66 @@ static void __init _cmdline_parse(const char *cmdline)
         }
 
         /* Boolean parameters can be inverted with 'no-' prefix. */
+        key = optkey;
         bool_assert = !!strncmp("no-", optkey, 3);
         if ( !bool_assert )
             optkey += 3;
 
+        rc = 0;
+        found = false;
         for ( param = __setup_start; param < __setup_end; param++ )
         {
+            int rctmp;
+            const char *s;
+
             if ( strcmp(param->name, optkey) )
             {
                 if ( param->type == OPT_CUSTOM && q &&
                      strlen(param->name) == q + 1 - opt &&
                      !strncmp(param->name, opt, q + 1 - opt) )
                 {
+                    found = true;
                     optval[-1] = '=';
-                    ((void (*)(const char *))param->var)(q);
+                    rctmp = param->par.func(q);
                     optval[-1] = '\0';
+                    if ( !rc )
+                        rc = rctmp;
                 }
                 continue;
             }
 
+            rctmp = 0;
+            found = true;
             switch ( param->type )
             {
             case OPT_STR:
-                strlcpy(param->var, optval, param->len);
+                strlcpy(param->par.var, optval, param->len);
                 break;
             case OPT_UINT:
-                assign_integer_param(
+                rctmp = assign_integer_param(
                     param,
-                    simple_strtoll(optval, NULL, 0));
+                    simple_strtoll(optval, &s, 0));
+                if ( *s )
+                    rctmp = -EINVAL;
                 break;
             case OPT_BOOL:
-                if ( !parse_bool(*optval ? optval : "yes", NULL) )
+                rctmp = *optval ? parse_bool(optval, NULL) : 0;
+                if ( rctmp < 0 )
+                    break;
+                if ( !rctmp )
                     bool_assert = !bool_assert;
+                rctmp = 0;
                 assign_integer_param(param, bool_assert);
                 break;
             case OPT_SIZE:
-                assign_integer_param(
+                rctmp = assign_integer_param(
                     param,
-                    parse_size_and_unit(optval, NULL));
+                    parse_size_and_unit(optval, &s));
+                if ( *s )
+                    rctmp = -EINVAL;
                 break;
             case OPT_CUSTOM:
+                rctmp = -EINVAL;
                 if ( !bool_assert )
                 {
                     if ( *optval )
@@ -131,13 +160,22 @@ static void __init _cmdline_parse(const char *cmdline)
                     safe_strcpy(opt, "no");
                     optval = opt;
                 }
-                ((void (*)(const char *))param->var)(optval);
+                rctmp = param->par.func(optval);
                 break;
             default:
                 BUG();
                 break;
             }
+
+            if ( !rc )
+                rc = rctmp;
         }
+
+        if ( rc )
+            printk("parameter \"%s\" has invalid value \"%s\", rc=%d!\n",
+                    key, optval, rc);
+        if ( !found )
+            printk("parameter \"%s\" unknown!\n", key);
     }
 }
 
xen/include/xen/init.h +24 -6
index 25d2eef8dd..234ec25aae 100644
@@ -83,7 +83,10 @@ struct kernel_param {
         OPT_CUSTOM
     } type;
     unsigned int len;
-    void *var;
+    union {
+        void *var;
+        int (*func)(const char *);
+    } par;
 };
 
 extern const struct kernel_param __setup_start[], __setup_end[];
@@ -95,23 +98,38 @@ extern const struct kernel_param __setup_start[], __setup_end[];
 
 #define custom_param(_name, _var) \
     __setup_str __setup_str_##_var[] = _name; \
-    __kparam __setup_##_var = { __setup_str_##_var, OPT_CUSTOM, 0, _var }
+    __kparam __setup_##_var = \
+        { .name = __setup_str_##_var, \
+          .type = OPT_CUSTOM, \
+          .par.func = _var }
 #define boolean_param(_name, _var) \
     __setup_str __setup_str_##_var[] = _name; \
     __kparam __setup_##_var = \
-        { __setup_str_##_var, OPT_BOOL, sizeof(_var), &_var }
+        { .name = __setup_str_##_var, \
+          .type = OPT_BOOL, \
+          .len = sizeof(_var), \
+          .par.var = &_var }
 #define integer_param(_name, _var) \
     __setup_str __setup_str_##_var[] = _name; \
     __kparam __setup_##_var = \
-        { __setup_str_##_var, OPT_UINT, sizeof(_var), &_var }
+        { .name = __setup_str_##_var, \
+          .type = OPT_UINT, \
+          .len = sizeof(_var), \
+          .par.var = &_var }
 #define size_param(_name, _var) \
     __setup_str __setup_str_##_var[] = _name; \
     __kparam __setup_##_var = \
-        { __setup_str_##_var, OPT_SIZE, sizeof(_var), &_var }
+        { .name = __setup_str_##_var, \
+          .type = OPT_SIZE, \
+          .len = sizeof(_var), \
+          .par.var = &_var }
 #define string_param(_name, _var) \
     __setup_str __setup_str_##_var[] = _name; \
     __kparam __setup_##_var = \
-        { __setup_str_##_var, OPT_STR, sizeof(_var), &_var }
+        { .name = __setup_str_##_var, \
+          .type = OPT_STR, \
+          .len = sizeof(_var), \
+          .par.var = &_var }
 
 #endif /* __ASSEMBLY__ */
 
xen/include/xen/types.h +3 -0
index b1dbb8720a..03f0fe612e 100644
@@ -14,12 +14,15 @@
 #define NULL ((void*)0)
 #endif
 
+#define INT8_MIN        (-127-1)
 #define INT16_MIN       (-32767-1)
 #define INT32_MIN       (-2147483647-1)
 
+#define INT8_MAX        (127)
 #define INT16_MAX       (32767)
 #define INT32_MAX       (2147483647)
 
+#define UINT8_MAX       (255)
 #define UINT16_MAX      (65535)
 #define UINT32_MAX      (4294967295U)
 
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#4 lore raw

PATCH v5 3/15 xen/arch/x86/apic.c: remove custom_param() error messages

In reply to Juergen Gross

With _cmdline_parse() now issuing error messages in case of illegal parameters signalled by parsing functions specified in custom_param() the message issued by apic_set_verbosity() can be removed.

---
 xen/arch/x86/apic.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
xen/arch/x86/apic.c +1 -4
index 325b48074a..2638414e08 100644
@@ -800,11 +800,8 @@ static int __init apic_set_verbosity(const char *str)
         apic_verbosity = APIC_DEBUG;
     else if (strcmp("verbose", str) == 0)
         apic_verbosity = APIC_VERBOSE;
-    else {
-        printk(KERN_WARNING "APIC Verbosity level %s not recognised"
-               " use apic_verbosity=verbose or apic_verbosity=debug", str);
+    else
         return -EINVAL;
-    }
 
     return 0;
 }
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#5 lore raw

PATCH v5 4/15 xen/arch/x86/cpu/mcheck/mce.c: remove custom_param() error messages

In reply to Juergen Gross

With _cmdline_parse() now issuing error messages in case of illegal parameters signalled by parsing functions specified in custom_param() the message issued by mce_set_verbosity() can be removed.

---
 xen/arch/x86/cpu/mcheck/mce.c | 4 ----
 1 file changed, 4 deletions(-)
xen/arch/x86/cpu/mcheck/mce.c +0 -4
index 8015dff8c4..7affe2591e 100644
@@ -67,11 +67,7 @@ static int __init mce_set_verbosity(const char *str)
     if (strcmp("verbose", str) == 0)
         mce_verbosity = MCE_VERBOSE;
     else
-    {
-        printk(KERN_DEBUG "Machine Check verbosity level %s not recognised"
-               "use mce_verbosity=verbose", str);
         return -EINVAL;
-    }
 
     return 0;
 }
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#6 lore raw

PATCH v5 5/15 xen/arch/x86/hvm/viridian.c: remove custom_param() error messages

In reply to Juergen Gross

With _cmdline_parse() now issuing error messages in case of illegal parameters signalled by parsing functions specified in custom_param() the message issued by parse_viridian_version() can be removed.

---
 xen/arch/x86/hvm/viridian.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
xen/arch/x86/hvm/viridian.c +3 -7
index 2edf9d0b23..e0546f32fc 100644
@@ -1104,7 +1104,7 @@ static int __init parse_viridian_version(const char *arg)
         {
             n[i] = simple_strtoul(arg, &e, 0);
             if ( e != t )
-                goto fail;
+                break;
         }
 
         i++;
@@ -1112,12 +1112,12 @@ static int __init parse_viridian_version(const char *arg)
     } while ( *t );
 
     if ( i != 3 )
-        goto fail;
+        return -EINVAL;
 
     if ( ((typeof(viridian_major))n[0] != n[0]) ||
          ((typeof(viridian_minor))n[1] != n[1]) ||
          ((typeof(viridian_build))n[2] != n[2]) )
-        goto fail;
+        return -EINVAL;
 
     viridian_major = n[0];
     viridian_minor = n[1];
@@ -1126,10 +1126,6 @@ static int __init parse_viridian_version(const char *arg)
     printk("viridian-version = %#x,%#x,%#x\n",
            viridian_major, viridian_minor, viridian_build);
     return 0;
-
- fail:
-    printk(XENLOG_WARNING "Invalid viridian-version, using default\n");
-    return -EINVAL;
 }
 custom_param("viridian-version", parse_viridian_version);
 
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#7 lore raw

PATCH v5 6/15 xen/arch/x86/io_apic.c: remove custom_param() error messages

In reply to Juergen Gross

With _cmdline_parse() now issuing error messages in case of illegal parameters signalled by parsing functions specified in custom_param() the message issued by setup_ioapic_ack() can be removed.

---
 xen/arch/x86/io_apic.c | 3 ---
 1 file changed, 3 deletions(-)
xen/arch/x86/io_apic.c +0 -3
index f767c4560c..f959090ca0 100644
@@ -1594,10 +1594,7 @@ static int __init setup_ioapic_ack(const char *s)
         ioapic_ack_forced = true;
     }
     else
-    {
-        printk("Unknown ioapic_ack value specified: '%s'\n", s);
         return -EINVAL;
-    }
 
     return 0;
 }
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#8 lore raw

PATCH v5 7/15 xen/common/kexec.c: remove custom_param() error messages

In reply to Juergen Gross

With _cmdline_parse() now issuing error messages in case of illegal parameters signalled by parsing functions specified in custom_param() some messages issued by parse_low_crashinfo() and parse_crashinfo_maxaddr() can be removed.

---
 xen/common/kexec.c | 5 -----
 1 file changed, 5 deletions(-)
xen/common/kexec.c +0 -5
index fcc68bd4d8..e0f1e3eafa 100644
@@ -213,7 +213,6 @@ static int __init parse_low_crashinfo(const char *str)
         low_crashinfo_mode = LOW_CRASHINFO_ALL;
     else
     {
-        printk("Unknown low_crashinfo parameter '%s'.  Defaulting to min.\n", str);
         low_crashinfo_mode = LOW_CRASHINFO_MIN;
         return -EINVAL;
     }
@@ -240,11 +239,7 @@ static int __init parse_crashinfo_maxaddr(const char *str)
     if ( (addr = parse_size_and_unit(str, &q)) )
         crashinfo_maxaddr = addr;
     else
-    {
-        printk("Unable to parse crashinfo_maxaddr. Defaulting to %"PRIpaddr"\n",
-               crashinfo_maxaddr);
         return -EINVAL;
-    }
 
     return *q ? -EINVAL : 0;
 }
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#10 lore raw

PATCH v5 9/15 xen: carve out a generic parsing function from _cmdline_parse()

In reply to Juergen Gross

In order to support generic parameter parsing carve out the parser from _cmdline_parse(). As this generic function might be called after boot remove the __init annotations from all called sub-functions.

Cc Andrew Cooper <[email protected]>
Cc George Dunlap <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Tim Deegan <[email protected]>
Cc Wei Liu <[email protected]>
---
 xen/common/kernel.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
xen/common/kernel.c +19 -6
index a0611d6c7c..6e2f5ed9da 100644
@@ -23,8 +23,7 @@ enum system_state system_state = SYS_STATE_early_boot;
 xen_commandline_t saved_cmdline;
 static const char __initconst opt_builtin_cmdline[] = CONFIG_CMDLINE;
 
-static int __init assign_integer_param(
-    const struct kernel_param *param, uint64_t val)
+static int assign_integer_param(const struct kernel_param *param, uint64_t val)
 {
     switch ( param->len )
     {
@@ -53,12 +52,13 @@ static int __init assign_integer_param(
     return 0;
 }
 
-static void __init _cmdline_parse(const char *cmdline)
+static int parse_params(const char *cmdline, const struct kernel_param *start,
+                        const struct kernel_param *end)
 {
     char opt[128], *optval, *optkey, *q;
     const char *p = cmdline, *key;
     const struct kernel_param *param;
-    int rc;
+    int rc, final_rc = 0;
     bool bool_assert, found;
 
     for ( ; ; )
@@ -100,7 +100,7 @@ static void __init _cmdline_parse(const char *cmdline)
 
         rc = 0;
         found = false;
-        for ( param = __setup_start; param < __setup_end; param++ )
+        for ( param = start; param < end; param++ )
         {
             int rctmp;
             const char *s;
@@ -172,11 +172,24 @@ static void __init _cmdline_parse(const char *cmdline)
         }
 
         if ( rc )
+        {
             printk("parameter \"%s\" has invalid value \"%s\", rc=%d!\n",
                     key, optval, rc);
+            final_rc = rc;
+        }
         if ( !found )
+        {
             printk("parameter \"%s\" unknown!\n", key);
+            final_rc = -EINVAL;
+        }
     }
+
+    return final_rc;
+}
+
+static void __init _cmdline_parse(const char *cmdline)
+{
+    parse_params(cmdline, __setup_start, __setup_end);
 }
 
 /**
@@ -201,7 +214,7 @@ void __init cmdline_parse(const char *cmdline)
 #endif
 }
 
-int __init parse_bool(const char *s, const char *e)
+int parse_bool(const char *s, const char *e)
 {
     unsigned int len;
 
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#11 lore raw

PATCH v5 10/15 xen: add basic support for runtime parameter changing

In reply to Juergen Gross

Add the needed infrastructure for runtime parameter changing similar to that used at boot time via cmdline. We are using the same parsing functions as for cmdline parsing, but with a different array of parameter definitions.

Cc Andrew Cooper <[email protected]>
Cc George Dunlap <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Tim Deegan <[email protected]>
Cc Wei Liu <[email protected]>

---
V2:
- added modification of ARM linker script (Wei Liu)

V3:
- moved runtime parameter array in linker scripts (Jan Beulich)
- renamed macros to *_runtime_param() (Jan Beulich)
- added *runtime_only_param() macros (Jan Beulich)
- let *_runtime_param() macros include boot param functionality (Jan Beulich)

---
 xen/arch/arm/xen.lds.S |  4 ++++
 xen/arch/x86/xen.lds.S |  4 ++++
 xen/common/kernel.c    |  5 +++++
 xen/include/xen/init.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++--
 xen/include/xen/lib.h  |  1 +
 5 files changed, 69 insertions(+), 2 deletions(-)
xen/arch/arm/xen.lds.S +4 -0
index 2d54f224ec..c9b9546435 100644
@@ -61,6 +61,10 @@ SECTIONS
        *(.lockprofile.data)
        __lock_profile_end = .;
 #endif
+       . = ALIGN(POINTER_ALIGN);
+       __param_start = .;
+       *(.data.param)
+       __param_end = .;
   } :text
 
 #if defined(BUILD_ID)
xen/arch/x86/xen.lds.S +4 -0
index ff08bbe42a..6a7bbb8ca1 100644
@@ -120,6 +120,10 @@ SECTIONS
        *(.lockprofile.data)
        __lock_profile_end = .;
 #endif
+       . = ALIGN(POINTER_ALIGN);
+       __param_start = .;
+       *(.data.param)
+       __param_end = .;
   } :text
 
 #if defined(BUILD_ID)
xen/common/kernel.c +5 -0
index 6e2f5ed9da..f96e402515 100644
@@ -192,6 +192,11 @@ static void __init _cmdline_parse(const char *cmdline)
     parse_params(cmdline, __setup_start, __setup_end);
 }
 
+int runtime_parse(const char *line)
+{
+    return parse_params(line, __param_start, __param_end);
+}
+
 /**
  *    cmdline_parse -- parses the xen command line.
  * If CONFIG_CMDLINE is set, it would be parsed prior to @cmdline.
xen/include/xen/init.h +55 -2

72 lines not on this page · raw message

xen/include/xen/lib.h +1 -0
index 8e57bbd021..ed00ae1379 100644
@@ -71,6 +71,7 @@
 struct domain;
 
 void cmdline_parse(const char *cmdline);
+int runtime_parse(const char *line);
 int parse_bool(const char *s, const char *e);
 
 /*#define DEBUG_TRACE_DUMP*/
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#12 lore raw

PATCH v5 11/15 xen: add hypercall for setting parameters at runtime

In reply to Juergen Gross

Add a sysctl hypercall to support setting parameters similar to command line parameters, but at runtime. The parameters to set are specified as a string, just like the boot parameters.

Cc Daniel De Graaf <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Wei Liu <[email protected]>
Cc Andrew Cooper <[email protected]>
Cc George Dunlap <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Tim Deegan <[email protected]>

---
V4:
- use copy_from_guest() (Jan Beulich)
- add more descriptive comment to sysctl.h (Jan Beulich)

V3:
- check pad[] to be zero (Jan Beulich)
- return E2BIG in case of parameters too long (Jan Beulich)
- move max. parameter size define to sysctl.c (Jan Beulich)

V2:
- corrected XSM test (Daniel De Graaf)

---
 tools/flask/policy/modules/dom0.te  |  2 +-
 xen/common/sysctl.c                 | 36 ++++++++++++++++++++++++++++++++++++
 xen/include/public/sysctl.h         | 20 ++++++++++++++++++++
 xen/xsm/flask/hooks.c               |  3 +++
 xen/xsm/flask/policy/access_vectors |  2 ++
 5 files changed, 62 insertions(+), 1 deletion(-)
tools/flask/policy/modules/dom0.te +1 -1
index d0a4d91ac0..338caaf41e 100644
@@ -16,7 +16,7 @@ allow dom0_t xen_t:xen {
 allow dom0_t xen_t:xen2 {
 	resource_op psr_cmt_op psr_cat_op pmu_ctrl get_symbol
 	get_cpu_levelling_caps get_cpu_featureset livepatch_op
-	gcov_op
+	gcov_op set_parameter
 };
 
 # Allow dom0 to use all XENVER_ subops that have checks.
xen/common/sysctl.c +36 -0
index ae58a0f650..a6882d1c9d 100644
@@ -467,6 +467,42 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
             copyback = 1;
         break;
 
+    case XEN_SYSCTL_set_parameter:
+    {
+#define XEN_SET_PARAMETER_MAX_SIZE 1023
+        char *params;
+
+        if ( op->u.set_parameter.pad[0] || op->u.set_parameter.pad[1] ||
+             op->u.set_parameter.pad[2] )
+        {
+            ret = -EINVAL;
+            break;
+        }
+        if ( op->u.set_parameter.size > XEN_SET_PARAMETER_MAX_SIZE )
+        {
+            ret = -E2BIG;
+            break;
+        }
+        params = xmalloc_bytes(op->u.set_parameter.size + 1);
+        if ( !params )
+        {
+            ret = -ENOMEM;
+            break;
+        }
+        if ( copy_from_guest(params, op->u.set_parameter.params,
+                             op->u.set_parameter.size) )
+            ret = -EFAULT;
+        else
+        {
+            params[op->u.set_parameter.size] = 0;
+            ret = runtime_parse(params);
+        }
+
+        xfree(params);
+
+        break;
+    }
+
     default:
         ret = arch_do_sysctl(op, u_sysctl);
         copyback = 0;
xen/include/public/sysctl.h +20 -0
index 9e51af61e1..7830b987da 100644
@@ -1096,6 +1096,24 @@ struct xen_sysctl_livepatch_op {
 typedef struct xen_sysctl_livepatch_op xen_sysctl_livepatch_op_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_livepatch_op_t);
 
+/*
+ * XEN_SYSCTL_set_parameter
+ *
+ * Change hypervisor parameters at runtime.
+ * The input string is parsed similar to the boot parameters.
+ * Parameters are a single string terminated by a NUL byte of max. size
+ * characters. Multiple settings can be specified by separating them
+ * with blanks.
+ */
+
+struct xen_sysctl_set_parameter {
+    XEN_GUEST_HANDLE_64(char) params;       /* IN: pointer to parameters. */
+    uint16_t size;                          /* IN: size of parameters. */
+    uint16_t pad[3];                        /* IN: MUST be zero. */
+};
+typedef struct xen_sysctl_set_parameter xen_sysctl_set_parameter_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_set_parameter_t);
+
 struct xen_sysctl {
     uint32_t cmd;
 #define XEN_SYSCTL_readconsole                    1
@@ -1124,6 +1142,7 @@ struct xen_sysctl {
 #define XEN_SYSCTL_get_cpu_levelling_caps        25
 #define XEN_SYSCTL_get_cpu_featureset            26
 #define XEN_SYSCTL_livepatch_op                  27
+#define XEN_SYSCTL_set_parameter                 28
     uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
     union {
         struct xen_sysctl_readconsole       readconsole;
@@ -1152,6 +1171,7 @@ struct xen_sysctl {
         struct xen_sysctl_cpu_levelling_caps cpu_levelling_caps;
         struct xen_sysctl_cpu_featureset    cpu_featureset;
         struct xen_sysctl_livepatch_op      livepatch;
+        struct xen_sysctl_set_parameter     set_parameter;
         uint8_t                             pad[128];
     } u;
 };
xen/xsm/flask/hooks.c +3 -0
index 276ca97608..4989335f4a 100644
@@ -828,6 +828,9 @@ static int flask_sysctl(int cmd)
     case XEN_SYSCTL_gcov_op:
         return avc_current_has_perm(SECINITSID_XEN, SECCLASS_XEN2,
                                     XEN2__GCOV_OP, NULL);
+    case XEN_SYSCTL_set_parameter:
+        return avc_current_has_perm(SECINITSID_XEN, SECCLASS_XEN2,
+                                    XEN2__SET_PARAMETER, NULL);
 
     default:
         return avc_unknown_permission("sysctl", cmd);
xen/xsm/flask/policy/access_vectors +2 -0
index f276f04e29..da9f3dfb2e 100644
@@ -101,6 +101,8 @@ class xen2
     livepatch_op
 # XEN_SYSCTL_gcov_op
     gcov_op
+# XEN_SYSCTL_set_parameter
+    set_parameter
 }
 
 # Classes domain and domain2 consist of operations that a domain performs on
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#13 lore raw

PATCH v5 12/15 libxc: add function to set hypervisor parameters

In reply to Juergen Gross

Add a new libxc function to set hypervisor parameters at runtime similar to boot time parameters via command line.

---
V3:
- zero padding fields in sysctl.u.set_parameter

---
 tools/libxc/include/xenctrl.h |  1 +
 tools/libxc/xc_misc.c         | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)
tools/libxc/include/xenctrl.h +1 -0
index c7710b8f36..ad5e6b3d77 100644
@@ -1210,6 +1210,7 @@ int xc_readconsolering(xc_interface *xch,
                        int clear, int incremental, uint32_t *pindex);
 
 int xc_send_debug_keys(xc_interface *xch, char *keys);
+int xc_set_parameters(xc_interface *xch, char *params);
 
 typedef xen_sysctl_physinfo_t xc_physinfo_t;
 typedef xen_sysctl_cputopo_t xc_cputopo_t;
tools/libxc/xc_misc.c +21 -0
index 2303293c6c..7e15e904e3 100644
@@ -187,6 +187,27 @@ int xc_send_debug_keys(xc_interface *xch, char *keys)
     return ret;
 }
 
+int xc_set_parameters(xc_interface *xch, char *params)
+{
+    int ret, len = strlen(params);
+    DECLARE_SYSCTL;
+    DECLARE_HYPERCALL_BOUNCE(params, len, XC_HYPERCALL_BUFFER_BOUNCE_IN);
+
+    if ( xc_hypercall_bounce_pre(xch, params) )
+        return -1;
+
+    sysctl.cmd = XEN_SYSCTL_set_parameter;
+    set_xen_guest_handle(sysctl.u.set_parameter.params, params);
+    sysctl.u.set_parameter.size = len;
+    memset(sysctl.u.set_parameter.pad, 0, sizeof(sysctl.u.set_parameter.pad));
+
+    ret = do_sysctl(xch, &sysctl);
+
+    xc_hypercall_bounce_post(xch, params);
+
+    return ret;
+}
+
 int xc_physinfo(xc_interface *xch,
                 xc_physinfo_t *put_info)
 {
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#14 lore raw

PATCH v5 13/15 libxl: add libxl_set_parameters() function

In reply to Juergen Gross

Add a new libxl function to set hypervisor parameters at runtime similar to boot time parameters via command line.

---
V2:
- corrected coding style (Wei Liu)
- removed superfluous #ifdef (Wei Liu)

V3:
- use LOGEV() for error message

---
 tools/libxl/libxl.c | 15 +++++++++++++++
 tools/libxl/libxl.h |  8 ++++++++
 2 files changed, 23 insertions(+)
tools/libxl/libxl.c +15 -0
index 0ef874406f..247c56cf83 100644
@@ -652,6 +652,21 @@ int libxl_send_debug_keys(libxl_ctx *ctx, char *keys)
     return 0;
 }
 
+int libxl_set_parameters(libxl_ctx *ctx, char *params)
+{
+    int ret;
+    GC_INIT(ctx);
+
+    ret = xc_set_parameters(ctx->xch, params);
+    if (ret < 0) {
+        LOGEV(ERROR, ret, "setting parameters");
+        GC_FREE;
+        return ERROR_FAIL;
+    }
+    GC_FREE;
+    return 0;
+}
+
 static int fd_set_flags(libxl_ctx *ctx, int fd,
                         int fcntlgetop, int fcntlsetop, const char *fl,
                         int flagmask, int set_p)
tools/libxl/libxl.h +8 -0
index 229e289750..17045253ab 100644
@@ -1051,6 +1051,13 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src);
  */
 #define LIBXL_HAVE_QED 1
 
+/*
+ * LIBXL_HAVE_SET_PARAMETERS
+ *
+ * If this is defined setting hypervisor parameters is supported.
+ */
+#define LIBXL_HAVE_SET_PARAMETERS 1
+
 typedef char **libxl_string_list;
 void libxl_string_list_dispose(libxl_string_list *sl);
 int libxl_string_list_length(const libxl_string_list *sl);
@@ -2105,6 +2112,7 @@ int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid,
                        libxl_trigger trigger, uint32_t vcpuid);
 int libxl_send_sysrq(libxl_ctx *ctx, uint32_t domid, char sysrq);
 int libxl_send_debug_keys(libxl_ctx *ctx, char *keys);
+int libxl_set_parameters(libxl_ctx *ctx, char *params);
 
 typedef struct libxl__xen_console_reader libxl_xen_console_reader;
 
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#0 lore raw

v5 cover Support for modifying parameters at runtime

Currently parameters of the hypervisor (e.g. console log level) can be set via boot command line. Instead of having to reboot the system in case another setting is desired, being able to modify many of those parameters at runtime would be the better option.

This patch series addresses this by adding a new xl command "xl set-parameters" which takes a string similar to the boot command line as parameter and passes this string to the hypervisor which will then use the same parsing infrastructure as for the command line in order to apply the parameter settings.

As error checks for invalid parameters or parameter values have been very sparse if present at all in the hypervisor, the first part of this patch series addresses this problem first: all custom parameter parsing functions are being changed to return success or an error. The main parsing function tests for generic parameter value errors (like e.g. overflow) or invalid parameters and issues a message in case an error has been detected. Most error messages in the custom parsing functions are removed then.

While not strictly required for runtime parameter modification I believe an improved parameter validation is a win with or without the runtime parameter modification support.

* Patch 1 modifies the last remaining custom parameter parsing function not returning success or error to do so
* Patch 2 adds generic parameter error tests in the core parameter parsing functions
* Patches 3-8 remove custom parsing function error messages
* Patches 9-14 add the runtime parameter modification support
* Patch 15 adds support for runtime modification of some console related parameters

Changes in V5:
- 38 patches dropped as they are already applied
- Patch 1: rename variable (value -> delim, val_str -> val_delim) (Jan Beulich)

Changes in V4:
- added new patch 01
- patches 19, 23, 32, 34: pass end of parameter value to parse_bool() (Jan Beulich)
- patch 21: issue a message in case of reboot=efi and no EFI runtime services (Jan Beulich)
- patch 23: style correction (Jan Beulich)
- patch 32: add __initdata (Jan Beulich)
- patch 35: differentiate error return values (Jan Beulich)
- patch 35: drop pointless test for input parameter being NULL (Jan Beulich)
- patch 40: removed test for empty string from parse_bool() again, avoid calling parse_bool() in that case (Jan Beulich)
- patch 40: print error number in failure case (Jan Beulich)
- patch 40: limit scope of some variables (Jan Beulich)
- patch 40: use type bool for bool_assert (Jan Beulich)
- patch 49: use copy_from_guest() (Jan Beulich)
- patch 49: add more descriptive comment to sysctl.h (Jan Beulich)

Changes in V3:
- patches 7, 14, 15, 24, 27, 34: cosmetic changes (Jan Beulich)
- patches 7, 9, 10, 18, 22, 25, 31, 33, 34: dont modify option value in parsing function
- patches 8, 22, 25: dont return out of loop (Jan Beulich)
- patch 9: fix error in parsing routine
- patch 18: let parse_psr_bool() return bool value (Jan Beulich)
- patch 18: return error in case no string matches (Jan Beulich)
- patch 20: dont stop loop at first invalid character (Jan Beulich)
- patch 31: remove prototype of cpufreq_cmdline_parse() from cpufreq.h and make it static
- patch 39: use function pointer in struct kernel_param (Jan Beulich)
- patch 39: better range check in assign_integer_param() (Jan Beulich)
- patch 39: dont assign int values in case of overflow (Jan Beulich)
- patch 39: allow multiple handlers for a parameter (Jan Beulich)
- patch 47: moved runtime parameter array in linker scripts (Jan Beulich)
- patch 47: renamed macros to *_runtime_param() (Jan Beulich)
- patch 47: added *runtime_only_param() macros (Jan Beulich)
- patch 47: let *_runtime_param() macros include boot param functionality (Jan Beulich)
- patch 48: check pad[] to be zero (Jan Beulich)
- patch 48: return E2BIG in case of parameters too long (Jan Beulich)
- patch 48: move max. parameter size define to sysctl.c (Jan Beulich)
- patch 49: zero padding fields in sysctl.u.set_parameter
- patch 50: use LOGEV() for error message
- patch 52: *_runtime_param() now includes boot parameter setting (Jan Beulich)

Changes in V2:
- patch 39 (xen: check parameter validity when parsing command line):
replaced literal 8 by BITS_PER_BYTE (Wei Liu)
added test for empty string to parse_bool()
- patch 47 (xen: add basic support for runtime parameter changing):
added modification of ARM linker script (Wei Liu)
- patch 48 (xen: add hypercall for setting parameters at runtime):
corrected XSM test (Daniel De Graaf)
- patch 50 (libxl: add libxl_set_parameters() function):
corrected coding style (Wei Liu)

Cc Andrew Cooper <[email protected]>
Cc Daniel De Graaf <[email protected]>
Cc Dario Faggioli <[email protected]>
Cc George Dunlap <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Paul Durrant <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Tim Deegan <[email protected]>
Cc Wei Liu <[email protected]>

Juergen Gross (15):
xen/arch/x86/psr.c: let custom parameter parsing routines return errno
xen: check parameter validity when parsing command line xen/arch/x86/apic.c: remove custom_param() error messages xen/arch/x86/cpu/mcheck/mce.c: remove custom_param() error messages xen/arch/x86/hvm/viridian.c: remove custom_param() error messages xen/arch/x86/io_apic.c: remove custom_param() error messages xen/common/kexec.c: remove custom_param() error messages xen/common/sched_credit2.c: remove custom_param() error messages
xen: carve out a generic parsing function from _cmdline_parse()
xen: add basic support for runtime parameter changing
xen: add hypercall for setting parameters at runtime
libxc: add function to set hypervisor parameters
libxl: add libxl_set_parameters() function
xl: add new xl command set-parameters
xen: make some console related parameters settable at runtime

 docs/man/xl.pod.1.in                |  5 ++
 docs/misc/xen-command-line.markdown |  8 ++++
 tools/flask/policy/modules/dom0.te  |  2 +-
 tools/libxc/include/xenctrl.h       |  1 +
 tools/libxc/xc_misc.c               | 21 +++++++++
 tools/libxl/libxl.c                 | 15 ++++++
 tools/libxl/libxl.h                 |  8 ++++
 tools/xl/xl.h                       |  1 +
 tools/xl/xl_cmdtable.c              |  5 ++
 tools/xl/xl_misc.c                  | 20 ++++++++
 xen/arch/arm/xen.lds.S              |  4 ++
 xen/arch/x86/apic.c                 |  5 +-
 xen/arch/x86/cpu/mcheck/mce.c       |  4 --
 xen/arch/x86/hvm/viridian.c         | 10 ++--
 xen/arch/x86/io_apic.c              |  3 --
 xen/arch/x86/psr.c                  | 58 ++++++++++++++---------
 xen/arch/x86/xen.lds.S              |  4 ++
 xen/common/kernel.c                 | 94 +++++++++++++++++++++++++++++--------
 xen/common/kexec.c                  |  5 --
 xen/common/sched_credit2.c          |  2 -
 xen/common/sysctl.c                 | 36 ++++++++++++++
 xen/drivers/char/console.c          | 18 +++----
 xen/include/public/sysctl.h         | 20 ++++++++
 xen/include/xen/init.h              | 87 ++++++++++++++++++++++++++++++----
 xen/include/xen/lib.h               |  1 +
 xen/include/xen/types.h             |  3 ++
 xen/xsm/flask/hooks.c               |  3 ++
 xen/xsm/flask/policy/access_vectors |  2 +
 28 files changed, 362 insertions(+), 83 deletions(-)
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#15 lore raw

PATCH v5 14/15 xl: add new xl command set-parameters

Add a new xl command "set-parameters" to set hypervisor parameters at runtime similar to boot time parameters via command line.

---
 docs/man/xl.pod.1.in   |  5 +++++
 tools/xl/xl.h          |  1 +
 tools/xl/xl_cmdtable.c |  5 +++++
 tools/xl/xl_misc.c     | 20 ++++++++++++++++++++
 4 files changed, 31 insertions(+)
docs/man/xl.pod.1.in +5 -0
index 16c83066fe..3d5f2f7359 100644
@@ -822,6 +822,11 @@ Pass the VNC password to vncviewer via stdin.
 Send debug I<keys> to Xen. It is the same as pressing the Xen
 "conswitch" (Ctrl-A by default) three times and then pressing "keys".
 
+=item B<set-parameters> I<params>
+
+Set hypervisor parameters as specified in I<params>. This allows for some
+boot parameters of the hypervisor to be modified in the running systems.
+
 =item B<dmesg> [I<OPTIONS>]
 
 Reads the Xen message buffer, similar to dmesg on a Linux system.  The
tools/xl/xl.h +1 -0
index aa95b77146..5d3d2a4835 100644
@@ -154,6 +154,7 @@ int main_rename(int argc, char **argv);
 int main_trigger(int argc, char **argv);
 int main_sysrq(int argc, char **argv);
 int main_debug_keys(int argc, char **argv);
+int main_set_parameters(int argc, char **argv);
 int main_dmesg(int argc, char **argv);
 int main_top(int argc, char **argv);
 int main_networkattach(int argc, char **argv);
tools/xl/xl_cmdtable.c +5 -0
index 2c71a9f776..ba0159df67 100644
@@ -309,6 +309,11 @@ struct cmd_spec cmd_table[] = {
       "Send debug keys to Xen",
       "<Keys>",
     },
+    { "set-parameters",
+      &main_set_parameters, 0, 1,
+      "Set hypervisor parameters",
+      "<Params>",
+    },
     { "dmesg",
       &main_dmesg, 0, 0,
       "Read and/or clear dmesg buffer",
tools/xl/xl_misc.c +20 -0
index 9c6227af23..dcf940a6d4 100644
@@ -155,6 +155,26 @@ int main_debug_keys(int argc, char **argv)
     return EXIT_SUCCESS;
 }
 
+int main_set_parameters(int argc, char **argv)
+{
+    int opt;
+    char *params;
+
+    SWITCH_FOREACH_OPT(opt, "", NULL, "set-parameters", 1) {
+        /* No options */
+    }
+
+    params = argv[optind];
+
+    if (libxl_set_parameters(ctx, params)) {
+        fprintf(stderr, "cannot set parameters: %s\n", params);
+        fprintf(stderr, "Use \"xl dmesg\" to look for possible reason.\n");
+        return EXIT_FAILURE;
+    }
+
+    return EXIT_SUCCESS;
+}
+
 int main_devd(int argc, char **argv)
 {
     int ret = 0, opt = 0, daemonize = 1;
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#16 lore raw

PATCH v5 15/15 xen: make some console related parameters settable at runtime

In reply to Juergen Gross

Support modifying conswitch, console_timestamps, loglvl and guest_loglvl at runtime.

Cc Andrew Cooper <[email protected]>
Cc George Dunlap <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Tim Deegan <[email protected]>
Cc Wei Liu <[email protected]>

---
V3:
- *_runtime_param() now includes boot parameter setting (Jan Beulich)

---
 docs/misc/xen-command-line.markdown |  8 ++++++++
 xen/drivers/char/console.c          | 18 +++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)
docs/misc/xen-command-line.markdown +8 -0
index 4002eab08b..9797c8db2d 100644
@@ -391,6 +391,8 @@ makes sense on its own.
 
 > Default: `none`
 
+> Can be modified at runtime
+
 Specify which timestamp format Xen should use for each console line.
 
 * `none`: No timestamps
@@ -417,6 +419,8 @@ into the console ring buffer.
 
 > Default: `conswitch=a`
 
+> Can be modified at runtime
+
 Specify which character should be used to switch serial input between
 Xen and dom0.  The required sequence is CTRL-&lt;switch char&gt; three
 times.
@@ -898,6 +902,8 @@ maximum number of maptrack frames domain.
 
 > Default: `guest_loglvl=none/warning`
 
+> Can be modified at runtime
+
 Set the logging level for Xen guests.  Any log message with equal more
 more importance will be printed.
 
@@ -1164,6 +1170,8 @@ if left disabled by the BIOS.
 
 > Default: `loglvl=warning`
 
+> Can be modified at runtime
+
 Set the logging level for Xen.  Any log message with equal more more
 importance will be printed.
 
xen/drivers/char/console.c +9 -9
index 36f94e6b94..19d0e74f17 100644
@@ -40,7 +40,7 @@ string_param("console", opt_console);
 /* Char 2: If this character is 'x', then do not auto-switch to DOM0 when it */
 /*         boots. Any other value, or omitting the char, enables auto-switch */
 static unsigned char __read_mostly opt_conswitch[3] = "a";
-string_param("conswitch", opt_conswitch);
+string_runtime_param("conswitch", opt_conswitch);
 
 /* sync_console: force synchronous console output (useful for debugging). */
 static bool_t __initdata opt_sync_console;
@@ -68,7 +68,7 @@ enum con_timestamp_mode
 static enum con_timestamp_mode __read_mostly opt_con_timestamp_mode = TSM_NONE;
 
 static int parse_console_timestamps(const char *s);
-custom_param("console_timestamps", parse_console_timestamps);
+custom_runtime_param("console_timestamps", parse_console_timestamps);
 
 /* conring_size: allows a large console ring than default (16kB). */
 static uint32_t __initdata opt_conring_size;
@@ -134,8 +134,8 @@ static int parse_guest_loglvl(const char *s);
  * Similar definitions for guest_loglvl, but applies to guest tracing.
  * Defaults: loglvl=warning ; guest_loglvl=none/warning
  */
-custom_param("loglvl", parse_loglvl);
-custom_param("guest_loglvl", parse_guest_loglvl);
+custom_runtime_param("loglvl", parse_loglvl);
+custom_runtime_param("guest_loglvl", parse_guest_loglvl);
 
 static atomic_t print_everything = ATOMIC_INIT(0);
 
@@ -145,7 +145,7 @@ static atomic_t print_everything = ATOMIC_INIT(0);
         return (lvlnum);                                \
     }
 
-static int __init __parse_loglvl(const char *s, const char **ps)
+static int __parse_loglvl(const char *s, const char **ps)
 {
     ___parse_loglvl(s, ps, "none",    0);
     ___parse_loglvl(s, ps, "error",   1);
@@ -156,7 +156,7 @@ static int __init __parse_loglvl(const char *s, const char **ps)
     return 2; /* sane fallback */
 }
 
-static int __init _parse_loglvl(const char *s, int *lower, int *upper)
+static int _parse_loglvl(const char *s, int *lower, int *upper)
 {
     *lower = *upper = __parse_loglvl(s, &s);
     if ( *s == '/' )
@@ -167,12 +167,12 @@ static int __init _parse_loglvl(const char *s, int *lower, int *upper)
     return *s ? -EINVAL : 0;
 }
 
-static int __init parse_loglvl(const char *s)
+static int parse_loglvl(const char *s)
 {
     return _parse_loglvl(s, &xenlog_lower_thresh, &xenlog_upper_thresh);
 }
 
-static int __init parse_guest_loglvl(const char *s)
+static int parse_guest_loglvl(const char *s)
 {
     return _parse_loglvl(s, &xenlog_guest_lower_thresh,
                          &xenlog_guest_upper_thresh);
@@ -606,7 +606,7 @@ static int printk_prefix_check(char *p, char **pp)
             ((loglvl < upper_thresh) && printk_ratelimit()));
 } 
 
-static int __init parse_console_timestamps(const char *s)
+static int parse_console_timestamps(const char *s)
 {
     switch ( parse_bool(s, NULL) )
     {
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#9 lore raw

PATCH v5 8/15 xen/common/sched_credit2.c: remove custom_param() error messages

In reply to Juergen Gross

With _cmdline_parse() now issuing error messages in case of illegal parameters signalled by parsing functions specified in custom_param() the message issued by parse_credit2_runqueue() can be removed.

---
 xen/common/sched_credit2.c | 2 --
 1 file changed, 2 deletions(-)
xen/common/sched_credit2.c +0 -2
index 9b1db1351f..2da9cc2ffb 100644
@@ -352,8 +352,6 @@ static int parse_credit2_runqueue(const char *s)
         }
     }
 
-    printk("WARNING, unrecognized value of credit2_runqueue option!\n");
-
     return -EINVAL;
 }
 custom_param("credit2_runqueue", parse_credit2_runqueue);
Signature · 7 lines
2.12.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v5 1/15
#2 lore raw

Re: [PATCH v5 01/15] xen/arch/x86/psr.c: let custom parameter parsing routines return errno

In reply to Juergen Gross
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 28.08.17 at 09:34, <[email protected]> wrote:

Modify the custom parameter parsing routines in:

xen/arch/x86/psr.c

to indicate whether the parameter value was parsed successfully.

Cc Jan Beulich <[email protected]>
Cc Andrew Cooper <[email protected]>

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel