1 // SPDX-License-Identifier: GPL-2.0+
4 * Copyright 2018 IBM Corporation.
7 #define __SANE_USERSPACE_TYPES__
17 #include "flush_utils.h"
19 static inline __u64 load(void *addr)
23 asm volatile("ld %0,0(%1)" : "=r"(tmp) : "b"(addr));
28 void syscall_loop(char *p, unsigned long iterations,
29 unsigned long zero_size)
31 for (unsigned long i = 0; i < iterations; i++) {
32 for (unsigned long j = 0; j < zero_size; j += CACHELINE_SIZE)
38 static void sigill_handler(int signr, siginfo_t *info, void *unused)
41 ucontext_t *ctx = (ucontext_t *)unused;
42 unsigned long *pc = &UCONTEXT_NIA(ctx);
44 /* mtspr 3,RS to check for move to DSCR below */
45 if ((*((unsigned int *)*pc) & 0xfc1fffff) == 0x7c0303a6) {
47 printf("WARNING: Skipping over dscr setup. Consider running 'ppc64_cpu --dscr=1' manually.\n");
50 printf("SIGILL at %p\n", pc);
55 void set_dscr(unsigned long val)
61 memset(&sa, 0, sizeof(sa));
62 sa.sa_sigaction = sigill_handler;
63 sa.sa_flags = SA_SIGINFO;
64 if (sigaction(SIGILL, &sa, NULL))
65 perror("sigill_handler");
69 asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR));