Skip to contentSkip to conversation

x86 fixes for 4.14

GIT PULL Thomas Gleixner 1 participant 1 message Oct 1, 2017

Subsystems (4)
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

This update contins the following fixes and improvements

- Avoid dereferencing an unprotected VMA pointer in the fault signal generation code

- Fix inline asm call constraints for GCC 4.4

- Use existing register variable to retrieve the stack pointer instead of forcing the compiler to create another indirect access which results in excessive extra 'mov %rsp, %<dst>' instructions

- Disable branch profiling for the memory encryption code to prevent an early boot crash

- Fix a sparse warning caused by casting the __user annotation in

    __get_user_asm_u64() away

- Fix an off by one error in the loop termination of the error patch in the x86 sysfs init code

- Add missing CPU IDs to various Intel specific drivers to enable the functionality on recent hardware

- More (init) constification in the numachip code

Thanks,

tglx

------------------>
Andrey Ryabinin (1):
x86/asm: Use register variable to get stack pointer value

Bhumika Goyal (1):
x86/numachip: Add const and __initconst to numachip2_clockevent

Josh Poimboeuf (1):
x86/asm: Fix inline asm call constraints for GCC 4.4

Kan Liang (4):
perf/x86/intel/cstate: Add missing CPU IDs perf/x86/msr: Add missing CPU IDs perf/x86/intel/rapl: Add missing CPU IDs perf/x86/intel/uncore: Correct num_boxes for IIO and IRP

Laurent Dufour (1):
x86/mm: Fix fault error path using unsafe vma pointer

Sean Fu (1):
x86/sysfs: Fix off-by-one error in loop termination

Tom Lendacky (1):
x86/mm: Disable branch profiling in mem_encrypt.c

Ville Syrjälä (1):

      x86: Don't cast away the __user in __get_user_asm_u64()
 arch/x86/events/intel/cstate.c       |  4 +++
 arch/x86/events/intel/rapl.c         |  3 +++
 arch/x86/events/intel/uncore_snbep.c |  4 +--
 arch/x86/events/msr.c                |  8 ++++++
 arch/x86/include/asm/asm.h           |  8 +++---
 arch/x86/include/asm/thread_info.h   | 11 ---------
 arch/x86/include/asm/uaccess.h       |  2 +-
 arch/x86/kernel/irq_32.c             |  6 ++---
 arch/x86/kernel/ksysfs.c             |  2 +-
 arch/x86/kernel/traps.c              |  2 +-
 arch/x86/mm/fault.c                  | 47 ++++++++++++++++++------------------
 arch/x86/mm/mem_encrypt.c            |  2 ++
 arch/x86/mm/tlb.c                    |  2 +-
 drivers/clocksource/numachip.c       |  2 +-
 14 files changed, 56 insertions(+), 47 deletions(-)
arch/x86/events/intel/cstate.c +4 -0
index 4cf100ff2a37..72db0664a53d 100644
@@ -552,6 +552,7 @@ static const struct x86_cpu_id intel_cstates_match[] __initconst = {
 
 	X86_CSTATES_MODEL(INTEL_FAM6_SKYLAKE_MOBILE,  snb_cstates),
 	X86_CSTATES_MODEL(INTEL_FAM6_SKYLAKE_DESKTOP, snb_cstates),
+	X86_CSTATES_MODEL(INTEL_FAM6_SKYLAKE_X, snb_cstates),
 
 	X86_CSTATES_MODEL(INTEL_FAM6_KABYLAKE_MOBILE,  snb_cstates),
 	X86_CSTATES_MODEL(INTEL_FAM6_KABYLAKE_DESKTOP, snb_cstates),
@@ -560,6 +561,9 @@ static const struct x86_cpu_id intel_cstates_match[] __initconst = {
 	X86_CSTATES_MODEL(INTEL_FAM6_XEON_PHI_KNM, knl_cstates),
 
 	X86_CSTATES_MODEL(INTEL_FAM6_ATOM_GOLDMONT, glm_cstates),
+	X86_CSTATES_MODEL(INTEL_FAM6_ATOM_DENVERTON, glm_cstates),
+
+	X86_CSTATES_MODEL(INTEL_FAM6_ATOM_GEMINI_LAKE, glm_cstates),
 	{ },
 };
 MODULE_DEVICE_TABLE(x86cpu, intel_cstates_match);
arch/x86/events/intel/rapl.c +3 -0
index 8e2457cb6b4a..005908ee9333 100644
@@ -775,6 +775,9 @@ static const struct x86_cpu_id rapl_cpu_match[] __initconst = {
 	X86_RAPL_MODEL_MATCH(INTEL_FAM6_KABYLAKE_DESKTOP, skl_rapl_init),
 
 	X86_RAPL_MODEL_MATCH(INTEL_FAM6_ATOM_GOLDMONT, hsw_rapl_init),
+	X86_RAPL_MODEL_MATCH(INTEL_FAM6_ATOM_DENVERTON, hsw_rapl_init),
+
+	X86_RAPL_MODEL_MATCH(INTEL_FAM6_ATOM_GEMINI_LAKE, hsw_rapl_init),
 	{},
 };
 
arch/x86/events/intel/uncore_snbep.c +2 -2
index db1fe377e6dd..a7196818416a 100644
@@ -3462,7 +3462,7 @@ static struct intel_uncore_ops skx_uncore_iio_ops = {
 static struct intel_uncore_type skx_uncore_iio = {
 	.name			= "iio",
 	.num_counters		= 4,
-	.num_boxes		= 5,
+	.num_boxes		= 6,
 	.perf_ctr_bits		= 48,
 	.event_ctl		= SKX_IIO0_MSR_PMON_CTL0,
 	.perf_ctr		= SKX_IIO0_MSR_PMON_CTR0,
@@ -3492,7 +3492,7 @@ static const struct attribute_group skx_uncore_format_group = {
 static struct intel_uncore_type skx_uncore_irp = {
 	.name			= "irp",
 	.num_counters		= 2,
-	.num_boxes		= 5,
+	.num_boxes		= 6,
 	.perf_ctr_bits		= 48,
 	.event_ctl		= SKX_IRP0_MSR_PMON_CTL0,
 	.perf_ctr		= SKX_IRP0_MSR_PMON_CTR0,
arch/x86/events/msr.c +8 -0
index 4bb3ec69e8ea..06723671ae4e 100644
@@ -63,6 +63,14 @@ static bool test_intel(int idx)
 	case INTEL_FAM6_ATOM_SILVERMONT1:
 	case INTEL_FAM6_ATOM_SILVERMONT2:
 	case INTEL_FAM6_ATOM_AIRMONT:
+
+	case INTEL_FAM6_ATOM_GOLDMONT:
+	case INTEL_FAM6_ATOM_DENVERTON:
+
+	case INTEL_FAM6_ATOM_GEMINI_LAKE:
+
+	case INTEL_FAM6_XEON_PHI_KNL:
+	case INTEL_FAM6_XEON_PHI_KNM:
 		if (idx == PERF_MSR_SMI)
 			return true;
 		break;
arch/x86/include/asm/asm.h +5 -3
index c1eadbaf1115..b0dc91f4bedc 100644
@@ -11,10 +11,12 @@
 # define __ASM_FORM_COMMA(x) " " #x ","
 #endif
 
-#ifdef CONFIG_X86_32
+#ifndef __x86_64__
+/* 32 bit */
 # define __ASM_SEL(a,b) __ASM_FORM(a)
 # define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(a)
 #else
+/* 64 bit */
 # define __ASM_SEL(a,b) __ASM_FORM(b)
 # define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(b)
 #endif
@@ -139,8 +141,8 @@
  * gets set up by the containing function.  If you forget to do this, objtool
  * may print a "call without frame pointer save/setup" warning.
  */
-register unsigned int __asm_call_sp asm("esp");
-#define ASM_CALL_CONSTRAINT "+r" (__asm_call_sp)
+register unsigned long current_stack_pointer asm(_ASM_SP);
+#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer)
 #endif
 
 #endif /* _ASM_X86_ASM_H */
arch/x86/include/asm/thread_info.h +0 -11
index 5161da1a0fa0..89e7eeb5cec1 100644
@@ -158,17 +158,6 @@ struct thread_info {
  */
 #ifndef __ASSEMBLY__
 
-static inline unsigned long current_stack_pointer(void)
-{
-	unsigned long sp;
-#ifdef CONFIG_X86_64
-	asm("mov %%rsp,%0" : "=g" (sp));
-#else
-	asm("mov %%esp,%0" : "=g" (sp));
-#endif
-	return sp;
-}
-
 /*
  * Walks up the stack frames to make sure that the specified object is
  * entirely contained by a single stack frame.
arch/x86/include/asm/uaccess.h +1 -1
index 78e8fcc87d4c..4b892917edeb 100644
@@ -337,7 +337,7 @@ do {									\
 		     _ASM_EXTABLE(1b, 4b)				\
 		     _ASM_EXTABLE(2b, 4b)				\
 		     : "=r" (retval), "=&A"(x)				\
-		     : "m" (__m(__ptr)), "m" __m(((u32 *)(__ptr)) + 1),	\
+		     : "m" (__m(__ptr)), "m" __m(((u32 __user *)(__ptr)) + 1),	\
 		       "i" (errret), "0" (retval));			\
 })
 
arch/x86/kernel/irq_32.c +3 -3
index 1f38d9a4d9de..d4eb450144fd 100644
@@ -64,7 +64,7 @@ static void call_on_stack(void *func, void *stack)
 
 static inline void *current_stack(void)
 {
-	return (void *)(current_stack_pointer() & ~(THREAD_SIZE - 1));
+	return (void *)(current_stack_pointer & ~(THREAD_SIZE - 1));
 }
 
 static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)
@@ -88,7 +88,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)
 
 	/* Save the next esp at the bottom of the stack */
 	prev_esp = (u32 *)irqstk;
-	*prev_esp = current_stack_pointer();
+	*prev_esp = current_stack_pointer;
 
 	if (unlikely(overflow))
 		call_on_stack(print_stack_overflow, isp);
@@ -139,7 +139,7 @@ void do_softirq_own_stack(void)
 
 	/* Push the previous esp onto the stack */
 	prev_esp = (u32 *)irqstk;
-	*prev_esp = current_stack_pointer();
+	*prev_esp = current_stack_pointer;
 
 	call_on_stack(__do_softirq, isp);
 }
arch/x86/kernel/ksysfs.c +1 -1
index 4b0592ca9e47..8c1cc08f514f 100644
@@ -299,7 +299,7 @@ static int __init create_setup_data_nodes(struct kobject *parent)
 	return 0;
 
 out_clean_nodes:
-	for (j = i - 1; j > 0; j--)
+	for (j = i - 1; j >= 0; j--)
 		cleanup_setup_data_node(*(kobjp + j));
 	kfree(kobjp);
 out_setup_data_kobj:
arch/x86/kernel/traps.c +1 -1
index 34ea3651362e..67db4f43309e 100644
@@ -142,7 +142,7 @@ void ist_begin_non_atomic(struct pt_regs *regs)
 	 * from double_fault.
 	 */
 	BUG_ON((unsigned long)(current_top_of_stack() -
-			       current_stack_pointer()) >= THREAD_SIZE);
+			       current_stack_pointer) >= THREAD_SIZE);
 
 	preempt_enable_no_resched();
 }
arch/x86/mm/fault.c +24 -23

155 lines not on this page · raw message

arch/x86/mm/mem_encrypt.c +2 -0
index 3fcc8e01683b..16c5f37933a2 100644
@@ -10,6 +10,8 @@
  * published by the Free Software Foundation.
  */
 
+#define DISABLE_BRANCH_PROFILING
+
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <linux/mm.h>
arch/x86/mm/tlb.c +1 -1
index 93fe97cce581..49d9778376d7 100644
@@ -191,7 +191,7 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next,
 			 * mapped in the new pgd, we'll double-fault.  Forcibly
 			 * map it.
 			 */
-			unsigned int index = pgd_index(current_stack_pointer());
+			unsigned int index = pgd_index(current_stack_pointer);
 			pgd_t *pgd = next->pgd + index;
 
 			if (unlikely(pgd_none(*pgd)))
drivers/clocksource/numachip.c +1 -1
index 6a20dc8b253f..9a7d7f0f23fe 100644
@@ -43,7 +43,7 @@ static int numachip2_set_next_event(unsigned long delta, struct clock_event_devi
 	return 0;
 }
 
-static struct clock_event_device numachip2_clockevent = {
+static const struct clock_event_device numachip2_clockevent __initconst = {
 	.name            = "numachip2",
 	.rating          = 400,
 	.set_next_event  = numachip2_set_next_event,