Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1376255 > unrolled thread

[PATCH v2] x86/mm/pat: Fix BUG_ON in mmap_mem on QEMU/i386

Started byToshi Kani <toshi.kani@hpe.com>
First post2016-04-11 21:50 +0200
Last post2016-04-13 13:40 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] x86/mm/pat: Fix BUG_ON in mmap_mem on QEMU/i386 Toshi Kani <toshi.kani@hpe.com> - 2016-04-11 21:50 +0200
    Re: [PATCH v2] x86/mm/pat: Fix BUG_ON in mmap_mem on QEMU/i386 Ingo Molnar <mingo@kernel.org> - 2016-04-13 11:40 +0200
      Re: [PATCH v2] x86/mm/pat: Fix BUG_ON in mmap_mem on QEMU/i386 Toshi Kani <toshi.kani@hpe.com> - 2016-04-13 15:30 +0200
    [tip:x86/asm] x86/mm/pat: Fix BUG_ON() in mmap_mem() on QEMU/i386 tip-bot for Toshi Kani <tipbot@zytor.com> - 2016-04-13 13:40 +0200

#1376255 — [PATCH v2] x86/mm/pat: Fix BUG_ON in mmap_mem on QEMU/i386

FromToshi Kani <toshi.kani@hpe.com>
Date2016-04-11 21:50 +0200
Subject[PATCH v2] x86/mm/pat: Fix BUG_ON in mmap_mem on QEMU/i386
Message-ID<rmQ0p-2ML-1@gated-at.bofh.it>
The following BUG_ON error was reported on QEMU/i386:

  kernel BUG at arch/x86/mm/physaddr.c:79!
  Call Trace:
  phys_mem_access_prot_allowed
  mmap_mem
  ? mmap_region
  mmap_region
  do_mmap
  vm_mmap_pgoff
  SyS_mmap_pgoff
  do_int80_syscall_32
  entry_INT80_32

after commit edfe63ec97ed ("x86/mtrr: Fix Xorg crashes in
Qemu sessions").

PAT is now set to disabled state when MTRRs are disabled.
Thus, reactivating the __pa(high_memory) check in
phys_mem_access_prot_allowed().

When CONFIG_DEBUG_VIRTUAL is set, __pa() calls __phys_addr(),
which in turn calls slow_virt_to_phys() for 'high_memory'.
Because 'high_memory' is set to (the max direct mapped virt
addr + 1), it is not a valid virtual address.  Hence,
slow_virt_to_phys() returns 0 and hit the BUG_ON.  Using
__pa_nodebug() instead of __pa() will fix this BUG_ON.

However, this code block, originally written for Pentiums and
earlier, is no longer adequate since a 32-bit Xen guest has
MTRRs disabled and supports ZONE_HIGHMEM.  In this setup,
this code sets UC attribute for accessing RAM in high memory
range.

Delete this code block as it has been unused for a long time.

Reported-by: kernel test robot <ying.huang@linux.intel.com>
Link: https://lkml.org/lkml/2016/4/1/608
Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Vrabel <david.vrabel@citrix.com>
---
This patch is based on -tip.
v2: Change to remove the code block.
---
 arch/x86/mm/pat.c |   19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index c4c3ddc..fb0604f 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -778,25 +778,6 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
 	if (file->f_flags & O_DSYNC)
 		pcm = _PAGE_CACHE_MODE_UC_MINUS;
 
-#ifdef CONFIG_X86_32
-	/*
-	 * On the PPro and successors, the MTRRs are used to set
-	 * memory types for physical addresses outside main memory,
-	 * so blindly setting UC or PWT on those pages is wrong.
-	 * For Pentiums and earlier, the surround logic should disable
-	 * caching for the high addresses through the KEN pin, but
-	 * we maintain the tradition of paranoia in this code.
-	 */
-	if (!pat_enabled() &&
-	    !(boot_cpu_has(X86_FEATURE_MTRR) ||
-	      boot_cpu_has(X86_FEATURE_K6_MTRR) ||
-	      boot_cpu_has(X86_FEATURE_CYRIX_ARR) ||
-	      boot_cpu_has(X86_FEATURE_CENTAUR_MCR)) &&
-	    (pfn << PAGE_SHIFT) >= __pa(high_memory)) {
-		pcm = _PAGE_CACHE_MODE_UC;
-	}
-#endif
-
 	*vma_prot = __pgprot((pgprot_val(*vma_prot) & ~_PAGE_CACHE_MASK) |
 			     cachemode2protval(pcm));
 	return 1;

[toc] | [next] | [standalone]


#1377691

FromIngo Molnar <mingo@kernel.org>
Date2016-04-13 11:40 +0200
Message-ID<rnprc-7F0-13@gated-at.bofh.it>
In reply to#1376255
* Toshi Kani <toshi.kani@hpe.com> wrote:

> The following BUG_ON error was reported on QEMU/i386:
> 
>   kernel BUG at arch/x86/mm/physaddr.c:79!
>   Call Trace:
>   phys_mem_access_prot_allowed
>   mmap_mem
>   ? mmap_region
>   mmap_region
>   do_mmap
>   vm_mmap_pgoff
>   SyS_mmap_pgoff
>   do_int80_syscall_32
>   entry_INT80_32
> 
> after commit edfe63ec97ed ("x86/mtrr: Fix Xorg crashes in
> Qemu sessions").
> 
> PAT is now set to disabled state when MTRRs are disabled.
> Thus, reactivating the __pa(high_memory) check in
> phys_mem_access_prot_allowed().
> 
> When CONFIG_DEBUG_VIRTUAL is set, __pa() calls __phys_addr(),
> which in turn calls slow_virt_to_phys() for 'high_memory'.
> Because 'high_memory' is set to (the max direct mapped virt
> addr + 1), it is not a valid virtual address.  Hence,
> slow_virt_to_phys() returns 0 and hit the BUG_ON.  Using
> __pa_nodebug() instead of __pa() will fix this BUG_ON.
> 
> However, this code block, originally written for Pentiums and
> earlier, is no longer adequate since a 32-bit Xen guest has
> MTRRs disabled and supports ZONE_HIGHMEM.  In this setup,
> this code sets UC attribute for accessing RAM in high memory
> range.
> 
> Delete this code block as it has been unused for a long time.
> 
> Reported-by: kernel test robot <ying.huang@linux.intel.com>
> Link: https://lkml.org/lkml/2016/4/1/608
> Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: David Vrabel <david.vrabel@citrix.com>

So you missed the Reviewed-by tag from Boris ...

I've added it, but please try to propagate tags!

Thanks,

	Ingo

[toc] | [prev] | [next] | [standalone]


#1377943

FromToshi Kani <toshi.kani@hpe.com>
Date2016-04-13 15:30 +0200
Message-ID<rnt1O-1O6-57@gated-at.bofh.it>
In reply to#1377691
On Wed, 2016-04-13 at 11:35 +0200, Ingo Molnar wrote:
> * Toshi Kani <toshi.kani@hpe.com> wrote:
 :
> > 
> > However, this code block, originally written for Pentiums and
> > earlier, is no longer adequate since a 32-bit Xen guest has
> > MTRRs disabled and supports ZONE_HIGHMEM.  In this setup,
> > this code sets UC attribute for accessing RAM in high memory
> > range.
> > 
> > Delete this code block as it has been unused for a long time.
> > 
> > Reported-by: kernel test robot <ying.huang@linux.intel.com>
> > Link: https://lkml.org/lkml/2016/4/1/608
> > Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Ingo Molnar <mingo@kernel.org>
> > Cc: H. Peter Anvin <hpa@zytor.com>
> > Cc: Borislav Petkov <bp@suse.de>
> > Cc: David Vrabel <david.vrabel@citrix.com>
>
> So you missed the Reviewed-by tag from Boris ...
>
> I've added it, but please try to propagate tags!

Thanks Ingo!

I decided to drop the Reviewed-by tag for v1 since v2 has a different
approach.

-Toshi

[toc] | [prev] | [next] | [standalone]


#1377792 — [tip:x86/asm] x86/mm/pat: Fix BUG_ON() in mmap_mem() on QEMU/i386

Fromtip-bot for Toshi Kani <tipbot@zytor.com>
Date2016-04-13 13:40 +0200
Subject[tip:x86/asm] x86/mm/pat: Fix BUG_ON() in mmap_mem() on QEMU/i386
Message-ID<rnrjk-x5-25@gated-at.bofh.it>
In reply to#1376255
Commit-ID:  1886297ce0c8d563a08c8a8c4c0b97743e06cd37
Gitweb:     http://git.kernel.org/tip/1886297ce0c8d563a08c8a8c4c0b97743e06cd37
Author:     Toshi Kani <toshi.kani@hpe.com>
AuthorDate: Mon, 11 Apr 2016 13:36:00 -0600
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 13 Apr 2016 11:35:33 +0200

x86/mm/pat: Fix BUG_ON() in mmap_mem() on QEMU/i386

The following BUG_ON() crash was reported on QEMU/i386:

  kernel BUG at arch/x86/mm/physaddr.c:79!
  Call Trace:
  phys_mem_access_prot_allowed
  mmap_mem
  ? mmap_region
  mmap_region
  do_mmap
  vm_mmap_pgoff
  SyS_mmap_pgoff
  do_int80_syscall_32
  entry_INT80_32

after commit:

  edfe63ec97ed ("x86/mtrr: Fix Xorg crashes in Qemu sessions")

PAT is now set to disabled state when MTRRs are disabled.
Thus, reactivating the __pa(high_memory) check in
phys_mem_access_prot_allowed().

When CONFIG_DEBUG_VIRTUAL is set, __pa() calls __phys_addr(),
which in turn calls slow_virt_to_phys() for 'high_memory'.
Because 'high_memory' is set to (the max direct mapped virt
addr + 1), it is not a valid virtual address.  Hence,
slow_virt_to_phys() returns 0 and hit the BUG_ON.  Using
__pa_nodebug() instead of __pa() will fix this BUG_ON.

However, this code block, originally written for Pentiums and
earlier, is no longer adequate since a 32-bit Xen guest has
MTRRs disabled and supports ZONE_HIGHMEM.  In this setup,
this code sets UC attribute for accessing RAM in high memory
range.

Delete this code block as it has been unused for a long time.

Reported-by: kernel test robot <ying.huang@linux.intel.com>
Reviewed-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: xen-devel@lists.xenproject.org
Link: http://lkml.kernel.org/r/1460403360-25441-1-git-send-email-toshi.kani@hpe.com
Link: https://lkml.org/lkml/2016/4/1/608
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/mm/pat.c | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index c4c3ddc..fb0604f 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -778,25 +778,6 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
 	if (file->f_flags & O_DSYNC)
 		pcm = _PAGE_CACHE_MODE_UC_MINUS;
 
-#ifdef CONFIG_X86_32
-	/*
-	 * On the PPro and successors, the MTRRs are used to set
-	 * memory types for physical addresses outside main memory,
-	 * so blindly setting UC or PWT on those pages is wrong.
-	 * For Pentiums and earlier, the surround logic should disable
-	 * caching for the high addresses through the KEN pin, but
-	 * we maintain the tradition of paranoia in this code.
-	 */
-	if (!pat_enabled() &&
-	    !(boot_cpu_has(X86_FEATURE_MTRR) ||
-	      boot_cpu_has(X86_FEATURE_K6_MTRR) ||
-	      boot_cpu_has(X86_FEATURE_CYRIX_ARR) ||
-	      boot_cpu_has(X86_FEATURE_CENTAUR_MCR)) &&
-	    (pfn << PAGE_SHIFT) >= __pa(high_memory)) {
-		pcm = _PAGE_CACHE_MODE_UC;
-	}
-#endif
-
 	*vma_prot = __pgprot((pgprot_val(*vma_prot) & ~_PAGE_CACHE_MASK) |
 			     cachemode2protval(pcm));
 	return 1;

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web