+ make-valid_mmap_phys_addr_range-take-a-pfn.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     make valid_mmap_phys_addr_range() take a pfn

has been added to the -mm tree.  Its filename is

     make-valid_mmap_phys_addr_range-take-a-pfn.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: make valid_mmap_phys_addr_range() take a pfn
From: Lennert Buytenhek <buytenh@xxxxxxxxxxxxxx>

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.

Signed-off-by: Lennert Buytenhek <buytenh@xxxxxxxxxxxxxx>
Cc: Bjorn Helgaas <bjorn.helgaas@xxxxxx>
Cc: "Luck, Tony" <tony.luck@xxxxxxxxx>
Cc: Russell King <rmk@xxxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 arch/ia64/kernel/efi.c |    2 +-
 arch/ia64/pci/pci.c    |    2 +-
 drivers/char/mem.c     |    4 ++--
 include/asm-ia64/io.h  |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff -puN arch/ia64/kernel/efi.c~make-valid_mmap_phys_addr_range-take-a-pfn arch/ia64/kernel/efi.c
--- a/arch/ia64/kernel/efi.c~make-valid_mmap_phys_addr_range-take-a-pfn
+++ a/arch/ia64/kernel/efi.c
@@ -764,7 +764,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.
diff -puN arch/ia64/pci/pci.c~make-valid_mmap_phys_addr_range-take-a-pfn arch/ia64/pci/pci.c
--- a/arch/ia64/pci/pci.c~make-valid_mmap_phys_addr_range-take-a-pfn
+++ a/arch/ia64/pci/pci.c
@@ -650,7 +650,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);
diff -puN drivers/char/mem.c~make-valid_mmap_phys_addr_range-take-a-pfn drivers/char/mem.c
--- a/drivers/char/mem.c~make-valid_mmap_phys_addr_range-take-a-pfn
+++ a/drivers/char/mem.c
@@ -95,7 +95,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;
 }
@@ -242,7 +242,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,
diff -puN include/asm-ia64/io.h~make-valid_mmap_phys_addr_range-take-a-pfn include/asm-ia64/io.h
--- a/include/asm-ia64/io.h~make-valid_mmap_phys_addr_range-take-a-pfn
+++ a/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.
_

Patches currently in -mm which might be from buytenh@xxxxxxxxxxxxxx are

origin.patch
make-valid_mmap_phys_addr_range-take-a-pfn.patch
valid_mmap_phys_addr_range-cleanup.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux