Kirill A. Shutemov | 0852907 | 2017-12-04 15:40:55 +0300 | [diff] [blame] | 1 | #include <asm/processor.h> |
| 2 | |
| 3 | /* |
| 4 | * __force_order is used by special_insns.h asm code to force instruction |
| 5 | * serialization. |
| 6 | * |
| 7 | * It is not referenced from the code, but GCC < 5 with -fPIE would fail |
| 8 | * due to an undefined symbol. Define it to make these ancient GCCs work. |
| 9 | */ |
| 10 | unsigned long __force_order; |
| 11 | |
| 12 | int l5_paging_required(void) |
| 13 | { |
| 14 | /* Check if leaf 7 is supported. */ |
| 15 | |
| 16 | if (native_cpuid_eax(0) < 7) |
| 17 | return 0; |
| 18 | |
| 19 | /* Check if la57 is supported. */ |
| 20 | if (!(native_cpuid_ecx(7) & (1 << (X86_FEATURE_LA57 & 31)))) |
| 21 | return 0; |
| 22 | |
| 23 | /* Check if 5-level paging has already been enabled. */ |
| 24 | if (native_read_cr4() & X86_CR4_LA57) |
| 25 | return 0; |
| 26 | |
| 27 | return 1; |
| 28 | } |