All of lore.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL] x86 fixes for v3.14-rc6 - bad patch dropped
@ 2014-03-10  0:15 H. Peter Anvin
  2014-03-10  1:51 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: H. Peter Anvin @ 2014-03-10  0:15 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: jolsa, vincent.weaver, Arnaldo Carvalho de Melo, Borislav Petkov,
	H. Peter Anvin, H. Peter Anvin, Ingo Molnar,
	Linux Kernel Mailing List, Matt Fleming, Paul Mackerras,
	Peter Zijlstra, Peter Zijlstra, Russ Anderson, Seiji Aguchi,
	Steven Rostedt, Thomas Gleixner, Vince Weaver

Hi Linus,

The same collection of fixes except the broken NMI patch dropped.  I
will send a fixed version of that plus Suresh' FPU fix in a few days,
to get them some testing, plus I will be on a trip (part of why I got
unduly rushed this past Friday.  Sorry again for that.)

The following changes since commit 0414855fdc4a40da05221fc6062cccbc0c30f169:

  Linux 3.14-rc5 (2014-03-02 18:56:16 -0800)

are available in the git repository at:

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

for you to fetch changes up to d4078e232267ff53f3b030b9698a3c001db4dbec:

  x86, trace: Further robustify CR2 handling vs tracing (2014-03-06 10:58:18 -0800)

----------------------------------------------------------------
Borislav Petkov (1):
      x86/efi: Quirk out SGI UV

H. Peter Anvin (1):
      Merge tag 'efi-urgent' into x86/urgent

Jiri Olsa (1):
      x86, trace: Fix CR2 corruption when tracing page faults

Peter Zijlstra (1):
      x86, trace: Further robustify CR2 handling vs tracing

 arch/x86/include/asm/efi.h  |  1 +
 arch/x86/kernel/setup.c     | 10 ++--------
 arch/x86/mm/fault.c         | 47 +++++++++++++++++++++++++++++++--------------
 arch/x86/platform/efi/efi.c | 20 +++++++++++++++++++
 4 files changed, 56 insertions(+), 22 deletions(-)

diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index 3d6b9f81cc68..acd86c850414 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -134,6 +134,7 @@ extern void efi_setup_page_tables(void);
 extern void __init old_map_region(efi_memory_desc_t *md);
 extern void __init runtime_code_page_mkexec(void);
 extern void __init efi_runtime_mkexec(void);
+extern void __init efi_apply_memmap_quirks(void);
 
 struct efi_setup_data {
 	u64 fw_vendor;
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 06853e670354..ce72964b2f46 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1239,14 +1239,8 @@ void __init setup_arch(char **cmdline_p)
 	register_refined_jiffies(CLOCK_TICK_RATE);
 
 #ifdef CONFIG_EFI
-	/* Once setup is done above, unmap the EFI memory map on
-	 * mismatched firmware/kernel archtectures since there is no
-	 * support for runtime services.
-	 */
-	if (efi_enabled(EFI_BOOT) && !efi_is_native()) {
-		pr_info("efi: Setup done, disabling due to 32/64-bit mismatch\n");
-		efi_unmap_memmap();
-	}
+	if (efi_enabled(EFI_BOOT))
+		efi_apply_memmap_quirks();
 #endif
 }
 
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 6dea040cc3a1..a10c8c792161 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1020,13 +1020,17 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
  * This routine handles page faults.  It determines the address,
  * and the problem, and then passes it off to one of the appropriate
  * routines.
+ *
+ * This function must have noinline because both callers
+ * {,trace_}do_page_fault() have notrace on. Having this an actual function
+ * guarantees there's a function trace entry.
  */
-static void __kprobes
-__do_page_fault(struct pt_regs *regs, unsigned long error_code)
+static void __kprobes noinline
+__do_page_fault(struct pt_regs *regs, unsigned long error_code,
+		unsigned long address)
 {
 	struct vm_area_struct *vma;
 	struct task_struct *tsk;
-	unsigned long address;
 	struct mm_struct *mm;
 	int fault;
 	unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
@@ -1034,9 +1038,6 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
 	tsk = current;
 	mm = tsk->mm;
 
-	/* Get the faulting address: */
-	address = read_cr2();
-
 	/*
 	 * Detect and handle instructions that would cause a page fault for
 	 * both a tracked kernel page and a userspace page.
@@ -1248,32 +1249,50 @@ good_area:
 	up_read(&mm->mmap_sem);
 }
 
-dotraplinkage void __kprobes
+dotraplinkage void __kprobes notrace
 do_page_fault(struct pt_regs *regs, unsigned long error_code)
 {
+	unsigned long address = read_cr2(); /* Get the faulting address */
 	enum ctx_state prev_state;
 
+	/*
+	 * We must have this function tagged with __kprobes, notrace and call
+	 * read_cr2() before calling anything else. To avoid calling any kind
+	 * of tracing machinery before we've observed the CR2 value.
+	 *
+	 * exception_{enter,exit}() contain all sorts of tracepoints.
+	 */
+
 	prev_state = exception_enter();
-	__do_page_fault(regs, error_code);
+	__do_page_fault(regs, error_code, address);
 	exception_exit(prev_state);
 }
 
-static void trace_page_fault_entries(struct pt_regs *regs,
+#ifdef CONFIG_TRACING
+static void trace_page_fault_entries(unsigned long address, struct pt_regs *regs,
 				     unsigned long error_code)
 {
 	if (user_mode(regs))
-		trace_page_fault_user(read_cr2(), regs, error_code);
+		trace_page_fault_user(address, regs, error_code);
 	else
-		trace_page_fault_kernel(read_cr2(), regs, error_code);
+		trace_page_fault_kernel(address, regs, error_code);
 }
 
-dotraplinkage void __kprobes
+dotraplinkage void __kprobes notrace
 trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
 {
+	/*
+	 * The exception_enter and tracepoint processing could
+	 * trigger another page faults (user space callchain
+	 * reading) and destroy the original cr2 value, so read
+	 * the faulting address now.
+	 */
+	unsigned long address = read_cr2();
 	enum ctx_state prev_state;
 
 	prev_state = exception_enter();
-	trace_page_fault_entries(regs, error_code);
-	__do_page_fault(regs, error_code);
+	trace_page_fault_entries(address, regs, error_code);
+	__do_page_fault(regs, error_code, address);
 	exception_exit(prev_state);
 }
+#endif /* CONFIG_TRACING */
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 1a201ac7cef8..b97acecf3fd9 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -52,6 +52,7 @@
 #include <asm/tlbflush.h>
 #include <asm/x86_init.h>
 #include <asm/rtc.h>
+#include <asm/uv/uv.h>
 
 #define EFI_DEBUG
 
@@ -1210,3 +1211,22 @@ static int __init parse_efi_cmdline(char *str)
 	return 0;
 }
 early_param("efi", parse_efi_cmdline);
+
+void __init efi_apply_memmap_quirks(void)
+{
+	/*
+	 * Once setup is done earlier, unmap the EFI memory map on mismatched
+	 * firmware/kernel architectures since there is no support for runtime
+	 * services.
+	 */
+	if (!efi_is_native()) {
+		pr_info("efi: Setup done, disabling due to 32/64-bit mismatch\n");
+		efi_unmap_memmap();
+	}
+
+	/*
+	 * UV doesn't support the new EFI pagetable mapping yet.
+	 */
+	if (is_uv_system())
+		set_bit(EFI_OLD_MEMMAP, &x86_efi_facility);
+}

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [GIT PULL] x86 fixes for v3.14-rc6 - bad patch dropped
  2014-03-10  0:15 [GIT PULL] x86 fixes for v3.14-rc6 - bad patch dropped H. Peter Anvin
@ 2014-03-10  1:51 ` Linus Torvalds
  2014-03-10  2:40   ` H. Peter Anvin
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2014-03-10  1:51 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Borislav Petkov,
	H. Peter Anvin, Ingo Molnar, Linux Kernel Mailing List,
	Matt Fleming, Paul Mackerras, Peter Zijlstra, Peter Zijlstra,
	Russ Anderson, Seiji Aguchi, Steven Rostedt, Thomas Gleixner,
	Vince Weaver

On Sun, Mar 9, 2014 at 5:15 PM, H. Peter Anvin <hpa@linux.intel.com> wrote:
>
> The same collection of fixes except the broken NMI patch dropped.  I
> will send a fixed version of that plus Suresh' FPU fix in a few days,
> to get them some testing, plus I will be on a trip (part of why I got
> unduly rushed this past Friday.  Sorry again for that.)

I already pulled the broken one, and had actually pushed it out in
that broken format, which was so upsetting. Normally I tend to delay
pushing things out until I've done my compile tests, but I had
stupidly thought I didn't need to that time.

            Linus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [GIT PULL] x86 fixes for v3.14-rc6 - bad patch dropped
  2014-03-10  1:51 ` Linus Torvalds
@ 2014-03-10  2:40   ` H. Peter Anvin
  0 siblings, 0 replies; 3+ messages in thread
From: H. Peter Anvin @ 2014-03-10  2:40 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, Borislav Petkov,
	H. Peter Anvin, Ingo Molnar, Linux Kernel Mailing List,
	Matt Fleming, Paul Mackerras, Peter Zijlstra, Peter Zijlstra,
	Russ Anderson, Seiji Aguchi, Steven Rostedt, Thomas Gleixner,
	Vince Weaver

On 03/09/2014 06:51 PM, Linus Torvalds wrote:
> On Sun, Mar 9, 2014 at 5:15 PM, H. Peter Anvin <hpa@linux.intel.com> wrote:
>>
>> The same collection of fixes except the broken NMI patch dropped.  I
>> will send a fixed version of that plus Suresh' FPU fix in a few days,
>> to get them some testing, plus I will be on a trip (part of why I got
>> unduly rushed this past Friday.  Sorry again for that.)
> 
> I already pulled the broken one, and had actually pushed it out in
> that broken format, which was so upsetting. Normally I tend to delay
> pushing things out until I've done my compile tests, but I had
> stupidly thought I didn't need to that time.
> 

So I see.  Thanks and sorry again.

	-hpa



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-10  2:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-10  0:15 [GIT PULL] x86 fixes for v3.14-rc6 - bad patch dropped H. Peter Anvin
2014-03-10  1:51 ` Linus Torvalds
2014-03-10  2:40   ` H. Peter Anvin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.