Commit 1f231e29 authored by Alexander Gordeev's avatar Alexander Gordeev Committed by Vasily Gorbik

s390/maccess: fix absolute lowcore virtual vs physical address confusion

Due to historical reasons memcpy_absolute() and friend functions
misuse the notion of physical vs virtual addresses difference.

Note: this does not fix a bug currently, since virtual and physical
addresses are identical.
Reviewed-by: default avatarSven Schnelle <svens@linux.ibm.com>
Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent 98c0d24d
...@@ -199,15 +199,15 @@ int copy_to_user_real(void __user *dest, void *src, unsigned long count) ...@@ -199,15 +199,15 @@ int copy_to_user_real(void __user *dest, void *src, unsigned long count)
/* /*
* Check if physical address is within prefix or zero page * Check if physical address is within prefix or zero page
*/ */
static int is_swapped(unsigned long addr) static int is_swapped(phys_addr_t addr)
{ {
unsigned long lc; phys_addr_t lc;
int cpu; int cpu;
if (addr < sizeof(struct lowcore)) if (addr < sizeof(struct lowcore))
return 1; return 1;
for_each_online_cpu(cpu) { for_each_online_cpu(cpu) {
lc = (unsigned long) lowcore_ptr[cpu]; lc = virt_to_phys(lowcore_ptr[cpu]);
if (addr > lc + sizeof(struct lowcore) - 1 || addr < lc) if (addr > lc + sizeof(struct lowcore) - 1 || addr < lc)
continue; continue;
return 1; return 1;
...@@ -223,7 +223,8 @@ static int is_swapped(unsigned long addr) ...@@ -223,7 +223,8 @@ static int is_swapped(unsigned long addr)
*/ */
void *xlate_dev_mem_ptr(phys_addr_t addr) void *xlate_dev_mem_ptr(phys_addr_t addr)
{ {
void *bounce = (void *) addr; void *ptr = phys_to_virt(addr);
void *bounce = ptr;
unsigned long size; unsigned long size;
cpus_read_lock(); cpus_read_lock();
...@@ -232,7 +233,7 @@ void *xlate_dev_mem_ptr(phys_addr_t addr) ...@@ -232,7 +233,7 @@ void *xlate_dev_mem_ptr(phys_addr_t addr)
size = PAGE_SIZE - (addr & ~PAGE_MASK); size = PAGE_SIZE - (addr & ~PAGE_MASK);
bounce = (void *) __get_free_page(GFP_ATOMIC); bounce = (void *) __get_free_page(GFP_ATOMIC);
if (bounce) if (bounce)
memcpy_absolute(bounce, (void *) addr, size); memcpy_absolute(bounce, ptr, size);
} }
preempt_enable(); preempt_enable();
cpus_read_unlock(); cpus_read_unlock();
...@@ -242,8 +243,8 @@ void *xlate_dev_mem_ptr(phys_addr_t addr) ...@@ -242,8 +243,8 @@ void *xlate_dev_mem_ptr(phys_addr_t addr)
/* /*
* Free converted buffer for /dev/mem access (if necessary) * Free converted buffer for /dev/mem access (if necessary)
*/ */
void unxlate_dev_mem_ptr(phys_addr_t addr, void *buf) void unxlate_dev_mem_ptr(phys_addr_t addr, void *ptr)
{ {
if ((void *) addr != buf) if (addr != virt_to_phys(ptr))
free_page((unsigned long) buf); free_page((unsigned long)ptr);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment