/* * Tests for prctl(PR_GET_TSC, ...) / prctl(PR_SET_TSC, ...) * * Tests if the control register is updated correctly * when set with prctl() * * 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 /* snippet from wikipedia :-) */ 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; } int should_segv = 0; static void sigsegv_cb(int sig) { if (!should_segv) { fprintf(stderr, "FATAL ERROR, rdtsc() failed while enabled\n"); exit(0); } if (prctl(PR_SET_TSC, PR_TSC_ENABLE) < 0) { perror("prctl"); exit(0); } should_segv = 0; rdtsc(); } static void task(void) { signal(SIGSEGV, sigsegv_cb); alarm(10); for(;;) { rdtsc(); if (should_segv) { fprintf(stderr, "FATAL ERROR, rdtsc() succeeded while disabled\n"); exit(0); } if (prctl(PR_SET_TSC, PR_TSC_SIGSEGV) < 0) { perror("prctl"); exit(0); } should_segv = 1; } } 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:
authorDave Airlie <airlied@redhat.com>2017-02-10 10:14:24 +1000
committerDave Airlie <airlied@redhat.com>2017-02-10 10:14:24 +1000
commit697d3a21615672b2bf7724a65755799260325dda (patch)
tree79dfa1b95274ee71e9d8c4a35b377f88d1cdd9e0 /drivers/usb/host/ohci-sm501.c
parent811b40c83db047ba22a0c5b638186ed2b8c9810c (diff)
parent6e7eb1783be7f19eb071c96ddda0bbf22279ff46 (diff)
Merge tag 'drm-intel-fixes-2017-02-09' of git://anongit.freedesktop.org/git/drm-intel into drm-fixes
Hopefully final fixes for v4.10, about half of them stable material. * tag 'drm-intel-fixes-2017-02-09' of git://anongit.freedesktop.org/git/drm-intel: drm/i915: Always convert incoming exec offsets to non-canonical drm/i915: Remove overzealous fence warn on runtime suspend drm/i915/bxt: Add MST support when do DPLL calculation drm/i915: don't warn about Skylake CPU - KabyPoint PCH combo drm/i915: fix i915 running as dom0 under Xen drm/i915: Flush untouched framebuffers before display on !llc drm/i915: fix use-after-free in page_flip_completed()
Diffstat (limited to 'drivers/usb/host/ohci-sm501.c')