Skip to content

Commit 66abdd3

Browse files
linuswRussell King (Oracle)
authored andcommitted
ARM: 9356/2: Move asm statements accessing TTBCR into C functions
This patch implements cpu_get_ttbcr() and cpu_set_ttbcr() and replaces the corresponding asm statements. Signed-off-by: Catalin Marinas <[email protected]> Reviewed-by: Kees Cook <[email protected]> Tested-by: Florian Fainelli <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]>
1 parent a8f15b3 commit 66abdd3

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

arch/arm/include/asm/proc-fns.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,18 @@ extern void cpu_resume(void);
178178
})
179179
#endif
180180

181+
static inline unsigned int cpu_get_ttbcr(void)
182+
{
183+
unsigned int ttbcr;
184+
asm("mrc p15, 0, %0, c2, c0, 2" : "=r" (ttbcr));
185+
return ttbcr;
186+
}
187+
188+
static inline void cpu_set_ttbcr(unsigned int ttbcr)
189+
{
190+
asm("mcr p15, 0, %0, c2, c0, 2" : : "r" (ttbcr));
191+
}
192+
181193
#else /*!CONFIG_MMU */
182194

183195
#define cpu_switch_mm(pgd,mm) { }

arch/arm/mm/mmu.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,9 +1687,8 @@ static void __init early_paging_init(const struct machine_desc *mdesc)
16871687
*/
16881688
cr = get_cr();
16891689
set_cr(cr & ~(CR_I | CR_C));
1690-
asm("mrc p15, 0, %0, c2, c0, 2" : "=r" (ttbcr));
1691-
asm volatile("mcr p15, 0, %0, c2, c0, 2"
1692-
: : "r" (ttbcr & ~(3 << 8 | 3 << 10)));
1690+
ttbcr = cpu_get_ttbcr();
1691+
cpu_set_ttbcr(ttbcr & ~(3 << 8 | 3 << 10));
16931692
flush_cache_all();
16941693

16951694
/*
@@ -1701,7 +1700,7 @@ static void __init early_paging_init(const struct machine_desc *mdesc)
17011700
lpae_pgtables_remap(offset, pa_pgd);
17021701

17031702
/* Re-enable the caches and cacheable TLB walks */
1704-
asm volatile("mcr p15, 0, %0, c2, c0, 2" : : "r" (ttbcr));
1703+
cpu_set_ttbcr(ttbcr);
17051704
set_cr(cr);
17061705
}
17071706

0 commit comments

Comments
 (0)