Commit eb225344 authored by Andrew Jones's avatar Andrew Jones Committed by Marcelo Tosatti
Browse files

arm/arm64: make mmu_on per cpu

We introduced a variable called mmu_on to the mmu implementation
because unit tests may want to run with the mmu off, yet still
call into common code that could lead to {Load,Store}-Exclusive
instructions - which is illegal. So, the mmu_on variable was added
and made query-able (through mmu_enabled()) in order to guard those
paths. But, mmu_on is really a per cpu concept, so for smp we need
to change it. As it's just a bool, we can easily make it per cpu by
changing it into a cpumask. We rename it more appropriately too.

Signed-off-by: Andrew Jones's avatarAndrew Jones <>
Signed-off-by: default avatarMarcelo Tosatti <>
parent f20e2561
......@@ -2,6 +2,7 @@
#define __ASMARM_MMU_API_H_
extern pgd_t *mmu_idmap;
extern bool mmu_enabled(void);
extern void mmu_set_enabled(void);
extern void mmu_enable(pgd_t *pgtable);
extern void mmu_enable_idmap(void);
extern void mmu_init_io_sect(pgd_t *pgtable, unsigned long virt_offset);
......@@ -6,16 +6,25 @@
* This work is licensed under the terms of the GNU LGPL, version 2.
#include <asm/setup.h>
#include <asm/thread_info.h>
#include <asm/cpumask.h>
#include <asm/mmu.h>
extern unsigned long etext;
pgd_t *mmu_idmap;
static bool mmu_on;
static cpumask_t mmu_enabled_cpumask;
bool mmu_enabled(void)
return mmu_on;
struct thread_info *ti = current_thread_info();
return cpumask_test_cpu(ti->cpu, &mmu_enabled_cpumask);
void mmu_set_enabled(void)
struct thread_info *ti = current_thread_info();
cpumask_set_cpu(ti->cpu, &mmu_enabled_cpumask);
extern void asm_mmu_enable(phys_addr_t pgtable);
......@@ -23,7 +32,7 @@ void mmu_enable(pgd_t *pgtable)
mmu_on = true;
void mmu_set_range_ptes(pgd_t *pgtable, unsigned long virt_offset,
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment