diff mbox

common: clean up taint logic

Message ID 57A9CEF502000078001042B9@prv-mh.provo.novell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Beulich Aug. 9, 2016, 10:39 a.m. UTC
Drop unused UNSAFE_SMP and BAD_PAGE flags. Style adjstments.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
common: clean up taint logic

Drop unused UNSAFE_SMP and BAD_PAGE flags. Style adjstments.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -22,8 +22,6 @@
 
 enum system_state system_state = SYS_STATE_early_boot;
 
-int tainted;
-
 xen_commandline_t saved_cmdline;
 
 static void __init assign_integer_param(
@@ -168,14 +166,15 @@ int __init parse_bool(const char *s)
     return -1;
 }
 
+unsigned int tainted;
+
 /**
  *      print_tainted - return a string to represent the kernel taint state.
  *
- *  'S' - SMP with CPUs not designed for SMP.
- *  'M' - Machine had a machine check experience.
- *  'B' - System has hit bad_page.
  *  'C' - Console output is synchronous.
+ *  'E' - An error (e.g. a machine check exceptions) has been injected.
  *  'H' - HVM forced emulation prefix is permitted.
+ *  'M' - Machine had a machine check experience.
  *
  *      The string is overwritten by the next call to print_taint().
  */
@@ -183,11 +182,10 @@ char *print_tainted(char *str)
 {
     if ( tainted )
     {
-        snprintf(str, TAINT_STRING_MAX_LEN, "Tainted: %c%c%c%c%c",
-                 tainted & TAINT_UNSAFE_SMP ? 'S' : ' ',
+        snprintf(str, TAINT_STRING_MAX_LEN, "Tainted: %c%c%c%c",
                  tainted & TAINT_MACHINE_CHECK ? 'M' : ' ',
-                 tainted & TAINT_BAD_PAGE ? 'B' : ' ',
                  tainted & TAINT_SYNC_CONSOLE ? 'C' : ' ',
+                 tainted & TAINT_ERROR_INJECT ? 'E' : ' ',
                  tainted & TAINT_HVM_FEP ? 'H' : ' ');
     }
     else
@@ -198,7 +196,7 @@ char *print_tainted(char *str)
     return str;
 }
 
-void add_taint(unsigned flag)
+void add_taint(unsigned int flag)
 {
     tainted |= flag;
 }
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -137,16 +137,14 @@ unsigned long long parse_size_and_unit(c
 
 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
 
-#define TAINT_UNSAFE_SMP                (1<<0)
-#define TAINT_MACHINE_CHECK             (1<<1)
-#define TAINT_BAD_PAGE                  (1<<2)
-#define TAINT_SYNC_CONSOLE              (1<<3)
-#define TAINT_ERROR_INJECT              (1<<4)
-#define TAINT_HVM_FEP                   (1<<5)
-extern int tainted;
+#define TAINT_SYNC_CONSOLE              (1u << 0)
+#define TAINT_MACHINE_CHECK             (1u << 1)
+#define TAINT_ERROR_INJECT              (1u << 2)
+#define TAINT_HVM_FEP                   (1u << 3)
+extern unsigned int tainted;
 #define TAINT_STRING_MAX_LEN            20
 extern char *print_tainted(char *str);
-extern void add_taint(unsigned);
+extern void add_taint(unsigned int taint);
 
 struct cpu_user_regs;
 void dump_execstate(struct cpu_user_regs *);

Comments

George Dunlap Aug. 9, 2016, 1:16 p.m. UTC | #1
On 09/08/16 11:39, Jan Beulich wrote:
> Drop unused UNSAFE_SMP and BAD_PAGE flags. Style adjstments.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> --- a/xen/common/kernel.c
> +++ b/xen/common/kernel.c
> @@ -22,8 +22,6 @@
>  
>  enum system_state system_state = SYS_STATE_early_boot;
>  
> -int tainted;
> -
>  xen_commandline_t saved_cmdline;
>  
>  static void __init assign_integer_param(
> @@ -168,14 +166,15 @@ int __init parse_bool(const char *s)
>      return -1;
>  }
>  
> +unsigned int tainted;
> +
>  /**
>   *      print_tainted - return a string to represent the kernel taint state.
>   *
> - *  'S' - SMP with CPUs not designed for SMP.
> - *  'M' - Machine had a machine check experience.
> - *  'B' - System has hit bad_page.
>   *  'C' - Console output is synchronous.
> + *  'E' - An error (e.g. a machine check exceptions) has been injected.
>   *  'H' - HVM forced emulation prefix is permitted.
> + *  'M' - Machine had a machine check experience.

The wording here seems to imply that M -> E; but I don't see anything
which adds ERROR_INJECT.  Are you  planning on adding this at some point
in the future?

 -George

>   *
>   *      The string is overwritten by the next call to print_taint().
>   */
> @@ -183,11 +182,10 @@ char *print_tainted(char *str)
>  {
>      if ( tainted )
>      {
> -        snprintf(str, TAINT_STRING_MAX_LEN, "Tainted: %c%c%c%c%c",
> -                 tainted & TAINT_UNSAFE_SMP ? 'S' : ' ',
> +        snprintf(str, TAINT_STRING_MAX_LEN, "Tainted: %c%c%c%c",
>                   tainted & TAINT_MACHINE_CHECK ? 'M' : ' ',
> -                 tainted & TAINT_BAD_PAGE ? 'B' : ' ',
>                   tainted & TAINT_SYNC_CONSOLE ? 'C' : ' ',
> +                 tainted & TAINT_ERROR_INJECT ? 'E' : ' ',
>                   tainted & TAINT_HVM_FEP ? 'H' : ' ');
>      }
>      else
> @@ -198,7 +196,7 @@ char *print_tainted(char *str)
>      return str;
>  }
>  
> -void add_taint(unsigned flag)
> +void add_taint(unsigned int flag)
>  {
>      tainted |= flag;
>  }
> --- a/xen/include/xen/lib.h
> +++ b/xen/include/xen/lib.h
> @@ -137,16 +137,14 @@ unsigned long long parse_size_and_unit(c
>  
>  uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
>  
> -#define TAINT_UNSAFE_SMP                (1<<0)
> -#define TAINT_MACHINE_CHECK             (1<<1)
> -#define TAINT_BAD_PAGE                  (1<<2)
> -#define TAINT_SYNC_CONSOLE              (1<<3)
> -#define TAINT_ERROR_INJECT              (1<<4)
> -#define TAINT_HVM_FEP                   (1<<5)
> -extern int tainted;
> +#define TAINT_SYNC_CONSOLE              (1u << 0)
> +#define TAINT_MACHINE_CHECK             (1u << 1)
> +#define TAINT_ERROR_INJECT              (1u << 2)
> +#define TAINT_HVM_FEP                   (1u << 3)
> +extern unsigned int tainted;
>  #define TAINT_STRING_MAX_LEN            20
>  extern char *print_tainted(char *str);
> -extern void add_taint(unsigned);
> +extern void add_taint(unsigned int taint);
>  
>  struct cpu_user_regs;
>  void dump_execstate(struct cpu_user_regs *);
> 
> 
>
Jan Beulich Aug. 9, 2016, 2:06 p.m. UTC | #2
>>> On 09.08.16 at 15:16, <george.dunlap@citrix.com> wrote:
> On 09/08/16 11:39, Jan Beulich wrote:
>> --- a/xen/common/kernel.c
>> +++ b/xen/common/kernel.c
>> @@ -22,8 +22,6 @@
>>  
>>  enum system_state system_state = SYS_STATE_early_boot;
>>  
>> -int tainted;
>> -
>>  xen_commandline_t saved_cmdline;
>>  
>>  static void __init assign_integer_param(
>> @@ -168,14 +166,15 @@ int __init parse_bool(const char *s)
>>      return -1;
>>  }
>>  
>> +unsigned int tainted;
>> +
>>  /**
>>   *      print_tainted - return a string to represent the kernel taint state.
>>   *
>> - *  'S' - SMP with CPUs not designed for SMP.
>> - *  'M' - Machine had a machine check experience.
>> - *  'B' - System has hit bad_page.
>>   *  'C' - Console output is synchronous.
>> + *  'E' - An error (e.g. a machine check exceptions) has been injected.
>>   *  'H' - HVM forced emulation prefix is permitted.
>> + *  'M' - Machine had a machine check experience.
> 
> The wording here seems to imply that M -> E; but I don't see anything
> which adds ERROR_INJECT.  Are you  planning on adding this at some point
> in the future?

Did you grep the tree? I find two uses of ERROR_INJECT when I do.

Jan
George Dunlap Aug. 9, 2016, 2:14 p.m. UTC | #3
On 09/08/16 15:06, Jan Beulich wrote:
>>>> On 09.08.16 at 15:16, <george.dunlap@citrix.com> wrote:
>> On 09/08/16 11:39, Jan Beulich wrote:
>>> --- a/xen/common/kernel.c
>>> +++ b/xen/common/kernel.c
>>> @@ -22,8 +22,6 @@
>>>  
>>>  enum system_state system_state = SYS_STATE_early_boot;
>>>  
>>> -int tainted;
>>> -
>>>  xen_commandline_t saved_cmdline;
>>>  
>>>  static void __init assign_integer_param(
>>> @@ -168,14 +166,15 @@ int __init parse_bool(const char *s)
>>>      return -1;
>>>  }
>>>  
>>> +unsigned int tainted;
>>> +
>>>  /**
>>>   *      print_tainted - return a string to represent the kernel taint state.
>>>   *
>>> - *  'S' - SMP with CPUs not designed for SMP.
>>> - *  'M' - Machine had a machine check experience.
>>> - *  'B' - System has hit bad_page.
>>>   *  'C' - Console output is synchronous.
>>> + *  'E' - An error (e.g. a machine check exceptions) has been injected.
>>>   *  'H' - HVM forced emulation prefix is permitted.
>>> + *  'M' - Machine had a machine check experience.
>>
>> The wording here seems to imply that M -> E; but I don't see anything
>> which adds ERROR_INJECT.  Are you  planning on adding this at some point
>> in the future?
> 
> Did you grep the tree? I find two uses of ERROR_INJECT when I do.

Oh right -- I didn't because it looked like you were adding ERROR_INJECT
as a new #define; I see now you're just redefining it.

Everything looks correct then:

Acked-by: George Dunlap <george.dunlap@citrix.com>
diff mbox

Patch

--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -22,8 +22,6 @@ 
 
 enum system_state system_state = SYS_STATE_early_boot;
 
-int tainted;
-
 xen_commandline_t saved_cmdline;
 
 static void __init assign_integer_param(
@@ -168,14 +166,15 @@  int __init parse_bool(const char *s)
     return -1;
 }
 
+unsigned int tainted;
+
 /**
  *      print_tainted - return a string to represent the kernel taint state.
  *
- *  'S' - SMP with CPUs not designed for SMP.
- *  'M' - Machine had a machine check experience.
- *  'B' - System has hit bad_page.
  *  'C' - Console output is synchronous.
+ *  'E' - An error (e.g. a machine check exceptions) has been injected.
  *  'H' - HVM forced emulation prefix is permitted.
+ *  'M' - Machine had a machine check experience.
  *
  *      The string is overwritten by the next call to print_taint().
  */
@@ -183,11 +182,10 @@  char *print_tainted(char *str)
 {
     if ( tainted )
     {
-        snprintf(str, TAINT_STRING_MAX_LEN, "Tainted: %c%c%c%c%c",
-                 tainted & TAINT_UNSAFE_SMP ? 'S' : ' ',
+        snprintf(str, TAINT_STRING_MAX_LEN, "Tainted: %c%c%c%c",
                  tainted & TAINT_MACHINE_CHECK ? 'M' : ' ',
-                 tainted & TAINT_BAD_PAGE ? 'B' : ' ',
                  tainted & TAINT_SYNC_CONSOLE ? 'C' : ' ',
+                 tainted & TAINT_ERROR_INJECT ? 'E' : ' ',
                  tainted & TAINT_HVM_FEP ? 'H' : ' ');
     }
     else
@@ -198,7 +196,7 @@  char *print_tainted(char *str)
     return str;
 }
 
-void add_taint(unsigned flag)
+void add_taint(unsigned int flag)
 {
     tainted |= flag;
 }
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -137,16 +137,14 @@  unsigned long long parse_size_and_unit(c
 
 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
 
-#define TAINT_UNSAFE_SMP                (1<<0)
-#define TAINT_MACHINE_CHECK             (1<<1)
-#define TAINT_BAD_PAGE                  (1<<2)
-#define TAINT_SYNC_CONSOLE              (1<<3)
-#define TAINT_ERROR_INJECT              (1<<4)
-#define TAINT_HVM_FEP                   (1<<5)
-extern int tainted;
+#define TAINT_SYNC_CONSOLE              (1u << 0)
+#define TAINT_MACHINE_CHECK             (1u << 1)
+#define TAINT_ERROR_INJECT              (1u << 2)
+#define TAINT_HVM_FEP                   (1u << 3)
+extern unsigned int tainted;
 #define TAINT_STRING_MAX_LEN            20
 extern char *print_tainted(char *str);
-extern void add_taint(unsigned);
+extern void add_taint(unsigned int taint);
 
 struct cpu_user_regs;
 void dump_execstate(struct cpu_user_regs *);