public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.39-rc5] ioremap: Delay sanity check until after a successful mapping
@ 2011-04-28 17:00 Tim Gardner
  2011-04-28 19:49 ` Suresh Siddha
  2011-04-29  6:31 ` [tip:x86/mm] " tip-bot for Tim Gardner
  0 siblings, 2 replies; 3+ messages in thread
From: Tim Gardner @ 2011-04-28 17:00 UTC (permalink / raw)
  To: tglx, mingo, hpa, suresh.b.siddha; +Cc: linux-kernel@vger.kernel.org, x86

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

While tracking down the reason for an ioremap() failure I was distracted 
by the WARN_ONCE() in __ioremap_caller(). Can we move the sanity check 
later in the function until _after_ the mapping has been performed?

rtg
-- 
Tim Gardner tim.gardner@canonical.com

[-- Attachment #2: 0001-ioremap-Delay-sanity-check-until-after-a-successful-.patch --]
[-- Type: text/x-patch, Size: 2086 bytes --]

>From 31dec327a254888fcd0b6aa963414b09626d3168 Mon Sep 17 00:00:00 2001
From: Tim Gardner <tim.gardner@canonical.com>
Date: Thu, 28 Apr 2011 10:07:51 -0600
Subject: [PATCH] ioremap: Delay sanity check until after a successful mapping

Performing a WARN_ONCE() sanity check before the mapping
is successful seems pointless if the caller sends bad values.
A case in point is when the BIOS provides erroneous screen_info values
causing vesafb_probe() to request an outrageuous size. The
WARN_ONCE is then wasted on bogosity. Move the warning to a
point where the mapping has been successfully allocated.

http://bugs.launchpad.net/bugs/772042

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 arch/x86/mm/ioremap.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 0369843..be1ef57 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -91,13 +91,6 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
 		return (__force void __iomem *)phys_to_virt(phys_addr);
 
 	/*
-	 * Check if the request spans more than any BAR in the iomem resource
-	 * tree.
-	 */
-	WARN_ONCE(iomem_map_sanity_check(phys_addr, size),
-		  KERN_INFO "Info: mapping multiple BARs. Your kernel is fine.");
-
-	/*
 	 * Don't allow anybody to remap normal RAM that we're using..
 	 */
 	last_pfn = last_addr >> PAGE_SHIFT;
@@ -170,6 +163,13 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
 	ret_addr = (void __iomem *) (vaddr + offset);
 	mmiotrace_ioremap(unaligned_phys_addr, unaligned_size, ret_addr);
 
+	/*
+	 * Check if the request spans more than any BAR in the iomem resource
+	 * tree.
+	 */
+	WARN_ONCE(iomem_map_sanity_check(unaligned_phys_addr, unaligned_size),
+		  KERN_INFO "Info: mapping multiple BARs. Your kernel is fine.");
+
 	return ret_addr;
 err_free_area:
 	free_vm_area(area);
-- 
1.7.0.4


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

* Re: [PATCH 2.6.39-rc5] ioremap: Delay sanity check until after a successful mapping
  2011-04-28 17:00 [PATCH 2.6.39-rc5] ioremap: Delay sanity check until after a successful mapping Tim Gardner
@ 2011-04-28 19:49 ` Suresh Siddha
  2011-04-29  6:31 ` [tip:x86/mm] " tip-bot for Tim Gardner
  1 sibling, 0 replies; 3+ messages in thread
From: Suresh Siddha @ 2011-04-28 19:49 UTC (permalink / raw)
  To: tim.gardner@canonical.com
  Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
	linux-kernel@vger.kernel.org, x86@kernel.org

On Thu, 2011-04-28 at 10:00 -0700, Tim Gardner wrote:
> While tracking down the reason for an ioremap() failure I was
> distracted 
> by the WARN_ONCE() in __ioremap_caller(). Can we move the sanity
> check 
> later in the function until _after_ the mapping has been performed?
> 
> rtg
> -- 
> Tim Gardner tim.gardner@canonical.com
> 
> 
> 
> 
> 
> 
> 
> differences
> between files
> attachment
> (0001-ioremap-Delay-sanity-check-until-after-a-successful-.patch)
> 
> From 31dec327a254888fcd0b6aa963414b09626d3168 Mon Sep 17 00:00:00 2001
> From: Tim Gardner <tim.gardner@canonical.com>
> Date: Thu, 28 Apr 2011 10:07:51 -0600
> Subject: [PATCH] ioremap: Delay sanity check until after a successful
> mapping
> 
> Performing a WARN_ONCE() sanity check before the mapping
> is successful seems pointless if the caller sends bad values.
> A case in point is when the BIOS provides erroneous screen_info values
> causing vesafb_probe() to request an outrageuous size. The
> WARN_ONCE is then wasted on bogosity. Move the warning to a
> point where the mapping has been successfully allocated.
> 
> http://bugs.launchpad.net/bugs/772042

Sounds good to me.

Reviewed-by: Suresh Siddha <suresh.b.siddha@intel.com>

thanks.


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

* [tip:x86/mm] ioremap: Delay sanity check until after a successful mapping
  2011-04-28 17:00 [PATCH 2.6.39-rc5] ioremap: Delay sanity check until after a successful mapping Tim Gardner
  2011-04-28 19:49 ` Suresh Siddha
@ 2011-04-29  6:31 ` tip-bot for Tim Gardner
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Tim Gardner @ 2011-04-29  6:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, suresh.b.siddha, tim.gardner, tglx,
	mingo

Commit-ID:  c7a7b814c9dca9ee01b38e63b4a46de87156d3b6
Gitweb:     http://git.kernel.org/tip/c7a7b814c9dca9ee01b38e63b4a46de87156d3b6
Author:     Tim Gardner <tim.gardner@canonical.com>
AuthorDate: Thu, 28 Apr 2011 11:00:30 -0600
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 29 Apr 2011 08:02:47 +0200

ioremap: Delay sanity check until after a successful mapping

While tracking down the reason for an ioremap() failure I was
distracted  by the WARN_ONCE() in __ioremap_caller().

Performing a WARN_ONCE() sanity check before the mapping
is successful seems pointless if the caller sends bad values.

A case in point is when the BIOS provides erroneous screen_info
values causing vesafb_probe() to request an outrageuous size.
The WARN_ONCE is then wasted on bogosity. Move the warning to a
point where the mapping has been successfully allocated.

Addresses:

  http://bugs.launchpad.net/bugs/772042

Reviewed-by: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Link: http://lkml.kernel.org/r/4DB99D2E.9080106@canonical.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/mm/ioremap.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 0369843..be1ef57 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -91,13 +91,6 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
 		return (__force void __iomem *)phys_to_virt(phys_addr);
 
 	/*
-	 * Check if the request spans more than any BAR in the iomem resource
-	 * tree.
-	 */
-	WARN_ONCE(iomem_map_sanity_check(phys_addr, size),
-		  KERN_INFO "Info: mapping multiple BARs. Your kernel is fine.");
-
-	/*
 	 * Don't allow anybody to remap normal RAM that we're using..
 	 */
 	last_pfn = last_addr >> PAGE_SHIFT;
@@ -170,6 +163,13 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
 	ret_addr = (void __iomem *) (vaddr + offset);
 	mmiotrace_ioremap(unaligned_phys_addr, unaligned_size, ret_addr);
 
+	/*
+	 * Check if the request spans more than any BAR in the iomem resource
+	 * tree.
+	 */
+	WARN_ONCE(iomem_map_sanity_check(unaligned_phys_addr, unaligned_size),
+		  KERN_INFO "Info: mapping multiple BARs. Your kernel is fine.");
+
 	return ret_addr;
 err_free_area:
 	free_vm_area(area);

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

end of thread, other threads:[~2011-04-29  6:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-28 17:00 [PATCH 2.6.39-rc5] ioremap: Delay sanity check until after a successful mapping Tim Gardner
2011-04-28 19:49 ` Suresh Siddha
2011-04-29  6:31 ` [tip:x86/mm] " tip-bot for Tim Gardner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox