mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] i386: additional fix for making ioremap() accept 64-bit addresses
@ 2008-04-04 12:19 Jan Beulich
  2008-04-04 12:55 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2008-04-04 12:19 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Ingo Molnar, hpa, tglx, linux-kernel

The recent change to __ioremap()'s first parameter's type didn't yield
the intended effect as the first conditional inside the function would
still have filtered out any addresses with bits [63:32] set. Correct
last_addr's type and at once also add a check that the address range
doesn't extend into space hardware cannot support even theoretically.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: H. Peter Anvin <hpa@kernel.org>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/mm/ioremap.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- linux-2.6.25-rc8/arch/x86/mm/ioremap.c	2008-04-02 16:21:19.000000000 +0200
+++ 2.6.25-rc8-i386-ioremap-64bit/arch/x86/mm/ioremap.c	2008-04-02 15:21:42.000000000 +0200
@@ -109,13 +109,14 @@ static int ioremap_change_attr(unsigned 
 static void __iomem *__ioremap(resource_size_t phys_addr, unsigned long size,
 			       enum ioremap_mode mode)
 {
-	unsigned long pfn, offset, last_addr, vaddr;
+	unsigned long pfn, offset, vaddr;
+	resource_size_t last_addr;
 	struct vm_struct *area;
 	pgprot_t prot;
 
 	/* Don't allow wraparound or zero size */
 	last_addr = phys_addr + size - 1;
-	if (!size || last_addr < phys_addr)
+	if (!size || last_addr < phys_addr || last_addr > __PHYSICAL_MASK)
 		return NULL;
 
 	/*




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

* Re: [PATCH] i386: additional fix for making ioremap() accept 64-bit addresses
  2008-04-04 12:19 [PATCH] i386: additional fix for making ioremap() accept 64-bit addresses Jan Beulich
@ 2008-04-04 12:55 ` Ingo Molnar
  2008-04-04 15:34   ` [PATCH] i386: additional fix for making ioremap() accept64-bit addresses Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2008-04-04 12:55 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Linus Torvalds, hpa, tglx, linux-kernel


* Jan Beulich <jbeulich@novell.com> wrote:

> The recent change to __ioremap()'s first parameter's type didn't yield 
> the intended effect as the first conditional inside the function would 
> still have filtered out any addresses with bits [63:32] set. Correct 
> last_addr's type and at once also add a check that the address range 
> doesn't extend into space hardware cannot support even theoretically.

i fixed this in x86.git more than a week ago, see:

|  Subject: x86: ioremap of 64-bit resource on 32-bit kernel fix
|  From: Ingo Molnar <mingo@elte.hu>
|  Date: Tue, 25 Mar 2008 08:31:17 +0100

but since 64-bit resources never worked on 32-bit and the initiator 
regression causing this discussion turned out to be something else, i 
delayed this fix as .26 material.

the PHYSICAL_MASK fix looks good as an additional check - could you 
please resend it against x86.git/latest which has my fix already?

	Ingo

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

* Re: [PATCH] i386: additional fix for making ioremap() accept64-bit addresses
  2008-04-04 12:55 ` Ingo Molnar
@ 2008-04-04 15:34   ` Jan Beulich
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2008-04-04 15:34 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: hpa, tglx, Linus Torvalds, linux-kernel

>>> Ingo Molnar <mingo@elte.hu> 04.04.08 14:55 >>>
>
>* Jan Beulich <jbeulich@novell.com> wrote:
>
>> The recent change to __ioremap()'s first parameter's type didn't yield 
>> the intended effect as the first conditional inside the function would 
>> still have filtered out any addresses with bits [63:32] set. Correct 
>> last_addr's type and at once also add a check that the address range 
>> doesn't extend into space hardware cannot support even theoretically.
>
>i fixed this in x86.git more than a week ago, see:
>
>|  Subject: x86: ioremap of 64-bit resource on 32-bit kernel fix
>|  From: Ingo Molnar <mingo@elte.hu>
>|  Date: Tue, 25 Mar 2008 08:31:17 +0100
>
>but since 64-bit resources never worked on 32-bit and the initiator 
>regression causing this discussion turned out to be something else, i 
>delayed this fix as .26 material.
>
>the PHYSICAL_MASK fix looks good as an additional check - could you 
>please resend it against x86.git/latest which has my fix already?

No need to do this afaics: you've already got the better

	if (!phys_addr_valid(phys_addr)) {
		printk(KERN_WARNING "ioremap: invalid physical address %llx\n",
		       phys_addr);
		WARN_ON_ONCE(1);
		return NULL;
	}

in there. What needs fixing is that this returns 1 on 32-bits
unconditionally, whereas the x86-64 definition should also be used for
PAE (and the parameter type should also be resource_size_t).

Jan


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

end of thread, other threads:[~2008-04-04 15:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-04 12:19 [PATCH] i386: additional fix for making ioremap() accept 64-bit addresses Jan Beulich
2008-04-04 12:55 ` Ingo Molnar
2008-04-04 15:34   ` [PATCH] i386: additional fix for making ioremap() accept64-bit addresses Jan Beulich

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

Powered by JetHome