Merge branch 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 mm updates from Ingo Molnar: "Various x86 low level modifications: - preparatory work to support virtually mapped kernel stacks (Andy Lutomirski) - support for 64-bit __get_user() on 32-bit kernels (Benjamin LaHaise) - (involved) workaround for Knights Landing CPU erratum (Dave Hansen) - MPX enhancements (Dave Hansen) - mremap() extension to allow remapping of the special VDSO vma, for purposes of user level context save/restore (Dmitry Safonov) - hweight and entry code cleanups (Borislav Petkov) - bitops code generation optimizations and cleanups with modern GCC (H. Peter Anvin) - syscall entry code optimizations (Paolo Bonzini)" * 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (43 commits) x86/mm/cpa: Add missing comment in populate_pdg() x86/mm/cpa: Fix populate_pgd(): Stop trying to deallocate failed PUDs x86/syscalls: Add compat_sys_preadv64v2/compat_sys_pwritev64v2 x86/smp: Remove unnecessary initialization of thread_info::cpu x86/smp: Remove stack_smp_processor_id() x86/uaccess: Move thread_info::addr_limit to thread_struct x86/dumpstack: Rename thread_struct::sig_on_uaccess_error to sig_on_uaccess_err x86/uaccess: Move thread_info::uaccess_err and thread_info::sig_on_uaccess_err to thread_struct x86/dumpstack: When OOPSing, rewind the stack before do_exit() x86/mm/64: In vmalloc_fault(), use CR3 instead of current->active_mm x86/dumpstack/64: Handle faults when printing the "Stack: " part of an OOPS x86/dumpstack: Try harder to get a call trace on stack overflow x86/mm: Remove kernel_unmap_pages_in_pgd() and efi_cleanup_page_tables() x86/mm/cpa: In populate_pgd(), don't set the PGD entry until it's populated x86/mm/hotplug: Don't remove PGD entries in remove_pagetable() x86/mm: Use pte_none() to test for empty PTE x86/mm: Disallow running with 32-bit PTEs to work around erratum x86/mm: Ignore A/D bits in pte/pmd/pud_none() x86/mm: Move swap offset/type up in PTE to work around erratum x86/entry: Inline enter_from_user_mode() ...
This commit is contained in:
@@ -16,14 +16,16 @@
|
||||
#define BOOT_BITOPS_H
|
||||
#define _LINUX_BITOPS_H /* Inhibit inclusion of <linux/bitops.h> */
|
||||
|
||||
static inline int constant_test_bit(int nr, const void *addr)
|
||||
#include <linux/types.h>
|
||||
|
||||
static inline bool constant_test_bit(int nr, const void *addr)
|
||||
{
|
||||
const u32 *p = (const u32 *)addr;
|
||||
return ((1UL << (nr & 31)) & (p[nr >> 5])) != 0;
|
||||
}
|
||||
static inline int variable_test_bit(int nr, const void *addr)
|
||||
static inline bool variable_test_bit(int nr, const void *addr)
|
||||
{
|
||||
u8 v;
|
||||
bool v;
|
||||
const u32 *p = (const u32 *)addr;
|
||||
|
||||
asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/edd.h>
|
||||
#include <asm/setup.h>
|
||||
#include <asm/asm.h>
|
||||
#include "bitops.h"
|
||||
#include "ctype.h"
|
||||
#include "cpuflags.h"
|
||||
@@ -176,18 +177,18 @@ static inline void wrgs32(u32 v, addr_t addr)
|
||||
}
|
||||
|
||||
/* Note: these only return true/false, not a signed return value! */
|
||||
static inline int memcmp_fs(const void *s1, addr_t s2, size_t len)
|
||||
static inline bool memcmp_fs(const void *s1, addr_t s2, size_t len)
|
||||
{
|
||||
u8 diff;
|
||||
asm volatile("fs; repe; cmpsb; setnz %0"
|
||||
: "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
|
||||
bool diff;
|
||||
asm volatile("fs; repe; cmpsb" CC_SET(nz)
|
||||
: CC_OUT(nz) (diff), "+D" (s1), "+S" (s2), "+c" (len));
|
||||
return diff;
|
||||
}
|
||||
static inline int memcmp_gs(const void *s1, addr_t s2, size_t len)
|
||||
static inline bool memcmp_gs(const void *s1, addr_t s2, size_t len)
|
||||
{
|
||||
u8 diff;
|
||||
asm volatile("gs; repe; cmpsb; setnz %0"
|
||||
: "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
|
||||
bool diff;
|
||||
asm volatile("gs; repe; cmpsb" CC_SET(nz)
|
||||
: CC_OUT(nz) (diff), "+D" (s1), "+S" (s2), "+c" (len));
|
||||
return diff;
|
||||
}
|
||||
|
||||
@@ -294,6 +295,7 @@ static inline int cmdline_find_option_bool(const char *option)
|
||||
|
||||
/* cpu.c, cpucheck.c */
|
||||
int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr);
|
||||
int check_knl_erratum(void);
|
||||
int validate_cpu(void);
|
||||
|
||||
/* early_serial_console.c */
|
||||
|
@@ -93,6 +93,8 @@ int validate_cpu(void)
|
||||
show_cap_strs(err_flags);
|
||||
putchar('\n');
|
||||
return -1;
|
||||
} else if (check_knl_erratum()) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@
|
||||
# include "boot.h"
|
||||
#endif
|
||||
#include <linux/types.h>
|
||||
#include <asm/intel-family.h>
|
||||
#include <asm/processor-flags.h>
|
||||
#include <asm/required-features.h>
|
||||
#include <asm/msr-index.h>
|
||||
@@ -175,6 +176,8 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
|
||||
puts("WARNING: PAE disabled. Use parameter 'forcepae' to enable at your own risk!\n");
|
||||
}
|
||||
}
|
||||
if (!err)
|
||||
err = check_knl_erratum();
|
||||
|
||||
if (err_flags_ptr)
|
||||
*err_flags_ptr = err ? err_flags : NULL;
|
||||
@@ -185,3 +188,33 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
|
||||
|
||||
return (cpu.level < req_level || err) ? -1 : 0;
|
||||
}
|
||||
|
||||
int check_knl_erratum(void)
|
||||
{
|
||||
/*
|
||||
* First check for the affected model/family:
|
||||
*/
|
||||
if (!is_intel() ||
|
||||
cpu.family != 6 ||
|
||||
cpu.model != INTEL_FAM6_XEON_PHI_KNL)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* This erratum affects the Accessed/Dirty bits, and can
|
||||
* cause stray bits to be set in !Present PTEs. We have
|
||||
* enough bits in our 64-bit PTEs (which we have on real
|
||||
* 64-bit mode or PAE) to avoid using these troublesome
|
||||
* bits. But, we do not have enough space in our 32-bit
|
||||
* PTEs. So, refuse to run on 32-bit non-PAE kernels.
|
||||
*/
|
||||
if (IS_ENABLED(CONFIG_X86_64) || IS_ENABLED(CONFIG_X86_PAE))
|
||||
return 0;
|
||||
|
||||
puts("This 32-bit kernel can not run on this Xeon Phi x200\n"
|
||||
"processor due to a processor erratum. Use a 64-bit\n"
|
||||
"kernel, or enable PAE in this 32-bit kernel.\n\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -102,6 +102,7 @@ void get_cpuflags(void)
|
||||
cpuid(0x1, &tfms, &ignored, &cpu.flags[4],
|
||||
&cpu.flags[0]);
|
||||
cpu.level = (tfms >> 8) & 15;
|
||||
cpu.family = cpu.level;
|
||||
cpu.model = (tfms >> 4) & 15;
|
||||
if (cpu.level >= 6)
|
||||
cpu.model += ((tfms >> 16) & 0xf) << 4;
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
struct cpu_features {
|
||||
int level; /* Family, or 64 for x86-64 */
|
||||
int family; /* Family, always */
|
||||
int model;
|
||||
u32 flags[NCAPINTS];
|
||||
};
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
int memcmp(const void *s1, const void *s2, size_t len)
|
||||
{
|
||||
u8 diff;
|
||||
bool diff;
|
||||
asm("repe; cmpsb; setnz %0"
|
||||
: "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
|
||||
return diff;
|
||||
|
Reference in New Issue
Block a user