forked from Minki/linux
/dev/mem: use phys_addr_t for physical addresses
This patch fixes the /dev/mem driver to use phys_addr_t for physical addresses. This is required on PAE systems, especially those that run entirely out of >4G physical memory space. Signed-off-by: Cyril Chemparathy <cyril@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
6f0c0580b7
commit
7e6735c357
@ -374,7 +374,7 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
|
|||||||
|
|
||||||
#ifdef CONFIG_MMU
|
#ifdef CONFIG_MMU
|
||||||
#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
|
#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
|
||||||
extern int valid_phys_addr_range(unsigned long addr, size_t size);
|
extern int valid_phys_addr_range(phys_addr_t addr, size_t size);
|
||||||
extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
|
extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
|
||||||
extern int devmem_is_allowed(unsigned long pfn);
|
extern int devmem_is_allowed(unsigned long pfn);
|
||||||
#endif
|
#endif
|
||||||
|
@ -279,7 +279,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
|
|||||||
* You really shouldn't be using read() or write() on /dev/mem. This
|
* You really shouldn't be using read() or write() on /dev/mem. This
|
||||||
* might go away in the future.
|
* might go away in the future.
|
||||||
*/
|
*/
|
||||||
int valid_phys_addr_range(unsigned long addr, size_t size)
|
int valid_phys_addr_range(phys_addr_t addr, size_t size)
|
||||||
{
|
{
|
||||||
if (addr < PHYS_OFFSET)
|
if (addr < PHYS_OFFSET)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -90,7 +90,7 @@ phys_to_virt (unsigned long address)
|
|||||||
|
|
||||||
#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
|
#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
|
||||||
extern u64 kern_mem_attribute (unsigned long phys_addr, unsigned long size);
|
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_phys_addr_range (phys_addr_t addr, size_t count); /* efi.c */
|
||||||
extern int valid_mmap_phys_addr_range (unsigned long pfn, size_t count);
|
extern int valid_mmap_phys_addr_range (unsigned long pfn, size_t count);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -870,7 +870,7 @@ kern_mem_attribute (unsigned long phys_addr, unsigned long size)
|
|||||||
EXPORT_SYMBOL(kern_mem_attribute);
|
EXPORT_SYMBOL(kern_mem_attribute);
|
||||||
|
|
||||||
int
|
int
|
||||||
valid_phys_addr_range (unsigned long phys_addr, unsigned long size)
|
valid_phys_addr_range (phys_addr_t phys_addr, unsigned long size)
|
||||||
{
|
{
|
||||||
u64 attr;
|
u64 attr;
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ static inline int iounmap_fixed(void __iomem *addr) { return -EINVAL; }
|
|||||||
#define xlate_dev_kmem_ptr(p) p
|
#define xlate_dev_kmem_ptr(p) p
|
||||||
|
|
||||||
#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
|
#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
|
||||||
int valid_phys_addr_range(unsigned long addr, size_t size);
|
int valid_phys_addr_range(phys_addr_t addr, size_t size);
|
||||||
int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
|
int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
|
||||||
|
|
||||||
#endif /* __KERNEL__ */
|
#endif /* __KERNEL__ */
|
||||||
|
@ -238,7 +238,7 @@ bottomup:
|
|||||||
* You really shouldn't be using read() or write() on /dev/mem. This
|
* You really shouldn't be using read() or write() on /dev/mem. This
|
||||||
* might go away in the future.
|
* might go away in the future.
|
||||||
*/
|
*/
|
||||||
int valid_phys_addr_range(unsigned long addr, size_t count)
|
int valid_phys_addr_range(phys_addr_t addr, size_t count)
|
||||||
{
|
{
|
||||||
if (addr < __MEMORY_START)
|
if (addr < __MEMORY_START)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -48,7 +48,7 @@ static inline unsigned long size_inside_page(unsigned long start,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE
|
#ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE
|
||||||
static inline int valid_phys_addr_range(unsigned long addr, size_t count)
|
static inline int valid_phys_addr_range(phys_addr_t addr, size_t count)
|
||||||
{
|
{
|
||||||
return addr + count <= __pa(high_memory);
|
return addr + count <= __pa(high_memory);
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ void __weak unxlate_dev_mem_ptr(unsigned long phys, void *addr)
|
|||||||
static ssize_t read_mem(struct file *file, char __user *buf,
|
static ssize_t read_mem(struct file *file, char __user *buf,
|
||||||
size_t count, loff_t *ppos)
|
size_t count, loff_t *ppos)
|
||||||
{
|
{
|
||||||
unsigned long p = *ppos;
|
phys_addr_t p = *ppos;
|
||||||
ssize_t read, sz;
|
ssize_t read, sz;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
|
|||||||
static ssize_t write_mem(struct file *file, const char __user *buf,
|
static ssize_t write_mem(struct file *file, const char __user *buf,
|
||||||
size_t count, loff_t *ppos)
|
size_t count, loff_t *ppos)
|
||||||
{
|
{
|
||||||
unsigned long p = *ppos;
|
phys_addr_t p = *ppos;
|
||||||
ssize_t written, sz;
|
ssize_t written, sz;
|
||||||
unsigned long copied;
|
unsigned long copied;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
@ -226,7 +226,7 @@ int __weak phys_mem_access_prot_allowed(struct file *file,
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifdef pgprot_noncached
|
#ifdef pgprot_noncached
|
||||||
static int uncached_access(struct file *file, unsigned long addr)
|
static int uncached_access(struct file *file, phys_addr_t addr)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_IA64)
|
#if defined(CONFIG_IA64)
|
||||||
/*
|
/*
|
||||||
@ -258,7 +258,7 @@ static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
|
|||||||
unsigned long size, pgprot_t vma_prot)
|
unsigned long size, pgprot_t vma_prot)
|
||||||
{
|
{
|
||||||
#ifdef pgprot_noncached
|
#ifdef pgprot_noncached
|
||||||
unsigned long offset = pfn << PAGE_SHIFT;
|
phys_addr_t offset = pfn << PAGE_SHIFT;
|
||||||
|
|
||||||
if (uncached_access(file, offset))
|
if (uncached_access(file, offset))
|
||||||
return pgprot_noncached(vma_prot);
|
return pgprot_noncached(vma_prot);
|
||||||
|
Loading…
Reference in New Issue
Block a user