From: Lennert Buytenhek <buytenh@wantstofly.org>
To: akpm@osdl.org, linux-kernel@vger.kernel.org
Cc: rmk@arm.linux.org.uk
Subject: [PATCH,RFC] make valid_mmap_phys_addr_range() take a pfn
Date: Sun, 2 Jul 2006 12:35:18 +0200 [thread overview]
Message-ID: <20060702103518.GC30730@xi.wantstofly.org> (raw)
Newer ARMs have a 40 bit physical address space, but mapping physical
memory above 4G needs a special page table format which we (currently?)
do not use for userspace mappings, so what happens instead is that
mapping an address >= 4G will happily discard the upper bits and wrap.
There is a valid_mmap_phys_addr_range() arch hook where we could check
for >= 4G addresses and deny the mapping, but this hook takes an unsigned
long address:
static inline int valid_mmap_phys_addr_range(unsigned long addr, size_t size);
And drivers/char/mem.c:mmap_mem() calls it like this:
static int mmap_mem(struct file * file, struct vm_area_struct * vma)
{
size_t size = vma->vm_end - vma->vm_start;
if (!valid_mmap_phys_addr_range(vma->vm_pgoff << PAGE_SHIFT, size))
So that's not much help either.
This patch makes the hook take a pfn instead of a phys address -- how
does that look?
Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Index: linux-2.6.17-git16/drivers/char/mem.c
===================================================================
--- linux-2.6.17-git16.orig/drivers/char/mem.c
+++ linux-2.6.17-git16/drivers/char/mem.c
@@ -96,7 +96,7 @@ static inline int valid_phys_addr_range(
return 1;
}
-static inline int valid_mmap_phys_addr_range(unsigned long addr, size_t size)
+static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
{
return 1;
}
@@ -243,7 +243,7 @@ static int mmap_mem(struct file * file,
{
size_t size = vma->vm_end - vma->vm_start;
- if (!valid_mmap_phys_addr_range(vma->vm_pgoff << PAGE_SHIFT, size))
+ if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
return -EINVAL;
vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff,
Index: linux-2.6.17-git16/arch/ia64/kernel/efi.c
===================================================================
--- linux-2.6.17-git16.orig/arch/ia64/kernel/efi.c
+++ linux-2.6.17-git16/arch/ia64/kernel/efi.c
@@ -760,7 +760,7 @@ valid_phys_addr_range (unsigned long phy
}
int
-valid_mmap_phys_addr_range (unsigned long phys_addr, unsigned long size)
+valid_mmap_phys_addr_range (unsigned long pfn, unsigned long size)
{
/*
* MMIO regions are often missing from the EFI memory map.
Index: linux-2.6.17-git16/arch/ia64/pci/pci.c
===================================================================
--- linux-2.6.17-git16.orig/arch/ia64/pci/pci.c
+++ linux-2.6.17-git16/arch/ia64/pci/pci.c
@@ -651,7 +651,7 @@ pci_mmap_legacy_page_range(struct pci_bu
* Avoid attribute aliasing. See Documentation/ia64/aliasing.txt
* for more details.
*/
- if (!valid_mmap_phys_addr_range(vma->vm_pgoff << PAGE_SHIFT, size))
+ if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
return -EINVAL;
prot = phys_mem_access_prot(NULL, vma->vm_pgoff, size,
vma->vm_page_prot);
Index: linux-2.6.17-git16/include/asm-ia64/io.h
===================================================================
--- linux-2.6.17-git16.orig/include/asm-ia64/io.h
+++ linux-2.6.17-git16/include/asm-ia64/io.h
@@ -90,7 +90,7 @@ phys_to_virt (unsigned long address)
#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
extern u64 kern_mem_attribute (unsigned long phys_addr, unsigned long size);
extern int valid_phys_addr_range (unsigned long addr, size_t count); /* efi.c */
-extern int valid_mmap_phys_addr_range (unsigned long addr, size_t count);
+extern int valid_mmap_phys_addr_range (unsigned long pfn, size_t count);
/*
* The following two macros are deprecated and scheduled for removal.
reply other threads:[~2006-07-02 10:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060702103518.GC30730@xi.wantstofly.org \
--to=buytenh@wantstofly.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk@arm.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®