Skip to contentSkip to conversation

x86 fixes for 4.8

GIT PULL Thomas Gleixner 1 participant 1 message Oct 2, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Linus,

please pull the latest x86-urgent-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-urgent-for-linus

The last regression fixes for 4.8 final:

- Two patches addressing the fallout of the CR4 optimizations which caused CR4-less machines to fail.

- Fix the VDSO build on big endian machines

- Take care of FPU initialization if no CPUID is available otherwise task struct size ends up being zero

- Fix up context tracking in case load_gs_index fails

Thanks,

tglx

------------------>
Andy Lutomirski (3):
x86/init: Fix cr4_init_shadow() on CR4-less machines
x86/boot: Fix another __read_cr4() case on 486
x86/boot: Initialize FPU and X86_FEATURE_ALWAYS even if we don't have CPUID

Segher Boessenkool (1):
x86/vdso: Fix building on big endian host

Wanpeng Li (1):
x86/entry/64: Fix context tracking state warning when load_gs_index fails

 arch/x86/entry/entry_64.S       |  4 ++--
 arch/x86/entry/vdso/vdso2c.h    |  2 +-
 arch/x86/include/asm/tlbflush.h |  2 +-
 arch/x86/kernel/cpu/common.c    | 23 +++++++++++------------
 arch/x86/kernel/setup.c         |  4 +---
 5 files changed, 16 insertions(+), 19 deletions(-)
arch/x86/entry/entry_64.S +2 -2
index d172c619c449..02fff3ebfb87 100644
@@ -1002,7 +1002,6 @@ ENTRY(error_entry)
 	testb	$3, CS+8(%rsp)
 	jz	.Lerror_kernelspace
 
-.Lerror_entry_from_usermode_swapgs:
 	/*
 	 * We entered from user mode or we're pretending to have entered
 	 * from user mode due to an IRET fault.
@@ -1045,7 +1044,8 @@ ENTRY(error_entry)
 	 * gsbase and proceed.  We'll fix up the exception and land in
 	 * .Lgs_change's error handler with kernel gsbase.
 	 */
-	jmp	.Lerror_entry_from_usermode_swapgs
+	SWAPGS
+	jmp .Lerror_entry_done
 
 .Lbstep_iret:
 	/* Fix truncated RIP */
arch/x86/entry/vdso/vdso2c.h +1 -1
index 4f741192846d..3dab75f2a673 100644
@@ -22,7 +22,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
 
 	ELF(Phdr) *pt = (ELF(Phdr) *)(raw_addr + GET_LE(&hdr->e_phoff));
 
-	if (hdr->e_type != ET_DYN)
+	if (GET_LE(&hdr->e_type) != ET_DYN)
 		fail("input is not a shared object\n");
 
 	/* Walk the segment table. */
arch/x86/include/asm/tlbflush.h +1 -1
index 6fa85944af83..dee8a70382ba 100644
@@ -81,7 +81,7 @@ DECLARE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate);
 /* Initialize cr4 shadow for this CPU. */
 static inline void cr4_init_shadow(void)
 {
-	this_cpu_write(cpu_tlbstate.cr4, __read_cr4());
+	this_cpu_write(cpu_tlbstate.cr4, __read_cr4_safe());
 }
 
 /* Set in this cpu's CR4. */
arch/x86/kernel/cpu/common.c +11 -12
index 809eda03c527..bcc9ccc220c9 100644
@@ -804,21 +804,20 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 		identify_cpu_without_cpuid(c);
 
 	/* cyrix could have cpuid enabled via c_identify()*/
-	if (!have_cpuid_p())
-		return;
+	if (have_cpuid_p()) {
+		cpu_detect(c);
+		get_cpu_vendor(c);
+		get_cpu_cap(c);
 
-	cpu_detect(c);
-	get_cpu_vendor(c);
-	get_cpu_cap(c);
-
-	if (this_cpu->c_early_init)
-		this_cpu->c_early_init(c);
+		if (this_cpu->c_early_init)
+			this_cpu->c_early_init(c);
 
-	c->cpu_index = 0;
-	filter_cpuid_features(c, false);
+		c->cpu_index = 0;
+		filter_cpuid_features(c, false);
 
-	if (this_cpu->c_bsp_init)
-		this_cpu->c_bsp_init(c);
+		if (this_cpu->c_bsp_init)
+			this_cpu->c_bsp_init(c);
+	}
 
 	setup_force_cpu_cap(X86_FEATURE_ALWAYS);
 	fpu__init_system(c);
arch/x86/kernel/setup.c +1 -3
index 0fa60f5f5a16..98c9cd6f3b5d 100644
@@ -1137,9 +1137,7 @@ void __init setup_arch(char **cmdline_p)
 	 * auditing all the early-boot CR4 manipulation would be needed to
 	 * rule it out.
 	 */
-	if (boot_cpu_data.cpuid_level >= 0)
-		/* A CPU has %cr4 if and only if it has CPUID. */
-		mmu_cr4_features = __read_cr4();
+	mmu_cr4_features = __read_cr4_safe();
 
 	memblock_set_current_limit(get_max_mapped());