xref: /kvm-unit-tests/lib/powerpc/handlers.c (revision 6af53d29c81a54e1bac6b6e795d84774fabd7584)
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 the value specified when registering the
16  * handler
17  */
18 void dec_except_handler(struct pt_regs *regs __unused, void *data)
19 {
20 	uint64_t dec = *((uint64_t *) data);
21 
22 	asm volatile ("mtdec %0" : : "r" (dec));
23 }
24