xref: /kvm-unit-tests/lib/powerpc/handlers.c (revision f0ca153cc2d1e6a670b3571a8ac24c2ef7042594)
1 /*
2  * Generic exception handlers for registration and use in tests
3  *
4  * Copyright 2016 Suraj Jitindar Singh, IBM.
5  *
6  * This work is licensed under the terms of the GNU LGPL, version 2.
7  */
8 
9 #include <libcflat.h>
10 #include <asm/handlers.h>
11 #include <asm/ptrace.h>
12 
13 /*
14  * Generic handler for decrementer exceptions (0x900)
15  * Just reset the decrementer back to its maximum value (0x7FFFFFFF)
16  */
17 void dec_except_handler(struct pt_regs *regs __unused, void *data __unused)
18 {
19 	uint32_t dec = 0x7FFFFFFF;
20 
21 	asm volatile ("mtdec %0" : : "r" (dec));
22 }
23