Commit 1087e9b4 authored by Andi Kleen's avatar Andi Kleen

HWPOISON: Clean up PR_MCE_KILL interface

While writing the manpage I noticed some shortcomings in the
current interface.

- Define symbolic names for all the different values
- Boundary check the kill mode values
- For symmetry add a get interface too. This allows library
code to get/set the current state.
- For consistency define a PR_MCE_KILL_DEFAULT value
Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
parent f0a221ef
...@@ -88,6 +88,18 @@ ...@@ -88,6 +88,18 @@
#define PR_TASK_PERF_EVENTS_DISABLE 31 #define PR_TASK_PERF_EVENTS_DISABLE 31
#define PR_TASK_PERF_EVENTS_ENABLE 32 #define PR_TASK_PERF_EVENTS_ENABLE 32
/*
* Set early/late kill mode for hwpoison memory corruption.
* This influences when the process gets killed on a memory corruption.
*/
#define PR_MCE_KILL 33 #define PR_MCE_KILL 33
# define PR_MCE_KILL_CLEAR 0
# define PR_MCE_KILL_SET 1
# define PR_MCE_KILL_LATE 0
# define PR_MCE_KILL_EARLY 1
# define PR_MCE_KILL_DEFAULT 2
#define PR_MCE_KILL_GET 34
#endif /* _LINUX_PRCTL_H */ #endif /* _LINUX_PRCTL_H */
...@@ -1546,24 +1546,37 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, ...@@ -1546,24 +1546,37 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
if (arg4 | arg5) if (arg4 | arg5)
return -EINVAL; return -EINVAL;
switch (arg2) { switch (arg2) {
case 0: case PR_MCE_KILL_CLEAR:
if (arg3 != 0) if (arg3 != 0)
return -EINVAL; return -EINVAL;
current->flags &= ~PF_MCE_PROCESS; current->flags &= ~PF_MCE_PROCESS;
break; break;
case 1: case PR_MCE_KILL_SET:
current->flags |= PF_MCE_PROCESS; current->flags |= PF_MCE_PROCESS;
if (arg3 != 0) if (arg3 == PR_MCE_KILL_EARLY)
current->flags |= PF_MCE_EARLY; current->flags |= PF_MCE_EARLY;
else else if (arg3 == PR_MCE_KILL_LATE)
current->flags &= ~PF_MCE_EARLY; current->flags &= ~PF_MCE_EARLY;
else if (arg3 == PR_MCE_KILL_DEFAULT)
current->flags &=
~(PF_MCE_EARLY|PF_MCE_PROCESS);
else
return -EINVAL;
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
error = 0; error = 0;
break; break;
case PR_MCE_KILL_GET:
if (arg2 | arg3 | arg4 | arg5)
return -EINVAL;
if (current->flags & PF_MCE_PROCESS)
error = (current->flags & PF_MCE_EARLY) ?
PR_MCE_KILL_EARLY : PR_MCE_KILL_LATE;
else
error = PR_MCE_KILL_DEFAULT;
break;
default: default:
error = -EINVAL; error = -EINVAL;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment