diff options
author | Roland Dreier <rolandd@cisco.com> | 2005-10-28 20:46:18 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-10-29 00:25:49 -0400 |
commit | 8b150478aeb1a8edb9015c2f7ac4da637ff65c45 (patch) | |
tree | 621b038b9c041fe82b708c6c5cbee655be2a519a /arch/ppc | |
parent | d49b340124a34fcb8bceda472558ccef7232c16f (diff) |
[PATCH] ppc: make phys_mem_access_prot() work with pfns instead of addresses
Change the phys_mem_access_prot() function to take a pfn instead of an
address. This allows mmap64() to work on /dev/mem for addresses above 4G
on 32-bit architectures. We start with a pfn in mmap_mem(), so there's no
need to convert to an address; in fact, it's actively bad, since the
conversion can overflow when the address is above 4G.
Similarly fix the ppc32 page_is_ram() function to avoid a conversion to an
address by directly comparing to max_pfn. Working with max_pfn instead of
high_memory fixes page_is_ram() to give the right answer for highmem pages.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Cc: Anton Blanchard <anton@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/ppc')
-rw-r--r-- | arch/ppc/kernel/pci.c | 5 | ||||
-rw-r--r-- | arch/ppc/mm/init.c | 10 |
2 files changed, 7 insertions, 8 deletions
diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c index ad4ef2aaa6ab..e8f4e576750a 100644 --- a/arch/ppc/kernel/pci.c +++ b/arch/ppc/kernel/pci.c | |||
@@ -1594,16 +1594,17 @@ static pgprot_t __pci_mmap_set_pgprot(struct pci_dev *dev, struct resource *rp, | |||
1594 | * above routine | 1594 | * above routine |
1595 | */ | 1595 | */ |
1596 | pgprot_t pci_phys_mem_access_prot(struct file *file, | 1596 | pgprot_t pci_phys_mem_access_prot(struct file *file, |
1597 | unsigned long offset, | 1597 | unsigned long pfn, |
1598 | unsigned long size, | 1598 | unsigned long size, |
1599 | pgprot_t protection) | 1599 | pgprot_t protection) |
1600 | { | 1600 | { |
1601 | struct pci_dev *pdev = NULL; | 1601 | struct pci_dev *pdev = NULL; |
1602 | struct resource *found = NULL; | 1602 | struct resource *found = NULL; |
1603 | unsigned long prot = pgprot_val(protection); | 1603 | unsigned long prot = pgprot_val(protection); |
1604 | unsigned long offset = pfn << PAGE_SHIFT; | ||
1604 | int i; | 1605 | int i; |
1605 | 1606 | ||
1606 | if (page_is_ram(offset >> PAGE_SHIFT)) | 1607 | if (page_is_ram(pfn)) |
1607 | return prot; | 1608 | return prot; |
1608 | 1609 | ||
1609 | prot |= _PAGE_NO_CACHE | _PAGE_GUARDED; | 1610 | prot |= _PAGE_NO_CACHE | _PAGE_GUARDED; |
diff --git a/arch/ppc/mm/init.c b/arch/ppc/mm/init.c index db94efd25369..99b48abd3296 100644 --- a/arch/ppc/mm/init.c +++ b/arch/ppc/mm/init.c | |||
@@ -637,18 +637,16 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, | |||
637 | */ | 637 | */ |
638 | int page_is_ram(unsigned long pfn) | 638 | int page_is_ram(unsigned long pfn) |
639 | { | 639 | { |
640 | unsigned long paddr = (pfn << PAGE_SHIFT); | 640 | return pfn < max_pfn; |
641 | |||
642 | return paddr < __pa(high_memory); | ||
643 | } | 641 | } |
644 | 642 | ||
645 | pgprot_t phys_mem_access_prot(struct file *file, unsigned long addr, | 643 | pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, |
646 | unsigned long size, pgprot_t vma_prot) | 644 | unsigned long size, pgprot_t vma_prot) |
647 | { | 645 | { |
648 | if (ppc_md.phys_mem_access_prot) | 646 | if (ppc_md.phys_mem_access_prot) |
649 | return ppc_md.phys_mem_access_prot(file, addr, size, vma_prot); | 647 | return ppc_md.phys_mem_access_prot(file, pfn, size, vma_prot); |
650 | 648 | ||
651 | if (!page_is_ram(addr >> PAGE_SHIFT)) | 649 | if (!page_is_ram(pfn)) |
652 | vma_prot = __pgprot(pgprot_val(vma_prot) | 650 | vma_prot = __pgprot(pgprot_val(vma_prot) |
653 | | _PAGE_GUARDED | _PAGE_NO_CACHE); | 651 | | _PAGE_GUARDED | _PAGE_NO_CACHE); |
654 | return vma_prot; | 652 | return vma_prot; |