xref: /kvm-unit-tests/lib/s390x/asm/interrupt.h (revision 2667b05e14ca8acebeb1ef0b0be04900bdd486dd)
14da93626SDavid Hildenbrand /*
24da93626SDavid Hildenbrand  * Copyright (c) 2017 Red Hat Inc
34da93626SDavid Hildenbrand  *
44da93626SDavid Hildenbrand  * Authors:
54da93626SDavid Hildenbrand  *  David Hildenbrand <david@redhat.com>
64da93626SDavid Hildenbrand  *
74da93626SDavid Hildenbrand  * This code is free software; you can redistribute it and/or modify it
84da93626SDavid Hildenbrand  * under the terms of the GNU Library General Public License version 2.
94da93626SDavid Hildenbrand  */
104da93626SDavid Hildenbrand #ifndef _ASMS390X_IRQ_H_
114da93626SDavid Hildenbrand #define _ASMS390X_IRQ_H_
124da93626SDavid Hildenbrand #include <asm/arch_def.h>
134da93626SDavid Hildenbrand 
144da93626SDavid Hildenbrand void handle_pgm_int(void);
154da93626SDavid Hildenbrand void expect_pgm_int(void);
164da93626SDavid Hildenbrand void check_pgm_int_code(uint16_t code);
174da93626SDavid Hildenbrand 
18*2667b05eSThomas Huth /* Activate low-address protection */
19*2667b05eSThomas Huth static inline void low_prot_enable(void)
20*2667b05eSThomas Huth {
21*2667b05eSThomas Huth 	uint64_t cr0;
22*2667b05eSThomas Huth 
23*2667b05eSThomas Huth 	asm volatile (" stctg %%c0,%%c0,%0 " : : "Q"(cr0) : "memory");
24*2667b05eSThomas Huth 	cr0 |= 1ULL << (63-35);
25*2667b05eSThomas Huth 	asm volatile (" lctlg %%c0,%%c0,%0 " : : "Q"(cr0));
26*2667b05eSThomas Huth }
27*2667b05eSThomas Huth 
28*2667b05eSThomas Huth /* Disable low-address protection */
29*2667b05eSThomas Huth static inline void low_prot_disable(void)
30*2667b05eSThomas Huth {
31*2667b05eSThomas Huth 	uint64_t cr0;
32*2667b05eSThomas Huth 
33*2667b05eSThomas Huth 	asm volatile (" stctg %%c0,%%c0,%0 " : : "Q"(cr0) : "memory");
34*2667b05eSThomas Huth 	cr0 &= ~(1ULL << (63-35));
35*2667b05eSThomas Huth 	asm volatile (" lctlg %%c0,%%c0,%0 " : : "Q"(cr0));
36*2667b05eSThomas Huth }
37*2667b05eSThomas Huth 
384da93626SDavid Hildenbrand #endif
39