/* * Tests for prctl(PR_GET_TSC, ...) / prctl(PR_SET_TSC, ...) * * Tests if the control register is updated correctly * at context switches * * Warning: this test will cause a very high load for a few seconds * */ #include #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 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_expect(int sig) { /* */ } static void segvtask(void) { if (prctl(PR_SET_TSC, PR_TSC_SIGSEGV) < 0) { perror("prctl"); exit(0); } signal(SIGSEGV, sigsegv_expect); alarm(10); rdtsc(); fprintf(stderr, "FATAL ERROR, rdtsc() succeeded while disabled\n"); exit(0); } static void sigsegv_fail(int sig) { fprintf(stderr, "FATAL ERROR, rdtsc() failed while enabled\n"); exit(0); } static void rdtsctask(void) { if (prctl(PR_SET_TSC, PR_TSC_ENABLE) < 0) { perror("prctl"); exit(0); } signal(SIGSEGV, sigsegv_fail); alarm(10); for(;;) rdtsc(); } int main(void) { int n_tasks = 100, i; fprintf(stderr, "[No further output means we're allright]\n"); for (i=0; ilogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-15 12:40:53 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-15 12:40:53 -0800
commitc92816275674c1491ce228ee49aa030a5fa1be04 (patch)
tree97deb97f282c6b9f4f58e45a60ea78d1fe31df4e /drivers/usb/gadget/epautoconf.c
parent2d5a7101a140adcf7a5d8677649847fbb2dd5a2f (diff)
parentc8a6a09c1c617402cc9254b2bc8da359a0347d75 (diff)
Merge tag 'char-misc-4.10-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver fixes from Greg KH: "Here are some small char/misc driver fixes for 4.10-rc4 that resolve some reported issues. The MEI driver issue resolves a lot of problems that people have been having, as does the mem driver fix. The other minor fixes resolve other reported issues. All of these have been in linux-next for a while" * tag 'char-misc-4.10-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: vme: Fix wrong pointer utilization in ca91cx42_slave_get auxdisplay: fix new ht16k33 build errors ppdev: don't print a free'd string extcon: return error code on failure drivers: char: mem: Fix thinkos in kmem address checks mei: bus: enable OS version only for SPT and newer
Diffstat (limited to 'drivers/usb/gadget/epautoconf.c')