/[linux-patches]/genpatches-2.6/tags/2.6.21-2/4405_alpha-sysctl-uac.patch
Gentoo

Contents of /genpatches-2.6/tags/2.6.21-2/4405_alpha-sysctl-uac.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 962 - (show annotations) (download)
Fri May 18 22:56:34 2007 UTC (11 years, 5 months ago) by dsd
File size: 5776 byte(s)
2.6.21-2 release
1 diff -urN linux-2.6.21.orig/arch/alpha/Kconfig linux-2.6.21/arch/alpha/Kconfig
2 --- linux-2.6.21.orig/arch/alpha/Kconfig 2007-04-26 03:08:32.000000000 +0000
3 +++ linux-2.6.21/arch/alpha/Kconfig 2007-05-14 16:20:45.000000000 +0000
4 @@ -602,6 +602,32 @@
5
6 Take the default (1) unless you want more control or more info.
7
8 +config ALPHA_UAC_SYSCTL
9 + bool "Configure UAC policy via sysctl"
10 + depends on SYSCTL
11 + default y
12 + ---help---
13 + Configuring the UAC (unaligned access control) policy on a Linux
14 + system usually involves setting a compile time define. If you say
15 + Y here, you will be able to modify the UAC policy at runtime using
16 + the /proc interface.
17 +
18 + The UAC policy defines the action Linux should take when an
19 + unaligned memory access occurs. The action can include printing a
20 + warning message (NOPRINT), sending a signal to the offending
21 + program to help developers debug their applications (SIGBUS), or
22 + disabling the transparent fixing (NOFIX).
23 +
24 + The sysctls will be initialized to the compile-time defined UAC
25 + policy. You can change these manually, or with the sysctl(8)
26 + userspace utility.
27 +
28 + To disable the warning messages at runtime, you would use
29 +
30 + echo 1 > /proc/sys/kernel/uac/noprint
31 +
32 + This is pretty harmless. Say Y if you're not sure.
33 +
34 source "drivers/pci/Kconfig"
35 source "drivers/eisa/Kconfig"
36
37 diff -urN linux-2.6.21.orig/arch/alpha/kernel/traps.c linux-2.6.21/arch/alpha/kernel/traps.c
38 --- linux-2.6.21.orig/arch/alpha/kernel/traps.c 2007-04-26 03:08:32.000000000 +0000
39 +++ linux-2.6.21/arch/alpha/kernel/traps.c 2007-05-14 16:22:16.000000000 +0000
40 @@ -14,6 +14,7 @@
41 #include <linux/delay.h>
42 #include <linux/smp_lock.h>
43 #include <linux/module.h>
44 +#include <linux/sysctl.h>
45 #include <linux/init.h>
46 #include <linux/kallsyms.h>
47
48 @@ -102,6 +103,38 @@
49 "t10", "t11", "ra", "pv", "at", "gp", "sp", "zero"};
50 #endif
51
52 +#ifdef CONFIG_ALPHA_UAC_SYSCTL
53 +static struct ctl_table_header *uac_sysctl_header;
54 +
55 +static int enabled_noprint = 0;
56 +static int enabled_sigbus = 0;
57 +static int enabled_nofix = 0;
58 +
59 +ctl_table uac_table[] = {
60 + {KERN_UAC_NOPRINT, "noprint", &enabled_noprint, sizeof (int), 0644, NULL, NULL, &proc_dointvec},
61 + {KERN_UAC_SIGBUS, "sigbus", &enabled_sigbus, sizeof (int), 0644, NULL, NULL, &proc_dointvec},
62 + {KERN_UAC_NOFIX, "nofix", &enabled_nofix, sizeof (int), 0644, NULL, NULL, &proc_dointvec},
63 + {0}
64 +};
65 +
66 +static int __init init_uac_sysctl(void)
67 +{
68 + /* Initialize sysctls with the #defined UAC policy */
69 + enabled_noprint = (test_thread_flag (TIF_UAC_NOPRINT)) ? 1 : 0;
70 + enabled_sigbus = (test_thread_flag (TIF_UAC_SIGBUS)) ? 1 : 0;
71 + enabled_nofix = (test_thread_flag (TIF_UAC_NOFIX)) ? 1 : 0;
72 +
73 + /* save this for later so we can clean up */
74 + uac_sysctl_header = register_sysctl_table(uac_table);
75 + return 0;
76 +}
77 +
78 +static void __exit exit_uac_sysctl(void)
79 +{
80 + unregister_sysctl_table(uac_sysctl_header);
81 +}
82 +#endif
83 +
84 static void
85 dik_show_code(unsigned int *pc)
86 {
87 @@ -779,7 +812,11 @@
88 /* Check the UAC bits to decide what the user wants us to do
89 with the unaliged access. */
90
91 +#ifndef CONFIG_ALPHA_UAC_SYSCTL
92 if (!test_thread_flag (TIF_UAC_NOPRINT)) {
93 +#else /* CONFIG_ALPHA_UAC_SYSCTL */
94 + if (!(enabled_noprint)) {
95 +#endif /* CONFIG_ALPHA_UAC_SYSCTL */
96 if (cnt >= 5 && jiffies - last_time > 5*HZ) {
97 cnt = 0;
98 }
99 @@ -790,10 +827,18 @@
100 }
101 last_time = jiffies;
102 }
103 +#ifndef CONFIG_ALPHA_UAC_SYSCTL
104 if (test_thread_flag (TIF_UAC_SIGBUS))
105 +#else /* CONFIG_ALPHA_UAC_SYSCTL */
106 + if (enabled_sigbus)
107 +#endif /* CONFIG_ALPHA_UAC_SYSCTL */
108 goto give_sigbus;
109 /* Not sure why you'd want to use this, but... */
110 +#ifndef CONFIG_ALPHA_UAC_SYSCTL
111 if (test_thread_flag (TIF_UAC_NOFIX))
112 +#else /* CONFIG_ALPHA_UAC_SYSCTL */
113 + if (enabled_nofix)
114 +#endif /* CONFIG_ALPHA_UAC_SYSCTL */
115 return;
116
117 /* Don't bother reading ds in the access check since we already
118 @@ -1088,3 +1133,7 @@
119 wrent(entSys, 5);
120 wrent(entDbg, 6);
121 }
122 +
123 +#ifdef CONFIG_ALPHA_UAC_SYSCTL
124 +__initcall(init_uac_sysctl);
125 +#endif
126 diff -urN linux-2.6.21.orig/include/linux/sysctl.h linux-2.6.21/include/linux/sysctl.h
127 --- linux-2.6.21.orig/include/linux/sysctl.h 2007-05-14 16:20:23.000000000 +0000
128 +++ linux-2.6.21/include/linux/sysctl.h 2007-05-14 16:20:45.000000000 +0000
129 @@ -166,6 +166,9 @@
130 KERN_NMI_WATCHDOG=75, /* int: enable/disable nmi watchdog */
131 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
132 KERN_FBSPLASH=77, /* string: path to fbsplash helper */
133 +#ifdef CONFIG_ALPHA_UAC_SYSCTL
134 + KERN_UAC_POLICY=78, /* int: Alpha unaligned access control policy flags */
135 +#endif /* CONFIG_ALPHA_UAC_SYSCTL */
136 };
137
138
139 @@ -259,6 +262,17 @@
140 PTY_NR=2
141 };
142
143 +#ifdef CONFIG_ALPHA_UAC_SYSCTL
144 +/* /proc/sys/kernel/uac */
145 +enum
146 +{
147 + /* UAC policy on Alpha */
148 + KERN_UAC_NOPRINT=1, /* int: printk() on unaligned access */
149 + KERN_UAC_SIGBUS=2, /* int: send SIGBUS on unaligned access */
150 + KERN_UAC_NOFIX=3, /* int: don't fix the unaligned access */
151 +};
152 +#endif /* CONFIG_ALPHA_UAC_SYSCTL */
153 +
154 /* /proc/sys/bus/isa */
155 enum
156 {
157 diff -urN linux-2.6.21.orig/kernel/sysctl.c linux-2.6.21/kernel/sysctl.c
158 --- linux-2.6.21.orig/kernel/sysctl.c 2007-05-14 16:20:23.000000000 +0000
159 +++ linux-2.6.21/kernel/sysctl.c 2007-05-14 16:20:45.000000000 +0000
160 @@ -156,6 +156,9 @@
161 #ifdef CONFIG_INOTIFY_USER
162 extern ctl_table inotify_table[];
163 #endif
164 +#ifdef CONFIG_ALPHA_UAC_SYSCTL
165 +extern ctl_table uac_table[];
166 +#endif
167
168 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
169 int sysctl_legacy_va_layout;
170 @@ -203,7 +206,14 @@
171 .mode = 0555,
172 .child = dev_table,
173 },
174 -
175 +#ifdef CONFIG_ALPHA_UAC_SYSCTL
176 + {
177 + .ctl_name = KERN_UAC_POLICY,
178 + .procname = "uac",
179 + .mode = 0555,
180 + .child = uac_table,
181 + },
182 +#endif /* CONFIG_ALPHA_UAC_SYSCTL */
183 { .ctl_name = 0 }
184 };
185

  ViewVC Help
Powered by ViewVC 1.1.20