/* * Tests for prctl(PR_GET_TSC, ...) / prctl(PR_SET_TSC, ...) * * Basic test to test behaviour of PR_GET_TSC and PR_SET_TSC */ #include #include #include #include #include #include #include /* Get/set the process' ability to use the timestamp counter instruction */ #ifndef PR_GET_TSC #define PR_GET_TSC 25 #define PR_SET_TSC 26 # define PR_TSC_ENABLE 1 /* allow the use of the timestamp counter */ # define PR_TSC_SIGSEGV 2 /* throw a SIGSEGV instead of reading the TSC */ #endif const char *tsc_names[] = { [0] = "[not set]", [PR_TSC_ENABLE] = "PR_TSC_ENABLE", [PR_TSC_SIGSEGV] = "PR_TSC_SIGSEGV", }; static uint64_t rdtsc(void) { uint32_t lo, hi; /* We cannot use "=A", since this would use %rax on x86_64 */ __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); return (uint64_t)hi << 32 | lo; } static void sigsegv_cb(int sig) { int tsc_val = 0; printf("[ SIG_SEGV ]\n"); printf("prctl(PR_GET_TSC, &tsc_val); "); fflush(stdout); if ( prctl(PR_GET_TSC, &tsc_val) == -1) perror("prctl"); printf("tsc_val == %s\n", tsc_names[tsc_val]); printf("prctl(PR_SET_TSC, PR_TSC_ENABLE)\n"); fflush(stdout); if ( prctl(PR_SET_TSC, PR_TSC_ENABLE) == -1) perror("prctl"); printf("rdtsc() == "); } int main(void) { int tsc_val = 0; signal(SIGSEGV, sigsegv_cb); printf("rdtsc() == %llu\n", (unsigned long long)rdtsc()); printf("prctl(PR_GET_TSC, &tsc_val); "); fflush(stdout); if ( prctl(PR_GET_TSC, &tsc_val) == -1) perror("prctl"); printf("tsc_val == %s\n", tsc_names[tsc_val]); printf("rdtsc() == %llu\n", (unsigned long long)rdtsc()); printf("prctl(PR_SET_TSC, PR_TSC_ENABLE)\n"); fflush(stdout); if ( prctl(PR_SET_TSC, PR_TSC_ENABLE) == -1) perror("prctl"); printf("rdtsc() == %llu\n", (unsigned long long)rdtsc()); printf("prctl(PR_SET_TSC, PR_TSC_SIGSEGV)\n"); fflush(stdout); if ( prctl(PR_SET_TSC, PR_TSC_SIGSEGV) == -1) perror("prctl"); printf("rdtsc() == "); fflush(stdout); printf("%llu\n", (unsigned long long)rdtsc()); fflush(stdout); exit(EXIT_SUCCESS); } io.h?id=a9dbf5c8d4c90f54777f89daf0e34d390808b672&id2=646ebd4166ca00bdf682a36bd2e1c9a74d848ac6'>diff
diff options
context:
space:
mode:
Diffstat (limited to 'include/acpi/acpi_io.h')
/td>
committerDavid S. Miller <davem@davemloft.net>2017-01-30 14:28:22 -0800
commit54791b276b4000b307339f269d3bf7db877d536f (patch)
tree1c2616bd373ce5ea28aac2a53e32f5b5834901ce /include/trace/events/fib.h
parent5d0e7705774dd412a465896d08d59a81a345c1e4 (diff)
parent047487241ff59374fded8c477f21453681f5995c (diff)
Merge branch 'sparc64-non-resumable-user-error-recovery'
Liam R. Howlett says: ==================== sparc64: Recover from userspace non-resumable PIO & MEM errors A non-resumable error from userspace is able to cause a kernel panic or trap loop due to the setup and handling of the queued traps once in the kernel. This patch series addresses both of these issues. The queues are fixed by simply zeroing the memory before use. PIO errors from userspace will result in a SIGBUS being sent to the user process. The MEM errors form userspace will result in a SIGKILL and also cause the offending pages to be claimed so they are no longer used in future tasks. SIGKILL is used to ensure that the process does not try to coredump and result in an attempt to read the memory again from within kernel space. Although there is a HV call to scrub the memory (mem_scrub), there is no easy way to guarantee that the real memory address(es) are not used by other tasks. Clearing the error with mem_scrub would zero the memory and cause the other processes to proceed with bad data. The handling of other non-resumable errors remain unchanged and will cause a panic. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/trace/events/fib.h')