Skip to content

Commit 4dc9a81

Browse files
author
Santosh Shilimkar
committed
ARM: mm: Introduce virt_to_idmap() with an arch hook
On some PAE systems (e.g. TI Keystone), memory is above the 32-bit addressable limit, and the interconnect provides an aliased view of parts of physical memory in the 32-bit addressable space. This alias is strictly for boot time usage, and is not otherwise usable because of coherency limitations. On such systems, the idmap mechanism needs to take this aliased mapping into account. This patch introduces virt_to_idmap() and a arch function pointer which can be populated by platform which needs it. Also populate necessary idmap spots with now available virt_to_idmap(). Avoided #ifdef approach to be compatible with multi-platform builds. Most architecture won't touch it and in that case virt_to_idmap() fall-back to existing virt_to_phys() macro. Cc: Russell King <linux@arm.linux.org.uk> Acked-by: Nicolas Pitre <nico@linaro.org> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
1 parent ca5a45c commit 4dc9a81

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

arch/arm/include/asm/memory.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
*/
174174
#define __PV_BITS_31_24 0x81000000
175175

176+
extern phys_addr_t (*arch_virt_to_idmap) (unsigned long x);
176177
extern unsigned long __pv_phys_offset;
177178
#define PHYS_OFFSET __pv_phys_offset
178179

@@ -258,6 +259,21 @@ static inline void *phys_to_virt(phys_addr_t x)
258259
#define __va(x) ((void *)__phys_to_virt((phys_addr_t)(x)))
259260
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
260261

262+
/*
263+
* These are for systems that have a hardware interconnect supported alias of
264+
* physical memory for idmap purposes. Most cases should leave these
265+
* untouched.
266+
*/
267+
static inline phys_addr_t __virt_to_idmap(unsigned long x)
268+
{
269+
if (arch_virt_to_idmap)
270+
return arch_virt_to_idmap(x);
271+
else
272+
return __virt_to_phys(x);
273+
}
274+
275+
#define virt_to_idmap(x) __virt_to_idmap((unsigned long)(x))
276+
261277
/*
262278
* Virtual <-> DMA view memory address translations
263279
* Again, these are *only* valid on the kernel direct mapped RAM

arch/arm/kernel/smp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void __init smp_set_ops(struct smp_operations *ops)
8080

8181
static unsigned long get_arch_pgd(pgd_t *pgd)
8282
{
83-
phys_addr_t pgdir = virt_to_phys(pgd);
83+
phys_addr_t pgdir = virt_to_idmap(pgd);
8484
BUG_ON(pgdir & ARCH_PGD_MASK);
8585
return pgdir >> ARCH_PGD_SHIFT;
8686
}

arch/arm/mm/idmap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <asm/system_info.h>
1111

1212
pgd_t *idmap_pgd;
13+
phys_addr_t (*arch_virt_to_idmap) (unsigned long x);
1314

1415
#ifdef CONFIG_ARM_LPAE
1516
static void idmap_add_pmd(pud_t *pud, unsigned long addr, unsigned long end,
@@ -67,8 +68,8 @@ static void identity_mapping_add(pgd_t *pgd, const char *text_start,
6768
unsigned long addr, end;
6869
unsigned long next;
6970

70-
addr = virt_to_phys(text_start);
71-
end = virt_to_phys(text_end);
71+
addr = virt_to_idmap(text_start);
72+
end = virt_to_idmap(text_end);
7273

7374
prot |= PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AF;
7475

0 commit comments

Comments
 (0)