Index: linux-2.6.26-gentoo/arch/alpha/Kconfig =================================================================== --- linux-2.6.26-gentoo.orig/arch/alpha/Kconfig +++ linux-2.6.26-gentoo/arch/alpha/Kconfig @@ -624,6 +624,32 @@ config HZ default 1200 if ALPHA_RAWHIDE default 1024 +config ALPHA_UAC_SYSCTL + bool "Configure UAC policy via sysctl" + depends on SYSCTL + default y + ---help--- + Configuring the UAC (unaligned access control) policy on a Linux + system usually involves setting a compile time define. If you say + Y here, you will be able to modify the UAC policy at runtime using + the /proc interface. + + The UAC policy defines the action Linux should take when an + unaligned memory access occurs. The action can include printing a + warning message (NOPRINT), sending a signal to the offending + program to help developers debug their applications (SIGBUS), or + disabling the transparent fixing (NOFIX). + + The sysctls will be initialized to the compile-time defined UAC + policy. You can change these manually, or with the sysctl(8) + userspace utility. + + To disable the warning messages at runtime, you would use + + echo 1 > /proc/sys/kernel/uac/noprint + + This is pretty harmless. Say Y if you're not sure. + source "drivers/pci/Kconfig" source "drivers/eisa/Kconfig" Index: linux-2.6.26-gentoo/arch/alpha/kernel/traps.c =================================================================== --- linux-2.6.26-gentoo.orig/arch/alpha/kernel/traps.c +++ linux-2.6.26-gentoo/arch/alpha/kernel/traps.c @@ -103,6 +103,52 @@ static char * ireg_name[] = {"v0", "t0", "t10", "t11", "ra", "pv", "at", "gp", "sp", "zero"}; #endif +#ifdef CONFIG_ALPHA_UAC_SYSCTL + +#include + +static int enabled_noprint = 0; +static int enabled_sigbus = 0; +static int enabled_nofix = 0; + +ctl_table uac_table[] = { + { + .ctl_name = CTL_UNNUMBERED, + .procname = "noprint", + .data = &enabled_noprint, + .maxlen = sizeof (int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "sigbus", + .data = &enabled_sigbus, + .maxlen = sizeof (int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "nofix", + .data = &enabled_nofix, + .maxlen = sizeof (int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { .ctl_name = 0 } +}; + +static int __init init_uac_sysctl(void) +{ + /* Initialize sysctls with the #defined UAC policy */ + enabled_noprint = (test_thread_flag (TIF_UAC_NOPRINT)) ? 1 : 0; + enabled_sigbus = (test_thread_flag (TIF_UAC_SIGBUS)) ? 1 : 0; + enabled_nofix = (test_thread_flag (TIF_UAC_NOFIX)) ? 1 : 0; + return 0; +} +#endif + static void dik_show_code(unsigned int *pc) { @@ -782,7 +828,11 @@ do_entUnaUser(void __user * va, unsigned /* Check the UAC bits to decide what the user wants us to do with the unaliged access. */ +#ifndef CONFIG_ALPHA_UAC_SYSCTL if (!test_thread_flag (TIF_UAC_NOPRINT)) { +#else /* CONFIG_ALPHA_UAC_SYSCTL */ + if (!(enabled_noprint)) { +#endif /* CONFIG_ALPHA_UAC_SYSCTL */ if (cnt >= 5 && time_after(jiffies, last_time + 5 * HZ)) { cnt = 0; } @@ -793,10 +843,18 @@ do_entUnaUser(void __user * va, unsigned } last_time = jiffies; } +#ifndef CONFIG_ALPHA_UAC_SYSCTL if (test_thread_flag (TIF_UAC_SIGBUS)) +#else /* CONFIG_ALPHA_UAC_SYSCTL */ + if (enabled_sigbus) +#endif /* CONFIG_ALPHA_UAC_SYSCTL */ goto give_sigbus; /* Not sure why you'd want to use this, but... */ +#ifndef CONFIG_ALPHA_UAC_SYSCTL if (test_thread_flag (TIF_UAC_NOFIX)) +#else /* CONFIG_ALPHA_UAC_SYSCTL */ + if (enabled_nofix) +#endif /* CONFIG_ALPHA_UAC_SYSCTL */ return; /* Don't bother reading ds in the access check since we already @@ -1091,3 +1149,7 @@ trap_init(void) wrent(entSys, 5); wrent(entDbg, 6); } + +#ifdef CONFIG_ALPHA_UAC_SYSCTL + __initcall(init_uac_sysctl); +#endif Index: linux-2.6.26-gentoo/kernel/sysctl.c =================================================================== --- a/kernel/sysctl.c 2010-03-15 14:22:31.000000000 -0400 +++ b/kernel/sysctl.c 2010-03-15 14:29:06.000000000 -0400 @@ -239,6 +239,15 @@ static struct ctl_table root_table[] = { { } }; +#ifdef CONFIG_ALPHA_UAC_SYSCTL + { + .ctl_name = CTL_UNNUMBERED, + .procname = "uac", + .mode = 0555, + .child = uac_table, + }, +#endif /* CONFIG_ALPHA_UAC_SYSCTL */ + #ifdef CONFIG_SCHED_DEBUG static int min_sched_granularity_ns = 100000; /* 100 usecs */ static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */