xref: /linux/tools/testing/selftests/kvm/include/s390x/processor.h (revision 3efc57369a0ce8f76bf0804f7e673982384e4ac9)
1edf54478SThomas Huth /* SPDX-License-Identifier: GPL-2.0-only */
2edf54478SThomas Huth /*
3edf54478SThomas Huth  * s390x processor specific defines
4edf54478SThomas Huth  */
5edf54478SThomas Huth #ifndef SELFTEST_KVM_PROCESSOR_H
6edf54478SThomas Huth #define SELFTEST_KVM_PROCESSOR_H
7edf54478SThomas Huth 
817ae5ebcSSean Christopherson #include <linux/compiler.h>
917ae5ebcSSean Christopherson 
10edf54478SThomas Huth /* Bits in the region/segment table entry */
11edf54478SThomas Huth #define REGION_ENTRY_ORIGIN	~0xfffUL /* region/segment table origin	   */
12edf54478SThomas Huth #define REGION_ENTRY_PROTECT	0x200	 /* region protection bit	   */
13edf54478SThomas Huth #define REGION_ENTRY_NOEXEC	0x100	 /* region no-execute bit	   */
14edf54478SThomas Huth #define REGION_ENTRY_OFFSET	0xc0	 /* region table offset		   */
15edf54478SThomas Huth #define REGION_ENTRY_INVALID	0x20	 /* invalid region table entry	   */
16edf54478SThomas Huth #define REGION_ENTRY_TYPE	0x0c	 /* region/segment table type mask */
17edf54478SThomas Huth #define REGION_ENTRY_LENGTH	0x03	 /* region third length		   */
18edf54478SThomas Huth 
19edf54478SThomas Huth /* Bits in the page table entry */
20edf54478SThomas Huth #define PAGE_INVALID	0x400		/* HW invalid bit    */
21edf54478SThomas Huth #define PAGE_PROTECT	0x200		/* HW read-only bit  */
22edf54478SThomas Huth #define PAGE_NOEXEC	0x100		/* HW no-execute bit */
23edf54478SThomas Huth 
24*252b6fd2SChristoph Schlameuss /* Page size definitions */
25*252b6fd2SChristoph Schlameuss #define PAGE_SHIFT 12
26*252b6fd2SChristoph Schlameuss #define PAGE_SIZE BIT_ULL(PAGE_SHIFT)
27*252b6fd2SChristoph Schlameuss #define PAGE_MASK (~(PAGE_SIZE - 1))
28*252b6fd2SChristoph Schlameuss 
2917ae5ebcSSean Christopherson /* Is there a portable way to do this? */
cpu_relax(void)3017ae5ebcSSean Christopherson static inline void cpu_relax(void)
3117ae5ebcSSean Christopherson {
3217ae5ebcSSean Christopherson 	barrier();
3317ae5ebcSSean Christopherson }
3417ae5ebcSSean Christopherson 
35edf54478SThomas Huth #endif
36