xref: /kvm-unit-tests/lib/s390x/asm/interrupt.h (revision 0f87a91aa52b0b483ef649f8427ba6d5f1654f6a)
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);
15*0f87a91aSJanosch Frank void handle_ext_int(void);
16*0f87a91aSJanosch Frank void handle_mcck_int(void);
17*0f87a91aSJanosch Frank void handle_io_int(void);
18*0f87a91aSJanosch Frank void handle_svc_int(void);
194da93626SDavid Hildenbrand void expect_pgm_int(void);
203db880b6SDavid Hildenbrand uint16_t clear_pgm_int(void);
214da93626SDavid Hildenbrand void check_pgm_int_code(uint16_t code);
224da93626SDavid Hildenbrand 
232667b05eSThomas Huth /* Activate low-address protection */
242667b05eSThomas Huth static inline void low_prot_enable(void)
252667b05eSThomas Huth {
262667b05eSThomas Huth 	uint64_t cr0;
272667b05eSThomas Huth 
282667b05eSThomas Huth 	asm volatile (" stctg %%c0,%%c0,%0 " : : "Q"(cr0) : "memory");
292667b05eSThomas Huth 	cr0 |= 1ULL << (63-35);
302667b05eSThomas Huth 	asm volatile (" lctlg %%c0,%%c0,%0 " : : "Q"(cr0));
312667b05eSThomas Huth }
322667b05eSThomas Huth 
332667b05eSThomas Huth /* Disable low-address protection */
342667b05eSThomas Huth static inline void low_prot_disable(void)
352667b05eSThomas Huth {
362667b05eSThomas Huth 	uint64_t cr0;
372667b05eSThomas Huth 
382667b05eSThomas Huth 	asm volatile (" stctg %%c0,%%c0,%0 " : : "Q"(cr0) : "memory");
392667b05eSThomas Huth 	cr0 &= ~(1ULL << (63-35));
402667b05eSThomas Huth 	asm volatile (" lctlg %%c0,%%c0,%0 " : : "Q"(cr0));
412667b05eSThomas Huth }
422667b05eSThomas Huth 
434da93626SDavid Hildenbrand #endif
44