mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-28 23:23:55 +08:00
b2a68c2356
Currently dev/mem for s390 provides only real memory access. This means that the CPU prefix pages are swapped. The prefix swap for real memory works as follows: Each CPU owns a prefix register that points to a page aligned memory location "P". If this CPU accesses the address range [0,0x1fff], it is translated by the hardware to [P,P+0x1fff]. Accordingly if this CPU accesses the address range [P,P+0x1fff], it is translated by the hardware to [0,0x1fff]. Therefore, if [P,P+0x1fff] or [0,0x1fff] is read from the current /dev/mem device, the incorrectly swapped memory content is returned. With this patch the /dev/mem architecture code is modified to provide absolute memory access. This is done via the arch specific functions xlate_dev_mem_ptr() and unxlate_dev_mem_ptr(). For swapped pages on s390 the function xlate_dev_mem_ptr() now returns a new buffer with a copy of the requested absolute memory. In case the buffer was allocated, the unxlate_dev_mem_ptr() function frees it after /dev/mem code has called copy_to_user(). Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
52 lines
1.0 KiB
C
52 lines
1.0 KiB
C
/*
|
|
* include/asm-s390/io.h
|
|
*
|
|
* S390 version
|
|
* Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
|
|
* Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
|
|
*
|
|
* Derived from "include/asm-i386/io.h"
|
|
*/
|
|
|
|
#ifndef _S390_IO_H
|
|
#define _S390_IO_H
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
#include <asm/page.h>
|
|
|
|
#define IO_SPACE_LIMIT 0xffffffff
|
|
|
|
/*
|
|
* Change virtual addresses to physical addresses and vv.
|
|
* These are pretty trivial
|
|
*/
|
|
static inline unsigned long virt_to_phys(volatile void * address)
|
|
{
|
|
unsigned long real_address;
|
|
asm volatile(
|
|
" lra %0,0(%1)\n"
|
|
" jz 0f\n"
|
|
" la %0,0\n"
|
|
"0:"
|
|
: "=a" (real_address) : "a" (address) : "cc");
|
|
return real_address;
|
|
}
|
|
|
|
static inline void * phys_to_virt(unsigned long address)
|
|
{
|
|
return (void *) address;
|
|
}
|
|
|
|
void *xlate_dev_mem_ptr(unsigned long phys);
|
|
void unxlate_dev_mem_ptr(unsigned long phys, void *addr);
|
|
|
|
/*
|
|
* Convert a virtual cached pointer to an uncached pointer
|
|
*/
|
|
#define xlate_dev_kmem_ptr(p) p
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
#endif
|