Skip to content

Commit 04e91b7

Browse files
author
Russell King (Oracle)
committed
ARM: early traps initialisation
Provide a couple of helpers to copy the vectors and stubs, and also to flush the copied vectors and stubs. Acked-by: Catalin Marinas <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]>
1 parent 9dd7819 commit 04e91b7

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

arch/arm/kernel/traps.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,22 @@ static inline void __init kuser_init(void *vectors)
787787
}
788788
#endif
789789

790+
#ifndef CONFIG_CPU_V7M
791+
static void copy_from_lma(void *vma, void *lma_start, void *lma_end)
792+
{
793+
memcpy(vma, lma_start, lma_end - lma_start);
794+
}
795+
796+
static void flush_vectors(void *vma, size_t offset, size_t size)
797+
{
798+
unsigned long start = (unsigned long)vma + offset;
799+
unsigned long end = start + size;
800+
801+
flush_icache_range(start, end);
802+
}
803+
790804
void __init early_trap_init(void *vectors_base)
791805
{
792-
#ifndef CONFIG_CPU_V7M
793-
unsigned long vectors = (unsigned long)vectors_base;
794806
extern char __stubs_start[], __stubs_end[];
795807
extern char __vectors_start[], __vectors_end[];
796808
unsigned i;
@@ -811,17 +823,20 @@ void __init early_trap_init(void *vectors_base)
811823
* into the vector page, mapped at 0xffff0000, and ensure these
812824
* are visible to the instruction stream.
813825
*/
814-
memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start);
815-
memcpy((void *)vectors + 0x1000, __stubs_start, __stubs_end - __stubs_start);
826+
copy_from_lma(vectors_base, __vectors_start, __vectors_end);
827+
copy_from_lma(vectors_base + 0x1000, __stubs_start, __stubs_end);
816828

817829
kuser_init(vectors_base);
818830

819-
flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
831+
flush_vectors(vectors_base, 0, PAGE_SIZE * 2);
832+
}
820833
#else /* ifndef CONFIG_CPU_V7M */
834+
void __init early_trap_init(void *vectors_base)
835+
{
821836
/*
822837
* on V7-M there is no need to copy the vector table to a dedicated
823838
* memory area. The address is configurable and so a table in the kernel
824839
* image can be used.
825840
*/
826-
#endif
827841
}
842+
#endif

0 commit comments

Comments
 (0)