diff mbox series

[Xen-devel,for-4.13,v4,12/19] xen/arm: traps: Don't ignore invalid value for serrors=

Message ID 20191031150922.22938-13-julien.grall@arm.com
State New
Headers show
Series xen/arm: XSA-201 and XSA-263 fixes | expand

Commit Message

Julien Grall Oct. 31, 2019, 3:09 p.m. UTC
serrors= only supports 3 values "diverse", "forward" and "panic".

The current implementation of parse_serrors_behavior() will default to
"diverse" for any invalid value and not tell the users.

Rather than ignore the invalid input, return an error to the caller so
it can decides the be approach.

This will be useful after a follow-up patch where the number of options
will be reduced.

Take the opportunity to initialize serrors_op to SERRORS_DIVERSE rather
than relying on the item to be the first in the enum and therefore
equal to 0.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellin <sstabellini@kernel.org>

    Changes in v3:
        - Add Stefano's reviewed-by

    Changes in v2:
        - Patch added
 xen/arch/arm/traps.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series


diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index cb4e3b627b..d028ec9224 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -104,14 +104,16 @@  register_t get_default_hcr_flags(void)
 static enum {
-} serrors_op;
+} serrors_op = SERRORS_DIVERSE;
 static int __init parse_serrors_behavior(const char *str)
     if ( !strcmp(str, "panic") )
         serrors_op = SERRORS_PANIC;
-    else
+    else if ( !strcmp(str, "diverse") )
         serrors_op = SERRORS_DIVERSE;
+    else
+        return -EINVAL;
     return 0;