xref: /kvm-unit-tests/lib/s390x/asm/interrupt.h (revision 728e71ee457384eb1cf2d5111d1e4329498581db)
1 /*
2  * Copyright (c) 2017 Red Hat Inc
3  *
4  * Authors:
5  *  David Hildenbrand <david@redhat.com>
6  *
7  * This code is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Library General Public License version 2.
9  */
10 #ifndef _ASMS390X_IRQ_H_
11 #define _ASMS390X_IRQ_H_
12 #include <asm/arch_def.h>
13 
14 void handle_pgm_int(void);
15 void handle_ext_int(void);
16 void handle_mcck_int(void);
17 void handle_io_int(void);
18 void handle_svc_int(void);
19 void expect_pgm_int(void);
20 uint16_t clear_pgm_int(void);
21 void check_pgm_int_code(uint16_t code);
22 
23 /* Activate low-address protection */
24 static inline void low_prot_enable(void)
25 {
26 	uint64_t cr0;
27 
28 	asm volatile (" stctg %%c0,%%c0,%0 " : : "Q"(cr0) : "memory");
29 	cr0 |= 1ULL << (63-35);
30 	asm volatile (" lctlg %%c0,%%c0,%0 " : : "Q"(cr0));
31 }
32 
33 /* Disable low-address protection */
34 static inline void low_prot_disable(void)
35 {
36 	uint64_t cr0;
37 
38 	asm volatile (" stctg %%c0,%%c0,%0 " : : "Q"(cr0) : "memory");
39 	cr0 &= ~(1ULL << (63-35));
40 	asm volatile (" lctlg %%c0,%%c0,%0 " : : "Q"(cr0));
41 }
42 
43 #endif
44