diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2016-03-15 14:55:03 +0000 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2016-05-03 11:13:54 +0100 |
commit | 981b6714dbd26609212536b9fed43e49db1459cf (patch) | |
tree | d1929db350c1ad747a5ff2ade1bc7b01c4fd39a2 /arch/arm/include/asm/memory.h | |
parent | 61603016e2122bf95328321b2f1a64277202b6e3 (diff) | |
download | linux-stable-981b6714dbd26609212536b9fed43e49db1459cf.tar.gz linux-stable-981b6714dbd26609212536b9fed43e49db1459cf.tar.bz2 linux-stable-981b6714dbd26609212536b9fed43e49db1459cf.zip |
ARM: provide improved virt_to_idmap() functionality
For kexec, we need more functionality from the IDMAP system. We need to
be able to convert physical addresses to their identity mappped versions
as well as virtual addresses.
Convert the existing arch_virt_to_idmap() to deal with physical
addresses instead.
Acked-by: Santosh Shilimkar <ssantosh@kernel.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/include/asm/memory.h')
-rw-r--r-- | arch/arm/include/asm/memory.h | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index 9427fd632552..ca208335fde6 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h @@ -288,19 +288,38 @@ static inline void *phys_to_virt(phys_addr_t x) #define __va(x) ((void *)__phys_to_virt((phys_addr_t)(x))) #define pfn_to_kaddr(pfn) __va((phys_addr_t)(pfn) << PAGE_SHIFT) -extern unsigned long (*arch_virt_to_idmap)(unsigned long x); +extern long long arch_phys_to_idmap_offset; /* - * These are for systems that have a hardware interconnect supported alias of - * physical memory for idmap purposes. Most cases should leave these + * These are for systems that have a hardware interconnect supported alias + * of physical memory for idmap purposes. Most cases should leave these * untouched. Note: this can only return addresses less than 4GiB. */ +#define IDMAP_INVALID_ADDR ((u32)~0) + +static inline unsigned long phys_to_idmap(phys_addr_t addr) +{ + if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) { + addr += arch_phys_to_idmap_offset; + if (addr > (u32)~0) + addr = IDMAP_INVALID_ADDR; + } + return addr; +} + +static inline phys_addr_t idmap_to_phys(unsigned long idmap) +{ + phys_addr_t addr = idmap; + + if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) + addr -= arch_phys_to_idmap_offset; + + return addr; +} + static inline unsigned long __virt_to_idmap(unsigned long x) { - if (IS_ENABLED(CONFIG_MMU) && arch_virt_to_idmap) - return arch_virt_to_idmap(x); - else - return __virt_to_phys(x); + return phys_to_idmap(__virt_to_phys(x)); } #define virt_to_idmap(x) __virt_to_idmap((unsigned long)(x)) |