x86/boot: Detect 5-level paging support
In this initial implementation we force-require 5-level paging support from the hardware, when compiled with CONFIG_X86_5LEVEL=y. (The kernel will panic during boot on CPUs that don't support 5-level paging.) We will implement boot-time switch between 4- and 5-level paging later. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-arch@vger.kernel.org Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20170330080731.65421-2-kirill.shutemov@linux.intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
7f75540ff2
commit
3677d4c6a2
@ -44,6 +44,15 @@ static const u32 req_flags[NCAPINTS] =
|
|||||||
0, /* REQUIRED_MASK5 not implemented in this file */
|
0, /* REQUIRED_MASK5 not implemented in this file */
|
||||||
REQUIRED_MASK6,
|
REQUIRED_MASK6,
|
||||||
0, /* REQUIRED_MASK7 not implemented in this file */
|
0, /* REQUIRED_MASK7 not implemented in this file */
|
||||||
|
0, /* REQUIRED_MASK8 not implemented in this file */
|
||||||
|
0, /* REQUIRED_MASK9 not implemented in this file */
|
||||||
|
0, /* REQUIRED_MASK10 not implemented in this file */
|
||||||
|
0, /* REQUIRED_MASK11 not implemented in this file */
|
||||||
|
0, /* REQUIRED_MASK12 not implemented in this file */
|
||||||
|
0, /* REQUIRED_MASK13 not implemented in this file */
|
||||||
|
0, /* REQUIRED_MASK14 not implemented in this file */
|
||||||
|
0, /* REQUIRED_MASK15 not implemented in this file */
|
||||||
|
REQUIRED_MASK16,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define A32(a, b, c, d) (((d) << 24)+((c) << 16)+((b) << 8)+(a))
|
#define A32(a, b, c, d) (((d) << 24)+((c) << 16)+((b) << 8)+(a))
|
||||||
|
@ -70,16 +70,19 @@ int has_eflag(unsigned long mask)
|
|||||||
# define EBX_REG "=b"
|
# define EBX_REG "=b"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void cpuid(u32 id, u32 *a, u32 *b, u32 *c, u32 *d)
|
static inline void cpuid_count(u32 id, u32 count,
|
||||||
|
u32 *a, u32 *b, u32 *c, u32 *d)
|
||||||
{
|
{
|
||||||
asm volatile(".ifnc %%ebx,%3 ; movl %%ebx,%3 ; .endif \n\t"
|
asm volatile(".ifnc %%ebx,%3 ; movl %%ebx,%3 ; .endif \n\t"
|
||||||
"cpuid \n\t"
|
"cpuid \n\t"
|
||||||
".ifnc %%ebx,%3 ; xchgl %%ebx,%3 ; .endif \n\t"
|
".ifnc %%ebx,%3 ; xchgl %%ebx,%3 ; .endif \n\t"
|
||||||
: "=a" (*a), "=c" (*c), "=d" (*d), EBX_REG (*b)
|
: "=a" (*a), "=c" (*c), "=d" (*d), EBX_REG (*b)
|
||||||
: "a" (id)
|
: "a" (id), "c" (count)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define cpuid(id, a, b, c, d) cpuid_count(id, 0, a, b, c, d)
|
||||||
|
|
||||||
void get_cpuflags(void)
|
void get_cpuflags(void)
|
||||||
{
|
{
|
||||||
u32 max_intel_level, max_amd_level;
|
u32 max_intel_level, max_amd_level;
|
||||||
@ -108,6 +111,11 @@ void get_cpuflags(void)
|
|||||||
cpu.model += ((tfms >> 16) & 0xf) << 4;
|
cpu.model += ((tfms >> 16) & 0xf) << 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (max_intel_level >= 0x00000007) {
|
||||||
|
cpuid_count(0x00000007, 0, &ignored, &ignored,
|
||||||
|
&cpu.flags[16], &ignored);
|
||||||
|
}
|
||||||
|
|
||||||
cpuid(0x80000000, &max_amd_level, &ignored, &ignored,
|
cpuid(0x80000000, &max_amd_level, &ignored, &ignored,
|
||||||
&ignored);
|
&ignored);
|
||||||
|
|
||||||
|
@ -36,6 +36,12 @@
|
|||||||
# define DISABLE_OSPKE (1<<(X86_FEATURE_OSPKE & 31))
|
# define DISABLE_OSPKE (1<<(X86_FEATURE_OSPKE & 31))
|
||||||
#endif /* CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS */
|
#endif /* CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS */
|
||||||
|
|
||||||
|
#ifdef CONFIG_X86_5LEVEL
|
||||||
|
# define DISABLE_LA57 0
|
||||||
|
#else
|
||||||
|
# define DISABLE_LA57 (1<<(X86_FEATURE_LA57 & 31))
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure to add features to the correct mask
|
* Make sure to add features to the correct mask
|
||||||
*/
|
*/
|
||||||
@ -55,7 +61,7 @@
|
|||||||
#define DISABLED_MASK13 0
|
#define DISABLED_MASK13 0
|
||||||
#define DISABLED_MASK14 0
|
#define DISABLED_MASK14 0
|
||||||
#define DISABLED_MASK15 0
|
#define DISABLED_MASK15 0
|
||||||
#define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE)
|
#define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57)
|
||||||
#define DISABLED_MASK17 0
|
#define DISABLED_MASK17 0
|
||||||
#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18)
|
#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18)
|
||||||
|
|
||||||
|
@ -53,6 +53,12 @@
|
|||||||
# define NEED_MOVBE 0
|
# define NEED_MOVBE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_X86_5LEVEL
|
||||||
|
# define NEED_LA57 (1<<(X86_FEATURE_LA57 & 31))
|
||||||
|
#else
|
||||||
|
# define NEED_LA57 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_X86_64
|
#ifdef CONFIG_X86_64
|
||||||
#ifdef CONFIG_PARAVIRT
|
#ifdef CONFIG_PARAVIRT
|
||||||
/* Paravirtualized systems may not have PSE or PGE available */
|
/* Paravirtualized systems may not have PSE or PGE available */
|
||||||
@ -98,7 +104,7 @@
|
|||||||
#define REQUIRED_MASK13 0
|
#define REQUIRED_MASK13 0
|
||||||
#define REQUIRED_MASK14 0
|
#define REQUIRED_MASK14 0
|
||||||
#define REQUIRED_MASK15 0
|
#define REQUIRED_MASK15 0
|
||||||
#define REQUIRED_MASK16 0
|
#define REQUIRED_MASK16 (NEED_LA57)
|
||||||
#define REQUIRED_MASK17 0
|
#define REQUIRED_MASK17 0
|
||||||
#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18)
|
#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user