aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2009-10-03 20:20:11 -0400
committerAndi Kleen <ak@linux.intel.com>2009-10-03 21:23:17 -0400
commit1087e9b4ff708976499b4de541d9e1d57d49b60a (patch)
treea370356b3f969b6081189d850d9a56921ed341c4
parentf0a221ef47df3cdde2123fe75ce3b61bb7df656d (diff)
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: Andi Kleen <ak@linux.intel.com>
-rw-r--r--include/linux/prctl.h12
-rw-r--r--kernel/sys.c23
2 files changed, 30 insertions, 5 deletions
diff --git a/include/linux/prctl.h b/include/linux/prctl.h
index 931150566ade..a3baeb2c2161 100644
--- a/include/linux/prctl.h
+++ b/include/linux/prctl.h
@@ -88,6 +88,18 @@
88#define PR_TASK_PERF_EVENTS_DISABLE 31 88#define PR_TASK_PERF_EVENTS_DISABLE 31
89#define PR_TASK_PERF_EVENTS_ENABLE 32 89#define PR_TASK_PERF_EVENTS_ENABLE 32
90 90
91/*
92 * Set early/late kill mode for hwpoison memory corruption.
93 * This influences when the process gets killed on a memory corruption.
94 */
91#define PR_MCE_KILL 33 95#define PR_MCE_KILL 33
96# define PR_MCE_KILL_CLEAR 0
97# define PR_MCE_KILL_SET 1
98
99# define PR_MCE_KILL_LATE 0
100# define PR_MCE_KILL_EARLY 1
101# define PR_MCE_KILL_DEFAULT 2
102
103#define PR_MCE_KILL_GET 34
92 104
93#endif /* _LINUX_PRCTL_H */ 105#endif /* _LINUX_PRCTL_H */
diff --git a/kernel/sys.c b/kernel/sys.c
index 255475d163e0..f6afe07d6c0b 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1546,24 +1546,37 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
1546 if (arg4 | arg5) 1546 if (arg4 | arg5)
1547 return -EINVAL; 1547 return -EINVAL;
1548 switch (arg2) { 1548 switch (arg2) {
1549 case 0: 1549 case PR_MCE_KILL_CLEAR:
1550 if (arg3 != 0) 1550 if (arg3 != 0)
1551 return -EINVAL; 1551 return -EINVAL;
1552 current->flags &= ~PF_MCE_PROCESS; 1552 current->flags &= ~PF_MCE_PROCESS;
1553 break; 1553 break;
1554 case 1: 1554 case PR_MCE_KILL_SET:
1555 current->flags |= PF_MCE_PROCESS; 1555 current->flags |= PF_MCE_PROCESS;
1556 if (arg3 != 0) 1556 if (arg3 == PR_MCE_KILL_EARLY)
1557 current->flags |= PF_MCE_EARLY; 1557 current->flags |= PF_MCE_EARLY;
1558 else 1558 else if (arg3 == PR_MCE_KILL_LATE)
1559 current->flags &= ~PF_MCE_EARLY; 1559 current->flags &= ~PF_MCE_EARLY;
1560 else if (arg3 == PR_MCE_KILL_DEFAULT)
1561 current->flags &=
1562 ~(PF_MCE_EARLY|PF_MCE_PROCESS);
1563 else
1564 return -EINVAL;
1560 break; 1565 break;
1561 default: 1566 default:
1562 return -EINVAL; 1567 return -EINVAL;
1563 } 1568 }
1564 error = 0; 1569 error = 0;
1565 break; 1570 break;
1566 1571 case PR_MCE_KILL_GET:
1572 if (arg2 | arg3 | arg4 | arg5)
1573 return -EINVAL;
1574 if (current->flags & PF_MCE_PROCESS)
1575 error = (current->flags & PF_MCE_EARLY) ?
1576 PR_MCE_KILL_EARLY : PR_MCE_KILL_LATE;
1577 else
1578 error = PR_MCE_KILL_DEFAULT;
1579 break;
1567 default: 1580 default:
1568 error = -EINVAL; 1581 error = -EINVAL;
1569 break; 1582 break;